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,178 @@
/**
* @file JATriangleWaveGAM.cpp
* @brief Source file for class JATriangleWaveGAM
* @date Jan, 2019
* @author rhari
*
* @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 source file contains the definition of all the methods for
* the class JATriangleWaveGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "AdvancedErrorManagement.h"
#include "JATriangleWaveGAM.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
MARTe::float32 absFloat(MARTe::float32 x) {
if (x < 0.0f) {
return -x;
}
return x;
}
JATriangleWaveGAM::JATriangleWaveGAM() {
frequency = NULL_PTR(MARTe::float32 *);
amplitude = NULL_PTR(MARTe::float32 *);
offset = NULL_PTR(MARTe::float32 *);
plcStandby = NULL_PTR(MARTe::uint32 *);
waveOutput = NULL_PTR(MARTe::float32 *);
time = 0.0f;
}
JATriangleWaveGAM::~JATriangleWaveGAM() {
}
bool JATriangleWaveGAM::Initialise(MARTe::StructuredDataI & data) {
using namespace MARTe;
return GAM::Initialise(data);
}
bool JATriangleWaveGAM::Setup() {
using namespace MARTe;
bool ok = (numberOfInputSignals == 4u);
if (ok) {
ok = (numberOfOutputSignals == 1u);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "One output signal shall be defined.");
}
}
else {
REPORT_ERROR(ErrorManagement::ParametersError, "Four input signals shall be defined.");
}
uint32 freqIndex;
uint32 ampIndex;
uint32 offsetIndex;
uint32 plcStandbyIndex;
if (ok) {
StreamString signalName = "Frequency";
ok = GetSignalIndex(InputSignals, freqIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Frequency input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, freqIndex);
ok = (inputType == Float32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Frequency shall be defined as float32.");
}
}
}
if (ok) {
StreamString signalName = "Amplitude";
ok = GetSignalIndex(InputSignals, ampIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Amplitude input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, ampIndex);
ok = (inputType == Float32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Amplitude shall be defined as float32.");
}
}
}
if (ok) {
StreamString signalName = "Offset";
ok = GetSignalIndex(InputSignals, offsetIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Offset input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, offsetIndex);
ok = (inputType == Float32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Offset shall be defined as float32.");
}
}
}
if (ok) {
StreamString signalName = "PLCSTANDBY";
ok = GetSignalIndex(InputSignals, plcStandbyIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "PLCSTANDBY input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, plcStandbyIndex);
ok = (inputType == UnsignedInteger32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "PLCSTANDBY shall be defined as uint32.");
}
}
}
if (ok) {
TypeDescriptor inputType = GetSignalType(OutputSignals, 0);
ok = (inputType == Float32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Amplitude shall be defined as float32.");
}
}
if (ok) {
frequency = reinterpret_cast<float32 *>(GetInputSignalMemory(freqIndex));
amplitude = reinterpret_cast<float32 *>(GetInputSignalMemory(ampIndex));
offset = reinterpret_cast<float32 *>(GetInputSignalMemory(offsetIndex));
plcStandby = reinterpret_cast<uint32 *>(GetInputSignalMemory(plcStandbyIndex));
waveOutput = reinterpret_cast<float32 *>(GetOutputSignalMemory(0));
}
return ok;
}
bool JATriangleWaveGAM::Execute() {
using namespace MARTe;
// If frequency is not set, output 0.
if (*frequency <= 0.0f || *plcStandby == 0u) {
*waveOutput = 0.0f;
return true;
}
// Increase the current time.
++time;
// Calculate the period in milliseconds
float32 periodMs = 1000.0 / *frequency;
// Make sure the time is on [0, periodMs] interval.
while (time > periodMs) {
time -= periodMs;
}
// Formula:
// f(x) = |x - 0.5| * 2 * amplitude
// where x is between 0 and 1
*waveOutput = absFloat((time / periodMs) - 0.5f) * 2.0f * (*amplitude) + *offset;
return true;
}
CLASS_REGISTER(JATriangleWaveGAM, "1.0")

View File

@@ -0,0 +1,130 @@
/**
* @file JATriangleWaveGAM.h
* @brief Header file for class JATriangleWaveGAM
* @date Jan, 2019
* @author rhari
*
* @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 JATriangleWaveGAM
* 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_JATRIANGLEWAVEGAM_H_
#define GAMS_JATRIANGLEWAVEGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM provides triangular waveform output within 1kHz thread.
*
* The configuration syntax is (names and signal quantity are only given as an example):
* <pre>
* +CCPSWaveformGAM = {
* Class = JATriangleWaveGAM
* InputSignals = {
* Offset = {
* Alias = OFFSET
* DataSource = EPICSCAInput
* Type = float32
* }
* Frequency = {
* Alias = CCPS_OUTPUT_FREQ
* DataSource = EPICSCAInput
* Type = float32
* }
* Amplitude = {
* Alias = CCPS_OUTPUT_AMP
* DataSource = EPICSCAInput
* Type = float32
* }
* PLCCCPSON = {
* Alias = PLC_CCPSON
* DataSource = EPICSCAInput
* Type = uint32
* }
* READY = {
* Alias = PLC_READY
* DataSource = EPICSCAInput
* Type = uint32
* }
* }
* OutputSignals = {
* CCPS_REF = {
* DataSource = DDB1
* Type = float32
* }
* }
* }
*
* </pre>
*
*/
class JATriangleWaveGAM : public MARTe::GAM {
public:
CLASS_REGISTER_DECLARATION()
JATriangleWaveGAM();
virtual ~JATriangleWaveGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
private:
// Input signal containing the frequency of the waveform.
MARTe::float32 *frequency;
// Input signal containing the amplitude of the waveform.
MARTe::float32 *amplitude;
// Input signal cantaining the offset of the waveform.
MARTe::float32 *offset;
// Input signal containing CCPS_ON_REQUEST
//MARTe::uint32 *plcccpson;
// Input signal condition CCPS_READY
//MARTe::uint32 *plcReady;
// Input signal condition CCPS_STANDBY
MARTe::uint32 *plcStandby;
MARTe::float32 *waveOutput;
MARTe::float32 time;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JATRIANGLEWAVEGAM_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# 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
#
# 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 for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,56 @@
#############################################################
#
# 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
#
# 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 for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JATriangleWaveGAM.x
PACKAGE=GAMs
ROOT_DIR=../../../../obj
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JATriangleWaveGAM$(LIBEXT) \
$(BUILD_DIR)/JATriangleWaveGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)