Signals
8.3 Time-Triggered Systems
8.3.3 A multi-periodic SpringMassDamper
Figure 8.29 - The trace for the evaluation of 3 macro
2-steps from
SpringMassDamper.Structure
Fig. 8.30 shows the structure for the system. The structural differences from the previous example are the additions of an active class for theObserver as well as its classifier behavior and the signal emitted by itControllerIsOutOfRange.
Figure 8.30 - The structure of multi-periodic
SpringMassDampermodeled using hybrid fUML.
Also, the active objects are connected accordingly. The composite structure shown in Fig. 8.31 de-termines how the communication between the active objects is established as well as between the system and the environment. Likewise synchronous languages, hybrid fUML supports the substi-tution of the behaviorSpringMassDamperPlantControllerClassifierBehavior by external writings in the input ports, now, explicitly defined in the model.
Therefore, one can compose the system plugging other components to the input ports or the output ports (conjugated ports - output ports - are indicated by the gray color). Still regarding the composite structure shown in Fig. 8.31, it is the first example that uses broadcasting explicitly because the control signal is sent to the plant and to the observer instantaneously.
Discrete Behavior
Fig. 8.32 shows the extended version for theSpringMassDamperPlantControllerClassifierBehavior.
This behavior creates the ports to interact with the environment, namely SCreateObjectAction_-second,SCreateObjectAction_2secondsandSCreateObjectAction_alarm.
Afterwards, it consumes tree macro2-steps in its internal loop, the first macro2-step is consumed by the join node stereotyped withPausable, the second one emits the signalTickfor the ports
second-Figure 8.31 - The composite structure of multi-periodic
SpringMassDampermodeled using hybrid fUML.
Figure 8.32 - The classifier behavior for the
SpringMassDamperPlantController.Portand2SecondsPorts(those signals are broadcasted to the controller and observer respectively) and, finally, it emits the signal Tick for the port secondPort. Therefore, the expected semantics for the system’s behavior is that in one macro2-step the state of the system is not changed, the subsequently macro2-step the controller, the plant and the observer may change the state of the
116
system, and the next macro2-step only the controller and the plant may change the state of the system.
Fig. 8.33 shows the ObserverClassifierBehavior, it has the typical structure of a time-triggered component, i.e., it awaits the signal meaning time OAcceptEventAction_2Seconds, and then it awaits the signals to be processedOAcceptEventAction_controlSignal. With the control signal, it checks the predefined range, and if it is not in the range a signal is sent to its output port.
Figure 8.33 - The classifier behavior for the
Observer.Temporal concerns
Lastly, the CCSLs shown in Fig. 8.34 are defined ensuring that the multi-periodic SpringMass-Damper is an enichronous system. They are an extension of the previous ones (see Fig. 8.27), where a logical clock with period 200 is defined and equalized to the 2SecondsSignalEvent in ClockConstraint2Seconds, and a tree is explicitly declared in the ClockConstraintReactionClk us-ing subclockus-ing. The tree has as root thereactionClk, its child isSecondSignalEvent, which has as
child the2SecondsSignalEvent.
The semantics interprets these CCSLs allowing two types of macro2-steps: (1) a pure discrete one that ticks only reactionClk and (2) a hybrid one that ticks the reactionClk and the SecondSig-nalEvent. In addition, when theSecondSignalEvent ticks the 2SecondsSignalEvent may tick only when its period is respected. For example, at 1 second, if the system receives a2SecondsSignalEvent the semantics generates an error because it does not respect the period defined so the indirect re-lationship between the clocksSecondSignalEvent and2SecondsSignalEvent shall be respected.
Figure 8.34 - The clock constraint defining the multi-periodic
SpringMassDamperas an enichronous system.
Table 8.5 shows the synchronous streams for this example including thephysicalClk. As the Spring-MassDamperPlantControllerClassifierBehavior defines two hybrid macro2-steps instead of one in the previous example, the results are shifted left so the third macro2-step contains continuous evolution. At the end of the third macro2-step thephysicalClk has 1 second as value.
Note the clock ofPlantStateSignalis equally fast as thereactionClock, which is a consequence of its flexible behavior. In fact, one can use static analysis of the composite structure shown in Fig. 8.30 to infer that the only interesting rate of execution of the plant behavior is the execution’s rate of the active class connected to it, namely the controller, and then define its execution’s rate as the same of the controller5.
Using the Distributed Package
The multi-periodic SpringMassDamper is available in the project Hybrid Models, specif-ically, in the folder SpringMassDamperControlled\hybridfUML that contains the model SpringMassDamperPlantControllerDifferentPreReactionObserver. Moreover, it contains the traces for a run of this model.
The evaluation of this model regarding hybrid fUML can be performed as follows.
5The operational semantics of hybrid fUML does not do this kind of inference, which is com-monly found in synchronous declarative languages (BENVENISTE et al., 1991; HALBWACHS et al., 1992)
118
Table 8.5 - Synchronous streams for multi-periodic
SpringMassDamperusing hybrid fUML.
Source: hybrid fUML’s simulator.
macro
2-step 1 macro
2-step 2 macro
2-step 3 Variables
mass 1 1 1
springConstant 1 1 1
dampingCoef f icient 0.1 0.1 0.1
controlF orce 0 0 2
position 1 1 ≈ 1.44
velocity 0 0 ≈ 0.80
Signals
SecondSignalEvent true true
ControlSignal true
ControlSignal.f orce ⊥ 2 ≈ 1.19
2SecondsSignalEvent true
ControllerIsOutOf Range true
P lantStateSignal true true true
P lantStateSignal.velocity 0 0 ≈ 0.80
Clocks
clock(SecondSignalEvent) f alse true true
currentT ime(SecondSignalEvent) 0 1 2
clock(ControlSignal) f alse true true
currentT ime(ControlSignal) 0 1 2
clock(2SecondsSignalEvent) f alse true f alse
currentT ime(2SecondsSignalEvent) 0 1 1
clock(ControllerIsOutOf Range) f alse true f alse
currentT ime(ControllerIsOut . . .) 0 1 1
clock(P lantStateSignal) true true true
currentT ime(P lantStateSignal) 1 2 3
currentT ime(reactionClk) 1 2 3
physicalClk 0 0 1
a) Call the configured run
EmbeddingM1_ASM - SpringMassDamperPlantControllerDifferentPreReactionObserver.
The transformation generates the file
Hybrid fUML Transformations\transformedFiles\3syntax_userModel_embedded.gs.
b) The generated file must be copied into the directory
Hybrid fUML ASMs\embeddedModelin order to be evaluated.
c) Run the external tool Hybrid fUML;
d) Run the following commands in the console:
Load hybrid fUML
:p hybfUML.p
Call initial rule from hybrid fUML fire1 rule_fUML_initTimed2 traceFH
Call main rule from hybrid fUML for evaluation of three macro2-steps fire 3 (trace traceFG rule_fUML_mainHyb)
Exit the hybrid fUML
fire1 (trace traceFG skip) :quit
e) Compare the generated traces in the directoryHybrid fUML ASMs\hybridfUML\traces shown in Fig. 8.35 with Table 8.56;
Figure 8.35 - The trace for the evaluation of 3 macro
2-steps from multi-periodic
Spring-MassDamper.6Table 8.5 shows the clocks for the signals which are not necessarily the same from the signal events used by the model.