Generation working and Compilation of MARTe components

This commit is contained in:
ferrog
2025-05-13 16:03:11 +00:00
parent 3a5e378d99
commit 4faee3802a
1571 changed files with 611466 additions and 0 deletions

View File

@@ -0,0 +1,389 @@
record (bi,"EC-GN-P01-GBF:DIO4900-YON")
{
field(DESC, "GY3 External trigger")
field(DTYP, "asynInt32")
field(INP, "@asyn(ni6528_0, 22) bitread")
field(ONAM, "ON")
field(PINI, "YES")
field(SCAN, "I/O Intr")
field(SIML, "EC-GN-P01-GBF:STAT-DI-SIMM")
field(VAL, "0")
field(ZNAM, "OFF")
}
record (bo,"EC-GN-P01-GBF:STAT-AI-SIMM")
{
field(DESC, "GY2 AI Simulation Mode SW")
field(ONAM, "YES")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "0")
field(ZNAM, "NO")
}
record (bo,"EC-GN-P01-GBF:STAT-AO-SIMM")
{
field(DESC, "GY2 AO Simulation Mode SW")
field(ONAM, "YES")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "0")
field(ZNAM, "NO")
}
record (bo,"EC-GN-P01-GBF:STAT-CSV-LOAD")
{
field(DESC, "File load trigger")
field(HIGH, "0.1")
field(ONAM, "Loading")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "0")
field(ZNAM, "Load")
}
record (bo,"EC-GN-P01-GBF:STAT-CSV-LOADED")
{
field(DESC, "File load status")
field(ONAM, "Loaded")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "0")
field(ZNAM, "Loading")
}
record (bo,"EC-GN-P01-GBF:STAT-DI-SIMM")
{
field(DESC, "GY2 DI Simulation Mode SW")
field(ONAM, "YES")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "0")
field(ZNAM, "NO")
}
record (bo,"EC-GN-P01-GBF:STAT-DO-SIMM")
{
field(DESC, "GY2 DO Simulation Mode SW")
field(ONAM, "YES")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "0")
field(ZNAM, "NO")
}
record (bo,"EC-GN-P01-GBF:STAT-DT-SHOTLEN-EGU")
{
field(DESC, "GY2 egu of shot length")
field(FLNK, "EC-GN-P01-GBF:STAT-DT-SHOTLEN-CALC")
field(ONAM, "s")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "0")
field(ZNAM, "ms")
}
record (bo,"EC-GN-P01-GBF:STAT-MST-TRIG")
{
field(DESC, "GY2 Master trigger")
field(ONAM, "ON")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "0")
field(ZNAM, "OFF")
}
record (bo,"EC-GN-P01-GBF:STAT-PREP-MODE")
{
field(DESC, "GY2 Pre-Pro mode ON")
field(ONAM, "ON")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "0")
field(ZNAM, "OFF")
}
record (bo,"EC-GN-P01-GBF:STAT-SHORT-PULSE")
{
field(DESC, "GY2 Short Pulse Mode")
field(ONAM, "ON")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "0")
field(ZNAM, "OFF")
}
record (bo,"EC-GN-P01-GBF:STAT-TRIG-SOUR")
{
field(DESC, "GY2 External Trigger Mode SW")
field(ONAM, "ON")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "0")
field(ZNAM, "OFF")
}
record (ai,"EC-GN-P01-GBF:MOE2810-ET")
{
field(DESC, "GY2 Arc detect signal 1")
field(EGU, "V")
field(PINI, "YES")
field(PREC, "3")
field(SCAN, ".1 second")
field(SIML, "EC-GN-P01-GBF:STAT-AI-SIMM")
}
record (waveform,"EC-GN-P01-GBF:MOE2810-ET-WF")
{
field(DESC, "GY2 Arc detect signal 1")
field(EGU, "V")
field(FTVL, "FLOAT")
field(NELM, "8000")
field(PINI, "YES")
field(PREC, "3")
field(SCAN, "Passive")
field(SIML, "EC-GN-P01-GBF:STAT-AI-SIMM")
}
record (ai,"EC-GN-P01-GBF:MOE2820-ET")
{
field(DESC, "GY2 Arc detect signal 2")
field(EGU, "V")
field(PINI, "YES")
field(PREC, "3")
field(SCAN, ".1 second")
field(SIML, "EC-GN-P01-GBF:STAT-AI-SIMM")
}
record (waveform,"EC-GN-P01-GBF:MOE2820-ET-WF")
{
field(DESC, "GY2 Arc detect signal 2")
field(EGU, "V")
field(FTVL, "FLOAT")
field(NELM, "8000")
field(PINI, "YES")
field(PREC, "3")
field(SCAN, "Passive")
field(SIML, "EC-GN-P01-GBF:STAT-AI-SIMM")
}
record (ai,"EC-GN-P01-GBF:MOE2830-ET")
{
field(DESC, "GY2 Arc detect signal 3")
field(EGU, "V")
field(PINI, "YES")
field(PREC, "3")
field(SCAN, ".1 second")
field(SIML, "EC-GN-P01-GBF:STAT-AI-SIMM")
}
record (waveform,"EC-GN-P01-GBF:MOE2830-ET-WF")
{
field(DESC, "GY2 Arc detect signal 3")
field(EGU, "V")
field(FTVL, "FLOAT")
field(NELM, "8000")
field(PINI, "YES")
field(PREC, "3")
field(SCAN, "Passive")
field(SIML, "EC-GN-P01-GBF:STAT-AI-SIMM")
}
record (ai,"EC-GN-P01-GBF:MRF2910-ET")
{
field(DESC, "GY2 RF Signal")
field(EGU, "V")
field(PINI, "YES")
field(PREC, "3")
field(SCAN, ".1 second")
field(SIML, "EC-GN-P01-GBF:STAT-AI-SIMM")
}
record (waveform,"EC-GN-P01-GBF:MRF2910-ET-WF")
{
field(DESC, "GY2 RF Signal")
field(EGU, "V")
field(FTVL, "FLOAT")
field(NELM, "8000")
field(PINI, "YES")
field(PREC, "3")
field(SCAN, "Passive")
field(SIML, "EC-GN-P01-GBF:STAT-AI-SIMM")
}
record (ai,"EC-GN-P01-GBF:STAT-BEAMON-TIME")
{
field(DESC, "GY2 Beam ON time")
field(EGU, "us")
field(HOPR, "3600000000")
field(LOPR, "0")
field(PINI, "YES")
field(PREC, "0")
field(SCAN, "Passive")
field(VAL, "0")
}
record (mbbo,"EC-GN-P01-GBF:STAT-CSV-ERR")
{
field(DESC, "File load error status")
field(FRST, "Format error")
field(FRSV, "MAJOR")
field(FRVL, "4")
field(FVST, "Out of range")
field(FVSV, "MAJOR")
field(FVVL, "5")
field(ONST, "Successfully loaded")
field(ONSV, "NO_ALARM")
field(ONVL, "1")
field(PINI, "YES")
field(SCAN, "Passive")
field(THST, "Empty data")
field(THSV, "MAJOR")
field(THVL, "3")
field(TWST, "Failed to open")
field(TWSV, "MAJOR")
field(TWVL, "2")
field(VAL, "0")
field(ZRST, "Not loaded yet")
field(ZRSV, "MINOR")
field(ZRVL, "0")
}
record (stringout,"EC-GN-P01-GBF:STAT-CSV-NAME")
{
field(DESC, "CSV file name")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "shot000000")
}
record (ai,"EC-GN-P01-GBF:STAT-DT-SHOTLEN")
{
field(DESC, "GY2 Shot length")
field(EGU, "us")
field(HOPR, "3600000000")
field(LOPR, "100")
field(PINI, "YES")
field(PREC, "0")
field(SCAN, "Passive")
field(VAL, "1000000")
}
record (calcout,"EC-GN-P01-GBF:STAT-DT-SHOTLEN-CALC")
{
field(CALC, "(!A)?1000*B:1000000*B")
field(DESC, "GY2 shot length convert")
field(FLNK, "EC-GN-P01-GBF:STAT-DT-SHOTLEN")
field(INPA, "EC-GN-P01-GBF:STAT-DT-SHOTLEN-EGU")
field(INPB, "EC-GN-P01-GBF:STAT-DT-SHOTLEN-DAM")
field(OUT, "EC-GN-P01-GBF:STAT-DT-SHOTLEN")
field(SCAN, "Passive")
}
record (ao,"EC-GN-P01-GBF:STAT-DT-SHOTLEN-DAM")
{
field(DESC, "GY2 shot length without unit")
field(DRVH, "3600")
field(DRVL, "0")
field(FLNK, "EC-GN-P01-GBF:STAT-DT-SHOTLEN-CALC")
field(HOPR, "3600")
field(LOPR, "0")
field(PINI, "NO")
field(SCAN, "Passive")
field(VAL, "0")
}
record (ai,"EC-GN-P01-GBF:STAT-ELAPSED")
{
field(DESC, "GY2 Elapsed time")
field(EGU, "us")
field(HOPR, "4000000000")
field(LOPR, "0")
field(PINI, "YES")
field(PREC, "0")
field(SCAN, "Passive")
field(VAL, "0")
}
record (longin,"EC-GN-P01-GBF:STAT-PREHEAT-TIME")
{
field(DESC, "Pre-heating time")
field(HOPR, "999999")
field(LOPR, "0")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "0")
}
record (waveform,"EC-GN-P01-GBF:STAT-PREP-TIME-WF")
{
field(DESC, "GY2 prepro time schedule")
field(EGU, "ms")
field(FTVL, "FLOAT")
field(NELM, "8000")
field(PINI, "NO")
field(PREC, "0")
field(SCAN, "Passive")
}
record (fanout,"EC-GN-P01-GBF:STAT-SHOT-FLNK1")
{
field(DESC, "GY2 fanout1 to AI waveform signal")
}
record (fanout,"EC-GN-P01-GBF:STAT-SHOT-FLNK2")
{
field(DESC, "GY2 fanout2 to AI waveform signal")
}
record (longin,"EC-GN-P01-GBF:STAT-SHOT-ID")
{
field(DESC, "GY2 shot ID")
field(HOPR, "999999")
field(LOPR, "0")
field(PINI, "YES")
field(SCAN, "Passive")
field(VAL, "0")
}
record (calcout,"EC-GN-P01-GBF:STAT-SHOT-PLOT")
{
field(CALC, "A andand (B >= C)")
field(DESC, "GY2 judge to plot measured values")
field(INPA, "EC-GN-P01-GPS:PLC4110-YTS-ST3R")
field(INPB, "EC-GN-P01-GBF:STAT-BEAMON-TIME")
field(INPC, "6000000")
field(OOPT, "Transition To Non-zero")
field(OUT, "EC-GN-P01-GBF:STAT-SHOT-FLNK1 PP")
field(SCAN, ".1 second")
}
record (mbbi,"EC-GN-P01-GBF:STAT-SM")
{
field(DESC, "GY#2 state machine")
field(EIST, "WaitHVON_SDN")
field(EIVL, "8")
field(FLNK, "EC-GN-P01-GBF:STAT-SHOT-PLOT")
field(FRST, "WaitReady")
field(FRVL, "4")
field(FVST, "WaitPermit")
field(FVVL, "5")
field(NIST, "WaitHVON_SDN_PREP")
field(NIVL, "9")
field(ONST, "Error")
field(ONVL, "1")
field(PINI, "YES")
field(SCAN, "Passive")
field(SVST, "WaitHVON_PREP")
field(SVVL, "7")
field(SXST, "WaitHVON")
field(SXVL, "6")
field(THST, "WaitStandby")
field(THVL, "3")
field(TWST, "Disabled")
field(TWVL, "2")
field(VAL, "0")
field(ZRST, "Init")
field(ZRVL, "0")
}

View File

@@ -0,0 +1,264 @@
/**
* @file JARTStateMachineGAM.h
* @brief Header file for class JARTStateMachineGAM
* @date Nov 26, 2018
* @author aneto
*
* @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 This header file contains the declaration of the class JARTStateMachineGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JARTSTATEMACHINEGAM_H_
#define GAMS_JARTSTATEMACHINEGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM that provides real-time state machine.
*
* The configuration syntax is (names and signal quantity are only given as an example):
* <pre>
* +GAMRealTimeStateMachine = {
* Class = JARTStateMachineGAM
* ConditionTrigger = 1
* mhvps_hvon = 4
* aps_hvon = 1
* aps_swon = 16
* bps_hvon = 2
* bps_swon = 8
* InputSignals = {
* Time = {
* DataSource = DDB1
* Type = uint32
* }
* PLC_ON = {
* DataSource = DDB1
* Type = uint32
* }
* MHVPS_DT = {
* DataSource = DDB1
* Type = uint32
* }
* APS_HVON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* APS_SWON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* BPS_HVON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* BPS_SWON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* SHOTLEN = {
* DataSource = DDB1
* Type = uint32
* }
* StopRequest = {
* DataSource = DDB1
* Type = uint32
* }
* MODE_SHOTLEN_FLAG = {
* DataSource = DDB1
* Type = uint32
* }
* }
* OutputSignals = {
* Value = {
* DataSource = DDB1
* Type = uint32
* Trigger = 1
* }
* BEAM_ON_STAT = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* HVARMED = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* HVINJECTION = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* RFON = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* BeamONTime = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* RFONTime = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* SHOT_ID = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* }
* }
*
* </pre>
*
*/
class JARTStateMachineGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JARTStateMachineGAM();
virtual ~JARTStateMachineGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
//The list of possible states
enum JARealTimeState {
WaitTrigger = 0,
SwitchingHVPS = 1,
RFON = 2,
HVTerminate = 3
};
//The current rtState
JARealTimeState currentState;
//A given condition
MARTe::uint32 conditionTrigger;
//What to output in a given state and condition
MARTe::uint32 mhvps_hvon;
MARTe::uint32 aps_hvon;
MARTe::uint32 aps_swon;
MARTe::uint32 bps_hvon;
MARTe::uint32 bps_swon;
//The trigger signal (PLC_ON)
MARTe::uint32 *triggerSignal;
//Time signal
MARTe::uint32 *currentTime;
// Input signals for trigger delay parameters
MARTe::uint32 *triggerDelay_mhvps_hvon;
MARTe::uint32 *triggerDelay_aps_hvon;
MARTe::uint32 *triggerDelay_aps_swon;
MARTe::uint32 *triggerDelay_bps_hvon;
MARTe::uint32 *triggerDelay_bps_swon;
MARTe::uint32 *triggerDelay_shotlen;
// Input signal for sequence stop request.
MARTe::uint32 *stopRequest;
// Input signal for pulse length limit by mode.
MARTe::uint32 *modePulseLengthLimit;
// Input signal for short pulse mode.
MARTe::uint32 *short_pulse_mode;
// Input signal for modulation pv.
MARTe::uint32 *modulation;
// Input signal for pause signal set pv.
MARTe::uint32 *pauseSet;
// Output signal to which the output value will be written.
// One state write One signal.
MARTe::uint32 *outputSignal;
// state notify output
MARTe::uint32 *outputBeamON;
MARTe::uint32 *outputHVArmed;
MARTe::uint32 *outputHVInjection;
MARTe::uint32 *outputRFON;
// elapsed time notify output;
MARTe::uint32 *outputBeamONTime;
MARTe::uint32 *outputRFONTime;
// shot counter (coutup every RFON time.)
MARTe::uint32 *shotCounter;
// Added for HVPS state (20201117)
MARTe::uint32 *outputAPSHVON;
MARTe::uint32 *outputAPSSWON;
MARTe::uint32 *outputBPSHVON;
MARTe::uint32 *outputBPSSWON;
MARTe::uint32 *outputMHVPSON;
// Output signals for NI devices
MARTe::uint32 *outputSignalNI6259;
MARTe::uint8 *outputSignalNI6528P3;
MARTe::uint8 *outputSignalNI6528P4;
//////////////////////////////
//Internal Parameters
//////////////////////////////
//PLC_ON time holder
MARTe::uint32 plcOnTime;
//APS_SWON time holder
MARTe::uint32 apsSwonTime;
MARTe::uint32 apsSwoffTime;
MARTe::uint64 apsSwonHighResolutionTime;
//PS turn off delay
MARTe::uint32 turn_off_delay;
//HVPS state holder
bool mhvps_hvon_is_on;
bool aps_hvon_is_on;
bool aps_swon_is_on;
bool bps_hvon_is_on;
bool bps_swon_is_on;
// terminal values
MARTe::uint8 p3Value;
MARTe::uint8 p4Value;
MARTe::uint8 aps_hvon_state;
MARTe::uint8 aps_swon_state;
MARTe::uint8 mhvps_hvon_state;
MARTe::uint8 bps_hvon_state;
MARTe::uint8 bps_swon_state;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JARTSTATEMACHINEGAM_H_ */

View File

@@ -0,0 +1,45 @@
#======================================================================
# Loading DBs
#======================================================================
cd $(TOP)/db
dbLoadRecords("PCF0-EC-GN-HWCF-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GAF-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GAF-CCPS-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GAF-FHPS-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GAF-GCPS-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GAF-MCPS-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GAFP-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GBF-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GBF-CCPS-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GBF-FHPS-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GBF-GCPS-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GBF-MCPS-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GBFP-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GPF-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-GPS-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-PA1F-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-PA2F-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-PB1F-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-PB2F-iocEC-GN-PSH0PCF.db")
dbLoadRecords("PCF0-EC-GN-P01-PMF-iocEC-GN-PSH0PCF.db")
#======================================================================
# Loading Substitution Files
#======================================================================
cd $(TOP)/iocBoot/$(IOC)
#======================================================================
# PLC Communication Monitoring PVs DB Loading
#======================================================================
cd $(EPICS_ROOT)/db
#======================================================================
# IOC Monitor
#======================================================================
cd $(EPICS_ROOT)/db
#dbLoadRecords("iocmon.db","CBS=EC-GN-SYSM, CTRLTYPE=F, IDX=0, IOCTYPE=CORE, PP=01, PPPP=52RF, NNNN=4210, TTT=PCF")
#- End-of-file marker - do not delete or add lines below!

View File

@@ -0,0 +1,233 @@
/**
* @file EPICSCAOutput.h
* @brief Header file for class EPICSCAOutput
* @date 20/04/2017
* @author Andre Neto
*
* @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 This header file contains the declaration of the class EPICSCAOutput
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef JAEPICSCAOutput_H_
#define JAEPICSCAOutput_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
#include <cadef.h>
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "DataSourceI.h"
#include "JAEPICSCAInput.h"
#include "EmbeddedServiceMethodBinderI.h"
#include "EventSem.h"
#include "SingleThreadService.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
namespace MARTe {
//Maximum size that a PV name may have
/**
* @brief A DataSource which allows to output data into any number of PVs using the EPICS channel access client protocol.
* Data is asynchronously ca_put in the context of a different thread (w.r.t. to the real-time thread).
*
* The configuration syntax is (names are only given as an example):
*
* <pre>
* +EPICSCAOutput_1 = {
* Class = EPICSCA::EPICSCAOutput
* StackSize = 1048576 //Optional the EmbeddedThread stack size. Default value is THREADS_DEFAULT_STACKSIZE * 4u
* CPUs = 0xff //Optional the affinity of the EmbeddedThread (where the EPICS context is attached).
* IgnoreBufferOverrun = 1 //Optional. If true no error will be triggered when the thread that writes into EPICS does not consume the data fast enough.
* NumberOfBuffers = 10 //Compulsory. Number of buffers in a circular buffer that asynchronously writes the PV values. Each buffer is capable of holding a copy of all the DataSourceI signals.
* Signals = {
* PV1 = { //At least one shall be defined
* PVName = My::PV1 //Compulsory. Name of the PV.
* Type = uint32 //Compulsory. Supported types are char8[40], string[40], uint8, int8, uint16, int16, int32, uint32, float32 and float64
* }
* ...
* }
* }
*
* </pre>
*/
class JAEPICSCAOutput: public DataSourceI {
public:
CLASS_REGISTER_DECLARATION()
/**
* @brief Default constructor. NOOP.
*/
JAEPICSCAOutput();
/**
* @brief Destructor.
* @details TODO.
*/
virtual ~JAEPICSCAOutput();
/**
* @brief See DataSourceI::AllocateMemory. NOOP.
* @return true.
*/
virtual bool AllocateMemory();
/**
* @brief See DataSourceI::GetNumberOfMemoryBuffers.
* @return 1.
*/
virtual uint32 GetNumberOfMemoryBuffers();
/**
* @brief See DataSourceI::GetSignalMemoryBuffer.
* @pre
* SetConfiguredDatabase
*/
virtual bool GetSignalMemoryBuffer(const uint32 signalIdx,
const uint32 bufferIdx,
void *&signalAddress);
/**
* @brief See DataSourceI::GetNumberOfMemoryBuffers.
* @details Only OutputSignals are supported.
* @return MemoryMapAsyncOutputBroker.
*/
virtual const char8 *GetBrokerName(StructuredDataI &data,
const SignalDirection direction);
/**
* @brief See DataSourceI::GetInputBrokers.
* @return false.
*/
virtual bool GetInputBrokers(ReferenceContainer &inputBrokers,
const char8* const functionName,
void * const gamMemPtr);
/**
* @brief See DataSourceI::GetOutputBrokers.
* @details adds a memory MemoryMapOutputBroker instance to the outputBrokers
* @return true.
*/
virtual bool GetOutputBrokers(ReferenceContainer &outputBrokers,
const char8* const functionName,
void * const gamMemPtr);
/**
* @brief See DataSourceI::PrepareNextState. NOOP.
* @return true.
*/
virtual bool PrepareNextState(const char8 * const currentStateName,
const char8 * const nextStateName);
/**
* @brief Loads and verifies the configuration parameters detailed in the class description.
* @return true if all the mandatory parameters are correctly specified and if the specified optional parameters have valid values.
*/
virtual bool Initialise(StructuredDataI & data);
/**
* @brief Final verification of all the parameters. Setup of the memory required to hold all the signals.
* @details This method verifies that all the parameters requested by the GAMs interacting with this DataSource
* are valid and consistent with the parameters set during the initialisation phase.
* In particular the following conditions shall be met:
* - All the signals have the PVName defined
* - All the signals have one of the following types: uint32, int32, float32 or float64.
* @return true if all the parameters are valid and the conditions above are met.
*/
virtual bool SetConfiguredDatabase(StructuredDataI & data);
/**
* @brief Gets the affinity of the thread which is going to be used to asynchronously write data with ca_put.
* @return the affinity of the thread which is going to be used to asynchronously write data with ca_put.
*/
uint32 GetCPUMask() const;
/**
* @brief Gets the stack size of the thread which is going to be used to asynchronously write data with ca_put.
* @return the stack size of the thread which is going to be used to asynchronously write data with ca_put.
*/
uint32 GetStackSize() const;
/**
* @brief Gets the number of buffers in the circular buffer that asynchronously writes the PV values.
* @return the number of buffers in the circular buffer that asynchronously writes the PV values.
*/
uint32 GetNumberOfBuffers() const;
/**
* @brief Provides the context to execute all the EPICS ca_put calls.
* @details Executes in the context of the MemoryMapAsyncOutputBroker thread the following EPICS calls:
* ca_context_create, ca_create_channel, ca_create_subscription, ca_clear_subscription,
* ca_clear_event, ca_clear_channel, ca_detach_context and ca_context_destroy
* @return true if all the EPICS calls return without any error.
*/
virtual bool Synchronise();
/**
* @brief Gets if buffer overruns is being ignored (i.e. the consumer thread which writes into EPICS is not consuming the data fast enough).
* @return if true no error is to be triggered when there is a buffer overrun.
*/
bool IsIgnoringBufferOverrun() const;
private:
/**
* List of PVs.
*/
PVWrapper *pvs;
/**
* The CPU mask for the executor
*/
uint32 cpuMask;
/**
* The stack size
*/
uint32 stackSize;
/**
* Stores the configuration information received at Initialise.
*/
ConfigurationDatabase originalSignalInformation;
/**
* The number of buffers for the circular buffer that flushes data into EPICS
*/
uint32 numberOfBuffers;
/**
* True once the epics thread context is set
*/
bool threadContextSet;
/**
* If true no error will be triggered when the data cannot be consumed by the thread doing the caputs.
*/
uint32 ignoreBufferOverrun;
};
}
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* EPICSCADATASOURCE_H_ */