I have a problem with my model.
I'm writing a method that if one condition is true, it must execute another method, however in a parallel rather than sequential manner as is happening. I did not find a solution that would do that.
Is there any way for one method to call another and not wait for its completion to continue the instructions?
if test = true Method2 end ...
Solved! Go to Solution.
As pointed out by Steffen_B you could use a methcall, this will schedual the method to run in x amount of time, so will allow the method that called it to continue running and after it is finished then Method2 will start running.
To get them to run at the same time as eachover is a bit more of a tricky one and using a methcall is only the start.
As you suspend 1 method then other methods will continue to run, you can suspend a method through a wait command (takes simulation time), a sleep command (takes real computer time) or a waituntil (waits until an attribute changes).
Using a waituntil and some boolean flags you can sequence methods to run in time with eachover by using checkpoints, so Method1 and Method2 must get to a set stage before they can both continue.
Hope this is of help,
I have two additional notes. First, instead of using &Method.methCall(0) I would advise to use &Method.newCallChain. That way the Method is being executed after the currently executed and the other already installed Methods, but before the next event of the event controller is being processed. So it cannot happen that another event that is also scheduled at the same simulation time will be processed before the Method scheduled by methCall.
Secondly, in Plant Simulation Methods are never actually be executed in parallel. The result would be non-deterministic and irreproducible. If you really need to interweave the execution of two Methods, I suggest you use waituntil or stopuntil as has already been proposed. You should put the waituntil statements only at those locations in the source code, where logic demands it, i.e. when one Method really needs the other Method do have completed a task before the next statement can be executed.