How to run two states in parallel after a given time is met?

104 Views Asked by At

I have a very simple example. Two fans (A and B) are in a facility, representing each as a state. State Fan B will enter after 20 seconds state Fan A starts working. Therefore, after 20 sec, state FanA and state FanB will work in parallel.

How can I do this in Stateflow?

When I do parallel decomposition and assign state FanB execution in the second order, both state Fans work together simultaneously, even though I am using the after function (please neglect the L1 and x1 in the example).

model

1

There are 1 best solutions below

2
scotty3785 On

For each current Fan A/Fan B parallel blocks, add an Off and On state.

For Fan A, it will immediately transition from Off to On.

For Fan B, it will monitor the state of Fan A and the transition from Off to On will be something like

[in(Fan_A.On)&&after(20,sec)]

This means that if Fan A is in the on state and 20 seconds has elapsed, take the transition.