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 A and then agent B comes then XX delay time. If the predecessor is agent A and then agent C comes then XX delay time.... and so on.
CodePudding user response:
You need to store the predecessor somewhere and use it accordingly:
- create a variable
v_Predecessor
next to the Service block, type should be your agent type flowing through the blocks (sayMyAgent
) - create a function
f_getDuration
that takes 2 arguments of typeMyAgent
: first iscurrentAgent
and 2nd ispredecessor
. Function returns a double. - Call this function in your service block delay code section using
f_getDuration(agent, v_Predecessor)
- In the on-exit code block of the service block, update
v_Predecessor = agent;
The code in f_getDuration
will look something like:
if (currentAgent.myType == "A" && predecessor.myType == "B") {
return 12.;
} else if (currentAgent.myType == "A" && predecessor.myType == "C") {
return 13.;
} else if ... // add your logic