Hello,
currently I’m trying to replicate the examples given in the OMG document:
Here on page 53, there is an example about the ‘Transition Guards and Effect Actions’ in State Diagrams.
The original example is as follows:
action performSelfTest{in vehicle : Vehicle;}
state def VehicleStates {
in operatingVehicle : Vehicle;
in controller : VehicleController; }
state vehicleStates : VehicleStates {
in operatingVehicle : Vehicle;
in controller : VehicleController;
entry; then off;
state off;
accept VehicleStartSignal
if operatingVehicle.brakePedalDepressed
do send new ControllerStartSignal() to controller
then starting;
state starting;
accept VehicleOnSignal
then on;
state on { … }
accept VehicleOffSignal
then off;
}
As it is an example, some definitions are missing:
- part def Vehicle with action brakePedalDepressed defined as Boolean for the guard
- part def VehicleController
- action def ControllerStartSignal
- action def VehicleStartSignal
- action def VehicleOnSignal
- action def VehicleOffSignal
Once included and formated (using “Format Selection”), the code in syside will look like this:
// Definitions not included in original example
part def Vehicle {action brakePedalDepressed : Boolean;}
part def VehicleController;
action def ControllerStartSignal;
action def VehicleStartSignal;
action def VehicleOnSignal;
action def VehicleOffSignal;
// Original example formated in syside
action performSelfTest { in vehicle : Vehicle; }
state def VehicleStates {
in operatingVehicle : Vehicle;
in controller : VehicleController;
}
state vehicleStates : VehicleStates {
in operatingVehicle : Vehicle;
in controller : VehicleController;
entry;
then off;
state off;
transition
off
accept VehicleStartSignal
if operatingVehicle.brakePedalDepressed
do send new ControllerStartSignal() to controller
then starting;
state starting;
transition starting accept VehicleOnSignal then on;
state on;
transition on accept VehicleOffSignal then off;
What it is interesting to me is that the formatting added the word “transition“ that were not included in the original code.
My question:
Is there a way to control what the “Format Selection“ is adding to the code?
Acc. to same document (page 49), one can use a “shorthand for transition a whose source is the lexically previous state”.
Many thanks in advance!

