configuration Trigger "on state change" - change the color

configuration Trigger "on state change" - change the color

samuel_patarroyodiaz
Enthusiast Enthusiast
445 Views
5 Replies
Message 1 of 6

configuration Trigger "on state change" - change the color

samuel_patarroyodiaz
Enthusiast
Enthusiast

Hello,

 

I have a question about my model, in my model i want to change the color of one of the task executers (crane) when its state changes to "allocated idle",  I found a trigger called "on state change" and added a color palette. With this script, the crane changes colors based on the palette. 

 

samuel_patarroyodiaz_0-1762311969951.png

 

But i only need it to change color in one specific state "allocated idle", not in all of them , . I'm not sure how to adjust the script to do that. 

 

I'm also looking for a way to count how many times the crane enters that state, but I'm not sure what the easiest method would be. I thought about using a StadisticsCollector, or maybe a dashboard that allows it, but I haven’t found one yet. 

 

Thank you for any help. 

 

 

0 Likes
Accepted solutions (2)
446 Views
5 Replies
Replies (5)
Message 2 of 6

FelixMoehlmann
Collaborator
Collaborator
Accepted solution

You can just use an if-condition to change the color only when the allocated idle state is involved. At the same time you can increment a label as a simple way to count how often the crane entered that state.

If you plan on using the Experimenter than I would recommend to use a Statistics Collector, so the data gets saved in the result database.

In both cases I check whether the "toState" is equal to "allocated idle" and if the previous state is different from it. I do this to prevent counting events where fromState and toState are the same (this happens when you stop and resume the model, for example).

 

0 Likes
Message 3 of 6

samuel_patarroyodiaz
Enthusiast
Enthusiast

Thanks @FelixMoehlmann 

0 Likes
Message 4 of 6

samuel_patarroyodiaz
Enthusiast
Enthusiast

Hello @FelixMoehlmann 

 

I just want to ask one question if you could you help me. I tried to do the same with the state  "setup" in the combiner . The script for the color works well, but the statistics collector that calculates how many setups are done is not working. I'm not sure if it requires a different configuration or if i made a mistake that i haven't found yet.

 

It's counting too many. There are only around 10 setups, but the counter reaches more than 400

 

Here the configuration. (same that used for the crane). 

samuel_patarroyodiaz_0-1762486200354.png

samuel_patarroyodiaz_1-1762486225390.png

samuel_patarroyodiaz_2-1762486239743.png

samuel_patarroyodiaz_4-1762486343638.png

 

 

Thank you. 

 

 

 

 

 

 

0 Likes
Message 5 of 6

FelixMoehlmann
Collaborator
Collaborator
Accepted solution

The combiner always enters the setup state when it receives an item through port 1, regardless of how long the setup time for that item is.

For the label on the combiner you can change to incrementing it as part of the setup time code if the duration that will get used is larger than 0.

The Statistics Collector could be made to store the current model time when the combiner enters the setup state. Then compare that value to the current time when the state changes away from setup and only trigger if the difference between the two times is larger than 0.

0 Likes
Message 6 of 6

samuel_patarroyodiaz
Enthusiast
Enthusiast

Thank you @FelixMoehlmann  

0 Likes