16 #include <config/CommandDispatcherImplCfg.hpp> 26 m_FPrimeSequence(*this),
27 m_sequence(&this->m_FPrimeSequence),
34 m_totalExecutedCount(0),
35 m_sequencesCompletedCount(0),
40 m_join_waiting(false) {}
43 this->m_timeout = timeout;
47 this->m_sequence = &sequence;
57 FW_ASSERT(this->m_runMode == STOPPED, this->m_runMode);
58 if (not this->loadFile(fileName)) {
59 this->m_sequence->
clear();
73 void CmdSequencerComponentImpl::CS_RUN_cmdHandler(
FwOpcodeType opCode,
77 if (not this->requireRunMode(STOPPED)) {
93 this->m_blockState = block.
e;
94 this->m_cmdSeq = cmdSeq;
95 this->m_opCode = opCode;
98 if (not this->loadFile(fileName)) {
108 this->m_executedCount = 0;
111 if (AUTO == this->m_stepMode) {
112 this->m_runMode = RUNNING;
120 this->performCmd_Step();
128 void CmdSequencerComponentImpl::CS_VALIDATE_cmdHandler(
FwOpcodeType opCode,
132 if (!this->requireRunMode(STOPPED)) {
138 if (not this->loadFile(fileName)) {
144 this->m_sequence->
clear();
152 void CmdSequencerComponentImpl::doSequenceRun(
const Fw::StringBase& filename) {
153 if (MANUAL == this->m_stepMode) {
159 if (!this->requireRunMode(STOPPED)) {
166 if (filename !=
"") {
168 const bool status = this->loadFile(cmdStr);
181 this->m_executedCount = 0;
184 if (AUTO == this->m_stepMode) {
185 this->m_runMode = RUNNING;
193 this->performCmd_Step();
199 void CmdSequencerComponentImpl::seqRunIn_handler(
FwIndexType portNum,
203 this->doSequenceRun(filename);
207 this->doSequenceRun(file_name);
210 void CmdSequencerComponentImpl ::seqCancelIn_handler(
const FwIndexType portNum) {
211 if (RUNNING == this->m_runMode) {
212 this->performCmd_Cancel();
214 ++this->m_cancelCmdCount;
221 void CmdSequencerComponentImpl::CS_CANCEL_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq) {
222 if (RUNNING == this->m_runMode) {
223 this->performCmd_Cancel();
225 ++this->m_cancelCmdCount;
233 void CmdSequencerComponentImpl::CS_JOIN_WAIT_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq) {
235 if (m_runMode != RUNNING) {
246 m_join_waiting =
true;
259 const bool status = this->m_sequence->
loadFile(fileName);
263 ++this->m_loadCmdCount;
274 this->m_sequence->
clear();
279 void CmdSequencerComponentImpl::error() {
280 ++this->m_errorCount;
284 void CmdSequencerComponentImpl::performCmd_Cancel() {
286 this->m_sequence->
reset();
287 this->m_runMode = STOPPED;
288 this->m_cmdTimer.clear();
289 this->m_cmdTimeoutTimer.clear();
290 this->m_executedCount = 0;
298 this->m_join_waiting =
false;
305 void CmdSequencerComponentImpl ::cmdResponseIn_handler(
FwIndexType portNum,
309 if (this->m_runMode == STOPPED) {
314 this->m_cmdTimeoutTimer.clear();
316 this->commandError(this->m_executedCount, opcode, response.
e);
317 this->performCmd_Cancel();
318 }
else if (this->m_runMode == RUNNING && this->m_stepMode == AUTO) {
320 this->commandComplete(opcode);
323 this->m_runMode = STOPPED;
324 this->sequenceComplete();
326 this->performCmd_Step();
330 this->commandComplete(opcode);
332 this->m_runMode = STOPPED;
333 this->sequenceComplete();
339 void CmdSequencerComponentImpl ::schedIn_handler(
FwIndexType portNum, U32 order) {
342 if (this->m_cmdTimer.isExpiredAt(currTime)) {
344 this->m_cmdTimer.clear();
346 this->setCmdTimeout(currTime);
347 }
else if (this->m_cmdTimeoutTimer.isExpiredAt(this->getTime())) {
350 this->performCmd_Cancel();
354 void CmdSequencerComponentImpl ::CS_START_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
361 if (!this->requireRunMode(STOPPED)) {
367 this->m_runMode = RUNNING;
370 this->performCmd_Step();
379 void CmdSequencerComponentImpl ::CS_STEP_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
381 if (this->requireRunMode(RUNNING)) {
382 if (MANUAL != this->m_stepMode) {
395 this->performCmd_Step();
397 if (this->m_runMode != STOPPED) {
406 void CmdSequencerComponentImpl ::CS_AUTO_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
407 if (this->requireRunMode(STOPPED)) {
408 this->m_stepMode = AUTO;
416 void CmdSequencerComponentImpl ::CS_MANUAL_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
417 if (this->requireRunMode(STOPPED)) {
418 this->m_stepMode = MANUAL;
430 bool CmdSequencerComponentImpl::requireRunMode(RunMode mode) {
431 if (this->m_runMode == mode) {
439 void CmdSequencerComponentImpl ::commandError(
const U32 number,
const FwOpcodeType opCode,
const U32 error) {
445 void CmdSequencerComponentImpl::performCmd_Step() {
448 const Sequence::Header& header = this->m_sequence->
getHeader();
455 this->m_runMode = STOPPED;
456 this->sequenceComplete();
459 this->performCmd_Step_RELATIVE(currentTime);
462 this->performCmd_Step_ABSOLUTE(currentTime);
469 void CmdSequencerComponentImpl::sequenceComplete() {
471 ++this->m_sequencesCompletedCount;
473 this->m_sequence->
clear();
476 this->m_executedCount = 0;
486 m_join_waiting =
false;
491 void CmdSequencerComponentImpl::commandComplete(
const FwOpcodeType opcode) {
494 ++this->m_executedCount;
495 ++this->m_totalExecutedCount;
499 void CmdSequencerComponentImpl ::performCmd_Step_RELATIVE(
Fw::Time& currentTime) {
501 this->performCmd_Step_ABSOLUTE(currentTime);
504 void CmdSequencerComponentImpl ::performCmd_Step_ABSOLUTE(
Fw::Time& currentTime) {
505 if (currentTime >= this->m_record.
m_timeTag) {
507 this->setCmdTimeout(currentTime);
509 this->m_cmdTimer.set(this->m_record.
m_timeTag);
513 void CmdSequencerComponentImpl ::pingIn_handler(
FwIndexType portNum,
520 void CmdSequencerComponentImpl ::setCmdTimeout(
const Fw::Time& currentTime) {
522 if ((this->m_timeout > 0) and (AUTO == this->m_stepMode)) {
524 expTime.
add(this->m_timeout, 0);
525 this->m_cmdTimeoutTimer.set(expTime);
constexpr FwOpcodeType getEventOpcode(const FwOpcodeType opcode)
void loadSequence(const Fw::ConstStringBase &fileName)
void tlmWrite_CS_LoadCommands(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void log_WARNING_HI_CS_InvalidMode() const
void setSequenceFormat(Sequence &sequence)
FwIdType FwOpcodeType
The type of a command opcode.
PlatformSizeType FwSizeType
CmdSequencerComponentImpl(const char *compName)
Construct a CmdSequencer.
void tlmWrite_CS_Errors(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void log_ACTIVITY_HI_CS_JoinWaiting(const Fw::StringBase &filename, U32 recordNumber, FwOpcodeType opCode) const
void log_WARNING_HI_CS_JoinWaitingNotComplete() const
void log_WARNING_HI_CS_UnexpectedCompletion(FwOpcodeType opcode) const
void log_ACTIVITY_LO_CS_SequenceLoaded(const Fw::StringBase &fileName) const
enum T e
The raw enum value.
Fw::Time m_timeTag
The time tag. NOTE: timeBase and context not filled in.
void tlmWrite_CS_CurrentSequence(const Fw::StringBase &arg, Fw::Time _tlmTime=Fw::Time())
void log_ACTIVITY_HI_CS_CmdStarted(const Fw::StringBase &filename) const
Enum representing a command response.
bool isConnected_seqDone_OutputPort(FwIndexType portNum) const
void log_WARNING_LO_CS_NoSequenceActive() const
void log_WARNING_HI_CS_SequenceTimeout(const Fw::StringBase &filename, U32 command) const
bool isConnected_seqStartOut_OutputPort(FwIndexType portNum) const
void allocateBuffer(FwEnumStoreType identifier, Fw::MemAllocator &allocator, FwSizeType bytes)
Give the sequence representation a memory buffer.
virtual bool hasMoreRecords() const =0
void tlmWrite_CS_CancelCommands(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void tlmWrite_CS_CommandsExecuted(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
~CmdSequencerComponentImpl()
Destroy a CmdDispatcherComponentBase.
Fw::ComBuffer m_command
The command.
void log_ACTIVITY_HI_CS_PortSequenceStarted(const Fw::StringBase &filename) const
void seqStartOut_out(FwIndexType portNum, const Fw::StringBase &filename, const Svc::SeqArgs &args) const
Invoke output port seqStartOut.
void log_ACTIVITY_HI_CS_SequenceCanceled(const Fw::StringBase &fileName) const
void setTimeContext(FwTimeContextStoreType context)
void allocateBuffer(const FwEnumStoreType identifier, Fw::MemAllocator &allocator, const FwSizeType bytes)
A sequence with unspecified binary format.
void deallocateBuffer(Fw::MemAllocator &allocator)
Deallocate the buffer.
Sequencer blocking state.
void setTimeBase(TimeBase timeBase)
void log_ACTIVITY_HI_CS_ModeSwitched(const Svc::CmdSequencer_SeqMode &mode) const
void setTimeout(const U32 seconds)
Command successfully executed.
virtual bool loadFile(const Fw::ConstStringBase &fileName)=0
Command had execution error.
static Time add(const Time &a, const Time &b)
void deallocateBuffer(Fw::MemAllocator &allocator)
Return allocated buffer. Call during shutdown.
Memory Allocation base class.
Fw::LogStringArg & getLogFileName()
A read-only abstract superclass for StringBase.
PlatformIndexType FwIndexType
Auto-generated base for CmdSequencer component.
Descriptor m_descriptor
The descriptor.
void comCmdOut_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context) const
Invoke output port comCmdOut.
RateGroupDivider component implementation.
virtual void nextRecord(Record &record)=0
void log_ACTIVITY_HI_CS_SequenceComplete(const Fw::StringBase &fileName) const
void seqDone_out(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) const
Invoke output port seqDone.
void log_ACTIVITY_LO_CS_CommandComplete(const Fw::StringBase &fileName, U32 recordNumber, FwOpcodeType opCode) const
void log_WARNING_HI_CS_CommandError(const Fw::StringBase &fileName, U32 recordNumber, FwOpcodeType opCode, U32 errorStatus) const
Fw::String & getStringFileName()
void pingOut_out(FwIndexType portNum, U32 key) const
Invoke output port pingOut.
const Header & getHeader() const
Get the sequence header.
void log_ACTIVITY_HI_CS_SequenceValid(const Fw::StringBase &filename) const
enum T e
The raw enum value.
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
void tlmWrite_CS_SequencesCompleted(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void log_ACTIVITY_HI_CS_CmdStepped(const Fw::StringBase &filename, U32 command) const