/** * @file SlowControlGAM.h * @brief GAM that emulates EPICS slow-control setpoints. * @date 29/08/2026 * @author Martino Ferrari * * @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and * the Development of Fusion Energy ('Fusion for Energy'). * Licensed under the EUPL, Version 1.1 or - as soon they will be approved * by the European Commission - subsequent versions of the EUPL (the "Licence") * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl * * @warning Unless required by applicable law or agreed to in writing, * software distributed under the Licence is distributed on an "AS IS" * basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the Licence permissions and limitations under the Licence. * * @details Stands in for the EPICS inputs that drive the PulseGeneratorGAM in * the real plant: it outputs a periodic square-wave "start" trigger and a * plateau-duration setpoint. Durations are configured in milliseconds and * converted to RT-cycle counts using CycleFrequency (default 1000 Hz = one * 1 ms cycle), so the trigger stays correct at any cycle rate: * * - Trigger = 1 while (cycle % cyclesPerPeriod) < cyclesPerWidth, else 0 * (a rising edge every TriggerPeriodMs); * - PlateauMs = the configured value, constant until re-configured. * * Configuration: *
* +MyGAM = {
* Class = SlowControlGAM
* TriggerPeriodMs = 5000 // time between pulses [ms]
* TriggerWidthMs = 10 // trigger pulse width [ms]
* PlateauMs = 500 // pulse plateau duration setpoint [ms]
* CycleFrequency = 1000 // RT cycle rate [Hz]; 1000 = 1 ms/cycle
* OutputSignals = {
* Trigger = { DataSource = DDB; Type = float32 }
* PlateauMs = { DataSource = DDB; Type = float32 }
* }
* }
*
*/
#ifndef SLOWCONTROLGAM_H_
#define SLOWCONTROLGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "CompilerTypes.h"
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
namespace MARTe {
class SlowControlGAM : public GAM {
public:
CLASS_REGISTER_DECLARATION()
/**
* @brief Constructor. Sets safe defaults.
*/
SlowControlGAM();
/**
* @brief Destructor.
*/
virtual ~SlowControlGAM();
/**
* @brief Reads TriggerPeriodMs, TriggerWidthMs, PlateauMs from config.
*/
virtual bool Initialise(StructuredDataI &data);
/**
* @brief Resolves the two output scalars.
* @return true if exactly two float32 output signals are present.
*/
virtual bool Setup();
/**
* @brief Emits the next trigger/plateau setpoint pair.
* @return true always.
*/
virtual bool Execute();
private:
float64 triggerPeriodMs; /**< Time between trigger pulses [ms] */
float64 triggerWidthMs; /**< Trigger pulse width [ms] */
float64 plateauMs; /**< Plateau duration setpoint [ms] */
float64 cycleFrequency; /**< RT cycle rate [Hz]; 1000 = 1 ms/cycle */
uint64 cycleCount; /**< RT cycle counter (1 cycle = 1 ms) */
float32 *triggerOut; /**< Output: trigger square wave */
float32 *plateauOut; /**< Output: plateau duration setpoint */
};
} /* namespace MARTe */
#endif /* SLOWCONTROLGAM_H_ */