How to link StateTables with state_current>profile of an object?

How to link StateTables with state_current>profile of an object?

jouky_d
Not applicable
103 Views
6 Replies
Message 1 of 7

How to link StateTables with state_current>profile of an object?

jouky_d
Not applicable

[ FlexSim 23.0.3 ]

Hello,

I have created a StateTable with 8 states. However, when I want to change the state in the Process Flow of an element, I can only use the Default table.

How can I use my new State table? I tried to write the following script to change the state:

#define Default 0

Object object1 = token.MotorElevacion;

int state = 2;

int profile = Default;

object1.setState(state, profile);


changing the Default 0 value into 1 or 2 and using object1.stats.state("NewStateTable").valueString = "State3"; or object1.stats.state("NewStateTable").value = 1;

Could someone help me please?:)

0 Likes
Accepted solutions (1)
104 Views
6 Replies
Replies (6)
Message 2 of 7

moehlmann_fe
Explorer
Explorer
Accepted solution

A state table only used to influence how states are displayed/interpreted in dashboard charts. In the background the object still uses the default state profile, but the names of the states are "overwritten" by the state table in the chart.

If you want to a add an actual second state profile to an object (that runs in parallel, the object will have a state in each profile) you can follow the description in this post.

Message 3 of 7

jouky_d
Not applicable

I tried. I have put state_profiles inside the TaskExecuter, and when I change using setstate(object, state, profile) the state_profiles current changes, however, the name associated into that state is not shown on TaskExecuter state (it shows idle or whatever the default state_current is).

0 Likes
Message 4 of 7

moehlmann_fe
Explorer
Explorer

The statistics panel in the properties will always show the current state in the default state profile with the name set in that profile node.

You can edit the default profile for a given object in the tree.

1677584799935.png

1677584828499.png

1677584876817.png

0 Likes
Message 5 of 7

andrew_o2
Not applicable

Hi @Jouky D, was Felix Möhlmann's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes
Message 6 of 7

jouky_d
Not applicable
Thank you Felix for your answer. But is there a way to set the state_current table as a created State Table? Or do I have to copy and paste that table into the state_current/profile in every object?
Message 7 of 7

moehlmann_fe
Explorer
Explorer

You can of course copy the names over by code.

Object object;
treenode stateProfile = object.stats.state(0).profile;
Table stateTable = Table("tableName");
int maxRowNum = Math.min(stateTable.numRows, getbundlenrentries(stateProfile)-1);
for(int row = 1; row <= maxRowNum; row++)
{
    setbundlevalue(stateProfile, row, 0, stateTable[row][2]);
}

This will change the profile names of object. If you have references to all objects this should be applied to, you can use a for-loop to do this for all at once.

(The code assumes that the state table contains entries for all states 1-X in ascending order)

0 Likes