Generation working and Compilation of MARTe components
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* @file JABitReverseGAM.cpp
|
||||
* @brief Source file for class JABitReverseGAM
|
||||
* @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 JABitReverseGAM (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 "JABitReverseGAM.h"
|
||||
|
||||
#include "AdvancedErrorManagement.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JABitReverseGAM::JABitReverseGAM() {
|
||||
//Input signals.
|
||||
input1 = NULL_PTR(MARTe::uint8 *);
|
||||
|
||||
//Output signals.
|
||||
output1= NULL_PTR(MARTe::uint8 *);
|
||||
}
|
||||
|
||||
JABitReverseGAM::~JABitReverseGAM() {
|
||||
}
|
||||
|
||||
bool JABitReverseGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
//GAM parameters are initialized.
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::Initialise(data);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JABitReverseGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
//This method changes internal parameter based on next realtime state.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JABitReverseGAM::Setup() {
|
||||
// Setup memory for input/output signals on the GAM.
|
||||
using namespace MARTe;
|
||||
bool ok = (numberOfInputSignals == 1u);
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals == 1u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "One output signal shall be defined");
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "One input signals shall be defined");
|
||||
}
|
||||
// Do type check for input signals.
|
||||
if (ok) {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||
ok = ((inputType == UnsignedInteger8Bit));
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint8.", 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 == UnsignedInteger8Bit));
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint8.", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
// Do type cast.
|
||||
if (ok) {
|
||||
input1 = reinterpret_cast<uint8 *>(GetInputSignalMemory(0));
|
||||
|
||||
output1 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(0));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JABitReverseGAM::Execute() {
|
||||
// This method is called every realtime state thread cycle.
|
||||
using namespace MARTe;
|
||||
*output1 = ~(*input1);
|
||||
return true;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JABitReverseGAM, "1.0")
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @file JABitReverseGAM.h
|
||||
* @brief Header file for class JABitReverseGAM
|
||||
* @date Mar 18, 2020
|
||||
* @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 JABitReverseGAM
|
||||
* 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_JABitReverseGAM_H_
|
||||
#define GAMS_JABitReverseGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GAM.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
class JABitReverseGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
JABitReverseGAM();
|
||||
|
||||
virtual ~JABitReverseGAM();
|
||||
|
||||
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
|
||||
|
||||
// Input signals
|
||||
MARTe::uint8 *input1;
|
||||
|
||||
// Output signals
|
||||
MARTe::uint8 *output1;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* GAMS_JABitReverseGAM_H_ */
|
||||
@@ -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
|
||||
@@ -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=JABitReverseGAM.x
|
||||
|
||||
PACKAGE=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/FileSystem/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/JABitReverseGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/JABitReverseGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* @file JABitSumGAM.cpp
|
||||
* @brief Source file for class JABitSumGAM
|
||||
* @date Feb 10, 2020
|
||||
* @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 source file contains the definition of all the methods for
|
||||
* the class JABitSumGAM (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 "JABitSumGAM.h"
|
||||
|
||||
#include "AdvancedErrorManagement.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JABitSumGAM::JABitSumGAM() {
|
||||
//Input signals.
|
||||
input0 = NULL_PTR(MARTe::uint32 *);
|
||||
input1 = NULL_PTR(MARTe::uint32 *);
|
||||
input2 = NULL_PTR(MARTe::uint32 *);
|
||||
input3 = NULL_PTR(MARTe::uint32 *);
|
||||
input4 = NULL_PTR(MARTe::uint32 *);
|
||||
input5 = NULL_PTR(MARTe::uint32 *);
|
||||
input6 = NULL_PTR(MARTe::uint32 *);
|
||||
input7 = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
//Output signals.
|
||||
output= NULL_PTR(MARTe::uint8 *);
|
||||
}
|
||||
|
||||
JABitSumGAM::~JABitSumGAM() {
|
||||
}
|
||||
|
||||
bool JABitSumGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
//GAM parameters are initialized.
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::Initialise(data);
|
||||
if (!ok){
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "ParametersError in init.");
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JABitSumGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
//This method changes internal parameter based on next realtime state.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JABitSumGAM::Setup() {
|
||||
// Setup memory for input/output signals on the GAM.
|
||||
using namespace MARTe;
|
||||
bool ok = (numberOfInputSignals == 8u);
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals == 1u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "One output signal shall be defined");
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Eight input signals shall be defined");
|
||||
}
|
||||
// Do type check for input signals.
|
||||
if (ok) {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||
ok = (inputType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32.", 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 == UnsignedInteger8Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint8.", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
// Do type cast.
|
||||
if (ok) {
|
||||
input0 = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||
input1 = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
|
||||
input2 = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||
input3 = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
|
||||
input4 = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
|
||||
input5 = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||
input6 = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
|
||||
input7 = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
|
||||
|
||||
output = reinterpret_cast<uint8 *>(GetOutputSignalMemory(0));
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JABitSumGAM::Execute() {
|
||||
// This method is called every realtime state thread cycle.
|
||||
using namespace MARTe;
|
||||
*output = *input0 + *input1*2 + *input2*4 + *input3*8 + *input4*16 +
|
||||
*input5*32 + *input6*64 + *input7*128;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JABitSumGAM, "1.0")
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @file JABitSumGAM.h
|
||||
* @brief Header file for class JABitSumGAM
|
||||
* @date Feb 10, 2020
|
||||
* @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 JABitSumGAM
|
||||
* 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_JABitSumGAM_H_
|
||||
#define GAMS_JABitSumGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GAM.h"
|
||||
#include "stdio.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
class JABitSumGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
JABitSumGAM();
|
||||
|
||||
virtual ~JABitSumGAM();
|
||||
|
||||
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:
|
||||
// Input signals
|
||||
MARTe::uint32 *input0;
|
||||
MARTe::uint32 *input1;
|
||||
MARTe::uint32 *input2;
|
||||
MARTe::uint32 *input3;
|
||||
MARTe::uint32 *input4;
|
||||
MARTe::uint32 *input5;
|
||||
MARTe::uint32 *input6;
|
||||
MARTe::uint32 *input7;
|
||||
|
||||
// Output signals
|
||||
MARTe::uint8 *output;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* GAMS_JABitSumGAM_H_ */
|
||||
@@ -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
|
||||
@@ -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=JABitSumGAM.x
|
||||
|
||||
PACKAGE=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/FileSystem/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/JABitSumGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/JABitSumGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
@@ -0,0 +1,309 @@
|
||||
/**
|
||||
* @file JAConditionalSignalUpdateGAM.cpp
|
||||
* @brief Source file for class JAConditionalSignalUpdateGAM
|
||||
* @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 JAConditionalSignalUpdateGAM (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 "JAConditionalSignalUpdateGAM.h"
|
||||
#include "AdvancedErrorManagement.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JAConditionalSignalUpdateGAM::JAConditionalSignalUpdateGAM() {
|
||||
inputSignals = NULL_PTR(void **);
|
||||
inputSignalTypes = NULL_PTR(MARTe::TypeDescriptor *);
|
||||
values = NULL_PTR(MARTe::uint32 *);
|
||||
valuesCount = 0u;
|
||||
outputSignals = NULL_PTR(MARTe::uint32 **);
|
||||
defaultValues = NULL_PTR(MARTe::uint32 **);
|
||||
needsReset = false;
|
||||
expectedValues = NULL_PTR(MARTe::uint32 *);
|
||||
expectedValuesCount = 0u;
|
||||
operation = And;
|
||||
comparators = NULL_PTR(ComparisonMode *);
|
||||
}
|
||||
|
||||
JAConditionalSignalUpdateGAM::~JAConditionalSignalUpdateGAM() {
|
||||
if (outputSignals != NULL_PTR(MARTe::uint32 **)) {
|
||||
delete[] outputSignals;
|
||||
}
|
||||
if (inputSignals != NULL_PTR(void **)) {
|
||||
delete[] inputSignals;
|
||||
}
|
||||
if (inputSignalTypes != NULL_PTR(MARTe::TypeDescriptor *)) {
|
||||
delete[] inputSignalTypes;
|
||||
}
|
||||
if (values != NULL_PTR(MARTe::uint32 *)) {
|
||||
delete[] values;
|
||||
}
|
||||
if (comparators != NULL_PTR(ComparisonMode *)) {
|
||||
delete[] comparators;
|
||||
}
|
||||
if (defaultValues != NULL_PTR(MARTe::uint32 **)) {
|
||||
delete[] defaultValues;
|
||||
}
|
||||
}
|
||||
|
||||
bool JAConditionalSignalUpdateGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::Initialise(data);
|
||||
if (ok) {
|
||||
// Read expected values.
|
||||
AnyType valuesArray = data.GetType("ExpectedValues");
|
||||
|
||||
if (valuesArray.GetDataPointer() != NULL) {
|
||||
expectedValuesCount = valuesArray.GetNumberOfElements(0u);
|
||||
|
||||
expectedValues = new uint32[expectedValuesCount];
|
||||
|
||||
Vector<uint32> valuesVector(expectedValues, expectedValuesCount);
|
||||
ok = (data.Read("ExpectedValues", valuesVector));
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
// Read comparators.
|
||||
AnyType comparatorsArray = data.GetType("Comparators");
|
||||
if (comparatorsArray.GetDataPointer() != NULL) {
|
||||
uint32 count;
|
||||
if (ok) {
|
||||
count = comparatorsArray.GetNumberOfElements(0u);
|
||||
ok = count == expectedValuesCount;
|
||||
}
|
||||
if (ok) {
|
||||
comparators = new ComparisonMode[count];
|
||||
StreamString* comp = new StreamString[count];
|
||||
Vector<StreamString> compVector(comp, count);
|
||||
|
||||
ok = (data.Read("Comparators", compVector));
|
||||
|
||||
if (ok) {
|
||||
for (uint32 i = 0; i < count; ++i) {
|
||||
if (comp[i] == "EQUALS") {
|
||||
comparators[i] = Equals;
|
||||
} else if (comp[i] == "NOT") {
|
||||
comparators[i] = Not;
|
||||
} else if (comp[i] == "GREATER") {
|
||||
comparators[i] = Greater;
|
||||
} else if (comp[i] == "EQUALS_OR_GREATER") {
|
||||
comparators[i] = EqualsOrGreater;
|
||||
} else if (comp[i] == "LESS") {
|
||||
comparators[i] = Less;
|
||||
} else if (comp[i] == "EQUALS_OR_LESS") {
|
||||
comparators[i] = EqualsOrLess;
|
||||
} else {
|
||||
ok = false;
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Comparator %s is not defined.", comp[i].Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
delete[] comp;
|
||||
} else {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Expected values and operators shall have the same "
|
||||
"number of elements.");
|
||||
}
|
||||
} else {
|
||||
// Create default comparators (equals) when they aren't provided in the configuration.
|
||||
comparators = new ComparisonMode[expectedValuesCount];
|
||||
for (uint32 i = 0; i < expectedValuesCount; ++i) {
|
||||
comparators[i] = Equals;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
MARTe::StreamString operationStr;
|
||||
if (data.Read("Operation", operationStr)) {
|
||||
if (operationStr == "AND") {
|
||||
operation = And;
|
||||
}
|
||||
else if (operationStr == "OR") {
|
||||
operation = Or;
|
||||
}
|
||||
else if (operationStr == "NOR") {
|
||||
operation = Nor;
|
||||
}
|
||||
else if (operationStr == "XOR") {
|
||||
operation = Xor;
|
||||
}
|
||||
else {
|
||||
ok = false;
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Operation %s is not defined", operationStr.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
// Read output signal values to be set.
|
||||
AnyType valuesArray = data.GetType("Values");
|
||||
ok = (valuesArray.GetDataPointer() != NULL);
|
||||
|
||||
if (ok) {
|
||||
valuesCount = valuesArray.GetNumberOfElements(0u);
|
||||
ok = valuesCount > 0u;
|
||||
}
|
||||
if (ok) {
|
||||
values = new uint32[valuesCount];
|
||||
|
||||
Vector<uint32> valuesVector(values, valuesCount);
|
||||
ok = (data.Read("Values", valuesVector));
|
||||
}
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Values shall be defined.");
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JAConditionalSignalUpdateGAM::Setup() {
|
||||
using namespace MARTe;
|
||||
bool ok = numberOfInputSignals == (expectedValuesCount + numberOfOutputSignals);
|
||||
if (ok) {
|
||||
inputSignals = new void*[expectedValuesCount];
|
||||
defaultValues = new uint32*[numberOfOutputSignals];
|
||||
uint32 i;
|
||||
for (i = 0u; i < expectedValuesCount; i++) {
|
||||
inputSignals[i] = GetInputSignalMemory(i);
|
||||
}
|
||||
for (; i < numberOfInputSignals; i++) {
|
||||
defaultValues[i - expectedValuesCount] = reinterpret_cast<uint32 *>(GetInputSignalMemory(i));
|
||||
}
|
||||
} else {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Number of input signals shall be equal to number "
|
||||
"of expected values plus number of output signals.");
|
||||
}
|
||||
if (ok) {
|
||||
inputSignalTypes = new TypeDescriptor[expectedValuesCount];
|
||||
uint32 i;
|
||||
for (i = 0u; (i < expectedValuesCount) && (ok); i++) {
|
||||
inputSignalTypes[i] = GetSignalType(InputSignals, i);
|
||||
ok = ((inputSignalTypes[i] == UnsignedInteger32Bit) || (inputSignalTypes[i] == UnsignedInteger16Bit));
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, i, signalName);
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or uint16", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = numberOfOutputSignals == valuesCount;
|
||||
if (ok) {
|
||||
ok = numberOfOutputSignals > 0u;
|
||||
if (ok) {
|
||||
outputSignals = new uint32*[numberOfOutputSignals];
|
||||
uint32 i;
|
||||
for (i = 0u; i < numberOfOutputSignals; i++) {
|
||||
outputSignals[i] = reinterpret_cast<uint32 *>(GetOutputSignalMemory(i));
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "At least one output signal shall be defined");
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Number of output signals shall be the same as "
|
||||
"number of provided values.");
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JAConditionalSignalUpdateGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
needsReset = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JAConditionalSignalUpdateGAM::Execute() {
|
||||
if (!needsReset) {
|
||||
bool eventDetected = expectedValuesCount == 0;
|
||||
if (!eventDetected) {
|
||||
if (operation == Or) {
|
||||
MARTe::uint32 j;
|
||||
for (j = 0; (j < expectedValuesCount) && (!eventDetected); j++) {
|
||||
eventDetected = Compare(j);
|
||||
}
|
||||
}
|
||||
else if (operation == Nor) {
|
||||
MARTe::uint32 j;
|
||||
for (j = 0; (j < expectedValuesCount) && (!eventDetected); j++) {
|
||||
eventDetected = Compare(j);
|
||||
}
|
||||
eventDetected = !eventDetected;
|
||||
}
|
||||
else if (operation == And) {
|
||||
MARTe::uint32 j;
|
||||
eventDetected = Compare(0);
|
||||
for (j = 1; (j < expectedValuesCount); j++) {
|
||||
eventDetected &= Compare(j);
|
||||
}
|
||||
}
|
||||
else if (operation == Xor) {
|
||||
MARTe::uint32 j;
|
||||
MARTe::uint32 eventDetectedUint32;
|
||||
if (inputSignalTypes[0] == MARTe::UnsignedInteger32Bit) {
|
||||
eventDetectedUint32 = *static_cast<MARTe::uint32 *>(inputSignals[0]);
|
||||
}
|
||||
else {
|
||||
eventDetectedUint32 = *static_cast<MARTe::uint16 *>(inputSignals[0]);
|
||||
}
|
||||
for (j = 1; (j < expectedValuesCount); j++) {
|
||||
eventDetectedUint32 ^= Compare(j);
|
||||
}
|
||||
eventDetected = (eventDetectedUint32 == 1u);
|
||||
}
|
||||
}
|
||||
if (eventDetected) {
|
||||
needsReset = true;
|
||||
MARTe::uint32 i;
|
||||
for (i = 0u; i < numberOfOutputSignals; ++i) {
|
||||
*outputSignals[i] = values[i];
|
||||
MARTe::StreamString signalName;
|
||||
(void) GetSignalName(MARTe::OutputSignals, i, signalName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
MARTe::uint32 i;
|
||||
for (i = 0u; i < numberOfOutputSignals; ++i) {
|
||||
*outputSignals[i] = *defaultValues[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JAConditionalSignalUpdateGAM::Compare(MARTe::uint32 index) {
|
||||
if (inputSignalTypes[index] == MARTe::UnsignedInteger32Bit) {
|
||||
return Compare<MARTe::uint32>(index);
|
||||
}
|
||||
return Compare<MARTe::uint16>(index);
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JAConditionalSignalUpdateGAM, "1.0")
|
||||
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* @file JAConditionalSignalUpdateGAM.h
|
||||
* @brief Header file for class JAConditionalSignalUpdateGAM
|
||||
* @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 JAConditionalSignalUpdateGAM
|
||||
* 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_JACONDITIONALSIGNALUPDATEGAM_H_
|
||||
#define GAMS_JACONDITIONALSIGNALUPDATEGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "GAM.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief GAM that writes predefined values to output signals when a condition is met.
|
||||
* If there are no conditional signals provided, the condition is presumed to be met.
|
||||
*
|
||||
* +ASYNCShotlengthControlGAM = {
|
||||
* Class = JAConditionalSignalUpdateGAM
|
||||
* Operation = OR // Logical operation performed between conditional signals
|
||||
* // Supported values: AND, OR, XOR, NOR
|
||||
* // Default: AND
|
||||
* ExpectedValues = {1 1} // Values to which conditional signals will be compared.
|
||||
* Comparators = {EQUALS EQUALS} // Operator between conditional signal an expected value
|
||||
* // Supported values: EQUALS, NOT, GREATER, EQUALS_OR_GREATER, LESS, EQUALS_OR_LESS
|
||||
* // Default: EQUALS
|
||||
* Values = {0 3} // Values that will be written to output signals when condition is met.
|
||||
* InputSignals = {
|
||||
* // Conditional Signals
|
||||
* SHOTLEN_FLAG = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* MODE_SHOTLEN_FLAG = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* // Default values (set to output signals before the condition is met)
|
||||
* APS_SWON = { // APS_SWON will keep the value from previous state.
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* BPS_SWON_DEFAULT = { // BPS_SWON will be set to 7 before condition is met.
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* Default = 7
|
||||
* }
|
||||
* }
|
||||
* OutputSignals = {
|
||||
* APS_SWON = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* BPS_SWON = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
class JAConditionalSignalUpdateGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
JAConditionalSignalUpdateGAM();
|
||||
|
||||
virtual ~JAConditionalSignalUpdateGAM();
|
||||
|
||||
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:
|
||||
/**
|
||||
* @brief Does the input signal at provided index have the expected value.
|
||||
* @param[in] index of the signal.
|
||||
* @return true if the signal has expected value.
|
||||
*/
|
||||
bool Compare(MARTe::uint32 index);
|
||||
|
||||
template <class T>
|
||||
bool Compare(MARTe::uint32 index);
|
||||
|
||||
enum OperationMode {
|
||||
And, Or, Xor, Nor
|
||||
};
|
||||
|
||||
enum ComparisonMode {
|
||||
Equals, Not, Greater, EqualsOrGreater, Less, EqualsOrLess
|
||||
};
|
||||
|
||||
// Input signals
|
||||
void **inputSignals;
|
||||
|
||||
MARTe::TypeDescriptor *inputSignalTypes;
|
||||
|
||||
// Condition operation.
|
||||
OperationMode operation;
|
||||
|
||||
// Array of expected values of input signals.
|
||||
MARTe::uint32* expectedValues;
|
||||
|
||||
// Expected values count (must be equal to numberOfInputSignals)
|
||||
MARTe::uint32 expectedValuesCount;
|
||||
|
||||
// Array of comparators
|
||||
ComparisonMode* comparators;
|
||||
|
||||
// Values to be written on output signals when input signal has the expected value.
|
||||
MARTe::uint32 *values;
|
||||
|
||||
// Number of values (must be equal to numberOfOutputSignals)
|
||||
MARTe::uint32 valuesCount;
|
||||
|
||||
// Output signals
|
||||
MARTe::uint32 **outputSignals;
|
||||
|
||||
// Default values of output signals
|
||||
MARTe::uint32 **defaultValues;
|
||||
|
||||
// Were output signals already set and we are waiting for a state change before they are set again.
|
||||
bool needsReset;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
template <class T>
|
||||
bool JAConditionalSignalUpdateGAM::Compare(MARTe::uint32 index) {
|
||||
switch (comparators[index]) {
|
||||
case Equals:
|
||||
return *static_cast<T *>(inputSignals[index]) == static_cast<T>(expectedValues[index]);
|
||||
case Not:
|
||||
return *static_cast<T *>(inputSignals[index]) != static_cast<T>(expectedValues[index]);
|
||||
case Greater:
|
||||
return *static_cast<T *>(inputSignals[index]) > static_cast<T>(expectedValues[index]);
|
||||
case EqualsOrGreater:
|
||||
return *static_cast<T *>(inputSignals[index]) >= static_cast<T>(expectedValues[index]);
|
||||
case Less:
|
||||
return *static_cast<T *>(inputSignals[index]) < static_cast<T>(expectedValues[index]);
|
||||
default: // case EqualsOrLess:
|
||||
return *static_cast<T *>(inputSignals[index]) <= static_cast<T>(expectedValues[index]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* GAMS_JACONDITIONALSIGNALUPDATEGAM_H_ */
|
||||
@@ -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
|
||||
@@ -0,0 +1,53 @@
|
||||
#############################################################
|
||||
#
|
||||
# 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=JAConditionalSignalUpdateGAM.x
|
||||
|
||||
PACKAGE=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
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/JAConditionalSignalUpdateGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/JAConditionalSignalUpdateGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
|
||||
@@ -0,0 +1,347 @@
|
||||
/**
|
||||
* @file JAMessageGAM.cpp
|
||||
* @brief Source file for class JAMessageGAM
|
||||
* @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 JAMessageGAM (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 "JAMessageGAM.h"
|
||||
#include "MessageI.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T, class U>
|
||||
bool Compare(JAMessageGAM::ComparisonMode comparator, void *inputSignal, U expectedValue) {
|
||||
switch (comparator) {
|
||||
case JAMessageGAM::Equals:
|
||||
return *static_cast<T *>(inputSignal) == expectedValue;
|
||||
case JAMessageGAM::Not:
|
||||
return *static_cast<T *>(inputSignal) != expectedValue;
|
||||
case JAMessageGAM::Greater:
|
||||
return *static_cast<T *>(inputSignal) > expectedValue;
|
||||
case JAMessageGAM::EqualsOrGreater:
|
||||
return *static_cast<T *>(inputSignal) >= expectedValue;
|
||||
case JAMessageGAM::Less:
|
||||
return *static_cast<T *>(inputSignal) < expectedValue;
|
||||
default: // case EqualsOrLess:
|
||||
return *static_cast<T *>(inputSignal) <= expectedValue;
|
||||
}
|
||||
}
|
||||
|
||||
JAMessageGAM::JAMessageGAM() {
|
||||
inputSignals = NULL_PTR(void **);
|
||||
inputSignalTypes = NULL_PTR(MARTe::TypeDescriptor *);
|
||||
operation = And;
|
||||
needsReset = false;
|
||||
expectedValuesInt = NULL_PTR(MARTe::uint64 *);
|
||||
expectedValuesFloat = NULL_PTR(MARTe::float64 *);
|
||||
intValuesCount = 0u;
|
||||
floatValuesCount = 0u;
|
||||
comparators = NULL_PTR(ComparisonMode *);
|
||||
}
|
||||
|
||||
JAMessageGAM::~JAMessageGAM() {
|
||||
if (inputSignals != NULL_PTR(void **)) {
|
||||
delete[] inputSignals;
|
||||
}
|
||||
if (inputSignalTypes != NULL_PTR(MARTe::TypeDescriptor *)) {
|
||||
delete[] inputSignalTypes;
|
||||
}
|
||||
if (expectedValuesInt != NULL_PTR(MARTe::uint64 *)) {
|
||||
delete[] expectedValuesInt;
|
||||
}
|
||||
if (expectedValuesFloat != NULL_PTR(MARTe::float64 *)) {
|
||||
delete[] expectedValuesFloat;
|
||||
}
|
||||
if (comparators != NULL_PTR(ComparisonMode *)) {
|
||||
delete[] comparators;
|
||||
}
|
||||
}
|
||||
|
||||
bool JAMessageGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::Initialise(data);
|
||||
if (ok) {
|
||||
// Read expected integer values.
|
||||
AnyType valuesArray = data.GetType("ExpectedIntValues");
|
||||
bool intValuesProvided = (valuesArray.GetDataPointer() != NULL);
|
||||
|
||||
if (intValuesProvided) {
|
||||
intValuesCount = valuesArray.GetNumberOfElements(0u);
|
||||
}
|
||||
if (intValuesProvided) {
|
||||
expectedValuesInt = new uint64[intValuesCount];
|
||||
|
||||
Vector<uint64> valuesVector(expectedValuesInt, intValuesCount);
|
||||
ok = (data.Read("ExpectedIntValues", valuesVector));
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Failed to read ExpectedIntValues.");
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
// Read expected float values.
|
||||
valuesArray = data.GetType("ExpectedFloatValues");
|
||||
bool floatValuesProvided = (valuesArray.GetDataPointer() != NULL);
|
||||
|
||||
if (floatValuesProvided) {
|
||||
floatValuesCount = valuesArray.GetNumberOfElements(0u);
|
||||
}
|
||||
if (floatValuesProvided) {
|
||||
expectedValuesFloat = new float64[floatValuesCount];
|
||||
|
||||
Vector<float64> valuesVector(expectedValuesFloat, floatValuesCount);
|
||||
ok = (data.Read("ExpectedFloatValues", valuesVector));
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Failed to read ExpectedFloatValues.");
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
ok = (floatValuesCount + intValuesCount) > 0u;
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "ExpectedFloatValues and or ExpectedIntValues shall be defined.");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
// Read comparators.
|
||||
AnyType comparatorsArray = data.GetType("Comparators");
|
||||
if (comparatorsArray.GetDataPointer() != NULL) {
|
||||
uint32 count = comparatorsArray.GetNumberOfElements(0u);
|
||||
ok = count == (intValuesCount + floatValuesCount);
|
||||
if (ok) {
|
||||
comparators = new ComparisonMode[count];
|
||||
StreamString* comp = new StreamString[count];
|
||||
Vector<StreamString> compVector(comp, count);
|
||||
|
||||
ok = (data.Read("Comparators", compVector));
|
||||
|
||||
if (ok) {
|
||||
for (uint32 i = 0; i < count; ++i) {
|
||||
if (comp[i] == "EQUALS") {
|
||||
comparators[i] = Equals;
|
||||
} else if (comp[i] == "NOT") {
|
||||
comparators[i] = Not;
|
||||
} else if (comp[i] == "GREATER") {
|
||||
comparators[i] = Greater;
|
||||
} else if (comp[i] == "EQUALS_OR_GREATER") {
|
||||
comparators[i] = EqualsOrGreater;
|
||||
} else if (comp[i] == "LESS") {
|
||||
comparators[i] = Less;
|
||||
} else if (comp[i] == "EQUALS_OR_LESS") {
|
||||
comparators[i] = EqualsOrLess;
|
||||
} else {
|
||||
ok = false;
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Comparator %s is not defined.", comp[i].Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Expected values and operators shall have the same "
|
||||
"number of elements.");
|
||||
}
|
||||
} else {
|
||||
uint32 count = intValuesCount + floatValuesCount;
|
||||
if (ok) {
|
||||
// Create default comparators (equals) when they aren't provided in the configuration.
|
||||
comparators = new ComparisonMode[count];
|
||||
for (uint32 i = 0; i < count; ++i) {
|
||||
comparators[i] = Equals;
|
||||
}
|
||||
} else {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Expected values and operators shall have the same "
|
||||
"number of elements.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
MARTe::StreamString operationStr;
|
||||
if (data.Read("Operation", operationStr)) {
|
||||
if (operationStr == "AND") {
|
||||
operation = And;
|
||||
}
|
||||
else if (operationStr == "OR") {
|
||||
operation = Or;
|
||||
}
|
||||
else if (operationStr == "NOR") {
|
||||
operation = Nor;
|
||||
}
|
||||
else if (operationStr == "XOR") {
|
||||
operation = Xor;
|
||||
}
|
||||
else {
|
||||
ok = false;
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Operation %s is not defined", operationStr.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = (Size() == 1);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "A Message object shall be added to this container");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
eventMsg = Get(0);
|
||||
ok = (eventMsg.IsValid());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "A valid Message shall be added to this container");
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JAMessageGAM::Setup() {
|
||||
using namespace MARTe;
|
||||
bool ok = numberOfInputSignals == (intValuesCount + floatValuesCount);
|
||||
if (ok) {
|
||||
ok = numberOfInputSignals > 0u;
|
||||
if (ok) {
|
||||
inputSignals = new void*[numberOfInputSignals];
|
||||
uint32 i;
|
||||
for (i = 0u; i < numberOfInputSignals; i++) {
|
||||
inputSignals[i] = GetInputSignalMemory(i);
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "At least one input signal shall be defined");
|
||||
}
|
||||
} else {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Number of input signals shall be the same as "
|
||||
"number of expected values.");
|
||||
}
|
||||
if (ok) {
|
||||
inputSignalTypes = new TypeDescriptor[numberOfInputSignals];
|
||||
uint32 i;
|
||||
for (i = 0u; (i < numberOfInputSignals) && (ok); i++) {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, i);
|
||||
inputSignalTypes[i] = inputType;
|
||||
ok = (inputType == UnsignedInteger32Bit) || (inputType == SignedInteger32Bit) ||
|
||||
(inputType == UnsignedInteger16Bit) || (inputType == SignedInteger16Bit) ||
|
||||
(inputType == UnsignedInteger8Bit) || (inputType == SignedInteger8Bit) ||
|
||||
(inputType == Float64Bit) || (inputType == Float32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, i, signalName);
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Signal %s shall be defined as 32/16/8 bit signed/unsigned integer "
|
||||
"or as 64/32 float.", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JAMessageGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
needsReset = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JAMessageGAM::Execute() {
|
||||
using namespace MARTe;
|
||||
bool ok = true;
|
||||
bool eventDetected = false;
|
||||
uint32 inputPortIndex = 0;
|
||||
uint32 intIndex = 0;
|
||||
uint32 floatIndex = 0;
|
||||
if (operation == Or) {
|
||||
for (inputPortIndex = 0; (inputPortIndex < numberOfInputSignals) && (!eventDetected); inputPortIndex++) {
|
||||
eventDetected = Compare(inputPortIndex, floatIndex, intIndex);
|
||||
}
|
||||
}
|
||||
else if (operation == Nor) {
|
||||
for (inputPortIndex = 0; (inputPortIndex < numberOfInputSignals) && (!eventDetected); inputPortIndex++) {
|
||||
eventDetected = Compare(inputPortIndex, floatIndex, intIndex);
|
||||
}
|
||||
eventDetected = !eventDetected;
|
||||
}
|
||||
else if (operation == And) {
|
||||
eventDetected = Compare(0, floatIndex, intIndex);
|
||||
for (inputPortIndex = 1; (inputPortIndex < numberOfInputSignals); inputPortIndex++) {
|
||||
eventDetected &= Compare(inputPortIndex, floatIndex, intIndex);
|
||||
}
|
||||
}
|
||||
else if (operation == Xor) {
|
||||
uint32 eventDetectedUInt32 = Compare(inputPortIndex, floatIndex, intIndex);
|
||||
for (inputPortIndex = 1; (inputPortIndex < numberOfInputSignals); inputPortIndex++) {
|
||||
eventDetectedUInt32 ^= Compare(inputPortIndex, floatIndex, intIndex);
|
||||
}
|
||||
eventDetected = (eventDetectedUInt32 == 1u);
|
||||
}
|
||||
if (eventDetected) {
|
||||
if (!needsReset) {
|
||||
ok = (MessageI::SendMessage(eventMsg, this) == ErrorManagement::NoError);
|
||||
needsReset = true;
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JAMessageGAM::Compare(MARTe::uint32 inputPortIndex, MARTe::uint32 &floatValueIndex, MARTe::uint32 &intValueIndex) {
|
||||
using namespace MARTe;
|
||||
bool ret = false;
|
||||
if (inputSignalTypes[inputPortIndex] == UnsignedInteger32Bit) {
|
||||
ret = ::Compare<uint32>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
|
||||
++intValueIndex;
|
||||
}
|
||||
else if (inputSignalTypes[inputPortIndex] == SignedInteger32Bit) {
|
||||
ret = ::Compare<int32>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
|
||||
++intValueIndex;
|
||||
}
|
||||
else if (inputSignalTypes[inputPortIndex] == UnsignedInteger16Bit) {
|
||||
ret = ::Compare<uint16>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
|
||||
++intValueIndex;
|
||||
}
|
||||
else if (inputSignalTypes[inputPortIndex] == SignedInteger16Bit) {
|
||||
ret = ::Compare<int16>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
|
||||
++intValueIndex;
|
||||
}
|
||||
else if (inputSignalTypes[inputPortIndex] == UnsignedInteger8Bit) {
|
||||
ret = ::Compare<uint8>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
|
||||
++intValueIndex;
|
||||
}
|
||||
else if (inputSignalTypes[inputPortIndex] == SignedInteger8Bit) {
|
||||
ret = ::Compare<int8>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
|
||||
++intValueIndex;
|
||||
}
|
||||
else if (inputSignalTypes[inputPortIndex] == Float64Bit) {
|
||||
ret = ::Compare<float64>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesFloat[floatValueIndex]);
|
||||
++floatValueIndex;
|
||||
}
|
||||
else {
|
||||
ret = ::Compare<float32>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesFloat[floatValueIndex]);
|
||||
++floatValueIndex;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JAMessageGAM, "1.0")
|
||||
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* @file JAMessageGAM.h
|
||||
* @brief Header file for class JAMessageGAM
|
||||
* @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 JAMessageGAM
|
||||
* 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_JAMESSAGEGAM_H_
|
||||
#define GAMS_JAMESSAGEGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GAM.h"
|
||||
#include "Message.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief GAM that sends a message when input signals have expected values. Message will not be sent multiple
|
||||
* times without first changing the application state.
|
||||
*
|
||||
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||
* <pre>
|
||||
* +MessageGAM = {
|
||||
* Class = JAMessageGAM
|
||||
* Operation = AND // Accepted values are: AND, OR, XOR, NOR. Default value is AND.
|
||||
* ExpectedIntValues = {1 10} // Expected values for input signals of integral type.
|
||||
* ExpectedFloatValues = {3.5} // Expected values for float signals of floting point type.
|
||||
* Comparators = {EQUALS GREATER NOT} // Accepted values are: EQUALS, NOT, GREATER, EQUALS_OR_GREATER, LESS, EQUALS_OR_LESS
|
||||
* // Comparators element is optional. Default comparator is EQUALS.
|
||||
* InputSignals = {
|
||||
* Sig1 = {
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = uint32
|
||||
* }
|
||||
* Sig2 = {
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = float32
|
||||
* }
|
||||
* Sig3 = {
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = uint32
|
||||
* }
|
||||
* }
|
||||
* +Event = { // Message to be sent when condition is true.
|
||||
* Class = Message
|
||||
* Destination = StateMachine
|
||||
* Function = GoDisabled
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* This example will send Event message when Sig1 == 1 && Sig2 > 3.5 && Sig3 != 10
|
||||
*/
|
||||
class JAMessageGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
JAMessageGAM();
|
||||
|
||||
virtual ~JAMessageGAM();
|
||||
|
||||
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);
|
||||
|
||||
enum ComparisonMode {
|
||||
Equals, Not, Greater, EqualsOrGreater, Less, EqualsOrLess
|
||||
};
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Does the input signal at provided index have the expected value.
|
||||
* @param[in] index of the signal.
|
||||
* @param[out] floatValueIndex lookup index for expected float values array.
|
||||
* @param[out] intValueIndex lookup index for expected integer values array.
|
||||
* @return true if the signal has expected value.
|
||||
*/
|
||||
bool Compare(MARTe::uint32 index, MARTe::uint32 &floatValueIndex, MARTe::uint32 &intValueIndex);
|
||||
|
||||
enum OperationMode {
|
||||
And, Or, Xor, Nor
|
||||
};
|
||||
|
||||
// Input signals
|
||||
void **inputSignals;
|
||||
|
||||
MARTe::TypeDescriptor *inputSignalTypes;
|
||||
|
||||
// Condition operation.
|
||||
OperationMode operation;
|
||||
|
||||
// Message to be sent when conditions are met.
|
||||
MARTe::ReferenceT<MARTe::Message> eventMsg;
|
||||
|
||||
// Was the message already sent and we are waiting for a state change before next message can be sent.
|
||||
bool needsReset;
|
||||
|
||||
// Array of expected integer values of input signals.
|
||||
MARTe::uint64* expectedValuesInt;
|
||||
|
||||
// Array of expected float values for input signals.
|
||||
MARTe::float64* expectedValuesFloat;
|
||||
|
||||
// Expected integer values count (must be equal to numberOfInputSignals - floatValuesCount)
|
||||
MARTe::uint32 intValuesCount;
|
||||
|
||||
// Expected integer values count (must be equal to numberOfInputSignals - floatValuesCount)
|
||||
MARTe::uint32 floatValuesCount;
|
||||
|
||||
// Array of comparators
|
||||
ComparisonMode* comparators;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* GAMS_JAMESSAGEGAM_H_ */
|
||||
@@ -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
|
||||
@@ -0,0 +1,53 @@
|
||||
#############################################################
|
||||
#
|
||||
# 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=JAMessageGAM.x
|
||||
|
||||
PACKAGE=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
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/JAMessageGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/JAMessageGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* @file JAModeControlGAM.cpp
|
||||
* @brief Source file for class JAModeControlGAM
|
||||
* @date Jan, 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 source file contains the definition of all the methods for
|
||||
* the class JAModeControlGAM (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 "JAModeControlGAM.h"
|
||||
#include "AdvancedErrorManagement.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JAModeControlGAM::JAModeControlGAM() {
|
||||
inputSignals = NULL_PTR(MARTe::uint32 **);
|
||||
outputSignal = NULL_PTR(MARTe::uint32 *);
|
||||
pulseLengthLimit = 360000000u;
|
||||
resetRemainingTime = true;
|
||||
previousState = 0u;
|
||||
}
|
||||
|
||||
JAModeControlGAM::~JAModeControlGAM() {
|
||||
if (inputSignals != NULL_PTR(MARTe::uint32 **)) {
|
||||
delete[] inputSignals;
|
||||
}
|
||||
}
|
||||
|
||||
bool JAModeControlGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
/* read hard coded on cfg file parameter values by using key name. */
|
||||
using namespace MARTe;
|
||||
return GAM::Initialise(data);
|
||||
}
|
||||
|
||||
bool JAModeControlGAM::Setup() {
|
||||
/* read GAM Input signal */
|
||||
using namespace MARTe;
|
||||
/* read 4 mode bits and 4 shot length limit values */
|
||||
|
||||
bool ok = numberOfInputSignals == 11;
|
||||
if (ok) {
|
||||
uint32 i;
|
||||
for (i = 0u; (i < numberOfInputSignals) && (ok); i++) {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, i);
|
||||
ok = inputType == UnsignedInteger32Bit;
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, i, signalName);
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "InputSignel %s shall be defined as uint32", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Eleven input signals shall be defined.");
|
||||
}
|
||||
if (ok) {
|
||||
ok = numberOfOutputSignals == 1;
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "One output signal shall be defined.");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor type = GetSignalType(OutputSignals, 0);
|
||||
ok = type == UnsignedInteger32Bit;
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(OutputSignals, 0, signalName);
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||
inputSignals = new uint32*[numberOfInputSignals];
|
||||
uint32 i;
|
||||
for (i = 0u; i < 11; i++) {
|
||||
inputSignals[i] = reinterpret_cast<uint32 *>(GetInputSignalMemory(i));
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JAModeControlGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
*outputSignal = 0u;
|
||||
previousState = 0u;
|
||||
resetRemainingTime = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JAModeControlGAM::Execute() {
|
||||
using namespace MARTe;
|
||||
//When RT state goes to RFON state, update the limit.
|
||||
if(previousState == 0u && *inputSignals[8] == 1u && resetRemainingTime) {
|
||||
rfonTime = *inputSignals[9];
|
||||
resetRemainingTime = false;
|
||||
pulseLengthLimit = CalcPulseLengthLimit(inputSignals);
|
||||
REPORT_ERROR(ErrorManagement::Debug, "Pulse Length was set to Limit:%d", pulseLengthLimit);
|
||||
}
|
||||
// Turn on the flag during RFON if the pulse legth over the limit.
|
||||
if ((*inputSignals[9] - rfonTime <= pulseLengthLimit) && (previousState == 1u)) {
|
||||
*outputSignal = 0u;
|
||||
return true;
|
||||
} else if(*inputSignals[9] == 1u){
|
||||
resetRemainingTime = true;
|
||||
*outputSignal = 1u;
|
||||
}
|
||||
|
||||
previousState = *inputSignals[8];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
MARTe::uint32 JAModeControlGAM::CalcPulseLengthLimit(MARTe::uint32 **inputSignals) {
|
||||
if (*inputSignals[0] == 1) {
|
||||
return *inputSignals[1];
|
||||
} else if (*inputSignals[2] == 1) {
|
||||
return *inputSignals[3];
|
||||
} else if (*inputSignals[4] == 1) {
|
||||
return *inputSignals[5];
|
||||
} else if (*inputSignals[6] == 1) {
|
||||
return *inputSignals[7];
|
||||
} else {
|
||||
return 3600000000;//us
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CLASS_REGISTER(JAModeControlGAM, "1.0")
|
||||
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* @file JAModeControlGAM.h
|
||||
* @brief Header file for class JAModeControlGAM
|
||||
* @date Jan, 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 JAModeControlGAM
|
||||
* 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_JAMODECONTROLGAM_H_
|
||||
#define GAMS_JAMODECONTROLGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GAM.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief GAM that check the pulse lenght limit.
|
||||
*
|
||||
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||
* <pre>
|
||||
* +ModeLimitGAM = {
|
||||
* Class = JAModeControlGAM
|
||||
* InputSignals = {
|
||||
* PLC_MODE1 = {
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = uint32
|
||||
* }
|
||||
* MD1_SHOTLEN_LIM = {
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = uint32
|
||||
* }
|
||||
* PLC_MODE2 = {
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = uint32
|
||||
* }
|
||||
* MD2_SHOTLEN_LIM = {
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = uint32
|
||||
* }
|
||||
* PLC_MODE3 = {
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = uint32
|
||||
* }
|
||||
* MD3_SHOTLEN_LIM = {
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = uint32
|
||||
* }
|
||||
* PLC_MODE4 = {
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = uint32
|
||||
* }
|
||||
* MD4_SHOTLEN_LIM = {
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = uint32
|
||||
* }
|
||||
* RFON = {
|
||||
* DataSource = RealTimeThreadAsyncBridge
|
||||
* Type = uint32
|
||||
* }
|
||||
* Time = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* HVInjection = {
|
||||
* DataSource = RealTimeThreadAsyncBridge
|
||||
* Type = uint32
|
||||
* }
|
||||
* }
|
||||
* OutputSignals = {
|
||||
* MODE_SHOTLEN_FLAG = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* If MODE1 is ON and Time is exceed MD1_SHOTLEN_LIM, MODE_SHOTLEN_FLAG become ON.
|
||||
*/
|
||||
|
||||
class JAModeControlGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
JAModeControlGAM();
|
||||
|
||||
virtual ~JAModeControlGAM();
|
||||
|
||||
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:
|
||||
|
||||
MARTe::uint32 CalcPulseLengthLimit(MARTe::uint32 **inputSignals);
|
||||
|
||||
// Input signals
|
||||
MARTe::uint32 **inputSignals;
|
||||
|
||||
// Output signals
|
||||
MARTe::uint32 *outputSignal;
|
||||
|
||||
// Calculated pulse lenght limit.
|
||||
MARTe::uint32 pulseLengthLimit;
|
||||
|
||||
// Amount of time passed per execution cycle.
|
||||
MARTe::uint32 rfonTime;
|
||||
|
||||
// reset flag
|
||||
bool resetRemainingTime;
|
||||
MARTe::uint32 previousState;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* GAMS_JAMODECONTROLGAM_H_ */
|
||||
@@ -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
|
||||
@@ -0,0 +1,52 @@
|
||||
#############################################################
|
||||
#
|
||||
# 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=JAModeControlGAM.x
|
||||
|
||||
PACKAGE=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
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/JAModeControlGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/JAModeControlGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
@@ -0,0 +1,460 @@
|
||||
/**
|
||||
* @file JAPreProgrammedGAM.cpp
|
||||
* @brief Source file for class JAPreProgrammedGAM
|
||||
* @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 JAPreProgrammedGAM (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 "CLASSMETHODREGISTER.h"
|
||||
#include "File.h"
|
||||
#include "JAPreProgrammedGAM.h"
|
||||
#include "MessageI.h"
|
||||
#include "RegisteredMethodsMessageFilter.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
// How often output signals are updated.
|
||||
const MARTe::uint32 cycleMs = 10u;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JAPreProgrammedGAM::JAPreProgrammedGAM() :
|
||||
GAM() {
|
||||
using namespace MARTe;
|
||||
filenameSignalIndex = 0u;
|
||||
timeSignal = NULL_PTR(MARTe::int32 *);
|
||||
loadTriggerSignal = NULL_PTR(MARTe::uint32 *);
|
||||
fhpsrefSignal = NULL_PTR(MARTe::float32 *);
|
||||
rfonStateSignal = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
valueSignals = NULL_PTR(MARTe::float32 **);
|
||||
preProgrammedValues = NULL_PTR(MARTe::float32 **);
|
||||
preProgrammedTime = NULL_PTR(MARTe::int32 *);
|
||||
fileLoadedSignal = NULL_PTR(MARTe::uint32 *);
|
||||
fileLoadErrorOutput = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
startTime = 0u;
|
||||
numberOfPreProgrammedValues = 0u;
|
||||
numberOfPreProgrammedTimeRows = 0u;
|
||||
currentRow = 0u;
|
||||
mode = None;
|
||||
preProgrammedExecutaionPeriodMs = 0u;
|
||||
msCounter = 0u;
|
||||
preProgrammedRow = 0u;
|
||||
resetOutputSignals = false;
|
||||
readOnce = true;
|
||||
}
|
||||
|
||||
JAPreProgrammedGAM::~JAPreProgrammedGAM() {
|
||||
DeleteArrays();
|
||||
if (valueSignals != NULL_PTR(MARTe::float32 **)) {
|
||||
delete[] valueSignals;
|
||||
}
|
||||
}
|
||||
|
||||
bool JAPreProgrammedGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::Initialise(data);
|
||||
if (ok) {
|
||||
ok = data.Read("Directory", directory);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Directory shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("PreProgrammedPeriodMs", preProgrammedExecutaionPeriodMs);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Directory shall be specified");
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JAPreProgrammedGAM::Setup() {
|
||||
using namespace MARTe;
|
||||
//Signal number check.
|
||||
bool ok = (numberOfInputSignals == 4u);
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals > 2u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "At least two output signal shall be defined");
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Four input signals with the filename and file load trigger shall be defined");
|
||||
}
|
||||
//Input signals type consistency check.
|
||||
if (ok) {
|
||||
StreamString signalName = "Filename";
|
||||
ok = GetSignalIndex(InputSignals, filenameSignalIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Filename input signal shall be defined");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, filenameSignalIndex);
|
||||
ok = (inputType == CharString);
|
||||
if (!ok) {
|
||||
ok = (inputType == Character8Bit);
|
||||
}
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, filenameSignalIndex, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as string", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
StreamString signalName = "CSV_LOAD";
|
||||
uint32 loadSignalIndex;
|
||||
ok = GetSignalIndex(InputSignals, loadSignalIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "CSV_LOAD input signal shall be defined");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, loadSignalIndex);
|
||||
ok = (inputType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, loadSignalIndex, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||
} else {
|
||||
loadTriggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(loadSignalIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
StreamString signalName = "FHPS_REF";
|
||||
uint32 fhpsrefIndex;
|
||||
ok = GetSignalIndex(InputSignals, fhpsrefIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "FHPS_REF input signal shall be defined");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, fhpsrefIndex);
|
||||
ok = (inputType == Float32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, fhpsrefIndex, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
|
||||
} else {
|
||||
fhpsrefSignal = reinterpret_cast<float32 *>(GetInputSignalMemory(fhpsrefIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
StreamString signalName = "RFON";
|
||||
uint32 rfonIndex;
|
||||
ok = GetSignalIndex(InputSignals, rfonIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "RFON input signal shall be defined");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, rfonIndex);
|
||||
ok = (inputType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, rfonIndex, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
|
||||
} else {
|
||||
rfonStateSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(rfonIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Output signals type check.
|
||||
if (ok) {
|
||||
TypeDescriptor timeType = GetSignalType(OutputSignals, 0);
|
||||
ok = (timeType == SignedInteger32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, 0, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as int32", signalName.Buffer());
|
||||
}
|
||||
|
||||
uint32 i;
|
||||
for (i = 1u; (i <= 6) && (ok); i++) {
|
||||
TypeDescriptor outputType = GetSignalType(OutputSignals, i);
|
||||
ok = (outputType == Float32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(OutputSignals, i, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
TypeDescriptor fileLoadedType = GetSignalType(OutputSignals, 7u);
|
||||
ok = (fileLoadedType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(OutputSignals, 6u, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
TypeDescriptor fileLoadErrorOutputType = GetSignalType(OutputSignals, 8u);
|
||||
ok = (fileLoadErrorOutputType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(OutputSignals, 7u, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Register signal memory
|
||||
if (ok) {
|
||||
timeSignal = reinterpret_cast<int32 *>(GetOutputSignalMemory(0));
|
||||
valueSignals = new float32*[6u];
|
||||
uint32 i;
|
||||
for (i = 1u; i <= 6u; i++) {
|
||||
valueSignals[i - 1] = reinterpret_cast<float32 *>(GetOutputSignalMemory(i));
|
||||
}
|
||||
fileLoadedSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7u));
|
||||
fileLoadErrorOutput = reinterpret_cast<uint32 *>(GetOutputSignalMemory(8u));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JAPreProgrammedGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
bool ok = true;
|
||||
if (strcmp(nextStateName, "WaitReady") == 0) {
|
||||
mode = LoadFileMode;
|
||||
resetOutputSignals = true;
|
||||
// Reset read once flag when reentering WaitReady state.
|
||||
readOnce = true;
|
||||
} else if (strcmp(nextStateName, "WaitPermit") == 0) {
|
||||
mode = LoadFileMode;
|
||||
resetOutputSignals = true;
|
||||
currentRow = 0u;
|
||||
} else if (strcmp(nextStateName, "WaitHVON_PREP") == 0 || strcmp(nextStateName, "WaitHVON_SDN_PREP") == 0) {
|
||||
ok = numberOfPreProgrammedTimeRows > 0;
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::IllegalOperation, "Entering PreProgrammed mode without any waveform data.");
|
||||
}
|
||||
mode = PreProgrammedMode;
|
||||
msCounter = cycleMs;
|
||||
currentRow = 0u;
|
||||
} else {
|
||||
mode = None;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JAPreProgrammedGAM::LoadFile() {
|
||||
using namespace MARTe;
|
||||
|
||||
DeleteArrays();
|
||||
|
||||
bool ok = true;
|
||||
|
||||
const MARTe::char8 * const filenameSignal = reinterpret_cast<const char8 * const >(GetInputSignalMemory(filenameSignalIndex));
|
||||
//Prepare full path to the configuration file.
|
||||
StreamString filename = directory;
|
||||
filename += DIRECTORY_SEPARATOR;
|
||||
filename += filenameSignal;
|
||||
REPORT_ERROR(MARTe::ErrorManagement::Debug, "Opening file %s", filename.Buffer());
|
||||
|
||||
//parse prepro configuration file into two arrays(time, values).
|
||||
File f;
|
||||
ok = f.Open(filename.Buffer(), BasicFile::ACCESS_MODE_R);
|
||||
if (ok) {
|
||||
//Count up number of file Rows.
|
||||
numberOfPreProgrammedTimeRows = 0u;
|
||||
StreamString tokenLine;
|
||||
while (f.GetLine(tokenLine)) {
|
||||
if (tokenLine[0] != '#' && tokenLine[0] != '-') {
|
||||
numberOfPreProgrammedTimeRows++;
|
||||
}
|
||||
tokenLine = "";
|
||||
}
|
||||
//Count up number of file lines
|
||||
numberOfPreProgrammedValues = 0u;
|
||||
f.Seek(0);
|
||||
uint32 t = 0u;
|
||||
tokenLine = "";
|
||||
while ((ok) && (f.GetLine(tokenLine))) {
|
||||
// Skip comment line and minus time
|
||||
if (tokenLine[0] == '#' || tokenLine[0] == '-') {
|
||||
tokenLine = "";
|
||||
continue;
|
||||
}
|
||||
// Prepare two arrays at first.
|
||||
if (numberOfPreProgrammedValues == 0) {
|
||||
StreamString token;
|
||||
char8 ignored;
|
||||
tokenLine.Seek(0);
|
||||
while (tokenLine.GetToken(token, ",", ignored)) {
|
||||
numberOfPreProgrammedValues++;
|
||||
token = "";
|
||||
}
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError,"numberOfPreProgrammedVal %d", numberOfPreProgrammedValues);
|
||||
ok = (numberOfPreProgrammedValues == 7u);//From time row to FHPS row.
|
||||
numberOfPreProgrammedValues -= 1u; //From MHVPS row to FHPS row.
|
||||
if (ok) {
|
||||
preProgrammedTime = new int32[numberOfPreProgrammedTimeRows];
|
||||
preProgrammedValues = new float32*[numberOfPreProgrammedTimeRows];
|
||||
uint32 j;
|
||||
for (j = 0u; j < numberOfPreProgrammedTimeRows; j++) {
|
||||
preProgrammedValues[j] = new float32[numberOfPreProgrammedValues];
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError,
|
||||
"Number of columns in csv file (%d) is not consistent with the number of output signals (%d)",
|
||||
numberOfPreProgrammedValues, 6u);
|
||||
*fileLoadErrorOutput = 1;
|
||||
}
|
||||
}
|
||||
// Add loaded data into two arrays.
|
||||
if (ok) {
|
||||
StreamString token;
|
||||
char8 ignored;
|
||||
tokenLine.Seek(0);
|
||||
uint32 idx = 0u;
|
||||
while (tokenLine.GetToken(token, ",", ignored)) {
|
||||
if (idx == 0u) {
|
||||
preProgrammedTime[t] = atoi(token.Buffer());
|
||||
if (t == 0 && preProgrammedTime[0] != 0) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::Debug, "Prepro start from none zero time.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
ok = ((idx - 1) < numberOfPreProgrammedValues);
|
||||
if (ok) {
|
||||
preProgrammedValues[t][idx - 1] = static_cast<float32>(atof(token.Buffer()));
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::FatalError, "Number of columns in csv file is not consistent with the number of output signals in line %d", t);
|
||||
*fileLoadErrorOutput = 1;
|
||||
}
|
||||
}
|
||||
token = "";
|
||||
idx++;
|
||||
}
|
||||
t++;
|
||||
}
|
||||
tokenLine = "";
|
||||
}
|
||||
f.Close();
|
||||
}
|
||||
if (ok) {
|
||||
currentRow = 0u;
|
||||
}
|
||||
else {
|
||||
numberOfPreProgrammedTimeRows = 0u;
|
||||
REPORT_ERROR(ErrorManagement::Warning, "Failed to read waveform data from file.");
|
||||
*fileLoadErrorOutput = 2;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JAPreProgrammedGAM::Execute() {
|
||||
using namespace MARTe;
|
||||
bool ok = true;
|
||||
|
||||
switch (mode) {
|
||||
case LoadFileMode: {
|
||||
if (*loadTriggerSignal == 1u) {
|
||||
if (readOnce) {
|
||||
*fileLoadErrorOutput = 0;
|
||||
*fileLoadedSignal = LoadFile() ? 1 : 0;
|
||||
readOnce = false;
|
||||
}
|
||||
} else {
|
||||
// Reset read once flag when loadTriggerSignal is reset.
|
||||
readOnce = true;
|
||||
}
|
||||
|
||||
if (resetOutputSignals) {
|
||||
// Write default values to output signals
|
||||
*timeSignal = 0u;
|
||||
*valueSignals[FHPS-1] = *fhpsrefSignal;
|
||||
resetOutputSignals = false;
|
||||
} else {
|
||||
*valueSignals[FHPS-1] = *fhpsrefSignal; //copy input(2) to val_arr(4)
|
||||
}
|
||||
} break;
|
||||
|
||||
case PreProgrammedMode: {
|
||||
ok = numberOfPreProgrammedTimeRows > 0;
|
||||
|
||||
//add 20210105. Before RFON, prepro setpoints should be same as the values listed at csv first line.
|
||||
if (ok && *rfonStateSignal == 0) {
|
||||
uint32 j;
|
||||
for (j = 0u; j < FHPS; j++) {
|
||||
*valueSignals[j] = preProgrammedValues[0][j];
|
||||
}
|
||||
}
|
||||
//end 20210105
|
||||
|
||||
if (ok && currentRow < numberOfPreProgrammedTimeRows && *rfonStateSignal == 1) {
|
||||
if (msCounter >= cycleMs) {
|
||||
msCounter -= cycleMs;
|
||||
int32 currentTime = preProgrammedTime[currentRow];
|
||||
//REPORT_ERROR(MARTe::ErrorManagement::Debug, "Write Time at %d",currentRow);
|
||||
// Write to output signals
|
||||
*timeSignal = currentTime;
|
||||
uint32 j;
|
||||
for (j = 0u; j < FHPS; j++) {
|
||||
*valueSignals[j] = preProgrammedValues[currentRow][j];
|
||||
//REPORT_ERROR(MARTe::ErrorManagement::Debug, "Write Value %f at row %d",preProgrammedValues[currentRow][j], currentRow);
|
||||
}
|
||||
//REPORT_ERROR(MARTe::ErrorManagement::Debug, "Writing pre programmed data for time %d", currentTime);
|
||||
|
||||
// Update row
|
||||
++currentRow;
|
||||
}
|
||||
msCounter += preProgrammedExecutaionPeriodMs;
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
// Nothing to do.
|
||||
REPORT_ERROR(MARTe::ErrorManagement::Warning, "Unhandled mode.");
|
||||
break;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void JAPreProgrammedGAM::DeleteArrays() {
|
||||
if (preProgrammedValues != NULL_PTR(MARTe::float32 **)) {
|
||||
MARTe::uint32 i;
|
||||
for (i = 0u; i < numberOfPreProgrammedValues; i++) {
|
||||
delete preProgrammedValues[i];
|
||||
}
|
||||
delete[] preProgrammedValues;
|
||||
}
|
||||
if (preProgrammedTime != NULL_PTR(MARTe::int32 *)) {
|
||||
delete[] preProgrammedTime;
|
||||
}
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JAPreProgrammedGAM, "1.0")
|
||||
@@ -0,0 +1,187 @@
|
||||
/**
|
||||
* @file JAPreProgrammedGAM.h
|
||||
* @brief Header file for class JAPreProgrammedGAM
|
||||
* @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 JAPreProgrammedGAM
|
||||
* 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_JAPREPROGRAMMEDGAM_H_
|
||||
#define GAMS_JAPREPROGRAMMEDGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "GAM.h"
|
||||
#include "Message.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief GAM that update PS output value for pre-programmed operation.
|
||||
*
|
||||
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||
* <pre>
|
||||
* +PreProgrammedGAM = {
|
||||
* Class = JAPreProgrammedGAM
|
||||
* Directory = "../Configurations" // Directory which has pre-pro configuration file.
|
||||
* PreProgrammedPeriodMs = 1 // RFON state is executed every millisecond.
|
||||
* InputSignals = {
|
||||
* CSV_LOAD = {
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = uint32
|
||||
* }
|
||||
* Filename = {
|
||||
* Alias = CSV_NAME
|
||||
* DataSource = EPICSCAInput
|
||||
* }
|
||||
* FHPS_REF = {
|
||||
* DataSource = DDB1
|
||||
* Type = float32
|
||||
* }
|
||||
* RFON = {
|
||||
* DataSource = RealTimeThreadAsyncBridge
|
||||
* Type = uint32
|
||||
* }
|
||||
* }
|
||||
* OutputSignals = {
|
||||
* GYA_PREHEAT_TIME = {
|
||||
* DataSource = DDB1
|
||||
* Type = int32
|
||||
* }
|
||||
* MHVPS_REF = {
|
||||
* DataSource = DDB1
|
||||
* Type = float32
|
||||
* }
|
||||
* BPS_REF = {
|
||||
* DataSource = DDB1
|
||||
* Type = float32
|
||||
* }
|
||||
* APS_REF = {
|
||||
* DataSource = DDB1
|
||||
* Type = float32
|
||||
* }
|
||||
* MCPS_TRG_CURR_SET = {
|
||||
* DataSource = DDB1
|
||||
* Type = float32
|
||||
* }
|
||||
* GCPS_TRG_CURR_SET = {
|
||||
* DataSource = DDB1
|
||||
* Type = float32
|
||||
* }
|
||||
* FHPS_REF = {
|
||||
* DataSource = DDB1
|
||||
* Type = float32
|
||||
* }
|
||||
* CSV_LOADED = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* CSV_ERR = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
||||
class JAPreProgrammedGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
JAPreProgrammedGAM();
|
||||
|
||||
virtual ~JAPreProgrammedGAM();
|
||||
|
||||
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:
|
||||
bool LoadFile();
|
||||
|
||||
void DeleteArrays();
|
||||
|
||||
//Parameters
|
||||
MARTe::StreamString directory; //Location for prepro configuration file.
|
||||
MARTe::uint32 preProgrammedExecutaionPeriodMs; // Time between to execution cycles in milliseconds in pre-programmed mode.
|
||||
|
||||
//Input Signals
|
||||
MARTe::uint32 *loadTriggerSignal; //index:0
|
||||
MARTe::uint32 filenameSignalIndex;//index:1
|
||||
MARTe::float32 *fhpsrefSignal; //index:2
|
||||
MARTe::uint32 *rfonStateSignal; //index:3
|
||||
|
||||
//Output Signals
|
||||
MARTe::int32 *timeSignal; //index:0
|
||||
MARTe::float32 **valueSignals; //index:1-5 = BPS,APS,MC,GC,FHPS
|
||||
MARTe::uint32 *fileLoadedSignal; //index:6
|
||||
MARTe::uint32 *fileLoadErrorOutput;//index:7
|
||||
|
||||
//Internal variables
|
||||
MARTe::int32 *preProgrammedTime;
|
||||
MARTe::float32 **preProgrammedValues;
|
||||
|
||||
MARTe::uint32 startTime;
|
||||
|
||||
//Number of columns in csv, EXCLUDING the time
|
||||
MARTe::uint32 numberOfPreProgrammedValues; //is 5.(BPS, APS, MC, GC, FHPS)
|
||||
MARTe::uint32 numberOfPreProgrammedTimeRows; //This start from t=0 row.
|
||||
MARTe::uint32 currentRow;
|
||||
|
||||
// Number of milliseconds since the last time output signals were updated.
|
||||
MARTe::uint32 msCounter;
|
||||
|
||||
// Row number where the pre-programmed data begins (time == 0).
|
||||
MARTe::uint32 preProgrammedRow;
|
||||
|
||||
enum OperationMode {
|
||||
LoadFileMode, PreProgrammedMode, None
|
||||
};
|
||||
enum PreProTableDefinition {
|
||||
Time, MHVPS, BPS, APS, MCPS, GCPS, FHPS
|
||||
};
|
||||
|
||||
OperationMode mode;
|
||||
|
||||
bool resetOutputSignals;
|
||||
|
||||
// Flag determining whether file should be read (so it isn't read multiple time)
|
||||
bool readOnce;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* GAMS_JAPREPROGRAMMEDGAM_H_ */
|
||||
@@ -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
|
||||
@@ -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=JAPreProgrammedGAM.x
|
||||
|
||||
PACKAGE=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/FileSystem/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/JAPreProgrammedGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/JAPreProgrammedGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
|
||||
@@ -0,0 +1,411 @@
|
||||
/**
|
||||
* @file JARTStateMachineGAM.cpp
|
||||
* @brief Source 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 source file contains the definition of all the methods for
|
||||
* the class JARTStateMachineGAM (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 "JARTStateMachineGAM.h"
|
||||
|
||||
#include "AdvancedErrorManagement.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static MARTe::uint64 getCurrentTimeUs() {
|
||||
using namespace MARTe;
|
||||
return static_cast<uint64>(HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1e6f + 0.5f);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JARTStateMachineGAM::JARTStateMachineGAM() {
|
||||
currentState = WaitTrigger; // Set Entry state.
|
||||
plcOnTime = 0; // Triggered time holder.
|
||||
|
||||
//Output and condition in a given state.
|
||||
conditionTrigger = 1;
|
||||
aps_hvon = 0;
|
||||
aps_swon = 0;
|
||||
bps_hvon = 0;
|
||||
bps_swon = 0;
|
||||
mhvps_hvon = 0;
|
||||
|
||||
// Parameters which get from Input signals.
|
||||
triggerSignal = NULL_PTR(MARTe::uint32 *);
|
||||
currentTime = NULL_PTR(MARTe::uint32 *);
|
||||
turn_off_delay = 2000; //us
|
||||
|
||||
triggerDelay_mhvps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_aps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_aps_swon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_bps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_bps_swon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_shotlen = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
stopRequest = NULL_PTR(MARTe::uint32 *);
|
||||
modePulseLengthLimit = NULL_PTR(MARTe::uint32 *);
|
||||
short_pulse_mode = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
modulation = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
// write out target.
|
||||
outputSignal = NULL_PTR(MARTe::uint32 *);
|
||||
outputBeamON = NULL_PTR(MARTe::uint32 *);
|
||||
outputHVArmed = NULL_PTR(MARTe::uint32 *);
|
||||
outputHVInjection = NULL_PTR(MARTe::uint32 *);
|
||||
outputRFON = NULL_PTR(MARTe::uint32 *);
|
||||
outputBeamONTime = NULL_PTR(MARTe::uint32 *);
|
||||
outputRFONTime = NULL_PTR(MARTe::uint32 *);
|
||||
shotCounter = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
mhvps_hvon_is_on = false;
|
||||
aps_hvon_is_on = false;
|
||||
aps_swon_is_on = false;
|
||||
bps_hvon_is_on = false;
|
||||
bps_swon_is_on = false;
|
||||
|
||||
apsSwonHighResolutionTime = 0;
|
||||
|
||||
aps_hvon_state=0;
|
||||
aps_swon_state=0;
|
||||
mhvps_hvon_state=0;
|
||||
bps_hvon_state=0;
|
||||
bps_swon_state=0;
|
||||
}
|
||||
|
||||
JARTStateMachineGAM::~JARTStateMachineGAM() {
|
||||
}
|
||||
|
||||
bool JARTStateMachineGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::Initialise(data);
|
||||
if (ok) {
|
||||
ok = data.Read("ConditionTrigger", conditionTrigger);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Condition1 shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("mhvps_hvon", mhvps_hvon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("aps_hvon", aps_hvon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("aps_swon", aps_swon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("bps_hvon", bps_hvon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("bps_swon", bps_swon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon shall be specified");
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JARTStateMachineGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JARTStateMachineGAM::Setup() {
|
||||
using namespace MARTe;
|
||||
bool ok = (numberOfInputSignals == 12u);
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals == 16u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Seven output signals shall be defined %d",numberOfOutputSignals);
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
|
||||
}
|
||||
if (ok) {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||
ok = (inputType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||
ok = (outputType == UnsignedInteger32Bit || outputType == UnsignedInteger8Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
currentTime = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||
triggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
|
||||
triggerDelay_mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||
triggerDelay_aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
|
||||
triggerDelay_aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
|
||||
triggerDelay_bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||
triggerDelay_bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
|
||||
triggerDelay_shotlen = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
|
||||
stopRequest = reinterpret_cast<uint32 *>(GetInputSignalMemory(8));
|
||||
modePulseLengthLimit = reinterpret_cast<uint32 *>(GetInputSignalMemory(9));
|
||||
short_pulse_mode = reinterpret_cast<uint32 *>(GetInputSignalMemory(10));
|
||||
modulation = reinterpret_cast<uint32 *>(GetInputSignalMemory(11));
|
||||
|
||||
|
||||
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||
outputBeamON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
|
||||
outputHVArmed = reinterpret_cast<uint32 *>(GetOutputSignalMemory(2));
|
||||
outputHVInjection = reinterpret_cast<uint32 *>(GetOutputSignalMemory(3));
|
||||
outputRFON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(4));
|
||||
outputBeamONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(5));
|
||||
outputRFONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(6));
|
||||
shotCounter = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7));
|
||||
|
||||
outputAPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(8));
|
||||
outputAPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(9));
|
||||
outputBPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(10));
|
||||
outputBPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(11));
|
||||
outputMHVPSON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(12));
|
||||
|
||||
outputSignalNI6259 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(13));
|
||||
outputSignalNI6528P3 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(14));
|
||||
outputSignalNI6528P4 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(15));
|
||||
|
||||
*shotCounter = 0;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JARTStateMachineGAM::Execute() {
|
||||
using namespace MARTe;
|
||||
|
||||
if (currentState == WaitTrigger) {
|
||||
|
||||
//State Transition condition
|
||||
if ((*triggerSignal == conditionTrigger)) {
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence at %d.", *currentTime);
|
||||
plcOnTime = *currentTime; //Save pulse start time.
|
||||
//*outputBeamON = 0;
|
||||
//State transition.
|
||||
currentState = SwitchingHVPS;
|
||||
}
|
||||
}
|
||||
else if (currentState == SwitchingHVPS) {
|
||||
|
||||
//Actions in this state.
|
||||
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||
*outputSignal = 0;
|
||||
currentState = HVTerminate;
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_bps_hvon) && bps_hvon_is_on == false){
|
||||
//Do action
|
||||
*outputSignal += bps_hvon;
|
||||
bps_hvon_is_on = true; bps_hvon_state=1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "bps_hvon was set to outputSignal at %d.", *currentTime);
|
||||
*outputBPSHVON=1;
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_aps_hvon) && aps_hvon_is_on == false) {
|
||||
//Do action
|
||||
*outputSignal += aps_hvon;
|
||||
aps_hvon_is_on = true; aps_hvon_state=1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal at %d.", *currentTime);
|
||||
*outputAPSHVON=1;
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_bps_swon) && bps_swon_is_on==false){
|
||||
//Do action
|
||||
*outputSignal += bps_swon;
|
||||
bps_swon_is_on = true; bps_swon_state=1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "bps_swon was set to outputSignal at %d.", *currentTime);
|
||||
*outputBPSSWON=1;
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_mhvps_hvon) && mhvps_hvon_is_on==false) {
|
||||
//Do action
|
||||
*outputSignal += mhvps_hvon;
|
||||
mhvps_hvon_is_on = true; mhvps_hvon_state=1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "mhvps_hvon was set to outputSignal at %d.", *currentTime);
|
||||
*outputMHVPSON=1;
|
||||
}
|
||||
if (bps_swon_is_on && mhvps_hvon_is_on && *currentTime >= (plcOnTime + *triggerDelay_aps_swon)){
|
||||
//Do action
|
||||
*outputSignal += aps_swon;
|
||||
aps_swon_is_on = true; aps_swon_state=1;
|
||||
apsSwonHighResolutionTime = getCurrentTimeUs();
|
||||
apsSwonTime = *currentTime;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "aps_swon was set to outputSignal at %d.", *currentTime);
|
||||
*outputAPSSWON=1;
|
||||
}
|
||||
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||
if (bps_hvon_is_on && aps_hvon_is_on){
|
||||
*outputHVArmed = 1;
|
||||
}
|
||||
if (bps_swon_is_on || mhvps_hvon_is_on){
|
||||
*outputHVInjection = 1;
|
||||
}
|
||||
|
||||
//State transition condition
|
||||
if (aps_swon_is_on){
|
||||
currentState = RFON;
|
||||
*outputRFON = 0;
|
||||
*outputBeamON = 1;
|
||||
*shotCounter += 1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to RFON");
|
||||
}
|
||||
}
|
||||
else if (currentState == RFON) {
|
||||
|
||||
//Action in this state.
|
||||
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||
//debug
|
||||
//if((*stopRequest != 0)){
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "Stop request was called.!!!");
|
||||
//} else {
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset.!!!");
|
||||
//}
|
||||
*outputSignal -= aps_swon;
|
||||
mhvps_hvon_is_on = false; mhvps_hvon_state=0;
|
||||
aps_hvon_is_on = false; aps_hvon_state=0;
|
||||
aps_swon_is_on = false; aps_swon_state=0;
|
||||
bps_hvon_is_on = false; bps_hvon_state=0;
|
||||
bps_swon_is_on = false; bps_swon_state=0;
|
||||
currentState = HVTerminate;
|
||||
*outputAPSHVON=0;
|
||||
*outputAPSSWON=0;
|
||||
*outputBPSHVON=0;
|
||||
*outputBPSSWON=0;
|
||||
*outputMHVPSON=0;
|
||||
}
|
||||
uint32 updatePeriod = 100; // in microsecnds (get this from Timer)
|
||||
if ((*modePulseLengthLimit == 1u) || (getCurrentTimeUs() + updatePeriod >= (apsSwonHighResolutionTime + *triggerDelay_shotlen))) {
|
||||
|
||||
// Now we do busy wait
|
||||
while (getCurrentTimeUs() < (apsSwonHighResolutionTime + *triggerDelay_shotlen)) {
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "!");
|
||||
}
|
||||
// We stop busy waiting #executionOverhead before expected pulse off time
|
||||
//debug
|
||||
//if((*modePulseLengthLimit == 1u)){
|
||||
// REPORT_ERROR(ErrorManagement::Debug, "Mode limit detected.!!!");
|
||||
//} else {
|
||||
// REPORT_ERROR(ErrorManagement::Debug, "Shot length reached to the setpoint.!!!");
|
||||
//}
|
||||
//debug end.
|
||||
//Do action
|
||||
*outputSignal -= aps_swon; //Turn off only APS_SWON first.
|
||||
mhvps_hvon_is_on = false;
|
||||
aps_hvon_is_on = false;
|
||||
aps_swon_is_on = false; aps_swon_state=0;
|
||||
bps_hvon_is_on = false;
|
||||
bps_swon_is_on = false;
|
||||
*outputAPSHVON=0;
|
||||
*outputAPSSWON=0;
|
||||
*outputBPSHVON=0;
|
||||
*outputBPSSWON=0;
|
||||
*outputMHVPSON=0;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
|
||||
}
|
||||
*outputRFON = 1;
|
||||
*outputBeamONTime = *currentTime - plcOnTime;
|
||||
*outputRFONTime = *currentTime - apsSwonTime;
|
||||
|
||||
|
||||
//State transition condition
|
||||
if (!aps_swon_is_on && !bps_swon_is_on && !mhvps_hvon_is_on) {
|
||||
currentState = HVTerminate;
|
||||
apsSwoffTime = *currentTime;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to HVTerminate");
|
||||
}
|
||||
}
|
||||
else if (currentState == HVTerminate) {
|
||||
//In the HVTerminate state, turn APS_SWON off first, and wait 1ms. Finally turn other PS off.
|
||||
//Action in this state.
|
||||
*outputBeamON = 0;
|
||||
*outputHVArmed = 0;
|
||||
*outputHVInjection = 0;
|
||||
*outputRFON = 0;
|
||||
|
||||
// State transition condition.
|
||||
if (*currentTime - apsSwoffTime >= turn_off_delay){
|
||||
*outputSignal = 0;
|
||||
mhvps_hvon_state=0;
|
||||
aps_hvon_state=0;
|
||||
bps_hvon_state=0;
|
||||
bps_swon_state=0;
|
||||
}
|
||||
if (*triggerSignal == false){
|
||||
//Check PLC_ON is reset
|
||||
currentState = WaitTrigger;
|
||||
*outputSignal = 0;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset. The State was changed to WaitTrigger at %d.", *currentTime);
|
||||
}
|
||||
}
|
||||
if(*short_pulse_mode == 1){
|
||||
p3Value = 1*aps_hvon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
|
||||
*outputSignalNI6259 = 1*aps_swon_state;
|
||||
*outputSignalNI6528P3 = ~p3Value;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "short pulse mode with p3: %d.", p3Value);
|
||||
} else {
|
||||
p3Value = 1*aps_hvon_state +2*aps_swon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
|
||||
*outputSignalNI6528P3 = ~p3Value;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "long pulse mode with p3: %d.", p3Value);
|
||||
}
|
||||
if (modulation) {
|
||||
p4Value = 8*mhvps_hvon_state + 32;
|
||||
}
|
||||
else {
|
||||
p4Value = 8*mhvps_hvon_state;
|
||||
}
|
||||
//*outputSignalNI6528P4 = ~(*ni6528p4Value | p4Value);
|
||||
*outputSignalNI6528P4 = ~p4Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JARTStateMachineGAM, "1.0")
|
||||
@@ -0,0 +1,262 @@
|
||||
/**
|
||||
* @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;
|
||||
|
||||
// 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_ */
|
||||
@@ -0,0 +1,409 @@
|
||||
/**
|
||||
* @file JARTStateMachineGAM.cpp
|
||||
* @brief Source 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 source file contains the definition of all the methods for
|
||||
* the class JARTStateMachineGAM (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 "JARTStateMachineGAM.h"
|
||||
|
||||
#include "AdvancedErrorManagement.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static MARTe::uint64 getCurrentTimeUs() {
|
||||
using namespace MARTe;
|
||||
return static_cast<uint64>(HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1e6f + 0.5f);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JARTStateMachineGAM::JARTStateMachineGAM() {
|
||||
currentState = WaitTrigger; // Set Entry state.
|
||||
plcOnTime = 0; // Triggered time holder.
|
||||
|
||||
//Output and condition in a given state.
|
||||
conditionTrigger = 1;
|
||||
aps_hvon = 0;
|
||||
aps_swon = 0;
|
||||
bps_hvon = 0;
|
||||
bps_swon = 0;
|
||||
mhvps_hvon = 0;
|
||||
|
||||
// Parameters which get from Input signals.
|
||||
triggerSignal = NULL_PTR(MARTe::uint32 *);
|
||||
currentTime = NULL_PTR(MARTe::uint32 *);
|
||||
turn_off_delay = 2000; //us
|
||||
|
||||
triggerDelay_mhvps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_aps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_aps_swon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_bps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_bps_swon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_shotlen = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
stopRequest = NULL_PTR(MARTe::uint32 *);
|
||||
modePulseLengthLimit = NULL_PTR(MARTe::uint32 *);
|
||||
short_pulse_mode = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
modulation = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
// write out target.
|
||||
outputSignal = NULL_PTR(MARTe::uint32 *);
|
||||
outputBeamON = NULL_PTR(MARTe::uint32 *);
|
||||
outputHVArmed = NULL_PTR(MARTe::uint32 *);
|
||||
outputHVInjection = NULL_PTR(MARTe::uint32 *);
|
||||
outputRFON = NULL_PTR(MARTe::uint32 *);
|
||||
outputBeamONTime = NULL_PTR(MARTe::uint32 *);
|
||||
outputRFONTime = NULL_PTR(MARTe::uint32 *);
|
||||
shotCounter = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
mhvps_hvon_is_on = false;
|
||||
aps_hvon_is_on = false;
|
||||
aps_swon_is_on = false;
|
||||
bps_hvon_is_on = false;
|
||||
bps_swon_is_on = false;
|
||||
|
||||
apsSwonHighResolutionTime = 0;
|
||||
|
||||
aps_hvon_state=0;
|
||||
aps_swon_state=0;
|
||||
mhvps_hvon_state=0;
|
||||
bps_hvon_state=0;
|
||||
bps_swon_state=0;
|
||||
}
|
||||
|
||||
JARTStateMachineGAM::~JARTStateMachineGAM() {
|
||||
}
|
||||
|
||||
bool JARTStateMachineGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::Initialise(data);
|
||||
if (ok) {
|
||||
ok = data.Read("ConditionTrigger", conditionTrigger);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Condition1 shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("mhvps_hvon", mhvps_hvon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("aps_hvon", aps_hvon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("aps_swon", aps_swon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("bps_hvon", bps_hvon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("bps_swon", bps_swon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon shall be specified");
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JARTStateMachineGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JARTStateMachineGAM::Setup() {
|
||||
using namespace MARTe;
|
||||
bool ok = (numberOfInputSignals == 13u);
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals == 16u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Seven output signals shall be defined %d",numberOfOutputSignals);
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
|
||||
}
|
||||
if (ok) {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||
ok = (inputType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||
ok = (outputType == UnsignedInteger32Bit || outputType == UnsignedInteger8Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
currentTime = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||
triggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
|
||||
triggerDelay_mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||
triggerDelay_aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
|
||||
triggerDelay_aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
|
||||
triggerDelay_bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||
triggerDelay_bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
|
||||
triggerDelay_shotlen = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
|
||||
stopRequest = reinterpret_cast<uint32 *>(GetInputSignalMemory(8));
|
||||
modePulseLengthLimit = reinterpret_cast<uint32 *>(GetInputSignalMemory(9));
|
||||
short_pulse_mode = reinterpret_cast<uint32 *>(GetInputSignalMemory(10));
|
||||
modulation = reinterpret_cast<uint32 *>(GetInputSignalMemory(11));
|
||||
pauseSet = reinterpret_cast<uint32 *>(GetInputSignalMemory(12));
|
||||
|
||||
|
||||
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||
outputBeamON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
|
||||
outputHVArmed = reinterpret_cast<uint32 *>(GetOutputSignalMemory(2));
|
||||
outputHVInjection = reinterpret_cast<uint32 *>(GetOutputSignalMemory(3));
|
||||
outputRFON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(4));
|
||||
outputBeamONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(5));
|
||||
outputRFONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(6));
|
||||
shotCounter = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7));
|
||||
|
||||
outputAPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(8));
|
||||
outputAPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(9));
|
||||
outputBPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(10));
|
||||
outputBPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(11));
|
||||
outputMHVPSON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(12));
|
||||
|
||||
outputSignalNI6259 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(13));
|
||||
outputSignalNI6528P3 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(14));
|
||||
outputSignalNI6528P4 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(15));
|
||||
|
||||
*shotCounter = 0;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JARTStateMachineGAM::Execute() {
|
||||
using namespace MARTe;
|
||||
|
||||
if (currentState == WaitTrigger) {
|
||||
|
||||
//State Transition condition
|
||||
if ((*triggerSignal == conditionTrigger)) {
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence at %d.", *currentTime);
|
||||
plcOnTime = *currentTime; //Save pulse start time.
|
||||
//*outputBeamON = 0;
|
||||
//State transition.
|
||||
currentState = SwitchingHVPS;
|
||||
}
|
||||
}
|
||||
else if (currentState == SwitchingHVPS) {
|
||||
|
||||
//Actions in this state.
|
||||
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||
*outputSignal = 0;
|
||||
currentState = HVTerminate;
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_bps_hvon) && bps_hvon_is_on == false){
|
||||
//Do action
|
||||
*outputSignal += bps_hvon;
|
||||
bps_hvon_is_on = true; bps_hvon_state=1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "bps_hvon was set to outputSignal at %d.", *currentTime);
|
||||
*outputBPSHVON=1;
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_aps_hvon) && aps_hvon_is_on == false) {
|
||||
//Do action
|
||||
*outputSignal += aps_hvon;
|
||||
aps_hvon_is_on = true; aps_hvon_state=1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal at %d.", *currentTime);
|
||||
*outputAPSHVON=1;
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_bps_swon) && bps_swon_is_on==false){
|
||||
//Do action
|
||||
*outputSignal += bps_swon;
|
||||
bps_swon_is_on = true; bps_swon_state=1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "bps_swon was set to outputSignal at %d.", *currentTime);
|
||||
*outputBPSSWON=1;
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_mhvps_hvon) && mhvps_hvon_is_on==false) {
|
||||
//Do action
|
||||
*outputSignal += mhvps_hvon;
|
||||
mhvps_hvon_is_on = true; mhvps_hvon_state=1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "mhvps_hvon was set to outputSignal at %d.", *currentTime);
|
||||
*outputMHVPSON=1;
|
||||
}
|
||||
if (bps_swon_is_on && mhvps_hvon_is_on && *currentTime >= (plcOnTime + *triggerDelay_aps_swon)){
|
||||
//Do action
|
||||
*outputSignal += aps_swon;
|
||||
aps_swon_is_on = true; aps_swon_state=1;
|
||||
apsSwonHighResolutionTime = getCurrentTimeUs();
|
||||
apsSwonTime = *currentTime;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "aps_swon was set to outputSignal at %d.", *currentTime);
|
||||
*outputAPSSWON=1;
|
||||
}
|
||||
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||
if (bps_hvon_is_on && aps_hvon_is_on){
|
||||
*outputHVArmed = 1;
|
||||
}
|
||||
if (bps_swon_is_on || mhvps_hvon_is_on){
|
||||
*outputHVInjection = 1;
|
||||
}
|
||||
|
||||
//State transition condition
|
||||
if (aps_swon_is_on){
|
||||
currentState = RFON;
|
||||
*outputRFON = 0;
|
||||
*outputBeamON = 1;
|
||||
*shotCounter += 1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to RFON");
|
||||
}
|
||||
}
|
||||
else if (currentState == RFON) {
|
||||
|
||||
//Action in this state.
|
||||
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||
//debug
|
||||
//if((*stopRequest != 0)){
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "Stop request was called.!!!");
|
||||
//} else {
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset.!!!");
|
||||
//}
|
||||
*outputSignal -= aps_swon;
|
||||
mhvps_hvon_is_on = false; mhvps_hvon_state=0;
|
||||
aps_hvon_is_on = false; aps_hvon_state=0;
|
||||
aps_swon_is_on = false; aps_swon_state=0;
|
||||
bps_hvon_is_on = false; bps_hvon_state=0;
|
||||
bps_swon_is_on = false; bps_swon_state=0;
|
||||
currentState = HVTerminate;
|
||||
*outputAPSHVON=0;
|
||||
*outputAPSSWON=0;
|
||||
*outputBPSHVON=0;
|
||||
*outputBPSSWON=0;
|
||||
*outputMHVPSON=0;
|
||||
}
|
||||
uint32 updatePeriod = 100; // in microsecnds (get this from Timer)
|
||||
if ((*modePulseLengthLimit == 1u) || (getCurrentTimeUs() + updatePeriod >= (apsSwonHighResolutionTime + *triggerDelay_shotlen))) {
|
||||
|
||||
// Now we do busy wait
|
||||
while (getCurrentTimeUs() < (apsSwonHighResolutionTime + *triggerDelay_shotlen)) {
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "!");
|
||||
}
|
||||
// We stop busy waiting #executionOverhead before expected pulse off time
|
||||
//debug
|
||||
//if((*modePulseLengthLimit == 1u)){
|
||||
// REPORT_ERROR(ErrorManagement::Debug, "Mode limit detected.!!!");
|
||||
//} else {
|
||||
// REPORT_ERROR(ErrorManagement::Debug, "Shot length reached to the setpoint.!!!");
|
||||
//}
|
||||
//debug end.
|
||||
//Do action
|
||||
*outputSignal -= aps_swon; //Turn off only APS_SWON first.
|
||||
mhvps_hvon_is_on = false;
|
||||
aps_hvon_is_on = false;
|
||||
aps_swon_is_on = false; aps_swon_state=0;
|
||||
bps_hvon_is_on = false;
|
||||
bps_swon_is_on = false;
|
||||
*outputAPSHVON=0;
|
||||
*outputAPSSWON=0;
|
||||
*outputBPSHVON=0;
|
||||
*outputBPSSWON=0;
|
||||
*outputMHVPSON=0;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
|
||||
}
|
||||
*outputRFON = 1;
|
||||
*outputBeamONTime = *currentTime - plcOnTime;
|
||||
*outputRFONTime = *currentTime - apsSwonTime;
|
||||
|
||||
|
||||
//State transition condition
|
||||
if (!aps_swon_is_on && !bps_swon_is_on && !mhvps_hvon_is_on) {
|
||||
currentState = HVTerminate;
|
||||
apsSwoffTime = *currentTime;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to HVTerminate");
|
||||
}
|
||||
}
|
||||
else if (currentState == HVTerminate) {
|
||||
//In the HVTerminate state, turn APS_SWON off first, and wait 1ms. Finally turn other PS off.
|
||||
//Action in this state.
|
||||
*outputBeamON = 0;
|
||||
*outputHVArmed = 0;
|
||||
*outputHVInjection = 0;
|
||||
*outputRFON = 0;
|
||||
|
||||
// State transition condition.
|
||||
if (*currentTime - apsSwoffTime >= turn_off_delay){
|
||||
*outputSignal = 0;
|
||||
mhvps_hvon_state=0;
|
||||
aps_hvon_state=0;
|
||||
bps_hvon_state=0;
|
||||
bps_swon_state=0;
|
||||
}
|
||||
if (*triggerSignal == false){
|
||||
//Check PLC_ON is reset
|
||||
currentState = WaitTrigger;
|
||||
*outputSignal = 0;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset. The State was changed to WaitTrigger at %d.", *currentTime);
|
||||
}
|
||||
}
|
||||
if(*short_pulse_mode == 1){
|
||||
p3Value = 1*aps_hvon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
|
||||
*outputSignalNI6259 = 1*aps_swon_state;
|
||||
*outputSignalNI6528P3 = ~p3Value;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "short pulse mode with p3: %d.", p3Value);
|
||||
} else {
|
||||
p3Value = 1*aps_hvon_state +2*aps_swon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
|
||||
*outputSignalNI6528P3 = ~p3Value;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "long pulse mode with p3: %d.", p3Value);
|
||||
}
|
||||
p4Value = 8*mhvps_hvon_state;
|
||||
if (modulation) p4Value += 32;
|
||||
if (pauseSet) p4Value += 1;
|
||||
//*outputSignalNI6528P4 = ~(*ni6528p4Value | p4Value);
|
||||
*outputSignalNI6528P4 = ~p4Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JARTStateMachineGAM, "1.0")
|
||||
@@ -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_ */
|
||||
@@ -0,0 +1,402 @@
|
||||
/**
|
||||
* @file JARTStateMachineGAM.cpp
|
||||
* @brief Source 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 source file contains the definition of all the methods for
|
||||
* the class JARTStateMachineGAM (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 "JARTStateMachineGAM.h"
|
||||
|
||||
#include "AdvancedErrorManagement.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static MARTe::uint64 getCurrentTimeUs() {
|
||||
using namespace MARTe;
|
||||
return static_cast<uint64>(HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1e6f + 0.5f);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JARTStateMachineGAM::JARTStateMachineGAM() {
|
||||
currentState = WaitTrigger; // Set Entry state.
|
||||
plcOnTime = 0; // Triggered time holder.
|
||||
|
||||
//Output and condition in a given state.
|
||||
conditionTrigger = 1;
|
||||
aps_hvon = 0;
|
||||
aps_swon = 0;
|
||||
bps_hvon = 0;
|
||||
bps_swon = 0;
|
||||
mhvps_hvon = 0;
|
||||
|
||||
// Parameters which get from Input signals.
|
||||
triggerSignal = NULL_PTR(MARTe::uint32 *);
|
||||
currentTime = NULL_PTR(MARTe::uint32 *);
|
||||
turn_off_delay = 2000; //us
|
||||
|
||||
triggerDelay_mhvps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_aps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_aps_swon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_bps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_bps_swon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_shotlen = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
stopRequest = NULL_PTR(MARTe::uint32 *);
|
||||
modePulseLengthLimit = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
// write out target.
|
||||
outputSignal = NULL_PTR(MARTe::uint32 *);
|
||||
outputBeamON = NULL_PTR(MARTe::uint32 *);
|
||||
outputHVArmed = NULL_PTR(MARTe::uint32 *);
|
||||
outputHVInjection = NULL_PTR(MARTe::uint32 *);
|
||||
outputRFON = NULL_PTR(MARTe::uint32 *);
|
||||
outputBeamONTime = NULL_PTR(MARTe::uint32 *);
|
||||
outputRFONTime = NULL_PTR(MARTe::uint32 *);
|
||||
shotCounter = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
mhvps_hvon_is_on = false;
|
||||
aps_hvon_is_on = false;
|
||||
aps_swon_is_on = false;
|
||||
bps_hvon_is_on = false;
|
||||
bps_swon_is_on = false;
|
||||
|
||||
apsSwonHighResolutionTime = 0;
|
||||
|
||||
aps_hvon_state=0;
|
||||
aps_swon_state=0;
|
||||
mhvps_hvon_state=0;
|
||||
bps_hvon_state=0;
|
||||
bps_swon_state=0;
|
||||
}
|
||||
|
||||
JARTStateMachineGAM::~JARTStateMachineGAM() {
|
||||
}
|
||||
|
||||
bool JARTStateMachineGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::Initialise(data);
|
||||
if (ok) {
|
||||
ok = data.Read("ConditionTrigger", conditionTrigger);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Condition1 shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("mhvps_hvon", mhvps_hvon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("aps_hvon", aps_hvon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("aps_swon", aps_swon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("bps_hvon", bps_hvon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("bps_swon", bps_swon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon shall be specified");
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JARTStateMachineGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JARTStateMachineGAM::Setup() {
|
||||
using namespace MARTe;
|
||||
bool ok = (numberOfInputSignals == 11u);
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals == 16u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Seven output signals shall be defined %d",numberOfOutputSignals);
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
|
||||
}
|
||||
if (ok) {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||
ok = (inputType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||
ok = (outputType == UnsignedInteger32Bit || outputType == UnsignedInteger8Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
currentTime = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||
triggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
|
||||
triggerDelay_mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||
triggerDelay_aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
|
||||
triggerDelay_aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
|
||||
triggerDelay_bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||
triggerDelay_bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
|
||||
triggerDelay_shotlen = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
|
||||
stopRequest = reinterpret_cast<uint32 *>(GetInputSignalMemory(8));
|
||||
modePulseLengthLimit = reinterpret_cast<uint32 *>(GetInputSignalMemory(9));
|
||||
short_pulse_mode = reinterpret_cast<uint32 *>(GetInputSignalMemory(10));
|
||||
|
||||
|
||||
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||
outputBeamON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
|
||||
outputHVArmed = reinterpret_cast<uint32 *>(GetOutputSignalMemory(2));
|
||||
outputHVInjection = reinterpret_cast<uint32 *>(GetOutputSignalMemory(3));
|
||||
outputRFON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(4));
|
||||
outputBeamONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(5));
|
||||
outputRFONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(6));
|
||||
shotCounter = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7));
|
||||
|
||||
outputAPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(8));
|
||||
outputAPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(9));
|
||||
outputBPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(10));
|
||||
outputBPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(11));
|
||||
outputMHVPSON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(12));
|
||||
|
||||
outputSignalNI6259 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(13));
|
||||
outputSignalNI6528P3 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(14));
|
||||
outputSignalNI6528P4 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(15));
|
||||
|
||||
*shotCounter = 0;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JARTStateMachineGAM::Execute() {
|
||||
using namespace MARTe;
|
||||
|
||||
if (currentState == WaitTrigger) {
|
||||
|
||||
//State Transition condition
|
||||
if ((*triggerSignal == conditionTrigger)) {
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence at %d.", *currentTime);
|
||||
plcOnTime = *currentTime; //Save pulse start time.
|
||||
//*outputBeamON = 0;
|
||||
//State transition.
|
||||
currentState = SwitchingHVPS;
|
||||
}
|
||||
}
|
||||
else if (currentState == SwitchingHVPS) {
|
||||
|
||||
//Actions in this state.
|
||||
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||
*outputSignal = 0;
|
||||
currentState = HVTerminate;
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_bps_hvon) && bps_hvon_is_on == false){
|
||||
//Do action
|
||||
*outputSignal += bps_hvon;
|
||||
bps_hvon_is_on = true; bps_hvon_state=1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "bps_hvon was set to outputSignal at %d.", *currentTime);
|
||||
*outputBPSHVON=1;
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_aps_hvon) && aps_hvon_is_on == false) {
|
||||
//Do action
|
||||
*outputSignal += aps_hvon;
|
||||
aps_hvon_is_on = true; aps_hvon_state=1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal at %d.", *currentTime);
|
||||
*outputAPSHVON=1;
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_bps_swon) && bps_swon_is_on==false){
|
||||
//Do action
|
||||
*outputSignal += bps_swon;
|
||||
bps_swon_is_on = true; bps_swon_state=1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "bps_swon was set to outputSignal at %d.", *currentTime);
|
||||
*outputBPSSWON=1;
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_mhvps_hvon) && mhvps_hvon_is_on==false) {
|
||||
//Do action
|
||||
*outputSignal += mhvps_hvon;
|
||||
mhvps_hvon_is_on = true; mhvps_hvon_state=1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "mhvps_hvon was set to outputSignal at %d.", *currentTime);
|
||||
*outputMHVPSON=1;
|
||||
}
|
||||
if (bps_swon_is_on && mhvps_hvon_is_on && *currentTime >= (plcOnTime + *triggerDelay_aps_swon)){
|
||||
//Do action
|
||||
*outputSignal += aps_swon;
|
||||
aps_swon_is_on = true; aps_swon_state=1;
|
||||
apsSwonHighResolutionTime = getCurrentTimeUs();
|
||||
apsSwonTime = *currentTime;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "aps_swon was set to outputSignal at %d.", *currentTime);
|
||||
*outputAPSSWON=1;
|
||||
}
|
||||
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||
if (bps_hvon_is_on && aps_hvon_is_on){
|
||||
*outputHVArmed = 1;
|
||||
}
|
||||
if (bps_swon_is_on || mhvps_hvon_is_on){
|
||||
*outputHVInjection = 1;
|
||||
}
|
||||
|
||||
//State transition condition
|
||||
if (aps_swon_is_on){
|
||||
currentState = RFON;
|
||||
*outputRFON = 0;
|
||||
*outputBeamON = 1;
|
||||
*shotCounter += 1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to RFON");
|
||||
}
|
||||
}
|
||||
else if (currentState == RFON) {
|
||||
|
||||
//Action in this state.
|
||||
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||
//debug
|
||||
//if((*stopRequest != 0)){
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "Stop request was called.!!!");
|
||||
//} else {
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset.!!!");
|
||||
//}
|
||||
*outputSignal -= aps_swon;
|
||||
mhvps_hvon_is_on = false; mhvps_hvon_state=0;
|
||||
aps_hvon_is_on = false; aps_hvon_state=0;
|
||||
aps_swon_is_on = false; aps_swon_state=0;
|
||||
bps_hvon_is_on = false; bps_hvon_state=0;
|
||||
bps_swon_is_on = false; bps_swon_state=0;
|
||||
currentState = HVTerminate;
|
||||
*outputAPSHVON=0;
|
||||
*outputAPSSWON=0;
|
||||
*outputBPSHVON=0;
|
||||
*outputBPSSWON=0;
|
||||
*outputMHVPSON=0;
|
||||
}
|
||||
uint32 updatePeriod = 100; // in microsecnds (get this from Timer)
|
||||
if ((*modePulseLengthLimit == 1u) || (getCurrentTimeUs() + updatePeriod >= (apsSwonHighResolutionTime + *triggerDelay_shotlen))) {
|
||||
|
||||
// Now we do busy wait
|
||||
while (getCurrentTimeUs() < (apsSwonHighResolutionTime + *triggerDelay_shotlen)) {
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "!");
|
||||
}
|
||||
// We stop busy waiting #executionOverhead before expected pulse off time
|
||||
//debug
|
||||
//if((*modePulseLengthLimit == 1u)){
|
||||
// REPORT_ERROR(ErrorManagement::Debug, "Mode limit detected.!!!");
|
||||
//} else {
|
||||
// REPORT_ERROR(ErrorManagement::Debug, "Shot length reached to the setpoint.!!!");
|
||||
//}
|
||||
//debug end.
|
||||
//Do action
|
||||
*outputSignal -= aps_swon; //Turn off only APS_SWON first.
|
||||
mhvps_hvon_is_on = false;
|
||||
aps_hvon_is_on = false;
|
||||
aps_swon_is_on = false; aps_swon_state=0;
|
||||
bps_hvon_is_on = false;
|
||||
bps_swon_is_on = false;
|
||||
*outputAPSHVON=0;
|
||||
*outputAPSSWON=0;
|
||||
*outputBPSHVON=0;
|
||||
*outputBPSSWON=0;
|
||||
*outputMHVPSON=0;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
|
||||
}
|
||||
*outputRFON = 1;
|
||||
*outputBeamONTime = *currentTime - plcOnTime;
|
||||
*outputRFONTime = *currentTime - apsSwonTime;
|
||||
|
||||
|
||||
//State transition condition
|
||||
if (!aps_swon_is_on && !bps_swon_is_on && !mhvps_hvon_is_on) {
|
||||
currentState = HVTerminate;
|
||||
apsSwoffTime = *currentTime;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to HVTerminate");
|
||||
}
|
||||
}
|
||||
else if (currentState == HVTerminate) {
|
||||
//In the HVTerminate state, turn APS_SWON off first, and wait 1ms. Finally turn other PS off.
|
||||
//Action in this state.
|
||||
*outputBeamON = 0;
|
||||
*outputHVArmed = 0;
|
||||
*outputHVInjection = 0;
|
||||
*outputRFON = 0;
|
||||
|
||||
// State transition condition.
|
||||
if (*currentTime - apsSwoffTime >= turn_off_delay){
|
||||
*outputSignal = 0;
|
||||
mhvps_hvon_state=0;
|
||||
aps_hvon_state=0;
|
||||
bps_hvon_state=0;
|
||||
bps_swon_state=0;
|
||||
}
|
||||
if (*triggerSignal == false){
|
||||
//Check PLC_ON is reset
|
||||
currentState = WaitTrigger;
|
||||
*outputSignal = 0;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset. The State was changed to WaitTrigger at %d.", *currentTime);
|
||||
}
|
||||
}
|
||||
if(*short_pulse_mode == 1){
|
||||
p3Value = 1*aps_hvon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
|
||||
*outputSignalNI6259 = 1*aps_swon_state;
|
||||
*outputSignalNI6528P3 = ~p3Value;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "short pulse mode with p3: %d.", p3Value);
|
||||
} else {
|
||||
p3Value = 1*aps_hvon_state +2*aps_swon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
|
||||
*outputSignalNI6528P3 = ~p3Value;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "long pulse mode with p3: %d.", p3Value);
|
||||
}
|
||||
p4Value = 8*mhvps_hvon_state;
|
||||
//*outputSignalNI6528P4 = ~(*ni6528p4Value | p4Value);
|
||||
*outputSignalNI6528P4 = ~p4Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JARTStateMachineGAM, "1.0")
|
||||
@@ -0,0 +1,260 @@
|
||||
/**
|
||||
* @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;
|
||||
|
||||
// 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_ */
|
||||
@@ -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
|
||||
@@ -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=JARTStateMachineGAM.x
|
||||
|
||||
PACKAGE=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/FileSystem/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/JARTStateMachineGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/JARTStateMachineGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
|
||||
@@ -0,0 +1,295 @@
|
||||
/**
|
||||
* @file JARampupGAM.cpp
|
||||
* @brief Source file for class JARampupGAM
|
||||
* @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 JARampupGAM (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 "JARampupGAM.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JARampupGAM::JARampupGAM() : GAM() {
|
||||
current_setpoint = NULL_PTR(MARTe::float32 *);
|
||||
target_value = NULL_PTR(MARTe::float32 *);
|
||||
rampup_time = NULL_PTR(MARTe::float32 *);
|
||||
start = NULL_PTR(MARTe::uint32 *);
|
||||
standby = NULL_PTR(MARTe::uint32 *);
|
||||
isAuto = NULL_PTR(MARTe::uint32 *);
|
||||
FHPS_PrePro = NULL_PTR(MARTe::float32 *);
|
||||
|
||||
output = NULL_PTR(MARTe::float32 *);
|
||||
state = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
rampup_rate = 0.0f;
|
||||
inRampup = false;
|
||||
resetFlag = true;
|
||||
inWaitHVON = false;
|
||||
inWaitStandby = false;
|
||||
}
|
||||
|
||||
JARampupGAM::~JARampupGAM() {
|
||||
}
|
||||
|
||||
bool JARampupGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
return GAM::Initialise(data);
|
||||
}
|
||||
|
||||
bool JARampupGAM::Setup() {
|
||||
using namespace MARTe;
|
||||
bool ok = (numberOfInputSignals == 7u);
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals == 2u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Two output signals shall be defined.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Six input signals shall be defined.");
|
||||
}
|
||||
uint32 currentspvIndex;
|
||||
uint32 targetvIndex;
|
||||
uint32 timeIndex;
|
||||
uint32 startIndex;
|
||||
uint32 standbyIndex;
|
||||
uint32 isAutoIndex;
|
||||
uint32 fhpsPreProIndex;
|
||||
|
||||
if (ok) {
|
||||
StreamString signalName = "Currspv";
|
||||
ok = GetSignalIndex(InputSignals, currentspvIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Currspv input signal shall be defined.");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, currentspvIndex);
|
||||
ok = (inputType == Float32Bit);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Currspv shall be defined as float32.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
StreamString signalName = "Targetv";
|
||||
ok = GetSignalIndex(InputSignals, targetvIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Targetv input signal shall be defined.");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, targetvIndex);
|
||||
ok = (inputType == Float32Bit);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Targetv shall be defined as float32.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
StreamString signalName = "Time";
|
||||
ok = GetSignalIndex(InputSignals, timeIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Time input signal shall be defined.");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, timeIndex);
|
||||
ok = (inputType == Float32Bit);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Time shall be defined as float32.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
StreamString signalName = "Start";
|
||||
ok = GetSignalIndex(InputSignals, startIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Start input signal shall be defined.");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, startIndex);
|
||||
ok = (inputType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Start shall be defined as uint32.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
StreamString signalName = "PLC_STANDBY";
|
||||
ok = GetSignalIndex(InputSignals, standbyIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "PLC_STANDBY input signal shall be defined.");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, standbyIndex);
|
||||
ok = (inputType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "PLC_STANDBY shall be defined as uint32.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
StreamString signalName = "MANUAL_AUTO";
|
||||
ok = GetSignalIndex(InputSignals, isAutoIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "MANUAL_AUTO input signal shall be defined.");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, isAutoIndex);
|
||||
ok = (inputType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "MANUAL_AUTO shall be defined as uint32.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
StreamString signalName = "FHPS_PrePro";
|
||||
ok = GetSignalIndex(InputSignals, fhpsPreProIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "FHPS_PrePro input signal shall be defined.");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, fhpsPreProIndex);
|
||||
ok = (inputType == Float32Bit);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Signal FHPS_PrePro shall be defined as float32.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
TypeDescriptor inputType = GetSignalType(OutputSignals, 0);
|
||||
ok = (inputType == Float32Bit);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Output shall be defined as float32.");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
TypeDescriptor inputType = GetSignalType(OutputSignals, 1);
|
||||
ok = (inputType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Signal state shall be defined as float32.");
|
||||
}
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
current_setpoint = reinterpret_cast<float32 *>(GetInputSignalMemory(currentspvIndex));
|
||||
target_value = reinterpret_cast<float32 *>(GetInputSignalMemory(targetvIndex));
|
||||
rampup_time = reinterpret_cast<float32 *>(GetInputSignalMemory(timeIndex));
|
||||
start = reinterpret_cast<uint32 *>(GetInputSignalMemory(startIndex));
|
||||
standby = reinterpret_cast<uint32 *>(GetInputSignalMemory(standbyIndex));
|
||||
isAuto = reinterpret_cast<uint32 *>(GetInputSignalMemory(isAutoIndex));
|
||||
FHPS_PrePro = reinterpret_cast<float32 *>(GetInputSignalMemory(fhpsPreProIndex));
|
||||
|
||||
output = reinterpret_cast<float32 *>(GetOutputSignalMemory(0));
|
||||
state = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JARampupGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName){
|
||||
if(strcmp(nextStateName, "WaitHVON_PREP")==0 || strcmp(nextStateName, "WaitHVON_SDN_PREP")==0 ||
|
||||
strcmp(nextStateName, "WaitHVON")==0 || strcmp(nextStateName, "WaitHVON_SDN")==0){
|
||||
inWaitHVON = true;
|
||||
inWaitStandby = false;
|
||||
} else{
|
||||
inWaitHVON = false;
|
||||
if(strcmp(nextStateName,"WaitStandby")==0 ){
|
||||
inWaitStandby = true;
|
||||
} else {
|
||||
inWaitStandby = false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JARampupGAM::Execute() {
|
||||
using namespace MARTe;
|
||||
if(!inWaitHVON){
|
||||
if (*target_value <= 0.0f || *standby == 0u) {
|
||||
*output = 0.0f;
|
||||
rampup_rate = 0.0f;
|
||||
if(*target_value <= 0.0f){
|
||||
*state = 3u;
|
||||
} else {
|
||||
*state = 0u;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(*start == 1u && *isAuto==0u){ //isAuto = 1.Manual, 0.auto-rampup.
|
||||
inRampup = true;
|
||||
resetFlag = true;
|
||||
*output = 0.0f; //Enable if it should start always zero.
|
||||
}
|
||||
|
||||
// Calcrate new rampup rate.
|
||||
if(*rampup_time != 0 && resetFlag == true){
|
||||
rampup_rate = (*target_value - *current_setpoint) / *rampup_time/1000.0f; // Volt/msec
|
||||
resetFlag = false;
|
||||
}
|
||||
|
||||
// Update Parameter
|
||||
if(*standby == 1u ){
|
||||
if(*isAuto == 1u){
|
||||
if (inWaitStandby){
|
||||
*output = *target_value;
|
||||
} else{
|
||||
*output = *FHPS_PrePro;
|
||||
}
|
||||
//*output = *target_value;
|
||||
*state = 0u;
|
||||
return true;
|
||||
}
|
||||
else if (inRampup){
|
||||
if (*output + rampup_rate < *target_value && *rampup_time != 0){
|
||||
*output = *output + rampup_rate;
|
||||
*state = 1u;
|
||||
} else {
|
||||
*output = *target_value;
|
||||
*state = 2u;
|
||||
inRampup = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if(*isAuto == 0){
|
||||
*output = *FHPS_PrePro;
|
||||
} else{
|
||||
*output = *target_value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JARampupGAM, "1.0")
|
||||
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* @file JARampupGAM.h
|
||||
* @brief Header file for class JARampupGAM
|
||||
* @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 JARampupGAM
|
||||
* 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_JARampupGAM_H_
|
||||
#define GAMS_JARampupGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GAM.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief GAM that rampup output value with specified target value and duration.
|
||||
*
|
||||
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||
* <pre>
|
||||
* +FHPSRampupGAM = {
|
||||
* Class = JARampupGAM
|
||||
* InputSignals = {
|
||||
* Currspv = {
|
||||
* Alias = FHPS_REF
|
||||
* DataSource = DDB1
|
||||
* Type = float32
|
||||
* }
|
||||
* Targetv = {
|
||||
* Alias = FHPS_AUTO_TAGV
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = float32
|
||||
* }
|
||||
* Time = {
|
||||
* Alias = FHPS_AUTO_TIME
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = float32
|
||||
* }
|
||||
* Start = {
|
||||
* Alias = FHPS_AUTO_START
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = uint32
|
||||
* }
|
||||
* }
|
||||
* OutputSignals = {
|
||||
* FHPS_REF = {
|
||||
* DataSource = DDB1
|
||||
* Type = float32
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
||||
class JARampupGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
JARampupGAM();
|
||||
|
||||
virtual ~JARampupGAM();
|
||||
|
||||
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:
|
||||
// Input signal containing current current_setpoint
|
||||
MARTe::float32 *current_setpoint;
|
||||
|
||||
// Input signal containing the frequency of the waveform.
|
||||
MARTe::float32 *target_value;
|
||||
|
||||
// Input signal containing the amplitude of the waveform.
|
||||
MARTe::float32 *rampup_time;
|
||||
|
||||
// Input signal containing CCPS_ON_REQUEST
|
||||
MARTe::uint32 *start;
|
||||
|
||||
// Input signal PLC_STANDBY
|
||||
MARTe::uint32 *standby;
|
||||
|
||||
// MANUAL AUTO button
|
||||
MARTe::uint32 *isAuto;
|
||||
|
||||
// Input signal
|
||||
MARTe::float32 *FHPS_PrePro;
|
||||
|
||||
// Output
|
||||
MARTe::float32 *output;
|
||||
// State output
|
||||
MARTe::uint32 *state; //0:NotOperation, 1:InOperation, 2:Finish, 3:Error
|
||||
|
||||
// Internal variables
|
||||
MARTe::float32 rampup_rate;
|
||||
bool inRampup;
|
||||
bool resetFlag;
|
||||
bool inWaitHVON;
|
||||
bool inWaitStandby;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* GAMS_JARampupGAM_H_ */
|
||||
@@ -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
|
||||
@@ -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=JARampupGAM.x
|
||||
|
||||
PACKAGE=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/FileSystem/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/JARampupGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/JARampupGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
@@ -0,0 +1,361 @@
|
||||
/**
|
||||
* @file JASDNRTStateMachineGAM.cpp
|
||||
* @brief Source file for class JASDNRTStateMachineGAM
|
||||
* @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 JASDNRTStateMachineGAM (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 "JASDNRTStateMachineGAM.h"
|
||||
|
||||
#include "AdvancedErrorManagement.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JASDNRTStateMachineGAM::JASDNRTStateMachineGAM() {
|
||||
currentState = WaitTrigger; // Set Entry state.
|
||||
plcOnTime = 0; // Triggered time holder.
|
||||
sdnTriggerTime = 0;
|
||||
//Output and condition in a given state.
|
||||
conditionTrigger = 1;
|
||||
aps_hvon = 0;
|
||||
aps_swon = 0;
|
||||
bps_hvon = 0;
|
||||
bps_swon = 0;
|
||||
mhvps_hvon = 0;
|
||||
|
||||
// Parameters which get from Input signals.
|
||||
triggerSignal = NULL_PTR(MARTe::uint32 *);
|
||||
currentTime = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_mhvps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_aps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_aps_swon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_bps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_bps_swon = NULL_PTR(MARTe::uint32 *);
|
||||
triggerDelay_shotlen = NULL_PTR(MARTe::uint32 *);
|
||||
stopRequest = NULL_PTR(MARTe::uint32 *);
|
||||
modePulseLengthLimit = NULL_PTR(MARTe::uint32 *);
|
||||
sdnCommand = NULL_PTR(MARTe::uint16 *);
|
||||
|
||||
// write out target.
|
||||
outputSignal = NULL_PTR(MARTe::uint32 *);
|
||||
outputBeamON = NULL_PTR(MARTe::uint32 *);
|
||||
outputHVArmed = NULL_PTR(MARTe::uint32 *);
|
||||
outputHVInjection = NULL_PTR(MARTe::uint32 *);
|
||||
outputRFON = NULL_PTR(MARTe::uint32 *);
|
||||
outputBeamONTime = NULL_PTR(MARTe::uint32 *);
|
||||
outputRFONTime = NULL_PTR(MARTe::uint32 *);
|
||||
shotCounter = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
mhvps_hvon_is_on = false;
|
||||
aps_hvon_is_on = false;
|
||||
aps_swon_is_on = false;
|
||||
bps_hvon_is_on = false;
|
||||
bps_swon_is_on = false;
|
||||
}
|
||||
|
||||
JASDNRTStateMachineGAM::~JASDNRTStateMachineGAM() {
|
||||
}
|
||||
|
||||
bool JASDNRTStateMachineGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::Initialise(data);
|
||||
if (ok) {
|
||||
ok = data.Read("ConditionTrigger", conditionTrigger);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Condition1 shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("mhvps_hvon", mhvps_hvon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("aps_hvon", aps_hvon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("aps_swon", aps_swon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("bps_hvon", bps_hvon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("bps_swon", bps_swon);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon shall be specified");
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JASDNRTStateMachineGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JASDNRTStateMachineGAM::Setup() {
|
||||
using namespace MARTe;
|
||||
bool ok = (numberOfInputSignals == 11u);
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals == 8u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Seven output signals shall be defined");
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
|
||||
}
|
||||
if (ok) {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||
ok = (inputType == UnsignedInteger32Bit || inputType == UnsignedInteger16Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or uint16", signalName.Buffer());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||
ok = (outputType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
currentTime = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||
triggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
|
||||
triggerDelay_mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||
triggerDelay_aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
|
||||
triggerDelay_aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
|
||||
triggerDelay_bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||
triggerDelay_bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
|
||||
triggerDelay_shotlen = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
|
||||
stopRequest = reinterpret_cast<uint32 *>(GetInputSignalMemory(8));
|
||||
modePulseLengthLimit = reinterpret_cast<uint32 *>(GetInputSignalMemory(9));
|
||||
sdnCommand = reinterpret_cast<uint16 *>(GetInputSignalMemory(10));
|
||||
|
||||
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||
outputBeamON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
|
||||
outputHVArmed = reinterpret_cast<uint32 *>(GetOutputSignalMemory(2));
|
||||
outputHVInjection = reinterpret_cast<uint32 *>(GetOutputSignalMemory(3));
|
||||
outputRFON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(4));
|
||||
outputBeamONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(5));
|
||||
outputRFONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(6));
|
||||
shotCounter = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7));
|
||||
*shotCounter = 0;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JASDNRTStateMachineGAM::Execute() {
|
||||
using namespace MARTe;
|
||||
if (currentState == WaitTrigger) {
|
||||
|
||||
//State Transition condition
|
||||
if ((*triggerSignal == conditionTrigger)) {
|
||||
REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence in SDN mode.");
|
||||
plcOnTime = *currentTime; //Save pulse start time.
|
||||
*outputBeamON = 0;
|
||||
//State transition.
|
||||
currentState = SwitchingHVPS_HVON;
|
||||
}
|
||||
}
|
||||
else if (currentState == SwitchingHVPS_HVON) {
|
||||
|
||||
//Actions in this state.
|
||||
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||
*outputSignal -= aps_swon;
|
||||
currentState = HVTerminate;
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_bps_hvon) && bps_hvon_is_on == false){
|
||||
//Do action
|
||||
*outputSignal += bps_hvon;
|
||||
bps_hvon_is_on = true;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "bps_hvon was set to outputSignal at %d.", *currentTime);
|
||||
}
|
||||
if (*currentTime >= (plcOnTime + *triggerDelay_aps_hvon) && aps_hvon_is_on == false) {
|
||||
//Do action
|
||||
*outputSignal += aps_hvon;
|
||||
aps_hvon_is_on = true;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal.");
|
||||
}
|
||||
|
||||
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||
if (bps_hvon_is_on && aps_hvon_is_on){
|
||||
*outputHVArmed = 0;
|
||||
currentState = WaitSDNTrigger;
|
||||
}
|
||||
|
||||
}
|
||||
else if (currentState == WaitSDNTrigger) {
|
||||
|
||||
// Action in this state
|
||||
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||
|
||||
// State change conditions
|
||||
if (*sdnCommand == 1){
|
||||
sdnTriggerTime = *currentTime;
|
||||
currentState = SwitchingHVPS_SWON;
|
||||
}
|
||||
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||
*outputSignal = 0;
|
||||
currentState = HVTerminate;
|
||||
}
|
||||
}
|
||||
else if (currentState == SwitchingHVPS_SWON) {
|
||||
|
||||
//Actions in this state.
|
||||
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||
*outputSignal = 0;
|
||||
currentState = HVTerminate;
|
||||
}
|
||||
|
||||
if (*currentTime >= (sdnTriggerTime + *triggerDelay_bps_swon) && bps_swon_is_on==false){
|
||||
//Do action
|
||||
*outputSignal += bps_swon;
|
||||
bps_swon_is_on = true;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "bps_swon was set to outputSignal at %d.", *currentTime);
|
||||
}
|
||||
if (*currentTime >= (sdnTriggerTime + *triggerDelay_mhvps_hvon) && mhvps_hvon_is_on==false) {
|
||||
//Do action
|
||||
*outputSignal += mhvps_hvon;
|
||||
mhvps_hvon_is_on = true;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "mhvps_hvon was set to outputSignal at %d.", *currentTime);
|
||||
}
|
||||
if (bps_swon_is_on && mhvps_hvon_is_on && *currentTime >= (sdnTriggerTime + *triggerDelay_aps_swon)){
|
||||
//Do action
|
||||
*outputSignal += aps_swon;
|
||||
aps_swon_is_on = true;
|
||||
apsSwonTime = *currentTime;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "aps_swon was set to outputSignal at %d.", *currentTime);
|
||||
}
|
||||
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||
|
||||
if (bps_swon_is_on || mhvps_hvon_is_on){
|
||||
*outputHVInjection = 0;
|
||||
}
|
||||
|
||||
//State transition condition
|
||||
if (aps_swon_is_on){
|
||||
currentState = RFON;
|
||||
*outputRFON = 0;
|
||||
*shotCounter += 1;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "state was changed to RFON");
|
||||
}
|
||||
}
|
||||
else if (currentState == RFON) {
|
||||
|
||||
//SDN command processing.
|
||||
if (*sdnCommand == 4 && aps_swon_is_on) {
|
||||
*outputSignal -= aps_swon;
|
||||
aps_swon_is_on = false;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "sdn command was 4");
|
||||
}
|
||||
if (*sdnCommand == 3 && !aps_swon_is_on) {
|
||||
*outputSignal += aps_swon;
|
||||
aps_swon_is_on = true;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "sdn command was 3");
|
||||
}
|
||||
|
||||
//Action in this state.
|
||||
if ((*sdnCommand == 2) || (*modePulseLengthLimit == 1u) || (*currentTime >= (sdnTriggerTime + *triggerDelay_aps_swon + *triggerDelay_shotlen))) {
|
||||
REPORT_ERROR(ErrorManagement::Debug, "shotlen: %d", *triggerDelay_shotlen);
|
||||
if (*sdnCommand == 2) {
|
||||
REPORT_ERROR(ErrorManagement::Information, "sdn command was 2");
|
||||
} else if (*currentTime >= (sdnTriggerTime + *triggerDelay_aps_swon + *triggerDelay_shotlen)){
|
||||
REPORT_ERROR(ErrorManagement::Information, "pulse length reached setpoint.");
|
||||
}
|
||||
//Do action
|
||||
*outputSignal -= aps_swon; //Turn off only aps_swon
|
||||
mhvps_hvon_is_on = false;
|
||||
aps_hvon_is_on = false;
|
||||
aps_swon_is_on = false;
|
||||
bps_hvon_is_on = false;
|
||||
bps_swon_is_on = false;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
|
||||
}
|
||||
*outputRFON = 0;
|
||||
*outputBeamONTime = *currentTime - plcOnTime;
|
||||
*outputRFONTime = *currentTime - apsSwonTime;
|
||||
|
||||
|
||||
//State transition condition
|
||||
if (!aps_swon_is_on && !bps_swon_is_on && !mhvps_hvon_is_on) {
|
||||
currentState = HVTerminate;
|
||||
apsSwoffTime = *currentTime;
|
||||
REPORT_ERROR(ErrorManagement::Information, "state was changed to HVTerminate");
|
||||
}
|
||||
}
|
||||
else if (currentState == HVTerminate) {
|
||||
|
||||
//Action in this state.
|
||||
*outputBeamON = 1;
|
||||
*outputHVArmed = 1;
|
||||
*outputHVInjection = 1;
|
||||
*outputRFON = 1;
|
||||
|
||||
// State transition condition.
|
||||
if (*currentTime - apsSwoffTime >= turn_off_delay){
|
||||
*outputSignal = 0;
|
||||
}
|
||||
if (*triggerSignal == false){
|
||||
//Check PLC_ON is reset
|
||||
currentState = WaitTrigger;
|
||||
*outputSignal = 0;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "state was changed to WaitTrigger");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JASDNRTStateMachineGAM, "1.0")
|
||||
@@ -0,0 +1,250 @@
|
||||
/**
|
||||
* @file JARTStateMachineGAM.h
|
||||
* @brief Header file for class JASDNRTStateMachineGAM
|
||||
* @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_JASDNRTSTATEMACHINEGAM_H_
|
||||
#define GAMS_JASDNRTSTATEMACHINEGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GAM.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief GAM provides real-time state machine that communicate with SDN packet.
|
||||
*
|
||||
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||
* <pre>
|
||||
* +GAMSDNRealTimeStateMachine = {
|
||||
* Class = JASDNRTStateMachineGAM
|
||||
* 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
|
||||
* }
|
||||
* Command = {
|
||||
* DataSource = RealTimeThreadAsyncBridge
|
||||
* Type = uint16
|
||||
* }
|
||||
* }
|
||||
* OutputSignals = {
|
||||
* Value = {
|
||||
* //DataSource = NI6259
|
||||
* DataSource = Display
|
||||
* Type = uint32
|
||||
* Trigger = 1
|
||||
* }
|
||||
* BeamON = {
|
||||
* 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 JASDNRTStateMachineGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
JASDNRTStateMachineGAM();
|
||||
|
||||
virtual ~JASDNRTStateMachineGAM();
|
||||
|
||||
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_HVON = 1,
|
||||
WaitSDNTrigger = 2,
|
||||
SwitchingHVPS_SWON = 3,
|
||||
RFON = 4,
|
||||
HVTerminate = 5
|
||||
};
|
||||
|
||||
//The current rtState
|
||||
JARealTimeState currentState;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Static parameter given by cfg File
|
||||
/////////////////////////////////////////////////
|
||||
//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;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Input signals
|
||||
/////////////////////////////////////////////////
|
||||
//The trigger signal (PLC_ON)
|
||||
MARTe::uint32 *triggerSignal;
|
||||
//Time signal (Time from TimerGAM)
|
||||
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 SDN commands.
|
||||
MARTe::uint16 *sdnCommand;
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// 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;
|
||||
|
||||
//////////////////////////////
|
||||
//Internal Parameters
|
||||
//////////////////////////////
|
||||
//PLC_ON time holder
|
||||
MARTe::uint32 plcOnTime;
|
||||
//APS_SWON time holder
|
||||
MARTe::uint32 apsSwonTime;
|
||||
MARTe::uint32 apsSwoffTime;
|
||||
|
||||
//PS turn off delay
|
||||
MARTe::uint32 turn_off_delay;
|
||||
|
||||
//SDN trigger command arrival time.
|
||||
MARTe::uint32 sdnTriggerTime;
|
||||
//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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* GAMS_JASDNRTSTATEMACHINEGAM_H_ */
|
||||
@@ -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
|
||||
@@ -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=JASDNRTStateMachineGAM.x
|
||||
|
||||
PACKAGE=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/FileSystem/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/JASDNRTStateMachineGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/JASDNRTStateMachineGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
@@ -0,0 +1,177 @@
|
||||
/**
|
||||
* @file JASampleGAM.cpp
|
||||
* @brief Source file for class JASampleGAM
|
||||
* @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 JASampleGAM (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 "JASampleGAM.h"
|
||||
|
||||
#include "AdvancedErrorManagement.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JASampleGAM::JASampleGAM() {
|
||||
// initialize member variables.
|
||||
param1 = 0;
|
||||
param2 = 0;
|
||||
|
||||
//Input signals.
|
||||
input1 = NULL_PTR(MARTe::uint32 *);
|
||||
input2 = NULL_PTR(MARTe::float32 *);
|
||||
//Output signals.
|
||||
output1= NULL_PTR(MARTe::uint32 *);
|
||||
output2 = NULL_PTR(MARTe::float32 *);
|
||||
|
||||
}
|
||||
|
||||
JASampleGAM::~JASampleGAM() {
|
||||
}
|
||||
|
||||
bool JASampleGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
//GAM parameters are initialized.
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::Initialise(data);
|
||||
if (ok) {
|
||||
ok = data.Read("param1", param1);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The param1 shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("param2", param2);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The param2 shall be specified");
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JASampleGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
//This method changes internal parameter based on next realtime state.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JASampleGAM::Setup() {
|
||||
// Setup memory for input/output signals on the GAM.
|
||||
using namespace MARTe;
|
||||
bool ok = (numberOfInputSignals == 2u);
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals == 2u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Two output signals shall be defined");
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Two input signals shall be defined");
|
||||
}
|
||||
// Do type check for input signals.
|
||||
if (ok) {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||
ok = ((inputType == UnsignedInteger32Bit) || (inputType == Float32Bit));
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Signal id can get by signal name in configuration file
|
||||
if (ok) {
|
||||
StreamString signalName = "InputXXX"; //Variable name in configuration file.
|
||||
uint32 signalxxxIndex; //Index is copied to this variable by using signal name.
|
||||
ok = GetSignalIndex(InputSignals, signalxxxIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "InputXXX input signal shall be defined");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, signalxxxIndex);
|
||||
ok = (inputType == Float32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, signalxxxIndex, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
|
||||
} else {
|
||||
inputXXX = reinterpret_cast<float32 *>(GetInputSignalMemory(signalxxxIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do type cast. with explicit signal id.
|
||||
if (ok) {
|
||||
input1 = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||
input2 = reinterpret_cast<float32 *>(GetInputSignalMemory(1));
|
||||
|
||||
output1 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||
output2 = reinterpret_cast<float32 *>(GetOutputSignalMemory(1));
|
||||
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JASampleGAM::Execute() {
|
||||
// This method is called every realtime state thread cycle.
|
||||
using namespace MARTe;
|
||||
REPORT_ERROR(ErrorManagement::Information, "input1 is %d.", *input1);
|
||||
REPORT_ERROR(ErrorManagement::Information, "input2 is %f.", *input2);
|
||||
REPORT_ERROR(ErrorManagement::Information, "inputXXX is %f.", *inputXXX);
|
||||
|
||||
REPORT_ERROR(ErrorManagement::Information, "maltiply param value to input.");
|
||||
|
||||
*output1 = *input1 * param1;
|
||||
*output2 = *input2 * param2;
|
||||
|
||||
REPORT_ERROR(ErrorManagement::Information, "output1 is %d.", *output1);
|
||||
REPORT_ERROR(ErrorManagement::Information, "output2 is %f.", *output2);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JASampleGAM, "1.0")
|
||||
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* @file JASampleGAM.h
|
||||
* @brief Header file for class JASampleGAM
|
||||
* @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 JASampleGAM
|
||||
* 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_JASampleGAM_H_
|
||||
#define GAMS_JASampleGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GAM.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief GAM Sample Usage.
|
||||
* @details Sample
|
||||
*
|
||||
* The configuration syntax is:
|
||||
*
|
||||
* <pre>
|
||||
* +SampleGAM = {
|
||||
* Class = JASampleGAM
|
||||
* InputSignals = {
|
||||
* Input1 = {
|
||||
* DataSource = "DDB"
|
||||
* Type = uint32
|
||||
* Default = 0
|
||||
* }
|
||||
* Input2 = {
|
||||
* DataSource = "DDB"
|
||||
* Type = float32
|
||||
* Default = 100
|
||||
* }
|
||||
* InputXXX = {
|
||||
* DataSource = "DDB"
|
||||
* Type = float32
|
||||
* NumberOfElements = 1
|
||||
* }
|
||||
* }
|
||||
* OutputSignals = {
|
||||
* Output1 = {
|
||||
* DataSource = "DDB"
|
||||
* Type = uint32
|
||||
* Default = 0
|
||||
* }
|
||||
* Output2 = {
|
||||
* DataSource = "DDB"
|
||||
* Type = int32
|
||||
* Default = 100
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
|
||||
class JASampleGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
JASampleGAM();
|
||||
|
||||
virtual ~JASampleGAM();
|
||||
|
||||
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:
|
||||
//GAM fixed parameters.
|
||||
MARTe::uint32 param1;
|
||||
MARTe::float32 param2;
|
||||
|
||||
// Input signals
|
||||
MARTe::uint32 *input1;
|
||||
MARTe::float32 *input2;
|
||||
MARTe::float32 *inputXXX;
|
||||
|
||||
// Output signals
|
||||
MARTe::uint32 *output1;
|
||||
MARTe::float32 *output2;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* GAMS_JASampleGAM_H_ */
|
||||
@@ -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
|
||||
@@ -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=JARTSampleGAM.x
|
||||
|
||||
PACKAGE=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/FileSystem/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/JARTSampleGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/JARTSampleGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
@@ -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")
|
||||
@@ -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_ */
|
||||
@@ -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
|
||||
@@ -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=../../
|
||||
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)
|
||||
@@ -0,0 +1,206 @@
|
||||
/**
|
||||
* @file JATerminalInterfaceGAM.cpp
|
||||
* @brief Source file for class JATerminalInterfaceGAM
|
||||
* @date Feb 19, 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 source file contains the definition of all the methods for
|
||||
* the class JATerminalInterfaceGAM (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 "JATerminalInterfaceGAM.h"
|
||||
|
||||
#include "AdvancedErrorManagement.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JATerminalInterfaceGAM::JATerminalInterfaceGAM() {
|
||||
|
||||
// Fixed GAM input
|
||||
aps_hvon_term = 0;
|
||||
|
||||
// Parameters which get from Input signals.
|
||||
mhvps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
aps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
aps_swon = NULL_PTR(MARTe::uint32 *);
|
||||
bps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||
bps_swon = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
stateMachineOutput = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
// write out target.
|
||||
outputSignalNI6259 = NULL_PTR(MARTe::uint32 *);
|
||||
outputSignalNI6528P3 = NULL_PTR(MARTe::uint8 *);
|
||||
outputSignalNI6528P4 = NULL_PTR(MARTe::uint8 *);
|
||||
|
||||
aps_hvon_state = 0;
|
||||
aps_swon_state = 0;
|
||||
mhvps_hvon_state = 0;
|
||||
bps_hvon_state = 0;
|
||||
bps_swon_state = 0;
|
||||
p3Value = 0;
|
||||
p4Value = 0;
|
||||
}
|
||||
|
||||
JATerminalInterfaceGAM::~JATerminalInterfaceGAM() {
|
||||
}
|
||||
|
||||
bool JATerminalInterfaceGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::Initialise(data);
|
||||
if (ok) {
|
||||
ok = data.Read("mhvps_hvon_term", mhvps_hvon_term);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon_term shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("aps_hvon_term", aps_hvon_term);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon_term shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("aps_swon_term", aps_swon_term);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon_term shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("bps_hvon_term", bps_hvon_term);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon_term shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("bps_swon_term", bps_swon_term);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon_term shall be specified");
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JATerminalInterfaceGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JATerminalInterfaceGAM::Setup() {
|
||||
using namespace MARTe;
|
||||
bool ok = (numberOfInputSignals == 9u);
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals == 3u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Three output signals shall be defined");
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
|
||||
}
|
||||
if (ok) {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||
ok = (inputType == UnsignedInteger32Bit || inputType == UnsignedInteger8Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or uint8", signalName.Buffer());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||
ok = (outputType == UnsignedInteger32Bit || outputType == UnsignedInteger8Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or uint8", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
//mhvps_manm = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||
mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||
//aps_manm = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||
aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
|
||||
aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||
//bps_manm = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||
bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
|
||||
bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
|
||||
short_pulse_mode = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||
stateMachineOutput = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
|
||||
ni6528p3Value = reinterpret_cast<uint8 *>(GetInputSignalMemory(7));
|
||||
ni6528p4Value = reinterpret_cast<uint8 *>(GetInputSignalMemory(8));
|
||||
|
||||
outputSignalNI6259 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||
outputSignalNI6528P3 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(1));
|
||||
outputSignalNI6528P4 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(2));
|
||||
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JATerminalInterfaceGAM::Execute() {
|
||||
using namespace MARTe;
|
||||
uint8 sm = *stateMachineOutput;
|
||||
|
||||
|
||||
//Update HVPS state
|
||||
aps_hvon_state = ((sm >> (0))&1);
|
||||
aps_swon_state = ((sm >> (4))&1);
|
||||
mhvps_hvon_state = ((sm >> (2))&1);
|
||||
bps_hvon_state = ((sm >> (1))&1);
|
||||
bps_swon_state = ((sm >> (3))&1);
|
||||
|
||||
if(*short_pulse_mode == 1){
|
||||
p3Value = 1*aps_hvon_state + 8*bps_hvon_state +16*bps_swon_state;
|
||||
*outputSignalNI6259 = 1*aps_swon_state;
|
||||
//uint8 ni6528p3ValueTemp = 0;//*ni6528p3Value;
|
||||
//ni6528p3ValueTemp &= ~(1<<2); //Does not turn on ni6258 aps switch
|
||||
//Update terminal value
|
||||
//*outputSignalNI6528P3 = ~(ni6528p3ValueTemp | p3Value);
|
||||
*outputSignalNI6528P3 = ~p3Value;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "short pulse mode with p3: %d.", p3Value);
|
||||
} else {
|
||||
p3Value = 1*aps_hvon_state +2*aps_swon_state + 8*bps_hvon_state +16*bps_swon_state;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "long pulse mode with p3: %d.", p3Value);
|
||||
}
|
||||
|
||||
p4Value = 8*mhvps_hvon_state;
|
||||
*outputSignalNI6528P4 = ~(*ni6528p4Value | p4Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JATerminalInterfaceGAM, "1.0")
|
||||
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* @file JATerminalInterfaceGAM.h
|
||||
* @brief Header file for class JATerminalInterfaceGAM
|
||||
* @date Feb 19, 2020
|
||||
* @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 JATerminalInterfaceGAM
|
||||
* 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_JATerminalInterfaceGAM_H_
|
||||
#define GAMS_JATerminalInterfaceGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GAM.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief GAM calculates one output value by comparing input value and fixed parameters.
|
||||
*
|
||||
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||
* <pre>
|
||||
*
|
||||
* +terminalInterfaceGAM = {
|
||||
* Class = JATerminalInterfaceGAM
|
||||
* mhvps_hvon_term = 4
|
||||
* aps_hvon_term = 1
|
||||
* aps_swon_term = 16
|
||||
* bps_hvon_term = 2
|
||||
* bps_swon_term = 8
|
||||
* InputSignals = {
|
||||
* MHVPS_HVON = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* APS_HVON = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* APS_SWON = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* BPS_HVON = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* BPS_SWON = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* Value = {
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* }
|
||||
* OutputSignals = {
|
||||
* Value = {
|
||||
* DataSource = NI6259
|
||||
* Type = uint32
|
||||
* Trigger = 1
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
||||
class JATerminalInterfaceGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
JATerminalInterfaceGAM();
|
||||
|
||||
virtual ~JATerminalInterfaceGAM();
|
||||
|
||||
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:
|
||||
// Fixed GAM input
|
||||
MARTe::uint32 mhvps_hvon_term;
|
||||
MARTe::uint32 aps_hvon_term;
|
||||
MARTe::uint32 aps_swon_term;
|
||||
MARTe::uint32 bps_hvon_term;
|
||||
MARTe::uint32 bps_swon_term;
|
||||
|
||||
// Input signals
|
||||
//MARTe::uint32 *mhvps_manm;
|
||||
MARTe::uint32 *mhvps_hvon;
|
||||
|
||||
//MARTe::uint32 *aps_manm;
|
||||
MARTe::uint32 *aps_hvon;
|
||||
MARTe::uint32 *aps_swon;
|
||||
|
||||
//MARTe::uint32 *bps_manm;
|
||||
MARTe::uint32 *bps_hvon;
|
||||
MARTe::uint32 *bps_swon;
|
||||
|
||||
MARTe::uint32 *short_pulse_mode;
|
||||
|
||||
MARTe::uint32 *stateMachineOutput;
|
||||
MARTe::uint8 *ni6528p3Value;
|
||||
MARTe::uint8 *ni6528p4Value;
|
||||
|
||||
// Output signals
|
||||
MARTe::uint32 *outputSignalNI6259;
|
||||
MARTe::uint8 *outputSignalNI6528P3;
|
||||
MARTe::uint8 *outputSignalNI6528P4;
|
||||
|
||||
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;
|
||||
MARTe::uint8 p3Value;
|
||||
MARTe::uint8 p4Value;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* GAMS_JATerminalInterfaceGAM_H_ */
|
||||
@@ -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
|
||||
@@ -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=JATerminalInterfaceGAM.x
|
||||
|
||||
PACKAGE=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/FileSystem/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/JATerminalInterfaceGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/JATerminalInterfaceGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
@@ -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")
|
||||
@@ -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_ */
|
||||
@@ -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
|
||||
@@ -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=../../
|
||||
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)
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
/**
|
||||
* @file JAWFRecordGAM.cpp
|
||||
* @brief Source file for class JAWFRecordGAM
|
||||
* @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 JAWFRecordGAM (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 "JAWFRecordGAM.h"
|
||||
|
||||
#include "AdvancedErrorManagement.h"
|
||||
#include "CLASSMETHODREGISTER.h"
|
||||
#include "File.h"
|
||||
#include "MessageI.h"
|
||||
#include "RegisteredMethodsMessageFilter.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
// How often output signals are updated.
|
||||
const MARTe::uint32 cycleMs = 10u;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JAWFRecordGAM::JAWFRecordGAM() :
|
||||
GAM() {
|
||||
filenameSignalIndex = 0u;
|
||||
timeSignal = NULL_PTR(MARTe::int32 *);
|
||||
loadTriggerSignal = NULL_PTR(MARTe::uint32 *);
|
||||
valueSignals = NULL_PTR(MARTe::float32 **);
|
||||
maxElements = 0u;
|
||||
readOnce = true;
|
||||
}
|
||||
|
||||
JAWFRecordGAM::~JAWFRecordGAM() {
|
||||
if (valueSignals != NULL_PTR(MARTe::float32 **)) {
|
||||
delete[] valueSignals;
|
||||
}
|
||||
}
|
||||
|
||||
bool JAWFRecordGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = GAM::Initialise(data);
|
||||
if (ok) {
|
||||
ok = data.Read("Directory", directory);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Directory shall be specified");
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JAWFRecordGAM::Setup() {
|
||||
using namespace MARTe;
|
||||
bool ok = (numberOfInputSignals == 2u);
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals > 1u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "At least two output signal shall be defined");
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Two input signal with the filename and file load trigger shall be defined");
|
||||
}
|
||||
if (ok) {
|
||||
StreamString signalName = "Filename";
|
||||
ok = GetSignalIndex(InputSignals, filenameSignalIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Filename input signal shall be defined");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, filenameSignalIndex);
|
||||
ok = (inputType == CharString);
|
||||
if (!ok) {
|
||||
ok = (inputType == Character8Bit);
|
||||
}
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, filenameSignalIndex, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as string", signalName.Buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
StreamString signalName = "CSV_LOAD";
|
||||
uint32 loadSignalIndex;
|
||||
ok = GetSignalIndex(InputSignals, loadSignalIndex, signalName.Buffer());
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "CSV_LOAD input signal shall be defined");
|
||||
}
|
||||
else {
|
||||
TypeDescriptor inputType = GetSignalType(InputSignals, loadSignalIndex);
|
||||
ok = (inputType == UnsignedInteger32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, loadSignalIndex, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||
} else {
|
||||
loadTriggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(loadSignalIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
TypeDescriptor timeType = GetSignalType(OutputSignals, 0);
|
||||
|
||||
ok = (timeType == SignedInteger32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, 0, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as int32", signalName.Buffer());
|
||||
}
|
||||
|
||||
uint32 i;
|
||||
for (i = 1u; (i < numberOfOutputSignals) && (ok); i++) {
|
||||
TypeDescriptor outputType = GetSignalType(OutputSignals, i);
|
||||
ok = (outputType == Float32Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(OutputSignals, i, signalName);
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
|
||||
}
|
||||
else {
|
||||
uint32 dimentionsCount;
|
||||
ok = GetSignalNumberOfDimensions(OutputSignals, 0u, dimentionsCount);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Output signals shall have 1 dimension.");
|
||||
}
|
||||
else {
|
||||
uint32 elementsCount;
|
||||
ok = GetSignalNumberOfElements(OutputSignals, 0u, elementsCount);
|
||||
if (maxElements == 0) {
|
||||
maxElements = elementsCount;
|
||||
}
|
||||
else {
|
||||
ok = (maxElements == elementsCount);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Output signals shall have consistent number of elements.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
valueSignals = new float32*[numberOfOutputSignals - 1u];
|
||||
uint32 i;
|
||||
for (i = 1u; i < numberOfOutputSignals; i++) {
|
||||
valueSignals[i - 1] = reinterpret_cast<float32 *>(GetOutputSignalMemory(i));
|
||||
}
|
||||
timeSignal = reinterpret_cast<int32 *>(GetOutputSignalMemory(0));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JAWFRecordGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
if (strcmp(nextStateName, "WaitReady") == 0) {
|
||||
// Reset read once flag when reentering WaitReady state.
|
||||
readOnce = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void JAWFRecordGAM::LoadFile() {
|
||||
using namespace MARTe;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
const char8 * const filenameSignal = reinterpret_cast<const char8 * const >(GetInputSignalMemory(filenameSignalIndex));
|
||||
StreamString filename = directory;
|
||||
filename += DIRECTORY_SEPARATOR;
|
||||
filename += filenameSignal;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "Opening file %s", filename.Buffer());
|
||||
|
||||
File f;
|
||||
ok = f.Open(filename.Buffer(), BasicFile::ACCESS_MODE_R);
|
||||
|
||||
uint32 numberOfPreProgrammedTimeRows = 0u;
|
||||
int32 *preProgrammedTime;
|
||||
float32 **preProgrammedValues;
|
||||
uint32 numberOfPreProgrammedValues = 0u;
|
||||
|
||||
if (ok) {
|
||||
StreamString tokenLine;
|
||||
while (f.GetLine(tokenLine)) {
|
||||
if (tokenLine[0] != '#') {
|
||||
numberOfPreProgrammedTimeRows++;
|
||||
}
|
||||
tokenLine = "";
|
||||
}
|
||||
f.Seek(0);
|
||||
uint32 t = 0u;
|
||||
tokenLine = "";
|
||||
while ((ok) && (f.GetLine(tokenLine))) {
|
||||
if (tokenLine[0] == '#') {
|
||||
tokenLine = "";
|
||||
continue;
|
||||
}
|
||||
if (numberOfPreProgrammedValues == 0) {
|
||||
StreamString token;
|
||||
char8 ignored;
|
||||
tokenLine.Seek(0);
|
||||
while (tokenLine.GetToken(token, ",", ignored)) {
|
||||
numberOfPreProgrammedValues++;
|
||||
token = "";
|
||||
}
|
||||
ok = numberOfPreProgrammedValues == numberOfOutputSignals;
|
||||
// Remove time from pre-programmed values count.
|
||||
numberOfPreProgrammedValues -= 1u;
|
||||
if (ok) {
|
||||
preProgrammedTime = new int32[maxElements];
|
||||
memset(preProgrammedTime, 0, maxElements * sizeof(int32));
|
||||
preProgrammedValues = new float32*[numberOfPreProgrammedValues];
|
||||
uint32 j;
|
||||
for (j = 0u; j < numberOfPreProgrammedValues; j++) {
|
||||
preProgrammedValues[j] = new float32[maxElements];
|
||||
memset(preProgrammedValues[j], 0, maxElements * sizeof(float32));
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Number of columns in csv file (%d) is not consistent with the number of output signals (%d)", numberOfPreProgrammedValues,
|
||||
numberOfOutputSignals - 1u);
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
StreamString token;
|
||||
char8 ignored;
|
||||
tokenLine.Seek(0);
|
||||
uint32 idx = 0u;
|
||||
while (tokenLine.GetToken(token, ",", ignored)) {
|
||||
if (idx == 0u) {
|
||||
preProgrammedTime[t] = atoi(token.Buffer());
|
||||
}
|
||||
else {
|
||||
ok = ((idx - 1) < numberOfPreProgrammedValues);
|
||||
if (ok) {
|
||||
preProgrammedValues[idx - 1][t] = static_cast<float32>(atof(token.Buffer()));
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(ErrorManagement::FatalError, "Number of columns in csv file is not consistent with the number of output signals in line %d", t);
|
||||
}
|
||||
}
|
||||
token = "";
|
||||
idx++;
|
||||
}
|
||||
t++;
|
||||
}
|
||||
tokenLine = "";
|
||||
}
|
||||
f.Close();
|
||||
} else {
|
||||
REPORT_ERROR(ErrorManagement::Debug, "Cannot open the file %s", filename.Buffer());
|
||||
return;
|
||||
}
|
||||
if (numberOfPreProgrammedTimeRows > maxElements) {
|
||||
REPORT_ERROR(ErrorManagement::Warning, "Only %d (out of %d) of pre-programmed values will be written to waveform record.",
|
||||
maxElements, numberOfPreProgrammedTimeRows);
|
||||
}
|
||||
ok = MemoryOperationsHelper::Copy(timeSignal, preProgrammedTime, maxElements * sizeof(int32));
|
||||
uint32 i;
|
||||
for (i = 0u; (i < numberOfPreProgrammedValues) && (ok); ++i) {
|
||||
ok = MemoryOperationsHelper::Copy(valueSignals[i], preProgrammedValues[i], maxElements * sizeof(float32));
|
||||
}
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::Warning, "Failed to write data to waveform record.");
|
||||
}
|
||||
|
||||
if (preProgrammedValues != NULL_PTR(float32 **)) {
|
||||
uint32 i;
|
||||
for (i = 0u; i < numberOfPreProgrammedValues; i++) {
|
||||
delete preProgrammedValues[i];
|
||||
}
|
||||
delete[] preProgrammedValues;
|
||||
}
|
||||
if (preProgrammedTime != NULL_PTR(int32 *)) {
|
||||
delete[] preProgrammedTime;
|
||||
}
|
||||
}
|
||||
|
||||
bool JAWFRecordGAM::Execute() {
|
||||
if (*loadTriggerSignal == 1u) {
|
||||
if (readOnce) {
|
||||
LoadFile();
|
||||
readOnce = false;
|
||||
}
|
||||
} else {
|
||||
// Reset read once flag when loadTriggerSignal is reset.
|
||||
readOnce = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JAWFRecordGAM, "1.0")
|
||||
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
* @file JAWFRecordGAM.h
|
||||
* @brief Header file for class JAWFRecordGAM
|
||||
* @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 JAWFRecordGAM
|
||||
* 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_JAWFRECORDGAM_H_
|
||||
#define GAMS_JAWFRECORDGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GAM.h"
|
||||
#include "Message.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief GAM that is used for pre-programmed operation.
|
||||
*
|
||||
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||
* <pre>
|
||||
* +WFRecordGAM = {
|
||||
* Class = JAWFRecordGAM
|
||||
* Directory = "../Configurations"
|
||||
* InputSignals = {
|
||||
* CSV_LOAD = {
|
||||
* DataSource = EPICSCAInput
|
||||
* Type = uint32
|
||||
* }
|
||||
* Filename = {
|
||||
* Alias = CSV_NAME
|
||||
* DataSource = EPICSCAInput
|
||||
* }
|
||||
* }
|
||||
* OutputSignals = {
|
||||
* PREP_TIME_WF = {
|
||||
* DataSource = DDB1
|
||||
* }
|
||||
* * MHVPS_PREP_WF = {
|
||||
* DataSource = DDB1
|
||||
* }
|
||||
* BPS_PREP_WF = {
|
||||
* DataSource = DDB1
|
||||
* }
|
||||
* APS_PREP_WF = {
|
||||
* DataSource = DDB1
|
||||
* }
|
||||
* MCPS_PREP_WF = {
|
||||
* DataSource = DDB1
|
||||
* }
|
||||
* GCPS_PREP_WF = {
|
||||
* DataSource = DDB1
|
||||
* }
|
||||
* FHPS_PREP_WF = {
|
||||
* DataSource = DDB1
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
||||
class JAWFRecordGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
JAWFRecordGAM();
|
||||
|
||||
virtual ~JAWFRecordGAM();
|
||||
|
||||
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:
|
||||
void LoadFile();
|
||||
|
||||
MARTe::uint32 filenameSignalIndex;
|
||||
|
||||
MARTe::uint32 *loadTriggerSignal;
|
||||
|
||||
MARTe::StreamString directory;
|
||||
|
||||
MARTe::float32 **valueSignals;
|
||||
|
||||
MARTe::int32 *timeSignal;
|
||||
|
||||
MARTe::uint32 maxElements;
|
||||
|
||||
// Flag determining whether file should be read (so it isn't read multiple time)
|
||||
bool readOnce;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* GAMS_JAWFRECORDGAM_H_ */
|
||||
@@ -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
|
||||
@@ -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=JAWFRecordGAM.x
|
||||
|
||||
PACKAGE=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/FileSystem/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/JAWFRecordGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/JAWFRecordGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#############################################################
|
||||
#
|
||||
# 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
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#############################################################
|
||||
#
|
||||
# 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 $
|
||||
#
|
||||
#############################################################
|
||||
|
||||
SPB = JAMessageGAM.x JAPreProgrammedGAM.x JAModeControlGAM.x \
|
||||
JAWFRecordGAM.x JATriangleWaveGAM.x JARampupGAM.x \
|
||||
JARTStateMachineGAM.x JASDNRTStateMachineGAM.x JATerminalInterfaceGAM.x \
|
||||
JABitSumGAM.x JAConditionalSignalUpdateGAM.x JASourceChoiseGAM.x JABitReverseGAM.x
|
||||
|
||||
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
||||
|
||||
ROOT_DIR=..
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) check-env
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
|
||||
check-env:
|
||||
ifndef MARTe2_DIR
|
||||
$(error MARTe2_DIR is undefined)
|
||||
endif
|
||||
Reference in New Issue
Block a user