Other GAMs

This section concludes the introduction to the GAMs used in the mass-spring-damper example, listing other commonly used GAMs that are not covered in the previous sections.

  • CRCGAM: computes the CRC checksum of the input signals.

  • MessageGAM: sends Message events on the basis of commands received in the input signals.

  • MuxGAM: selects the signal to be output based on a selector signal.

  • SimulinkWrapperGAM: encapsulates a shared library generated from a Simulink(r) model (requires the Simulink Coder(r) toolbox to generate the model, but not to execute the GAM).

  • TriggeredIOGAM: writes to an output DataSource only when a trigger condition is met.

The TriggeredIOGAM is commonly used to write to an output DataSource (e.g. logger, file, …) only when a trigger condition is met. In the mass-spring-damper example, the TriggeredIOGAM is used to log the system state only until the position converges to its final value.

MathExpressionGAM configuration to trigger while the position error is greater than a given value.
 1        +GAMMathTrigger = {
 2            Class = MathExpressionGAM
 3            Expression = "
 4                MaxPositionError = 0.001;
 5                TriggerDisplay = (uint8)(PositionErr > MaxPositionError);"
 6            InputSignals = {
 7                PositionErr = {
 8                    DataSource = DDB1
 9                    Type = float64
10                }
11            }
12            OutputSignals = {
13                TriggerDisplay = {
14                    DataSource = DDB1
15                    Type = uint8
16                }
17            }
GAMDisplay Class modified to TriggeredIOGAM and addition of the required Trigger signal.
1        +GAMDisplay = {
2            Class = TriggeredIOGAM
3            InputSignals = {
4                TriggerDisplay = {
5                    DataSource = "DDB1"
6                    Type = uint8
7                }

The complete list of GAMs is available in the GitLab repository at MARTe2-components/Source/Components/GAMs.

Running the application

Start the application with:

./MARTeApp.sh -f ../Configurations/MassSpring/RTApp-MassSpring-16.cfg -l RealTimeLoader -s State1

Once the application is running, inspect the screen output and verify that the log shows the Position converging to the ReferencePosition value and stops logging once the position converges. The log should show entries similar to the following:

$ [Information - LoggerBroker.cpp:152]: Velocity [0:0]:-0.041142
$ [Information - LoggerBroker.cpp:152]: VelocityM [0:0]:-0.096766
$ [Information - LoggerBroker.cpp:152]: PositionErr [0:0]:0.001040
$ [Information - LoggerBroker.cpp:152]: Force [0:0]:20.093487

Exercises

Ex. 1: Time-based logging

  1. Edit the file ../Configurations/MassSpring/RTApp-MassSpring-17.cfg and modify the trigger signal to log only the first 10 seconds of the application.

Solution

The solution is to modify the GAMMathTrigger to implement the time-based expression.

Updated MathExpressionGAM configuration to trigger while the time is less than 10 seconds. Note the required cast type for the constant value.
 1        +GAMMathTrigger = {
 2            Class = MathExpressionGAM
 3            Expression = "
 4                MaxAppTimeMicroSecs = 10000000;
 5                TriggerDisplay = (uint8)(Time < (uint32)MaxAppTimeMicroSecs);"
 6            InputSignals = {
 7                Time = {
 8                    DataSource = DDB1
 9                    Type = uint32
10                }
11            }
12            OutputSignals = {
13                TriggerDisplay = {
14                    DataSource = DDB1
15                    Type = uint8
16                }
17            }
18        }