From cdd700bf4e6b004329b3e311f000b9af6af77371 Mon Sep 17 00:00:00 2001 From: Martino Ferrari Date: Fri, 6 Feb 2026 18:15:42 +0100 Subject: [PATCH] Fixed types and feedback --- .../main/c++/GAMs/JARampupGAM/JARampupGAM.cpp | 455 +++++++++--------- .../main/c++/GAMs/JARampupGAM/JARampupGAM.h | 4 +- 2 files changed, 235 insertions(+), 224 deletions(-) diff --git a/EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/JARampupGAM.cpp b/EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/JARampupGAM.cpp index 98003a2..0b0eae0 100644 --- a/EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/JARampupGAM.cpp +++ b/EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/JARampupGAM.cpp @@ -41,255 +41,268 @@ /*---------------------------------------------------------------------------*/ JARampupGAM::JARampupGAM() : GAM() { - current_setpoint = NULL_PTR(MARTe::float32 *); - target_value = NULL_PTR(MARTe::float32 *); - rampup_time = NULL_PTR(MARTe::float32 *); - start = NULL_PTR(MARTe::uint32 *); - standby = NULL_PTR(MARTe::uint32 *); - isAuto = NULL_PTR(MARTe::uint32 *); - FHPS_PrePro = NULL_PTR(MARTe::float32 *); + target_value = NULL_PTR(MARTe::float32 *); + rampup_time = NULL_PTR(MARTe::float32 *); + start = NULL_PTR(MARTe::uint32 *); + standby = NULL_PTR(MARTe::uint8 *); + isAuto = NULL_PTR(MARTe::uint32 *); + FHPS_PrePro = NULL_PTR(MARTe::float32 *); - output = NULL_PTR(MARTe::float32 *); - state = NULL_PTR(MARTe::uint32 *); + output = NULL_PTR(MARTe::float32 *); + state = NULL_PTR(MARTe::uint32 *); - rampup_rate = 0.0f; - inRampup = false; - resetFlag = true; - inWaitHVON = false; - inWaitStandby = false; + rampup_rate = 0.0f; + inRampup = false; + resetFlag = true; + inWaitHVON = false; + inWaitStandby = false; } -JARampupGAM::~JARampupGAM() { -} +JARampupGAM::~JARampupGAM() {} -bool JARampupGAM::Initialise(MARTe::StructuredDataI & data) { - using namespace MARTe; - return GAM::Initialise(data); +bool JARampupGAM::Initialise(MARTe::StructuredDataI &data) { + using namespace MARTe; + return GAM::Initialise(data); } bool JARampupGAM::Setup() { - using namespace MARTe; - bool ok = (numberOfInputSignals == 7u); - if (ok) { - ok = (numberOfOutputSignals == 2u); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "Two output signals shall be defined."); - } + using namespace MARTe; + bool ok = (numberOfInputSignals == 6u); + if (ok) { + ok = (numberOfOutputSignals == 2u); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "Two output signals shall be defined."); } - else { - REPORT_ERROR(ErrorManagement::ParametersError, "Six input signals shall be defined."); - } - uint32 currentspvIndex; - uint32 targetvIndex; - uint32 timeIndex; - uint32 startIndex; - uint32 standbyIndex; - uint32 isAutoIndex; - uint32 fhpsPreProIndex; + } else { + REPORT_ERROR(ErrorManagement::ParametersError, + "Six input signals shall be defined."); + } + uint32 currentspvIndex; + uint32 targetvIndex; + uint32 timeIndex; + uint32 startIndex; + uint32 standbyIndex; + uint32 isAutoIndex; + uint32 fhpsPreProIndex; - if (ok) { - StreamString signalName = "Currspv"; - ok = GetSignalIndex(InputSignals, currentspvIndex, signalName.Buffer()); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "Currspv input signal shall be defined."); - } - else { - TypeDescriptor inputType = GetSignalType(InputSignals, currentspvIndex); - ok = (inputType == Float32Bit); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "Signal Currspv shall be defined as float32."); - } - } + if (ok) { + StreamString signalName = "Currspv"; + ok = GetSignalIndex(InputSignals, currentspvIndex, signalName.Buffer()); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "Currspv input signal shall be defined."); + } else { + TypeDescriptor inputType = GetSignalType(InputSignals, currentspvIndex); + ok = (inputType == Float32Bit); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "Signal Currspv shall be defined as float32."); + } } - if (ok) { - StreamString signalName = "Targetv"; - ok = GetSignalIndex(InputSignals, targetvIndex, signalName.Buffer()); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "Targetv input signal shall be defined."); - } - else { - TypeDescriptor inputType = GetSignalType(InputSignals, targetvIndex); - ok = (inputType == Float32Bit); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "Signal Targetv shall be defined as float32."); - } - } + } + if (ok) { + StreamString signalName = "Targetv"; + ok = GetSignalIndex(InputSignals, targetvIndex, signalName.Buffer()); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "Targetv input signal shall be defined."); + } else { + TypeDescriptor inputType = GetSignalType(InputSignals, targetvIndex); + ok = (inputType == Float32Bit); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "Signal Targetv shall be defined as float32."); + } } - if (ok) { - StreamString signalName = "Time"; - ok = GetSignalIndex(InputSignals, timeIndex, signalName.Buffer()); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "Time input signal shall be defined."); - } - else { - TypeDescriptor inputType = GetSignalType(InputSignals, timeIndex); - ok = (inputType == Float32Bit); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "Signal Time shall be defined as float32."); - } - } + } + if (ok) { + StreamString signalName = "Time"; + ok = GetSignalIndex(InputSignals, timeIndex, signalName.Buffer()); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "Time input signal shall be defined."); + } else { + TypeDescriptor inputType = GetSignalType(InputSignals, timeIndex); + ok = (inputType == Float32Bit); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "Signal Time shall be defined as float32."); + } } - if (ok) { - StreamString signalName = "Start"; - ok = GetSignalIndex(InputSignals, startIndex, signalName.Buffer()); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "Start input signal shall be defined."); - } - else { - TypeDescriptor inputType = GetSignalType(InputSignals, startIndex); - ok = (inputType == UnsignedInteger32Bit); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "Start shall be defined as uint32."); - } - } + } + if (ok) { + StreamString signalName = "Start"; + ok = GetSignalIndex(InputSignals, startIndex, signalName.Buffer()); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "Start input signal shall be defined."); + } else { + TypeDescriptor inputType = GetSignalType(InputSignals, startIndex); + ok = (inputType == UnsignedInteger32Bit); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "Start shall be defined as uint32."); + } } - if (ok) { - StreamString signalName = "PLC_STANDBY"; - ok = GetSignalIndex(InputSignals, standbyIndex, signalName.Buffer()); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "PLC_STANDBY input signal shall be defined."); - } - else { - TypeDescriptor inputType = GetSignalType(InputSignals, standbyIndex); - ok = (inputType == UnsignedInteger32Bit); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "PLC_STANDBY shall be defined as uint32."); - } - } + } + if (ok) { + StreamString signalName = "PLC_STANDBY"; + ok = GetSignalIndex(InputSignals, standbyIndex, signalName.Buffer()); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "PLC_STANDBY input signal shall be defined."); + } else { + TypeDescriptor inputType = GetSignalType(InputSignals, standbyIndex); + ok = (inputType == UnsignedInteger8Bit); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "PLC_STANDBY shall be defined as uint8."); + } } - if (ok) { - StreamString signalName = "MANUAL_AUTO"; - ok = GetSignalIndex(InputSignals, isAutoIndex, signalName.Buffer()); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "MANUAL_AUTO input signal shall be defined."); - } - else { - TypeDescriptor inputType = GetSignalType(InputSignals, isAutoIndex); - ok = (inputType == UnsignedInteger32Bit); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "MANUAL_AUTO shall be defined as uint32."); - } - } + } + if (ok) { + StreamString signalName = "MANUAL_AUTO"; + ok = GetSignalIndex(InputSignals, isAutoIndex, signalName.Buffer()); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "MANUAL_AUTO input signal shall be defined."); + } else { + TypeDescriptor inputType = GetSignalType(InputSignals, isAutoIndex); + ok = (inputType == UnsignedInteger32Bit); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "MANUAL_AUTO shall be defined as uint32."); + } } - if (ok) { - StreamString signalName = "FHPS_PrePro"; - ok = GetSignalIndex(InputSignals, fhpsPreProIndex, signalName.Buffer()); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "FHPS_PrePro input signal shall be defined."); - } - else { - TypeDescriptor inputType = GetSignalType(InputSignals, fhpsPreProIndex); - ok = (inputType == Float32Bit); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "Signal FHPS_PrePro shall be defined as float32."); - } - } + } + if (ok) { + StreamString signalName = "FHPS_PrePro"; + ok = GetSignalIndex(InputSignals, fhpsPreProIndex, signalName.Buffer()); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "FHPS_PrePro input signal shall be defined."); + } else { + TypeDescriptor inputType = GetSignalType(InputSignals, fhpsPreProIndex); + ok = (inputType == Float32Bit); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "Signal FHPS_PrePro shall be defined as float32."); + } } + } - if (ok) { - TypeDescriptor inputType = GetSignalType(OutputSignals, 0); - ok = (inputType == Float32Bit); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "Signal Output shall be defined as float32."); - } + if (ok) { + TypeDescriptor inputType = GetSignalType(OutputSignals, 0); + ok = (inputType == Float32Bit); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "Signal Output shall be defined as float32."); } - if (ok) { - TypeDescriptor inputType = GetSignalType(OutputSignals, 1); - ok = (inputType == UnsignedInteger32Bit); - if (!ok) { - REPORT_ERROR(ErrorManagement::ParametersError, "Signal state shall be defined as float32."); - } + } + if (ok) { + TypeDescriptor inputType = GetSignalType(OutputSignals, 1); + ok = (inputType == UnsignedInteger32Bit); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, + "Signal state shall be defined as float32."); } + } - if (ok) { - current_setpoint = reinterpret_cast(GetInputSignalMemory(currentspvIndex)); - target_value = reinterpret_cast(GetInputSignalMemory(targetvIndex)); - rampup_time = reinterpret_cast(GetInputSignalMemory(timeIndex)); - start = reinterpret_cast(GetInputSignalMemory(startIndex)); - standby = reinterpret_cast(GetInputSignalMemory(standbyIndex)); - isAuto = reinterpret_cast(GetInputSignalMemory(isAutoIndex)); - FHPS_PrePro = reinterpret_cast(GetInputSignalMemory(fhpsPreProIndex)); - - output = reinterpret_cast(GetOutputSignalMemory(0)); - state = reinterpret_cast(GetOutputSignalMemory(1)); - } - return ok; + if (ok) { + target_value = + reinterpret_cast(GetInputSignalMemory(targetvIndex)); + rampup_time = reinterpret_cast(GetInputSignalMemory(timeIndex)); + start = reinterpret_cast(GetInputSignalMemory(startIndex)); + standby = reinterpret_cast(GetInputSignalMemory(standbyIndex)); + isAuto = reinterpret_cast(GetInputSignalMemory(isAutoIndex)); + FHPS_PrePro = + reinterpret_cast(GetInputSignalMemory(fhpsPreProIndex)); + + output = reinterpret_cast(GetOutputSignalMemory(0)); + state = reinterpret_cast(GetOutputSignalMemory(1)); + } + return ok; } -bool JARampupGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName){ - if(strcmp(nextStateName, "WaitHVON_PREP")==0 || strcmp(nextStateName, "WaitHVON_SDN_PREP")==0 || - strcmp(nextStateName, "WaitHVON")==0 || strcmp(nextStateName, "WaitHVON_SDN")==0){ - inWaitHVON = true; - inWaitStandby = false; - } else{ - inWaitHVON = false; - if(strcmp(nextStateName,"WaitStandby")==0 ){ - inWaitStandby = true; - } else { - inWaitStandby = false; - } +bool JARampupGAM::PrepareNextState(const MARTe::char8 *const currentStateName, + const MARTe::char8 *const nextStateName) { + if (strcmp(nextStateName, "WaitHVON_PREP") == 0 || + strcmp(nextStateName, "WaitHVON_SDN_PREP") == 0 || + strcmp(nextStateName, "WaitHVON") == 0 || + strcmp(nextStateName, "WaitHVON_SDN") == 0) { + inWaitHVON = true; + inWaitStandby = false; + } else { + inWaitHVON = false; + if (strcmp(nextStateName, "WaitStandby") == 0) { + inWaitStandby = true; + } else { + inWaitStandby = false; } - return true; + } + return true; } bool JARampupGAM::Execute() { - using namespace MARTe; - if(!inWaitHVON){ - if (*target_value <= 0.0f || *standby == 0u) { - *output = 0.0f; - rampup_rate = 0.0f; - if(*target_value <= 0.0f){ - *state = 3u; - } else { - *state = 0u; - } - return true; - } - - if(*start == 1u && *isAuto==0u){ //isAuto = 1.Manual, 0.auto-rampup. - inRampup = true; - resetFlag = true; - *output = 0.0f; //Enable if it should start always zero. - } - - // Calcrate new rampup rate. - if(*rampup_time != 0 && resetFlag == true){ - rampup_rate = (*target_value - *current_setpoint) / *rampup_time/1000.0f; // Volt/msec - resetFlag = false; - } - - // Update Parameter - if(*standby == 1u ){ - if(*isAuto == 1u){ - if (inWaitStandby){ - *output = *target_value; - } else{ - *output = *FHPS_PrePro; - } - //*output = *target_value; - *state = 0u; - return true; - } - else if (inRampup){ - if (*output + rampup_rate < *target_value && *rampup_time != 0){ - *output = *output + rampup_rate; - *state = 1u; - } else { - *output = *target_value; - *state = 2u; - inRampup = false; - } - } - } - return true; - } else { - if(*isAuto == 0){ - *output = *FHPS_PrePro; - } else{ - *output = *target_value; - } - return true; + using namespace MARTe; + float32 current_setpoint = *output; + if (!inWaitHVON) { + if (*target_value <= 0.0f || *standby == 0u) { + *output = 0.0f; + rampup_rate = 0.0f; + if (*target_value <= 0.0f) { + *state = 3u; + } else { + *state = 0u; + } + return true; } + + if (*start == 1u && *isAuto == 0u) { // isAuto = 1.Manual, 0.auto-rampup. + inRampup = true; + resetFlag = true; + *output = 0.0f; // Enable if it should start always zero. + } + + // Calcrate new rampup rate. + if (*rampup_time != 0 && resetFlag == true) { + rampup_rate = (*target_value - current_setpoint) / *rampup_time / + 1000.0f; // Volt/msec + resetFlag = false; + } + + // Update Parameter + if (*standby == 1u) { + if (*isAuto == 1u) { + if (inWaitStandby) { + *output = *target_value; + } else { + *output = *FHPS_PrePro; + } + //*output = *target_value; + *state = 0u; + return true; + } else if (inRampup) { + if (*output + rampup_rate < *target_value && *rampup_time != 0) { + *output = *output + rampup_rate; + *state = 1u; + } else { + *output = *target_value; + *state = 2u; + inRampup = false; + } + } + } + return true; + } else { + if (*isAuto == 0) { + *output = *FHPS_PrePro; + } else { + *output = *target_value; + } + return true; + } } CLASS_REGISTER(JARampupGAM, "1.0") diff --git a/EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/JARampupGAM.h b/EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/JARampupGAM.h index 3c6e012..0666d44 100644 --- a/EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/JARampupGAM.h +++ b/EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/JARampupGAM.h @@ -97,8 +97,6 @@ public: const MARTe::char8 * const nextStateName); private: - // Input signal containing current current_setpoint - MARTe::float32 *current_setpoint; // Input signal containing the frequency of the waveform. MARTe::float32 *target_value; @@ -110,7 +108,7 @@ private: MARTe::uint32 *start; // Input signal PLC_STANDBY - MARTe::uint32 *standby; + MARTe::uint8 *standby; // MANUAL AUTO button MARTe::uint32 *isAuto;