question

Kari Payton avatar image
1 Like"
Kari Payton asked Adrian Haws edited

How to use custom code to set operator state?

In my model, I acquired an operator, and next I want to set his/her state to busy. I tried using a custom code block but when I run the program the operator's state stays busy. I have tried changing the object reference but no luck.

FlexSim 16.1.0
process flowcustom codestatesutilize operatorfreeoperator
operatorstate.png (32.9 KiB)
· 2
5 |100000

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

Dawid Dabal avatar image
3 Likes"
Dawid Dabal answered Dawid Dabal commented

In one of my models I used Custom Task =>TaskType Utilize and FreeOperator because I wasn't sure for how much time my operator is going to be busy. Maybe this could help.

· 8
5 |100000

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

Matt Long avatar image
2 Likes"
Matt Long answered

Assuming your reference to the operator is correct, operator's state is being set to busy, but then he's being set back to idle most likely by his own internal mechanics. Objects do a lot of state changing on their own and setting an object's state only overrides their current state until the object changes it again. For instance, giving an operator any task will change its state.

This means you can either do what was suggested in the answer by @Dawid Dabal or you'll need to place Set Object State activities everywhere that the state gets changed in order to keep it in a busy state.

5 |100000

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

Steven Hamoen avatar image
1 Like"
Steven Hamoen answered

I have struggled with this also and tried exactly the same solution. I think that Brenton pointed me to a solution with using he TSDelay activity where you can set the state. Maybe this could be a solution for you as well.

5 |100000

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