|
| 1 | +// ====================================================================== |
| 2 | +// \title Burnwire.cpp |
| 3 | +// \brief cpp file for Burnwire component implementation class |
| 4 | +// ====================================================================== |
| 5 | + |
| 6 | +#include "FprimeZephyrReference/Components/Burnwire/Burnwire.hpp" |
| 7 | + |
| 8 | +namespace Components { |
| 9 | + |
| 10 | +// ---------------------------------------------------------------------- |
| 11 | +// Component construction and destruction |
| 12 | +// ---------------------------------------------------------------------- |
| 13 | + |
| 14 | +Burnwire ::Burnwire(const char* const compName) : BurnwireComponentBase(compName) { |
| 15 | + this->m_safetyCounter = 0; |
| 16 | + this->m_state = Fw::On::OFF; |
| 17 | +} |
| 18 | + |
| 19 | +Burnwire ::~Burnwire() {} |
| 20 | + |
| 21 | +// ---------------------------------------------------------------------- |
| 22 | +// Handler implementations for typed input ports |
| 23 | +// ---------------------------------------------------------------------- |
| 24 | +void Burnwire ::burnStart_handler(FwIndexType portNum) { |
| 25 | + this->startBurn(); |
| 26 | +} |
| 27 | + |
| 28 | +void Burnwire ::burnStop_handler(FwIndexType portNum) { |
| 29 | + this->stopBurn(); |
| 30 | +} |
| 31 | + |
| 32 | +void Burnwire::startBurn() { |
| 33 | + this->log_ACTIVITY_HI_SetBurnwireState(Fw::On::ON); |
| 34 | + this->m_safetyCounter = 0; |
| 35 | + this->m_state = Fw::On::ON; |
| 36 | + |
| 37 | + Fw::ParamValid valid; |
| 38 | + U32 timeout = this->paramGet_SAFETY_TIMER(valid); |
| 39 | + this->log_ACTIVITY_HI_SafetyTimerState(timeout); |
| 40 | +} |
| 41 | + |
| 42 | +void Burnwire::stopBurn() { |
| 43 | + this->log_ACTIVITY_HI_SetBurnwireState(Fw::On::OFF); |
| 44 | + this->gpioSet_out(0, Fw::Logic::LOW); |
| 45 | + this->gpioSet_out(1, Fw::Logic::LOW); |
| 46 | + |
| 47 | + this->m_state = Fw::On::OFF; |
| 48 | + this->log_ACTIVITY_LO_BurnwireEndCount(m_safetyCounter); |
| 49 | +} |
| 50 | + |
| 51 | +void Burnwire ::schedIn_handler(FwIndexType portNum, U32 context) { |
| 52 | + Fw::ParamValid valid; |
| 53 | + U32 timeout = this->paramGet_SAFETY_TIMER(valid); |
| 54 | + |
| 55 | + if (this->m_state == Fw::On::ON) { |
| 56 | + this->m_safetyCounter++; |
| 57 | + if (this->m_safetyCounter == 1) { |
| 58 | + this->gpioSet_out(0, Fw::Logic::HIGH); |
| 59 | + this->gpioSet_out(1, Fw::Logic::HIGH); |
| 60 | + this->log_ACTIVITY_HI_SafetyTimerStatus(Fw::On::ON); |
| 61 | + } |
| 62 | + |
| 63 | + if (this->m_safetyCounter >= timeout) { |
| 64 | + stopBurn(); |
| 65 | + this->log_ACTIVITY_HI_SafetyTimerStatus(Fw::On::OFF); |
| 66 | + } |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +// ---------------------------------------------------------------------- |
| 71 | +// Handler implementations for commands |
| 72 | +// ---------------------------------------------------------------------- |
| 73 | + |
| 74 | +void Burnwire ::START_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { |
| 75 | + this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); |
| 76 | + this->startBurn(); |
| 77 | +} |
| 78 | + |
| 79 | +void Burnwire ::STOP_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { |
| 80 | + this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); |
| 81 | + this->stopBurn(); |
| 82 | +} |
| 83 | + |
| 84 | +} // namespace Components |
0 commit comments