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)
|
||||
@@ -120,7 +120,7 @@ bool JAModeControlGAM::Execute() {
|
||||
rfonTime = *inputSignals[9];
|
||||
resetRemainingTime = false;
|
||||
pulseLengthLimit = CalcPulseLengthLimit(inputSignals);
|
||||
REPORT_ERROR(ErrorManagement::Debug, "Pulse Length was set to Limit:%d", pulseLengthLimit);
|
||||
//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)) {
|
||||
|
||||
@@ -36,7 +36,10 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static MARTe::uint64 getCurrentTimeUs() {
|
||||
using namespace MARTe;
|
||||
return static_cast<uint64>(HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1e6f + 0.5f);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@@ -64,7 +67,9 @@ JASDNRTStateMachineGAM::JASDNRTStateMachineGAM() {
|
||||
triggerDelay_shotlen = NULL_PTR(MARTe::uint32 *);
|
||||
stopRequest = NULL_PTR(MARTe::uint32 *);
|
||||
modePulseLengthLimit = NULL_PTR(MARTe::uint32 *);
|
||||
sdnCommand = NULL_PTR(MARTe::uint16 *);
|
||||
Command = NULL_PTR(MARTe::uint16 *);
|
||||
Command2 = NULL_PTR(MARTe::uint16 *);
|
||||
sdnStatus = NULL_PTR(MARTe::uint8 *);
|
||||
|
||||
// write out target.
|
||||
outputSignal = NULL_PTR(MARTe::uint32 *);
|
||||
@@ -81,6 +86,17 @@ JASDNRTStateMachineGAM::JASDNRTStateMachineGAM() {
|
||||
aps_swon_is_on = false;
|
||||
bps_hvon_is_on = false;
|
||||
bps_swon_is_on = false;
|
||||
|
||||
sdnCommand = 0;
|
||||
groupFix = 0;
|
||||
|
||||
apsSwonHighResolutionTime = 0;
|
||||
|
||||
aps_hvon_state=0;
|
||||
aps_swon_state=0;
|
||||
mhvps_hvon_state=0;
|
||||
bps_hvon_state=0;
|
||||
bps_swon_state=0;
|
||||
}
|
||||
|
||||
JASDNRTStateMachineGAM::~JASDNRTStateMachineGAM() {
|
||||
@@ -135,21 +151,21 @@ bool JASDNRTStateMachineGAM::PrepareNextState(const MARTe::char8 * const current
|
||||
|
||||
bool JASDNRTStateMachineGAM::Setup() {
|
||||
using namespace MARTe;
|
||||
bool ok = (numberOfInputSignals == 11u);
|
||||
bool ok = (numberOfInputSignals == 13u);
|
||||
if (ok) {
|
||||
ok = (numberOfOutputSignals == 8u);
|
||||
ok = (numberOfOutputSignals == 15u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Seven output signals shall be defined");
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "15 output signals shall be defined");
|
||||
}
|
||||
}
|
||||
else {
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
|
||||
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "13 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);
|
||||
ok = (inputType == UnsignedInteger32Bit || inputType == UnsignedInteger16Bit || inputType == UnsignedInteger8Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
@@ -162,7 +178,7 @@ bool JASDNRTStateMachineGAM::Setup() {
|
||||
uint32 c;
|
||||
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||
ok = (outputType == UnsignedInteger32Bit);
|
||||
ok = (outputType == UnsignedInteger32Bit || outputType == UnsignedInteger8Bit);
|
||||
if (!ok) {
|
||||
StreamString signalName;
|
||||
(void) GetSignalName(InputSignals, c, signalName);
|
||||
@@ -181,7 +197,9 @@ bool JASDNRTStateMachineGAM::Setup() {
|
||||
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));
|
||||
Command = reinterpret_cast<uint16 *>(GetInputSignalMemory(10));
|
||||
Command2 = reinterpret_cast<uint16 *>(GetInputSignalMemory(11));
|
||||
sdnStatus = reinterpret_cast<uint8 *>(GetInputSignalMemory(12));
|
||||
|
||||
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||
outputBeamON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
|
||||
@@ -191,6 +209,15 @@ bool JASDNRTStateMachineGAM::Setup() {
|
||||
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));
|
||||
|
||||
outputSignalNI6528P3 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(13));
|
||||
outputSignalNI6528P4 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(14));
|
||||
*shotCounter = 0;
|
||||
}
|
||||
return ok;
|
||||
@@ -198,11 +225,19 @@ bool JASDNRTStateMachineGAM::Setup() {
|
||||
|
||||
bool JASDNRTStateMachineGAM::Execute() {
|
||||
using namespace MARTe;
|
||||
if (!groupFix && (*triggerSignal != false)) {
|
||||
sdnCommand = (1 - *sdnStatus)*(*Command) + (*sdnStatus)*(*Command2);
|
||||
groupFix = 1;
|
||||
sdnStatusFix = *sdnStatus;
|
||||
}
|
||||
else {
|
||||
sdnCommand = (1 - sdnStatusFix)*(*Command) + sdnStatusFix*(*Command2);
|
||||
}
|
||||
if (currentState == WaitTrigger) {
|
||||
|
||||
//State Transition condition
|
||||
if ((*triggerSignal == conditionTrigger)) {
|
||||
REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence in SDN mode.");
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence in SDN mode.");
|
||||
plcOnTime = *currentTime; //Save pulse start time.
|
||||
*outputBeamON = 0;
|
||||
//State transition.
|
||||
@@ -213,20 +248,22 @@ bool JASDNRTStateMachineGAM::Execute() {
|
||||
|
||||
//Actions in this state.
|
||||
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||
*outputSignal -= aps_swon;
|
||||
*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;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "bps_hvon was set to outputSignal at %d.", *currentTime);
|
||||
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;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal.");
|
||||
aps_hvon_is_on = true; aps_hvon_state=1;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal.");
|
||||
*outputAPSHVON=1;
|
||||
}
|
||||
|
||||
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||
@@ -242,7 +279,7 @@ bool JASDNRTStateMachineGAM::Execute() {
|
||||
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||
|
||||
// State change conditions
|
||||
if (*sdnCommand == 1){
|
||||
if (sdnCommand == 1){
|
||||
sdnTriggerTime = *currentTime;
|
||||
currentState = SwitchingHVPS_SWON;
|
||||
}
|
||||
@@ -262,68 +299,80 @@ bool JASDNRTStateMachineGAM::Execute() {
|
||||
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);
|
||||
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 >= (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);
|
||||
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 >= (sdnTriggerTime + *triggerDelay_aps_swon)){
|
||||
//Do action
|
||||
*outputSignal += aps_swon;
|
||||
aps_swon_is_on = true;
|
||||
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);
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "aps_swon was set to outputSignal at %d.", *currentTime);
|
||||
*outputAPSSWON=1;
|
||||
}
|
||||
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||
|
||||
if (bps_swon_is_on || mhvps_hvon_is_on){
|
||||
*outputHVInjection = 0;
|
||||
*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");
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to RFON");
|
||||
}
|
||||
}
|
||||
else if (currentState == RFON) {
|
||||
|
||||
//SDN command processing.
|
||||
if (*sdnCommand == 4 && aps_swon_is_on) {
|
||||
if (sdnCommand == 4 && aps_swon_is_on) {
|
||||
*outputSignal -= aps_swon;
|
||||
aps_swon_is_on = false;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "sdn command was 4");
|
||||
aps_swon_is_on = false; aps_swon_state=0;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "sdn command was 4");
|
||||
*outputAPSSWON=0;
|
||||
}
|
||||
if (*sdnCommand == 3 && !aps_swon_is_on) {
|
||||
if (sdnCommand == 3 && !aps_swon_is_on) {
|
||||
*outputSignal += aps_swon;
|
||||
aps_swon_is_on = true;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "sdn command was 3");
|
||||
aps_swon_is_on = true; aps_swon_state=0;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "sdn command was 3");
|
||||
*outputAPSSWON=1;
|
||||
}
|
||||
|
||||
//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");
|
||||
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.");
|
||||
//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;
|
||||
aps_swon_is_on = false; aps_swon_state=0;
|
||||
bps_hvon_is_on = false;
|
||||
bps_swon_is_on = false;
|
||||
REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
|
||||
*outputAPSHVON=0;
|
||||
*outputAPSSWON=0;
|
||||
*outputBPSHVON=0;
|
||||
*outputBPSSWON=0;
|
||||
*outputMHVPSON=0;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
|
||||
}
|
||||
*outputRFON = 0;
|
||||
*outputRFON = 1;
|
||||
*outputBeamONTime = *currentTime - plcOnTime;
|
||||
*outputRFONTime = *currentTime - apsSwonTime;
|
||||
|
||||
@@ -332,29 +381,37 @@ bool JASDNRTStateMachineGAM::Execute() {
|
||||
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");
|
||||
//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;
|
||||
*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, "state was changed to WaitTrigger");
|
||||
groupFix = 0;
|
||||
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to WaitTrigger");
|
||||
}
|
||||
}
|
||||
|
||||
p3Value = 1*aps_hvon_state +2*aps_swon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
|
||||
*outputSignalNI6528P3 = ~p3Value;
|
||||
p4Value = 8*mhvps_hvon_state;
|
||||
*outputSignalNI6528P4 = ~p4Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,10 +92,18 @@
|
||||
* DataSource = DDB1
|
||||
* Type = uint32
|
||||
* }
|
||||
* Command = {
|
||||
* Command = {//from packet x
|
||||
* DataSource = RealTimeThreadAsyncBridge
|
||||
* Type = uint16
|
||||
* }
|
||||
* Command2 = {//from packet y
|
||||
* DataSource = RealTimeThreadAsyncBridge
|
||||
* Type = uint16
|
||||
* }
|
||||
* ESDNStatus = {// 0 or 1. If 0, packet x is used, elif 1, packet y is used.
|
||||
* DataSource = RealTimeThreadAsyncBridge
|
||||
* Type = uint8
|
||||
* }
|
||||
* }
|
||||
* OutputSignals = {
|
||||
* Value = {
|
||||
@@ -199,8 +207,12 @@ private:
|
||||
MARTe::uint32 *stopRequest;
|
||||
// Input signal for pulse length limit by mode.
|
||||
MARTe::uint32 *modePulseLengthLimit;
|
||||
// Input signal for SDN commands.
|
||||
MARTe::uint16 *sdnCommand;
|
||||
// Input signal for SDN commands from packet x.
|
||||
MARTe::uint16 *Command;
|
||||
// Input signal for SDN commands from packet y.
|
||||
MARTe::uint16 *Command2;
|
||||
// Input signal for SDN status.
|
||||
MARTe::uint8 *sdnStatus;
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Output signal to which the output value will be written.
|
||||
@@ -217,6 +229,17 @@ private:
|
||||
MARTe::uint32 *outputRFONTime;
|
||||
// shot counter (coutup every RFON time.)
|
||||
MARTe::uint32 *shotCounter;
|
||||
|
||||
// Added for HVPS state (20210602)
|
||||
MARTe::uint32 *outputAPSHVON;
|
||||
MARTe::uint32 *outputAPSSWON;
|
||||
MARTe::uint32 *outputBPSHVON;
|
||||
MARTe::uint32 *outputBPSSWON;
|
||||
MARTe::uint32 *outputMHVPSON;
|
||||
|
||||
// Output signals for NI devices
|
||||
MARTe::uint8 *outputSignalNI6528P3;
|
||||
MARTe::uint8 *outputSignalNI6528P4;
|
||||
|
||||
//////////////////////////////
|
||||
//Internal Parameters
|
||||
@@ -226,6 +249,7 @@ private:
|
||||
//APS_SWON time holder
|
||||
MARTe::uint32 apsSwonTime;
|
||||
MARTe::uint32 apsSwoffTime;
|
||||
MARTe::uint64 apsSwonHighResolutionTime;
|
||||
|
||||
//PS turn off delay
|
||||
MARTe::uint32 turn_off_delay;
|
||||
@@ -239,6 +263,22 @@ private:
|
||||
bool bps_hvon_is_on;
|
||||
bool bps_swon_is_on;
|
||||
|
||||
//command x or y
|
||||
MARTe::uint16 sdnCommand;
|
||||
//packet group must not be changed during real time operation
|
||||
MARTe::uint16 groupFix; //0: packet group is not fixed yet, 1: fixed.
|
||||
//when packet group is fixed, sdnStatus is copied to this variable.
|
||||
MARTe::uint8 sdnStatusFix;
|
||||
|
||||
// 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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
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
|
||||
JABitSumGAM.x JAConditionalSignalUpdateGAM.x JASourceChoiseGAM.x JABitReverseGAM.x \
|
||||
JAESDNTimeCompareGAM.x
|
||||
|
||||
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
||||
|
||||
|
||||
Reference in New Issue
Block a user