(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")
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JARTStateMachineGAM/JARTStateMachineGAM-v1.h b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JARTStateMachineGAM/JARTStateMachineGAM-v1.h
deleted file mode 100644
index e968f39..0000000
--- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JARTStateMachineGAM/JARTStateMachineGAM-v1.h
+++ /dev/null
@@ -1,262 +0,0 @@
-/**
- * @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):
- *
- * +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
- * }
- * }
- * }
- *
- *
- *
- */
-
-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_ */
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JARTStateMachineGAM/JARTStateMachineGAM_stable.cpp b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JARTStateMachineGAM/JARTStateMachineGAM_stable.cpp
deleted file mode 100644
index 71c7669..0000000
--- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JARTStateMachineGAM/JARTStateMachineGAM_stable.cpp
+++ /dev/null
@@ -1,402 +0,0 @@
-/**
- * @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(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(GetInputSignalMemory(0));
- triggerSignal = reinterpret_cast(GetInputSignalMemory(1));
- triggerDelay_mhvps_hvon = reinterpret_cast(GetInputSignalMemory(2));
- triggerDelay_aps_hvon = reinterpret_cast(GetInputSignalMemory(3));
- triggerDelay_aps_swon = reinterpret_cast(GetInputSignalMemory(4));
- triggerDelay_bps_hvon = reinterpret_cast(GetInputSignalMemory(5));
- triggerDelay_bps_swon = reinterpret_cast(GetInputSignalMemory(6));
- triggerDelay_shotlen = reinterpret_cast(GetInputSignalMemory(7));
- stopRequest = reinterpret_cast(GetInputSignalMemory(8));
- modePulseLengthLimit = reinterpret_cast(GetInputSignalMemory(9));
- short_pulse_mode = reinterpret_cast(GetInputSignalMemory(10));
-
-
- outputSignal = reinterpret_cast(GetOutputSignalMemory(0));
- outputBeamON = reinterpret_cast(GetOutputSignalMemory(1));
- outputHVArmed = reinterpret_cast(GetOutputSignalMemory(2));
- outputHVInjection = reinterpret_cast(GetOutputSignalMemory(3));
- outputRFON = reinterpret_cast(GetOutputSignalMemory(4));
- outputBeamONTime = reinterpret_cast(GetOutputSignalMemory(5));
- outputRFONTime = reinterpret_cast(GetOutputSignalMemory(6));
- shotCounter = reinterpret_cast(GetOutputSignalMemory(7));
-
- outputAPSHVON = reinterpret_cast(GetOutputSignalMemory(8));
- outputAPSSWON = reinterpret_cast(GetOutputSignalMemory(9));
- outputBPSHVON = reinterpret_cast(GetOutputSignalMemory(10));
- outputBPSSWON = reinterpret_cast(GetOutputSignalMemory(11));
- outputMHVPSON = reinterpret_cast(GetOutputSignalMemory(12));
-
- outputSignalNI6259 = reinterpret_cast(GetOutputSignalMemory(13));
- outputSignalNI6528P3 = reinterpret_cast(GetOutputSignalMemory(14));
- outputSignalNI6528P4 = reinterpret_cast(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")
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JARTStateMachineGAM/JARTStateMachineGAM_stable.h b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JARTStateMachineGAM/JARTStateMachineGAM_stable.h
deleted file mode 100644
index e59f3fa..0000000
--- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JARTStateMachineGAM/JARTStateMachineGAM_stable.h
+++ /dev/null
@@ -1,260 +0,0 @@
-/**
- * @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):
- *
- * +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
- * }
- * }
- * }
- *
- *
- *
- */
-
-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_ */
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JASDNRTStateMachineGAM/JASDNRTStateMachineGAM.cpp b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JASDNRTStateMachineGAM/JASDNRTStateMachineGAM.cpp
index d164e89..7e0fca5 100644
--- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JASDNRTStateMachineGAM/JASDNRTStateMachineGAM.cpp
+++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JASDNRTStateMachineGAM/JASDNRTStateMachineGAM.cpp
@@ -36,7 +36,10 @@
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
-
+static MARTe::uint64 getCurrentTimeUs() {
+ using namespace MARTe;
+ return static_cast(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(GetInputSignalMemory(7));
stopRequest = reinterpret_cast(GetInputSignalMemory(8));
modePulseLengthLimit = reinterpret_cast(GetInputSignalMemory(9));
- sdnCommand = reinterpret_cast(GetInputSignalMemory(10));
+ Command = reinterpret_cast(GetInputSignalMemory(10));
+ Command2 = reinterpret_cast(GetInputSignalMemory(11));
+ sdnStatus = reinterpret_cast(GetInputSignalMemory(12));
outputSignal = reinterpret_cast(GetOutputSignalMemory(0));
outputBeamON = reinterpret_cast(GetOutputSignalMemory(1));
@@ -191,6 +209,15 @@ bool JASDNRTStateMachineGAM::Setup() {
outputBeamONTime = reinterpret_cast(GetOutputSignalMemory(5));
outputRFONTime = reinterpret_cast(GetOutputSignalMemory(6));
shotCounter = reinterpret_cast(GetOutputSignalMemory(7));
+
+ outputAPSHVON = reinterpret_cast(GetOutputSignalMemory(8));
+ outputAPSSWON = reinterpret_cast(GetOutputSignalMemory(9));
+ outputBPSHVON = reinterpret_cast(GetOutputSignalMemory(10));
+ outputBPSSWON = reinterpret_cast(GetOutputSignalMemory(11));
+ outputMHVPSON = reinterpret_cast(GetOutputSignalMemory(12));
+
+ outputSignalNI6528P3 = reinterpret_cast(GetOutputSignalMemory(13));
+ outputSignalNI6528P4 = reinterpret_cast(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;
}
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JASDNRTStateMachineGAM/JASDNRTStateMachineGAM.h b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JASDNRTStateMachineGAM/JASDNRTStateMachineGAM.h
index 91b4199..69f0eee 100644
--- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JASDNRTStateMachineGAM/JASDNRTStateMachineGAM.h
+++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/JASDNRTStateMachineGAM/JASDNRTStateMachineGAM.h
@@ -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;
+
};
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/Makefile.inc b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/Makefile.inc
index 9dfc5c1..bcf3450 100644
--- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/Makefile.inc
+++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/GAMs/Makefile.inc
@@ -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
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/Main.sh b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/Main.sh
old mode 100644
new mode 100755
index b425a77..4070fe0
--- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/Main.sh
+++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/Main.sh
@@ -123,6 +123,7 @@ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../Build/x86-linux/GAMs/JATerminalInterfaceGAM/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../Build/x86-linux/GAMs/JABitSumGAM/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../Build/x86-linux/GAMs/JASourceChoiseGAM/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../Build/x86-linux/GAMs/JABitReverseGAM/
+LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../Build/x86-linux/GAMs/JAESDNTimeCompareGAM/
### Add EPICS lib path
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$EPICS_BASE/lib/$EPICS_HOST_ARCH
#LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../Build/x86-linux/GAMs/FilterDownsamplingGAM/
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runECPCSub.sh b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runECPCSub.sh
old mode 100644
new mode 100755
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runEPICSTEST.sh b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runEPICSTEST.sh
old mode 100644
new mode 100755
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runHWTEST.sh b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runHWTEST.sh
old mode 100644
new mode 100755
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runMain.sh b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runMain.sh
old mode 100644
new mode 100755
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runMainB.sh b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runMainB.sh
old mode 100644
new mode 100755
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runNI6528TEST.sh b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runNI6528TEST.sh
old mode 100644
new mode 100755
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runTest.sh b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runTest.sh
new file mode 100755
index 0000000..f56837a
--- /dev/null
+++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Startup/runTest.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+taskset -c 8-11 ./Main.sh -f ../Configurations/JAGyro_Test.cfg -l RealTimeLoader -m StateMachine:Start
+
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test.py b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test.py
index 82a2603..d4b76bb 100644
--- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test.py
+++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test.py
@@ -60,6 +60,7 @@ while(1):
8: SYNC mode operation
9: GYA / Async mode --- operator set delay and pulse length on HMI
10: GYB / Async mode --- operator set delay and pulse length on HMI
+ 11: GYA / Async mode several times --- operator set delay and pulse length on HMI
'''
inpval = raw_input()
@@ -83,8 +84,10 @@ while(1):
test_async.test_async_GYA_manual()
elif inpval == "10":
test_async.test_async_GYB_manual()
+ elif inpval == "11":
+ test_async.test_async_GYA_times()
else:
- print 'invalid value. Enter 1 to 10!'
+ print 'invalid value. Enter 1 to 11!'
continue
print '..... End of test code .....'
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_async.py b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_async.py
index 8f595b2..0a78b0b 100644
--- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_async.py
+++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_async.py
@@ -147,7 +147,7 @@ def test_async_shortpulse():
res = subprocess.call('caput EC-GN-P01-PMF:STAT-DT-HVON 300', shell=True)
res = subprocess.call('caput EC-GN-P01-PB1F:STAT-DT-SWON 400', shell=True)
res = subprocess.call('caput EC-GN-P01-PA1F:STAT-DT-SWON 800', shell=True) #Should be grater than 1ms.
- res = subprocess.call('caput EC-GN-P01-GAF:STAT-DT-SHOTLEN 500', shell=True)
+ res = subprocess.call('caput EC-GN-P01-GAF:STAT-DT-SHOTLEN 100', shell=True)
print '2.Write PERMIT'
res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-CON-GY1PRM.SVAL 1', shell=True)
res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-CON-GY1PRM 1', shell=True)
@@ -412,3 +412,43 @@ def test_async_GYB_manual():
res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-CON-GY2PRM.SVAL 0', shell=True)
res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-CON-GY2PRM 0', shell=True)
print "end of async, non-prepro mode test!"
+
+def test_async_GYA_times():
+ """"
+ Test GYA operation with Async mode several times.
+ """
+ print '1.. Set delays and pulse length on HMI\n and set sleep time here:'
+ inp_val = raw_input()
+ try:
+ sleep_time = float(inp_val)
+ except:
+ return
+ print 'How many times is the pulse generated?'
+ times = raw_input()
+ for i in range(1, int(times) + 1):
+ # turn on permit
+ print '2.. set PulseLengthLimitMode to 1 flag'
+ res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-YTS-MD1.SVAL 1', shell = True)
+ res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-YTS-MD1 1', shell = True)
+ res = subprocess.call('caput EC-GN-P01-GPF:STAT-MD1-LIM 1000000', shell = True)
+ time.sleep(1)
+ print '3. Write PERMIT'
+ res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-CON-GY1PRM.SVAL 1', shell=True)
+ res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-CON-GY1PRM 1', shell=True)
+ time.sleep(1)
+ # trun on HVON trigger
+ print '4. Write HVON'
+ res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-YTS-ST3R.SVAL 1', shell=True)
+ res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-YTS-ST3R 1', shell=True) #HVON signal from PLC
+ time.sleep(sleep_time)
+ print '5. Confirm generated pulse'
+ print '6. Reset HVON'
+ res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-YTS-ST3R.SVAL 0', shell=True)
+ res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-YTS-ST3R 0', shell=True)
+ time.sleep(1)
+ print '7. Reset PERMIT'
+ res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-CON-GY1PRM.SVAL 0', shell=True)
+ res = subprocess.call('caput EC-GN-P01-GPS:PLC4110-CON-GY1PRM 0', shell=True)
+ print '%d times beam-on complete' % i
+ res = subprocess.call('caget EC-GN-P01-GAF:STAT-BEAMON-TIME >> BEAMON-TIME.log', shell=True)
+ print "end of async, non-prepro mode test!"
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_async.pyc b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_async.pyc
index f899918..1b54d6b 100644
Binary files a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_async.pyc and b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_async.pyc differ
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_ready.pyc b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_ready.pyc
index 68b2851..437f144 100644
Binary files a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_ready.pyc and b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_ready.pyc differ
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_ready_hw.pyc b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_ready_hw.pyc
index 05b88d6..5fa3351 100644
Binary files a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_ready_hw.pyc and b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_ready_hw.pyc differ
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_setup.pyc b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_setup.pyc
index e99d4b3..7e74c54 100644
Binary files a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_setup.pyc and b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_setup.pyc differ
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_setup_hw.pyc b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_setup_hw.pyc
index 67d714d..0a43529 100644
Binary files a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_setup_hw.pyc and b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_setup_hw.pyc differ
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_standby.pyc b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_standby.pyc
index bc74300..9861c3b 100644
Binary files a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_standby.pyc and b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_standby.pyc differ
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_standby_hw.pyc b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_standby_hw.pyc
index b19006e..760e656 100644
Binary files a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_standby_hw.pyc and b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_standby_hw.pyc differ
diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_sync.pyc b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_sync.pyc
index 3637b06..a368e79 100644
Binary files a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_sync.pyc and b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Test_P01/test_sync.pyc differ
diff --git a/ec-gn-ja-pcf-sdd-in b/ec-gn-ja-pcf-sdd-in
index 7eb4277..a2882e7 160000
--- a/ec-gn-ja-pcf-sdd-in
+++ b/ec-gn-ja-pcf-sdd-in
@@ -1 +1 @@
-Subproject commit 7eb4277b09e9627436f6333348dbe8bb90b83198
+Subproject commit a2882e7a5c4f80bf14d08c7ca9dec8dd86522efc
diff --git a/generate.sh b/generate.sh
index 61629c6..916be5c 100755
--- a/generate.sh
+++ b/generate.sh
@@ -88,12 +88,15 @@ ok=$(echo ${mask} | cut -c ${cid})
if [[ ${ok} != "0" ]]; then
- cat patches/EC-GN-PCF0CORE_sddPreDriverConf.patch ${project_name}/src/main/epics/iocBoot/iocEC-GN-PCF0CORE/sddPreDriverConf.cmd > sddPreDriverConf_patched.cmd
- mv -f sddPreDriverConf_patched.cmd ${project_name}/src/main/epics/iocBoot/iocEC-GN-PCF0CORE/sddPreDriverConf.cmd
+ cat patches/EC-GN-P01-PCF0CORE_sddPreDriverConf.patch ${project_name}/src/main/epics/iocBoot/iocEC-GN-P01-PCF0CORE/sddPreDriverConf.cmd > sddPreDriverConf_patched.cmd
+ mv -f sddPreDriverConf_patched.cmd ${project_name}/src/main/epics/iocBoot/iocEC-GN-P01-PCF0CORE/sddPreDriverConf.cmd
- cat patches/EC-GN-PCF0CORE_userPreDriverConf.patch ${project_name}/src/main/epics/iocBoot/iocEC-GN-PCF0CORE/userPreDriverConf.cmd > userPreDriverConf_patched.cmd
- mv -f userPreDriverConf_patched.cmd ${project_name}/src/main/epics/iocBoot/iocEC-GN-PCF0CORE/userPreDriverConf.cmd
+ cat patches/EC-GN-P01-PCF0CORE_userPreDriverConf.patch ${project_name}/src/main/epics/iocBoot/iocEC-GN-P01-PCF0CORE/userPreDriverConf.cmd > userPreDriverConf_patched.cmd
+ mv -f userPreDriverConf_patched.cmd ${project_name}/src/main/epics/iocBoot/iocEC-GN-P01-PCF0CORE/userPreDriverConf.cmd
+ sed -i 's+# Add all the support libraries needed by this IOC+# Add all the support libraries needed by this IOC\n-include $(EPICS_ROOT)/mk/asyn.mk\n-include $(EPICS_ROOT)/mk/picmg.mk\n-include $(EPICS_ROOT)/mk/stream.mk\n-include $(EPICS_ROOT)/mk/nisync-epics.mk\n-include $(EPICS_ROOT)/mk/nisync-generalTime.mk\n-include $(EPICS_ROOT)/mk/nixseries-epics.mk\n-include $(EPICS_ROOT)/mk/pxi6259-epics.mk\n-include $(EPICS_ROOT)/mk/pxi6528-epics.mk+g' EC-GN-JA-PCF/src/main/epics/EC-GN-P01App/src/Makefile
+
+ sed -i 's+epicsEnvSet("\(.*\)")+epicsEnvSet("\1:${TOP}/iocBoot/iocEC-GN-P01-PCF0CORE")+g' EC-GN-JA-PCF/src/main/epics/iocBoot/iocEC-GN-P01-PCF0CORE/envSystem
fi
cid=$((cid+1))
diff --git a/patches/EC-GN-PCF0CORE_dbToLoad.patch b/patches/EC-GN-P01-PCF0CORE_dbToLoad.patch
similarity index 100%
rename from patches/EC-GN-PCF0CORE_dbToLoad.patch
rename to patches/EC-GN-P01-PCF0CORE_dbToLoad.patch
diff --git a/patches/EC-GN-PCF0CORE_sddPreDriverConf.patch b/patches/EC-GN-P01-PCF0CORE_sddPreDriverConf.patch
similarity index 98%
rename from patches/EC-GN-PCF0CORE_sddPreDriverConf.patch
rename to patches/EC-GN-P01-PCF0CORE_sddPreDriverConf.patch
index b496ad5..d5d45a7 100644
--- a/patches/EC-GN-PCF0CORE_sddPreDriverConf.patch
+++ b/patches/EC-GN-P01-PCF0CORE_sddPreDriverConf.patch
@@ -60,4 +60,5 @@ pxi6528_init("ni6528_0", "/dev/pxi6528.0")
# pxi6528_reset("ni6528_0")
pxi6528_init("ni6528_1", "/dev/pxi6528.1")
# asynSetTraceMask("ni6528_1",0,255)
-# pxi6528_reset("ni6528_1")
\ No newline at end of file
+# pxi6528_reset("ni6528_1")
+
diff --git a/patches/EC-GN-PCF0CORE_userPreDriverConf.patch b/patches/EC-GN-P01-PCF0CORE_userPreDriverConf.patch
similarity index 97%
rename from patches/EC-GN-PCF0CORE_userPreDriverConf.patch
rename to patches/EC-GN-P01-PCF0CORE_userPreDriverConf.patch
index d88df88..1fe790b 100644
--- a/patches/EC-GN-PCF0CORE_userPreDriverConf.patch
+++ b/patches/EC-GN-P01-PCF0CORE_userPreDriverConf.patch
@@ -61,4 +61,5 @@ drvAsynIPPortConfigure("FHPS2", "192.168.5.7:6000")
drvAsynIPPortConfigure("MC2", "192.168.5.8:6000")
-drvAsynIPPortConfigure("GC2", "192.168.5.9:6000")
\ No newline at end of file
+drvAsynIPPortConfigure("GC2", "192.168.5.9:6000")
+