question

shanice.c avatar image
0 Likes"
shanice.c asked shanice.c commented

Using code to create TaskSequence problem

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

FlexSim 21.2.2
tasksequence
1642607593276.png (48.9 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered shanice.c commented

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.


1642696117309.png (12.1 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

shanice.c avatar image shanice.c commented ·
@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 0 ·
Ryan Clark avatar image
0 Likes"
Ryan Clark answered shanice.c edited

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


· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

shanice.c avatar image shanice.c commented ·

@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 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.