Using code to create TaskSequence problem

Using code to create TaskSequence problem

shanice_c
Not applicable
1,218 Views
4 Replies
Message 1 of 5

Using code to create TaskSequence problem

shanice_c
Not applicable

[ FlexSim 21.2.2 ]

Hello, I'm trying to use TaskSequence to control TaskExecuter. May I ask what's the difference between using TaskSequences activities and using customcode to control TE? I have this question because previously I usually put activities in an order I want a TE to run. Now with the method using code to create tasksequence, I found I have to put wait for event(wait for state change) to make operator work on. I feel it's a kind of like not let TE take actions in a row. Or I also tried another way to put a breathe between custom codes (with tasksequence create & dispatch inside.

1642607593276.png

I just could not understand why in my previous experiences, it seems no problem by putting several TaskSequences activities in a row.

In my attached model, the operator1 could not go back to Queue1,this FlexSim model just close. Could anybody tell me what mistake do I make using code to create tasksequence?

TestTaskSequence.fsm

0 Likes
Accepted solutions (1)
1,219 Views
4 Replies
Replies (4)
Message 2 of 5

ryan_c10
Not applicable

Hi @fiona.c,

The reason that your model wasn't working well before was because it was becoming stuck in an infinite loop since the Wait for Event was only pausing the first time. I added a couple more Wait for Event activities and changed them to listen for the On Resource Available trigger, which indicates when a task is complete. After I changed that, it all seems to work as intended.

I hope this helps! Let us know if you have further questions!

testtasksequence-rc.fsm

0 Likes
Message 3 of 5

shanice_c
Not applicable

@Ryan Clark Thank you for your reply. I have seen you use "wait for on resource available" between tasksequences. May I ask that should I always use "wait for on resource available" to enable the TE to move onto next action? I find if I don't use "wait for on resource available", the TE doesn't unload anymore, it keeps loadinf new box from Queue1.

0 Likes
Message 4 of 5

jason_lightfoot_adsk
Autodesk
Autodesk
Accepted solution

Task sequence activities manage the synchronisation between the completed tasks and the release of the token from the activity. They do this by placing an extra task after the main task of the activity as shown below after the Travel task:

1642696117309.png

By putting interttask statements into a code activity you don't get the benefit of the synchronisation and you need to manage it yourself as you've discovered. It is probably better to use the activities designed for this function, but if you prefer, you could also just add an activity to create a zero time delay task instead of using the waitforevent activity - that way if the TE gets preempted to a different task sequence and its state changes you'll still only proceed in your process when the correct task sequences reaches that point.

0 Likes
Message 5 of 5

shanice_c
Not applicable
@Jason Lightfoot Thank you for your response. Now I understand it is the synchronisation problem that leads to my process not working as I expected.
0 Likes