'Changing properties of source block for different states in a statechart

I have a model in Main that looks like this:

enter image description here

The source block is set to uniform(4,8) hours in interarrival time.

  1. When the statechart goes from "normalWeather" to "storm" I want source to stop injection
  2. When the statechart goes from "storm" to "normalWeather" I want the interarrival times to come back to uniform(4,8) hours.

What is a suitable solution for this problem?



Solution 1:[1]

Set the source block to inject instead of interarrival time. Then add a transition of type timeout from normalWeather state to itself. Set the timeout as:

uniform(4,8)

And set the action as:

source.inject();

enter image description here

That way, as long as your agent is in the state normal weather, agent injections will occur at your desired rate.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Emile Zankoul