Added EProbes GAM
Signed-off-by: Bernardo Carvalho <bernardo.carvalho@tecnico.ulisboa.pt>
This commit is contained in:
249
GAMs/ElectricProbesGAM/ElectricProbesGAM.cpp
Normal file
249
GAMs/ElectricProbesGAM/ElectricProbesGAM.cpp
Normal file
@@ -0,0 +1,249 @@
|
||||
/**
|
||||
* @file ElectricProbesGAM.cpp
|
||||
* @brief Source file for class ElectricProbesGAM
|
||||
* @date 06/04/2018
|
||||
* @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 source file contains the definition of all the methods for
|
||||
* the class ElectricProbesGAM (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 "ElectricProbesGAM.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
namespace MARTeIsttok {
|
||||
ElectricProbesGAM::ElectricProbesGAM() :
|
||||
GAM(),
|
||||
MessageI() {
|
||||
gain = 0u;
|
||||
inputSignals = NULL_PTR(MARTe::float32 **);
|
||||
outputSignals = NULL_PTR(MARTe::float32 **);
|
||||
outputSignal1 = NULL;
|
||||
}
|
||||
|
||||
ElectricProbesGAM::~ElectricProbesGAM() {
|
||||
if (inputSignals != NULL_PTR(MARTe::float32 **)) {
|
||||
delete[] inputSignals;
|
||||
}
|
||||
if (outputSignals != NULL_PTR(MARTe::float32 **)) {
|
||||
delete[] outputSignals;
|
||||
}
|
||||
outputSignal1 = NULL;
|
||||
}
|
||||
|
||||
bool ElectricProbesGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::Initialise(data);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Could not Initialise the GAM");
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("Gain", gain);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "The parameter Gain shall be set");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
REPORT_ERROR(ErrorManagement::Information, "Parameter Gain set to %d", gain);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool ElectricProbesGAM::Setup() {
|
||||
using namespace MARTe;
|
||||
uint32 numberOfInputSignals = GetNumberOfInputSignals();
|
||||
uint32 numberOfOutputSignals = GetNumberOfOutputSignals();
|
||||
bool ok = (numberOfInputSignals == 4u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "The number of input signals shall be equal to 4. numberOfInputSignals = %d ", numberOfInputSignals);
|
||||
}
|
||||
if (ok) {
|
||||
inputSignals = new float32*[numberOfInputSignals];
|
||||
}
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals == 1u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError,
|
||||
"The number of output signals shall be equal to 1. numberOfOutputSignals = %d", numberOfOutputSignals);
|
||||
}
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
uint32 n;
|
||||
for (n = 0u; (n < numberOfInputSignals) && (ok); n++) {
|
||||
StreamString inputSignalName;
|
||||
ok = GetSignalName(InputSignals, n, inputSignalName);
|
||||
TypeDescriptor inputSignalType = GetSignalType(InputSignals, n);
|
||||
ok = (inputSignalType == Float32Bit);
|
||||
if (!ok) {
|
||||
const char8 * const inputSignalTypeStr = TypeDescriptor::GetTypeNameFromTypeDescriptor(inputSignalType);
|
||||
REPORT_ERROR(ErrorManagement::ParametersError,
|
||||
"The type of the input signals shall be float32. inputSignalType = %s", inputSignalTypeStr);
|
||||
}
|
||||
uint32 numberOfInputSamples = 0u;
|
||||
if (ok) {
|
||||
ok = GetSignalNumberOfSamples(InputSignals, n, numberOfInputSamples);
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
ok = (numberOfInputSamples == 1u);
|
||||
}
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError,
|
||||
"The number of input signals samples shall be equal to 1. numberOfInputSamples = %d", numberOfInputSamples);
|
||||
}
|
||||
uint32 numberOfInputDimensions = 0u;
|
||||
if (ok) {
|
||||
ok = GetSignalNumberOfDimensions(InputSignals, n, numberOfInputDimensions);
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
ok = (numberOfInputDimensions == 0u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(
|
||||
ErrorManagement::ParametersError,
|
||||
"The number of input signals dimensions shall be equal to 0. numberOfInputDimensions(%s) = %d", inputSignalName.Buffer(), numberOfInputDimensions);
|
||||
}
|
||||
}
|
||||
uint32 numberOfInputElements = 0u;
|
||||
if (ok) {
|
||||
ok = GetSignalNumberOfElements(InputSignals, n, numberOfInputElements);
|
||||
}
|
||||
if (ok) {
|
||||
ok = (numberOfInputElements == 1u);
|
||||
}
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError,
|
||||
"The number of input signal elements shall be equal to 1. numberOfInputElements(%s) = %d", inputSignalName.Buffer(), numberOfInputElements);
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
inputSignals[n] = reinterpret_cast<float32 *>(GetInputSignalMemory(n));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
ok = (numberOfOutputSignals == 2u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "The number of output signals shall be equal to 2. numberOfOutputSignals = %d ", numberOfOutputSignals);
|
||||
}
|
||||
if (ok) {
|
||||
outputSignals = new float32*[numberOfOutputSignals];
|
||||
}
|
||||
if (ok) {
|
||||
uint32 n;
|
||||
for (n = 0u; (n < numberOfOutputSignals) && (ok); n++) {
|
||||
StreamString outputSignalName;
|
||||
ok = GetSignalName(OutputSignals, n, outputSignalName);
|
||||
TypeDescriptor outputSignalType = GetSignalType(OutputSignals, n);
|
||||
ok = (outputSignalType == Float32Bit);
|
||||
if (!ok) {
|
||||
const char8 * const outputSignalTypeStr = TypeDescriptor::GetTypeNameFromTypeDescriptor(outputSignalType);
|
||||
REPORT_ERROR(ErrorManagement::ParametersError,
|
||||
"The type of the output signals shall be float32. outputSignalType = %s", outputSignalTypeStr);
|
||||
}
|
||||
uint32 numberOfOutputSamples = 0u;
|
||||
if (ok) {
|
||||
ok = GetSignalNumberOfSamples(OutputSignals, n, numberOfOutputSamples);
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSamples == 1u);
|
||||
}
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError,
|
||||
"The number of output signals samples shall be equal to 1. numberOfOutputSamples = %d", numberOfOutputSamples);
|
||||
}
|
||||
uint32 numberOfOutputDimensions = 0u;
|
||||
if (ok) {
|
||||
ok = GetSignalNumberOfDimensions(OutputSignals, n, numberOfOutputDimensions);
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
ok = (numberOfOutputDimensions == 0u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(
|
||||
ErrorManagement::ParametersError,
|
||||
"The number of output signals dimensions shall be equal to 0. numberOfOutputDimensions (%s) = %d", outputSignalName.Buffer(), numberOfOutputDimensions);
|
||||
}
|
||||
}
|
||||
uint32 numberOfOutputElements = 0u;
|
||||
if (ok) {
|
||||
ok = GetSignalNumberOfElements(OutputSignals, n, numberOfOutputElements);
|
||||
}
|
||||
if (ok) {
|
||||
ok = (numberOfOutputElements == 1u);
|
||||
}
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError,
|
||||
"The number of output signals elements shall be equal to 1. (%s) numberOfOutputElements = %d", outputSignalName.Buffer(), numberOfOutputElements);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
if (ok) {
|
||||
outputSignals[0] = reinterpret_cast<float32 *>(GetOutputSignalMemory(0));
|
||||
outputSignal1 = reinterpret_cast<float32 *>(GetOutputSignalMemory(1));
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
|
||||
}
|
||||
|
||||
bool ElectricProbesGAM::Execute() {
|
||||
//*outputSignal = *inputSignal;
|
||||
//*outputSignal1 = *inputSignals[0] - *inputSignals[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ElectricProbesGAM::ExportData(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::ExportData(data);
|
||||
if (ok) {
|
||||
ok = data.CreateRelative("Parameters");
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Write("Gain", gain);
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.MoveToAncestor(1u);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(ElectricProbesGAM, "1.0")
|
||||
//CLASS_METHOD_REGISTER(AtcaIopConfig, WriteEoWo)
|
||||
|
||||
}
|
||||
|
||||
// vim: syntax=cpp ts=4 sw=4 sts=4 sr et
|
||||
135
GAMs/ElectricProbesGAM/ElectricProbesGAM.h
Normal file
135
GAMs/ElectricProbesGAM/ElectricProbesGAM.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* @file ElectricProbesGAM.h
|
||||
* @brief Header file for class ElectricProbesGAM
|
||||
* @date 06/04/2018
|
||||
* @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 ElectricProbesGAM
|
||||
* 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 ELECTRICPROBESGAM_H_
|
||||
#define ELECTRICPROBESGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GAM.h"
|
||||
#include "MessageI.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
namespace MARTeIsttok {
|
||||
/**
|
||||
* @brief An example of a GAM which has fixed inputs and outputs.
|
||||
*
|
||||
* @details This GAM multiplies the input signal by a Gain.
|
||||
* The configuration syntax is (names and types are only given as an example):
|
||||
*
|
||||
* +GAMElectricProbes = {
|
||||
* Class = ElectricProbesGAM
|
||||
* Gain = 5 //Compulsory
|
||||
* InputSignals = {
|
||||
* Signal1 = {
|
||||
* DataSource = "DDB1"
|
||||
* Type = uint32
|
||||
* }
|
||||
* }
|
||||
* OutputSignals = {
|
||||
* Signal1 = {
|
||||
* DataSource = "DDB1"
|
||||
* Type = uint32
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
class ElectricProbesGAM : public MARTe::GAM, public MARTe::MessageI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
/**
|
||||
* @brief Constructor. NOOP.
|
||||
*/
|
||||
ElectricProbesGAM();
|
||||
|
||||
/**
|
||||
* @brief Destructor. NOOP.
|
||||
*/
|
||||
virtual ~ElectricProbesGAM();
|
||||
|
||||
/**
|
||||
* @brief Reads the Gain from the configuration file.
|
||||
* @param[in] data see GAM::Initialise. The parameter Gain shall exist and will be read as an uint32.
|
||||
* @return true if the parameter Gain can be read.
|
||||
*/
|
||||
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||
|
||||
/**
|
||||
* @brief Verifies correctness of the GAM configuration.
|
||||
* @details Checks that the number of input signals is equal to the number of output signals is equal to one and that the same type is used.
|
||||
* @return true if the pre-conditions are met.
|
||||
* @pre
|
||||
* SetConfiguredDatabase() &&
|
||||
* GetNumberOfInputSignals() == GetNumberOfOutputSignals() == 1 &&
|
||||
* GetSignalType(InputSignals, 0) == GetSignalType(OutputSignals, 0) == uint32 &&
|
||||
* GetSignalNumberOfDimensions(InputSignals, 0) == GetSignalNumberOfDimensions(OutputSignals, 0) == 0 &&
|
||||
* GetSignalNumberOfSamples(InputSignals, 0) == GetSignalNumberOfSamples(OutputSignals, 0) == 1 &&
|
||||
* GetSignalNumberOfElements(InputSignals, 0) == GetSignalNumberOfElements(OutputSignals, 0) == 1
|
||||
*/
|
||||
virtual bool Setup();
|
||||
|
||||
/**
|
||||
* @brief Multiplies the input signal by the Gain.
|
||||
* @return true.
|
||||
*/
|
||||
virtual bool Execute();
|
||||
|
||||
/**
|
||||
* @brief Export information about the component
|
||||
*/
|
||||
virtual bool ExportData(MARTe::StructuredDataI & data);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The input signals
|
||||
*/
|
||||
MARTe::float32 **inputSignals;
|
||||
|
||||
/**
|
||||
* The output signals
|
||||
*/
|
||||
MARTe::float32 **outputSignals;
|
||||
MARTe::float32 *outputSignal1;
|
||||
|
||||
|
||||
/**
|
||||
* The configured gain.
|
||||
*/
|
||||
MARTe::uint32 gain;
|
||||
};
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* ELECTRICPROBESGAM_H_ */
|
||||
|
||||
28
GAMs/ElectricProbesGAM/Makefile.gcc
Normal file
28
GAMs/ElectricProbesGAM/Makefile.gcc
Normal file
@@ -0,0 +1,28 @@
|
||||
#############################################################
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#############################################################
|
||||
|
||||
|
||||
include Makefile.inc
|
||||
|
||||
LIBRARIES += -L$(MDSPLUS_DIR)/lib64 -L$(MDSPLUS_DIR)/lib -lMdsObjectsCppShr
|
||||
56
GAMs/ElectricProbesGAM/Makefile.inc
Normal file
56
GAMs/ElectricProbesGAM/Makefile.inc
Normal 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.
|
||||
#
|
||||
#############################################################
|
||||
|
||||
OBJSX=ElectricProbesGAM.x
|
||||
|
||||
PACKAGE=Components/GAMs
|
||||
|
||||
ROOT_DIR=../../
|
||||
|
||||
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/Scheduler/L5GAMs
|
||||
|
||||
all: $(OBJS) \
|
||||
$(BUILD_DIR)/ElectricProbesGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/ElectricProbesGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include depends.$(TARGET)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
|
||||
Reference in New Issue
Block a user