Search code examples
modelsimulationanylogic

Model the setuptime for one Agent with diffrent Agent Names in a service block


i have used a service block for my machine. i want to implement my setup time in it. So the setup time and the processing time will be a common time.

I would like to write a function for my delay time in the service block. How can I write the function that it gives me the following output: If the predecessor is agent.Name "A" and then agent.Name "B" comes then XX delay time. If the predecessor is agent.Name "A" and then agent.Name "C" comes then XX delay time.... and so on. Name is a Parameter in the Agent

Maybe i can use a variable?


Solution

    1. Put a variable of type String predecessorName next to the service block

    2. create a function getDelayTime that returns a double and takes 2 input arguments of type String: nameCurrentAgent and namePredecessor

    3. in the function, compare as you need, for example:

      if (nameCurrentAgent.equals("A") && namePredecessor.equals("B") {
           return 12.;
       } else if ...
      
    4. in the service block's delay code block, you call getDelayTime(agent.Name, predecessorName)

    5. in the service block's "on at exit" code block, update predecessorName = agent.Name for the next agent