question

emanuela.berton avatar image
0 Likes"
emanuela.berton asked emanuela.berton commented

getCategoryName of STATE_ON_BREAK

Hi to all, in a model I'm creating a table in the trigger OnStateChange of a processor where I record some data when the state change. I'm using this code

TrackedVariable tvProfile= objCurrent.stats.state();

string categoryNameFrom = tvProfile.getCategoryName(fromState);

string categoryNameTo = tvProfile.getCategoryName(toState);

to read the category name from the profile, but I have this exception when the state STATE_ON_BREAK appears as first time.

exception: FlexScript exception: Tracked Variable method 'getCategoryName' at /MEK/proc-1>stats/state_current: invalid category number.


I skip this exception with a check of the value of the state, but I continue to have the same exception as soon as I add a chart in a dashboard where I collect data from the objCurrent.

I see that when I add a processor to the model it starts with only 22 states in the profile. Is it possible to expand the profile with all available states and in which way?

Attached you find a simple model with the error. modelLight.fsm

ThanksmodelLight.fsm

FlexSim 21.2.0
getcategoryname
modellight.fsm (41.7 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.

1 Answer

·
Ryan Clark avatar image
0 Likes"
Ryan Clark answered emanuela.berton commented

Hi @emanuela.berton,

Here is my modified version of your model: modellight-rc.fsm

I just added a dashboard chart that shows the state percentages as a pie chart. I'm not sure if that's the chart you're referring to. I didn't observe the error that you're describing.

To help answer your question about the state profile of the processor when initially added to the model, please consult these other pages:

Add custom state to a state gantt chart - FlexSim Community

The State Table (flexsim.com) - this is a new feature in FlexSim 21.2.

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


modellight-rc.fsm (73.4 KiB)
· 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.

emanuela.berton avatar image emanuela.berton commented ·

Thanks for your answer. Unfortunately it is not exactly what I need. You have the exception when you use the Gantt chart. You should start with an empty model, create a time table with a break on the processor and link a Gantt chart to the processor. When you run the first time the model you can see the exception. I suppose because the processor starts with the state_profile with only 21 states. As soon as the 'on break' state is triggered, you see the expection. After this if you run again the model you don't have any other exception because now the state profile already contains a list for 35 states and 'on break' is present.

So my question is: is it possible to expand the state profile list with all available states as soon as I add a processor, or an operator, to the model? Thanks

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann emanuela.berton commented ·

What I would suggest to get around this:

Add a fresh processor/operator to the model. Use the script window to set its state to 50 (or 35 if you don't need states above it), which automatically expands its profile node.

model().last.as(Object).setState(50, 0);

Then add it to a user library. Objects from that library will then start with the expanded profile node.

If you are organizing your objects into groups or containers, you could also loop through those and set the objects state once, before starting the model.

0 Likes 0 ·
emanuela.berton avatar image emanuela.berton Felix Möhlmann commented ·
I supposed to do this. Thanks
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.