Phase 5. Defining Turbine behavior
this phase we will define the behavior of turbines with a statechart:
when and how they get out of service or get scheduled maintenance.
Also, we will set up the turbine animation: we want the blades to stop
rotating when a turbine is out of service; moreover, every turbine animation figure has color indicators
of its turbine state.
Set up time intervals on the turbine agent type
in the model tree to open its diagram. Start with adding two
elements from the
palette into the graphical editor.
- The parameter called
is of type
- The second parameter,
(mean time to failure), is also of type
Set up the function managing requests for transport
- Add a
palette and call it
sendRequest. This function is
and it has one argument you can set up in the properties section
TransportType type. In the function body we call the function
that we have created on
Main. When a turbine sends a service request, the maintenance center should send transport of a specified type,
Define the turbines behavior with the statechart
- Now we are ready to create a statechart. Open the
palette and drag and drop into
Statechart Entry Point
- Connect a
to the statechart entry point, name it
Operating. Increase the state size since we want it to act as a composite state containing two simple states inside. Into the
Initial state pointer,
then continue with drawing the remaining states, connecting them
together with transitions and configuring the transitions as shown in
the figure below. Additionally, you can resize the statechart elements
and set some custom colors for the states.
Each turbine state has its own
Entry action. When a turbine needs repair, it is in the
state sending a maintenance request for
transport (a helicopter). When it is time for the scheduled service, a turbine sends a request for
type of transport - a truck.
The transition from
is triggered by
per day - once in the mean time to failure period. The transition that goes back from
state is triggered by
- When an operating turbine receives a message
"scheduled", it means, a turbine needs scheduled service and the corresponding state is triggered. Being in
state, when a turbine receives a message
"repaired", the service is finished, and it can get back to the
- Add a cyclic
scheduledRepair. This event will happen when a turbine needs a scheduled maintenance (according to
serviceTimeout) that triggers the transition from
Change animation of the turbine blades
- We need to change the properties of the turbine blades. The
figure is actually a group consisting of 2 3D figures: turbine tower
and turbine blades. We need to open the properties of the blades.
- You can select the blades with a mouse click in the graphical editor, or open the
view and keep expanding the model tree levels until you get to the
- Go to its properties. Open the section
Position and size
in the property
Rotation Y, rad.
Now the blades will be rotating when the turbine is working, and when
it is out of service and needs repair the blades will remain still.
Create the turbine state indicator
- Open the
palette and double-click the
element to enable the drawing mode.
- Draw a circle around the turbine animation figure with the radius 25.
- Right-click the circle and select
Order > Send to Back
from the context menu.
- Go to the
section of the circle properties. Enter the expression that will be evaluated during the run-time for the
to make it change according to the turbine state.
- In order to switch to
mode for the property, click its icon
a turbine is waiting for service the shape displays the yellow color,
otherwise the circle is green which is the indicator for a working
turbine, and if it is out of service the indicator displays the red
Run the model now. You will see that
some turbines are working, some are waiting for the scheduled
maintenance and some turbines need urgent repair.
Now we are ready to define the transport movement.
Phase 4. Defining Maintenance Center behavior
Phase 6. Finishing the Transport logic