AnyLogic
Expand
Font size

Phase 5. Turbine Logic

In 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

  1. Double-click  Turbine in the model tree to open its diagram. Start with adding two  Parameter elements from the  Agent palette into the graphical editor.
  2. The parameter called serviceTimeout is of type Time and its Default value is 2 weeks (select weeks in the Units property).
  3. The second parameter, MTTF (mean time to failure), is also of type Time and its Default value is 50 days.

Set up the function managing requests for transport

  1. Add a  Function from the  Agent palette and name it sendRequest. This function is Just action and it has one argument you can set up in the properties section Arguments: TransportType type. In the function body we call the function findTransport that we have created on  Main. When a turbine sends a service request, the maintenance center should send transport of a specified type, AUTO or AVIA.

Define the turbines behavior with the statechart

  1. Now we are ready to create a statechart. Open the  Statechart palette and drag and drop into  Turbine diagram the  Statechart Entry Point element.
  2. Connect a  State 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 Operating state, add  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.

  3. Each turbine state has its own Entry action. When a turbine needs repair, it is in the  Failure state sending a maintenance request for AVIA transport (a helicopter). When it is time for the scheduled service, a turbine sends a request for AUTO type of transport — a truck.
    State Entry action
    Failure sendRequest(AVIA);
    ScheduledService sendRequest(AUTO);
  4. The transition from  Operating state to  Failure is triggered by  Rate that equals 1/MTTF per day — once in the mean time to failure period. The transition that goes back from  Failure to  Operating state is triggered by a  particular message — "repaired".

  5. When an operating turbine receives a message  "scheduled", it means, a turbine needs scheduled service and the corresponding state is triggered. Being in  ScheduledService state, when a turbine receives a message  "repaired", the service is finished, and it can get back to the Operating state.

  6. Add a cyclic timeout  Event called scheduledRepair. This event will happen when a turbine needs a scheduled maintenance (according to  serviceTimeout) that triggers the transition from  Operating state to  ScheduledService.

Change animation of the turbine blades

  1. We need to change the properties of the turbine blades. The Wind turbine rotating figure is actually a group consisting of 2 3D figures: turbine tower and turbine blades. We need to open the properties of the blades.
  2. You can select the blades with a mouse click in the graphical editor, or open the Projects view and keep expanding the model tree levels until you get to the wind_blades group.
  3. Go to its properties. Open the section Position and size and type inState(Operating)?time():0 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

  1. Open the  Presentation palette and double-click the  Oval element to enable the drawing mode.
  2. Draw a circle around the turbine animation figure with the radius 25.
  3. Right-click the circle and select Order > Send to Back from the context menu.
  4. Go to the Appearance section of the circle properties. Enter the expression that will be evaluated during the run-time for the Fill color to make it change according to the turbine state.
  5. In order to switch to dynamic value mode for the property, click its icon .

  6. If 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 color.

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.

How can we improve this article?