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,188 @@
/**
* @file JASourceChoiseGAM.cpp
* @brief Source file for class JASourceChoiseGAM
* @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 source file contains the definition of all the methods for
* the class JASourceChoiseGAM (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 "JASourceChoiseGAM.h"
#include "AdvancedErrorManagement.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JASourceChoiseGAM::JASourceChoiseGAM() {
// initialize member variables.
numberOfPVs = 0;
}
JASourceChoiseGAM::~JASourceChoiseGAM() {
}
bool JASourceChoiseGAM::Initialise(MARTe::StructuredDataI & data) {
//GAM parameters are initialized.
using namespace MARTe;
bool ok = GAM::Initialise(data);
if (ok) {
ok = data.Read("numberOfPVs", numberOfPVs);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The numberOfPVs parameter shall be specified");
}
}
return ok;
}
bool JASourceChoiseGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
//This method changes internal parameter based on next realtime state.
return true;
}
bool JASourceChoiseGAM::Setup() {
// Setup memory for input/output signals on the GAM.
using namespace MARTe;
bool ok = (numberOfInputSignals == numberOfPVs*3u);
if (ok) {
ok = (numberOfOutputSignals == numberOfPVs);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "%d *3 output signals shall be defined", numberOfPVs);
}
}
else {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "%d input signals shall be defined", numberOfPVs);
}
// Do type check for input signals.
int int_num = 0;
int float_num = 0;
if (ok) {
uint32 c;
for (c = 0u; c < numberOfInputSignals; c++) {
TypeDescriptor inputType = GetSignalType(InputSignals, c);
if(inputType == UnsignedInteger32Bit){
int_num++;
} else if (inputType == Float32Bit) {
float_num++;
} else {
ok = false;
};
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or flaot32", signalName.Buffer());
}
}
}
// Do type check for output signals
if (ok) {
uint32 c;
for (c = 0u; c < numberOfOutputSignals; c++) {
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
ok = ((outputType == UnsignedInteger32Bit) || (outputType == Float32Bit));
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or float32", signalName.Buffer());
}
}
}
// Set memory
inputUInt32.resize(numberOfPVs*2);
inputFloat32.resize(numberOfPVs*2);
choise.resize(numberOfPVs);
outputUInt32.resize(numberOfPVs);
outputFloat32.resize(numberOfPVs);
prevUInt32.resize(numberOfPVs*2);
prevFloat32.resize(numberOfPVs*2);
if(ok){
for(uint32 i=0; i<numberOfPVs; i++){ //Expected inp1, inp2, choise order in signal list.
TypeDescriptor inputType = GetSignalType(InputSignals, i*3);
if(inputType == UnsignedInteger32Bit){
inputUInt32[2*i] = reinterpret_cast<uint32 *>(GetInputSignalMemory(3*i));
inputUInt32[2*i+1] = reinterpret_cast<uint32 *>(GetInputSignalMemory(3*i+1));
choise[i] = reinterpret_cast<uint32 *>(GetInputSignalMemory(3*i+2));
outputUInt32[i] = reinterpret_cast<uint32 *>(GetOutputSignalMemory(i));
} else if(inputType == Float32Bit){
inputFloat32[2*i] = reinterpret_cast<float *>(GetInputSignalMemory(3*i));
inputFloat32[2*i+1] = reinterpret_cast<float *>(GetInputSignalMemory(3*i+1));
choise[i] = reinterpret_cast<uint32 *>(GetInputSignalMemory(3*i+2));
outputFloat32[i] = reinterpret_cast<float32 *>(GetOutputSignalMemory(i));
}
prevUInt32[2*i] = 0;
prevUInt32[2*i+1] = 0;
prevFloat32[2*i] = 0;
prevFloat32[2*i+1] = 0;
}
}
return ok;
}
bool JASourceChoiseGAM::Execute() {
// This method is called every realtime state thread cycle.
using namespace MARTe;
for (uint32 i=0; i < numberOfPVs; i++){
if(*choise[i]==0){
if(outputUInt32[i]){
if(prevUInt32[i*2] != *inputUInt32[i*2]){
*outputUInt32[i] = *inputUInt32[i*2];
prevUInt32[i*2] = *inputUInt32[i*2];
prevUInt32[1+i*2] = *inputUInt32[1+i*2];
}
} else if(outputFloat32[i]){
if(prevFloat32[i*2] != *inputFloat32[i*2]){
*outputFloat32[i] = *inputFloat32[i*2];
prevFloat32[i*2] = *inputFloat32[i*2];
prevFloat32[1+i*2] = *inputFloat32[1+i*2];
}
}
} else {
if(outputUInt32[i]){
if(prevUInt32[1+i*2] != *inputUInt32[1+i*2]){
*outputUInt32[i] = *inputUInt32[1+i*2];
prevUInt32[i*2] = *inputUInt32[i*2];
prevUInt32[1+i*2] = *inputUInt32[1+i*2];
}
} else if (outputFloat32[i]){
if(prevFloat32[1+i*2] != *inputFloat32[1+i*2]){
*outputFloat32[i] = *inputFloat32[1+i*2];
prevFloat32[i*2] = *inputFloat32[i*2];
prevFloat32[1+i*2] = *inputFloat32[1+i*2];
}
}
}
}
return true;
}
CLASS_REGISTER(JASourceChoiseGAM, "1.0")

View File

@@ -0,0 +1,84 @@
/**
* @file JASourceChoiseGAM.h
* @brief Header file for class JASourceChoiseGAM
* @date Mar 04, 2019
* @author kuchida
*
* @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 JASourceChoiseGAM
* 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_JASourceChoiseGAM_H_
#define GAMS_JASourceChoiseGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
#include <vector>
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
class JASourceChoiseGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JASourceChoiseGAM();
virtual ~JASourceChoiseGAM();
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
//GAM fixed parameters.
MARTe::uint32 numberOfPVs;
// Input signals
std::vector<MARTe::uint32 *> inputUInt32;
std::vector<MARTe::float32 *> inputFloat32;
std::vector<MARTe::uint32 *> choise;
// Output signals
std::vector<MARTe::uint32 *> outputUInt32;
std::vector<MARTe::float32 *> outputFloat32;
// Previous Input value
std::vector<MARTe::uint32> prevUInt32;
std::vector<MARTe::float32> prevFloat32;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JASourceChoiseGAM_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,55 @@
#############################################################
#
# 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=JASourceChoiseGAM.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)/JASourceChoiseGAM$(LIBEXT) \
$(BUILD_DIR)/JASourceChoiseGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)