Tested and working... NI libraries were missin
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* @file JAESDNTimeCompareGAM.cpp
|
||||
* @brief Source file for class JAESDNTimeCompareGAM
|
||||
* @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 JAESDNTimeCompareGAM (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 "JAESDNTimeCompareGAM.h"
|
||||
#include "AdvancedErrorManagement.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
JAESDNTimeCompareGAM::JAESDNTimeCompareGAM() {
|
||||
//ESDNTime holder
|
||||
esdntime_previous = 0;
|
||||
|
||||
//Input signals.
|
||||
esdntime = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
//Output signals.
|
||||
sdn_connection = NULL_PTR(MARTe::uint32 *);
|
||||
|
||||
}
|
||||
|
||||
JAESDNTimeCompareGAM::~JAESDNTimeCompareGAM() {
|
||||
if (esdntime != NULL_PTR(MARTe::uint32 *)) {
|
||||
delete[] esdntime;
|
||||
}
|
||||
if (sdn_connection != NULL_PTR(MARTe::uint32 *)) {
|
||||
delete[] sdn_connection;
|
||||
}
|
||||
}
|
||||
|
||||
bool JAESDNTimeCompareGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
return GAM::Initialise(data);
|
||||
}
|
||||
|
||||
bool JAESDNTimeCompareGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JAESDNTimeCompareGAM::Setup() {
|
||||
// Setup memory for input/output signals on the GAM.
|
||||
using namespace MARTe;
|
||||
bool ok = (numberOfInputSignals == 1u);
|
||||
// Do type check for input signals.
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals == 1u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Number of output signals shall be the same as "
|
||||
"number of expected values.");
|
||||
}
|
||||
} else {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "Number of input signals shall be the same as "
|
||||
"number of expected values.");
|
||||
}
|
||||
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);
|
||||
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) {
|
||||
esdntime = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||
sdn_connection = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool JAESDNTimeCompareGAM::Execute() {
|
||||
using namespace MARTe;
|
||||
bool connected;
|
||||
|
||||
connected = !(esdntime_previous == *esdntime);
|
||||
if (connected) *sdn_connection = 1;
|
||||
else *sdn_connection = 0;
|
||||
|
||||
esdntime_previous = *esdntime;
|
||||
return true;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(JAESDNTimeCompareGAM, "1.0")
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @file JAESDNTimeCompareGAM.h
|
||||
* @brief Header file for class JAESDNTimeCompareGAM
|
||||
* @date Feb, 2021
|
||||
* @author ksakakida
|
||||
*
|
||||
* @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 JAESDNTimeCompareGAM
|
||||
* 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_JAESDNTimeCompareGAM_H_
|
||||
#define GAMS_JAESDNTimeCompareGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GAM.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief GAM that sends a message when one-cycle before ESDNTime and current one are same. This GAM is based on JAMessageGAM.
|
||||
* @details Sample
|
||||
*
|
||||
* The configuration syntax is:
|
||||
*
|
||||
* <pre>
|
||||
* +SDNTimeCompareGAM = {
|
||||
* Class = JAESDNTimeCompareGAM
|
||||
* InputSignals = {
|
||||
* ESDNTime = {
|
||||
* DataSource = "DDB1"
|
||||
* Type = uint32
|
||||
* }
|
||||
* }
|
||||
* OutputSignals = {
|
||||
* SDN_Connection = {
|
||||
* DataSource = "DDB1"
|
||||
* Type = uint32
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
|
||||
class JAESDNTimeCompareGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
JAESDNTimeCompareGAM();
|
||||
|
||||
virtual ~JAESDNTimeCompareGAM();
|
||||
|
||||
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:
|
||||
// ESDNTime holder
|
||||
MARTe::uint32 esdntime_previous;
|
||||
|
||||
// Input signals
|
||||
MARTe::uint32 *esdntime;
|
||||
|
||||
// Output signals
|
||||
MARTe::uint32 *sdn_connection; // 0: disconnected, 1: connected
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* GAMS_JAESDNTimeCompareGAM_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=JAESDNTimeCompareGAM.x
|
||||
|
||||
PACKAGE=GAMs
|
||||
|
||||
ROOT_DIR=../../../../obj
|
||||
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
||||
|
||||
INCLUDES += -I.
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/JAESDNTimeCompareGAM$(LIBEXT) \
|
||||
$(BUILD_DIR)/JAESDNTimeCompareGAM$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
Reference in New Issue
Block a user