State Machine Transitions

Hello,

I’m trying to model state machines and I’m wondering if:

  1. Is it possible to create transition between states crossing hierarchies?

  2. Can I have two transitions (in the same direction) between two states?

Below is what I’ve been trying.

Thanks!

Tom

state def StateMachine {

  entry;
  then Unpowered;
  state Unpowered;
  then Powered.Standby;
  
  state Powered {
    state Standby;
  }
}

Tom,

State definitions (state def) declares the state machine itself; states within are usages (just state).

Within a state are three actions, entry, do, and exit, so entry; is inappropriate. Consider this hierarchical state machine example by Richard Page, leader of the Execution Working Group of OMG’s Systems Modeling Community:

item def TriggerItem;
state def ContextState {
	state MyInterruptableState {
		do action wait {
			accept after 5 [SI::s];
		}
		
		state one;
		state two;
		
		transition t1 first start accept after 1 [SI::s] then one;
		transition t2 first one accept after 1 [SI::s] then two;
	}
	transition tStart first start then MyInterruptableState;
	transition tInterrupt first MyInterruptableState accept TriggerItem then done;
}
case 'test state interruption' {
	subject s : ContextState;
	
	// As per minimum time rule, executed immediately before any "waiting"
	send new TriggerItem() to s;
}

MD messed up the formatting, but you can get the idea.

Thanks for your reply! I tried out your example, I don’t think it’s answering my question (unless I am not understanding it). I’ve attached a diagram of my above example using SysML v1. How can I model this state machine in v2?

It took a while, but I think I have figured it out (it is supposed to be the SysML v2 version of the image above).

package StateMachineExample {

    item def TurnOn;
    item def SecondTurnOn;

    state def StateMachineExample {
        state Unpowered;
        transition first start then Unpowered;
        state Powered {
            state Standby;
        }
        transition first Unpowered accept TurnOn then Powered.Standby;
        transition first Unpowered accept SecondTurnOn then Powered.Standby;
    }

}

@TomBaker did you also find a way to create a similar picture as you are showing above?

Not with the SysIDE visualizer unfortunately.. This is the error message that I get when trying to visualize:

Model has warnings, visualization may be incomplete. For details see the Problems pane and the Syside Modeler Output log.

Hi Tom,

This appears to be an issue with the Tom Sawyer visualizer, which does not support direct transitions to sub-states. I’ve flagged this internally - we’ll investigate further.

Best, Simas

1 Like