3.3. Modeling Dynamic Reconfigurations
Modes can be used to model various operational states and the dynamic reconfiguration of a system or component. In this section, we present the use of modes to represent the operation of the PBA speed control system. In this section, we develop another, slightly expanded model of the PBA speed control system.
3.3.1. Expanded PBA Model
We modify the PBA speed control model to include a display_unit. In addition, we add an out event port control_on to the interface_unit. Figure 3-3 shows the implementation of the expanded system including its subcomponents and their interconnections.
Figure 3-3. Expanded PBA Control System
The type classifiers used in the expanded PBA model are shown in Listing 3-12. In this table, we define a process type control_ex that includes the additional features required for interfacing to the display_unit and interface_unit. We could have declared this process type as an extension of the process type control, as shown in the comment. We also define the device type interface_unit as the device type interface with an additional port. Finally, we have added a new device type display_unit. The event port control_on is the trigger for a mode transition from monitoring to controlling and the event port disengage is the trigger for the reverse transition.
Listing 3-12. Type Classifiers for the Expanded PBA Model
-- Type classifiers for the expanded PBA control system model -- process control_ex features sensor_data: in data port; command_data: out data port; status: out data port; -- added port disengage: in event port; set_speed: in data port; control_on: in event port; -- added port properties Period => 50 Ms; end control_ex; device interface_unit features disengage: out event port; set_speed: out data port; control_on: out event port; -- added port end interface_unit; device display_unit -- new device features status: in data port; end display_unit; thread monitor -- new thread features sensor_data: in data port; status: out data port; end monitor; thread control_laws_ex features proc_data: in data port; set_speed: in data port; disengage: in event port; control_on: in event port; -- added port status: out data port; -- added port cmd: out data port; end control_laws_ex;
Listing 3-12 also includes the new thread type monitor, and the modified thread type control_laws with an extra port, now called control_laws_ex. These are the thread types of the subcomponents of the process implementation control_ex.speed. A graphical representation of the subcomponents and connections for the process implementation control_ex.speed is shown in Figure 3-4. The process speed_control, shown in Figure 3-3, is an instance of control_ex.speed.
Figure 3-4. Process Implementation control_ex.speed
3.3.2. Specifying Modes
The textual specification for the implementation control_ex.speed is shown in Listing 3-13. In this implementation, two modes monitoring and controlling are declared in the modes section of the implementation. In the declarations for the subcomponents, the in modes declarations constrain the thread monitor to execute only in the monitoring mode and the threads scale_speed_data and speed_control_laws execute only in the controlling mode. Similarly, in the connection declarations are mode dependent such that the connections to the monitor thread are only active in the monitoring mode. The transitions between modes are triggered by the in event ports control_on and disengage. These are declared in the modes section of the implementation. If the modes are observable or are controlled from outside a component, then you may want to declare the modes in the component type.
A graphical representation for the mode transitions is shown in the lower portion of Listing 3-13. Modes are represented as dotted hexagons. The short arrow terminating at the monitoring mode denotes that the initial state is monitoring. The arrows connecting modes represent transitions. The input events are associated with the transitions that they trigger with a dotted line.
Listing 3-13. Process Implementation of control_ex.speed with Modes
process implementation control_ex.speed subcomponents scale_speed_data: thread read_data in modes (controlling); speed_control_laws: thread control_laws_ex in modes (controlling); monitor: thread monitor in modes (monitoring); connections DC1: port sensor_data -> scale_speed_data.sensor_data in modes (controlling); DC2: port scale_speed_data.proc_data -> speed_control_laws.proc_data in modes (controlling); DC3: port speed_control_laws.cmd -> command_data in modes (controlling); DC4: port set_speed -> speed_control_laws.set_speed in modes (controlling); DC5: port monitor.status -> status in modes (monitoring); DC6: port sensor_data -> monitor.sensor_data in modes (monitoring); DC8: port speed_control_laws.status -> status in modes (controlling); EC1: port disengage -> speed_control_laws.disengage in modes (controlling); modes monitoring: initial mode ; controlling: mode ; monitoring -[ control_on ]-> controlling; controlling -[ disengage ]-> monitoring; end control_ex.speed;