question

Nicolas M6 avatar image
0 Likes"
Nicolas M6 asked Nicolas M6 commented

How to set the people state in a custom code?

How to set the people state in a custom code the same way we set the default state profile?

In the model attached, for exemple, the activity "time in State_X" is a certain activity like wait in a pull from list.

In the graph below, I would like to see
- idle =3s
- State_X = 4s
- InTransit...
- State_Y = 5s

Thanks in advance

20200318-set-peoplestate.fsm

FlexSim 20.0.3
statespeople flow
5 |100000

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

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Nicolas M6 commented

Use a code snippet like this:

Object person = token.Person;
person.stats.state("HC States").valueString = "State_X";

setpeoplestate.fsm


setpeoplestate.fsm (61.3 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.

Nicolas M6 avatar image Nicolas M6 commented ·

Thanks !

0 Likes 0 ·
Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered Nicolas M6 commented

You can use

token.Person.as(Object).stats.state("HC States").value = "State_X";

in your custom code.

Note that the people activities put the person in their previous state when they finish. In this case, that means that instead of going back to idle, they will go back to State_X.

· 3
5 |100000

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

Nicolas M6 avatar image Nicolas M6 commented ·

Thanks ! Indeed, it's a problem.

I notice another problem: During the animations "installation on the table" or "leaving the examination table" which are due to the activity "walk", the state HC is idle. It is false in my opinion. The patient is handling himself. He's active. This state should be in "InTransit" not idle state.

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Nicolas M6 commented ·

If you're concerned about those state times you can edit the enter/exit instructions of the location to set the person's state during the animations. However, if you use more realistic processing times (like 15 minutes not 4 seconds) and travel distances I think you'll see that the few seconds it takes a person to sit down and stand up will be negligible.

0 Likes 0 ·
Nicolas M6 avatar image Nicolas M6 Matthew Gillespie ♦♦ commented ·

thanks for your answer. Sure. I clearly agree with you. I was just understanding the mechanism and I did not understand where this idle time came from. Thanks again.

0 Likes 0 ·