question

Robert Hambright avatar image
0 Likes"
Robert Hambright asked Robert Hambright commented

Processor Custom State

Hello.

In the model, the processor is set to close it's input and output once Queue2 has an input value of 5. On the state chart, it shows blocked because there is an item in the processor looking for somewhere to go but it can't exit. Is there a way create a different state that only calculates when the input/output is closed? Blocking is still calculated as the default state. But there is another state that basically calculates the time spent with the input/output closed. This way I can see both separately. Thanks!

custom-state.fsm

FlexSim 16.2.0
statesstate chart
custom-state.fsm (16.2 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

Regan Blackett avatar image
2 Likes"
Regan Blackett answered Robert Hambright commented

You have two choices to do this. If you want to write some code, you would have to send a delayed message with a delay of 0 at the start of the Send to Port event, and in the OnMessage trigger use the command setstate() to put the object into a desired state, but you would want to make sure this only happens when the message comes from the Send to Port event. Best way to do that is set message parameter values such that you know what event the message is coming from.

The other option is Process Flow, using event listening activities. First use an Event Triggered Source activity to listen for when the Queue receives 5 items:

When this event in the model fires, use a Custom Code activity to Close the Processor output port:

Then use a Wait for Event Activity to listen for when the Processor send to port event fires:

Then use a Custom Code to set the state of the processor:

Now some things about either approach could change depending on what happens once you get your 5 items and shut the outputs from the processor; Like what causes the ports to reopen? Does this happen on every 5th flowitem or only when the queue has exactly 5?

custom-state-pf-version.fsm

custom-state-message-version.fsm


· 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.

Robert Hambright avatar image Robert Hambright commented ·

Thanks, Regan. I was able to implement the process flow version into my larger model.

0 Likes 0 ·