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)) {
103 this->m_executedCount = 0;
106 if (AUTO == this->m_stepMode) {
107 this->m_runMode = RUNNING;
115 this->performCmd_Step();
123 void CmdSequencerComponentImpl::CS_VALIDATE_cmdHandler(
FwOpcodeType opCode,
127 if (!this->requireRunMode(STOPPED)) {
133 if (not this->loadFile(fileName)) {
139 this->m_sequence->
clear();
147 void CmdSequencerComponentImpl::doSequenceRun(
const Fw::StringBase& filename) {
148 if (MANUAL == this->m_stepMode) {
154 if (!this->requireRunMode(STOPPED)) {
161 if (filename !=
"") {
163 const bool status = this->loadFile(cmdStr);
176 this->m_executedCount = 0;
179 if (AUTO == this->m_stepMode) {
180 this->m_runMode = RUNNING;
188 this->performCmd_Step();
194 void CmdSequencerComponentImpl::seqRunIn_handler(
FwIndexType portNum,
198 this->doSequenceRun(filename);
202 this->doSequenceRun(file_name);
205 void CmdSequencerComponentImpl ::seqCancelIn_handler(
const FwIndexType portNum) {
206 if (RUNNING == this->m_runMode) {
207 this->performCmd_Cancel();
209 ++this->m_cancelCmdCount;
216 void CmdSequencerComponentImpl::CS_CANCEL_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq) {
217 if (RUNNING == this->m_runMode) {
218 this->performCmd_Cancel();
220 ++this->m_cancelCmdCount;
228 void CmdSequencerComponentImpl::CS_JOIN_WAIT_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq) {
230 if (m_runMode != RUNNING) {
241 m_join_waiting =
true;
254 const bool status = this->m_sequence->
loadFile(fileName);
258 ++this->m_loadCmdCount;
269 this->m_sequence->
clear();
274 void CmdSequencerComponentImpl::error() {
275 ++this->m_errorCount;
279 void CmdSequencerComponentImpl::performCmd_Cancel() {
281 this->m_sequence->
reset();
282 this->m_runMode = STOPPED;
283 this->m_cmdTimer.clear();
284 this->m_cmdTimeoutTimer.clear();
285 this->m_executedCount = 0;
293 this->m_join_waiting =
false;
300 void CmdSequencerComponentImpl ::cmdResponseIn_handler(
FwIndexType portNum,
304 if (this->m_runMode == STOPPED) {
309 this->m_cmdTimeoutTimer.clear();
311 this->commandError(this->m_executedCount, opcode, response.
e);
312 this->performCmd_Cancel();
313 }
else if (this->m_runMode == RUNNING && this->m_stepMode == AUTO) {
315 this->commandComplete(opcode);
318 this->m_runMode = STOPPED;
319 this->sequenceComplete();
321 this->performCmd_Step();
325 this->commandComplete(opcode);
327 this->m_runMode = STOPPED;
328 this->sequenceComplete();
334 void CmdSequencerComponentImpl ::schedIn_handler(
FwIndexType portNum, U32 order) {
337 if (this->m_cmdTimer.isExpiredAt(currTime)) {
339 this->m_cmdTimer.clear();
341 this->setCmdTimeout(currTime);
342 }
else if (this->m_cmdTimeoutTimer.isExpiredAt(this->getTime())) {
345 this->performCmd_Cancel();
349 void CmdSequencerComponentImpl ::CS_START_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
356 if (!this->requireRunMode(STOPPED)) {
362 this->m_runMode = RUNNING;
365 this->performCmd_Step();
374 void CmdSequencerComponentImpl ::CS_STEP_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
376 if (this->requireRunMode(RUNNING)) {
384 this->performCmd_Step();
386 if (this->m_runMode != STOPPED) {
395 void CmdSequencerComponentImpl ::CS_AUTO_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
396 if (this->requireRunMode(STOPPED)) {
397 this->m_stepMode = AUTO;
405 void CmdSequencerComponentImpl ::CS_MANUAL_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
406 if (this->requireRunMode(STOPPED)) {
407 this->m_stepMode = MANUAL;
419 bool CmdSequencerComponentImpl::requireRunMode(RunMode mode) {
420 if (this->m_runMode == mode) {
428 void CmdSequencerComponentImpl ::commandError(
const U32 number,
const FwOpcodeType opCode,
const U32 error) {
434 void CmdSequencerComponentImpl::performCmd_Step() {
437 const Sequence::Header& header = this->m_sequence->
getHeader();
444 this->m_runMode = STOPPED;
445 this->sequenceComplete();
448 this->performCmd_Step_RELATIVE(currentTime);
451 this->performCmd_Step_ABSOLUTE(currentTime);
458 void CmdSequencerComponentImpl::sequenceComplete() {
460 ++this->m_sequencesCompletedCount;
462 this->m_sequence->
clear();
465 this->m_executedCount = 0;
475 m_join_waiting =
false;
480 void CmdSequencerComponentImpl::commandComplete(
const FwOpcodeType opcode) {
483 ++this->m_executedCount;
484 ++this->m_totalExecutedCount;
488 void CmdSequencerComponentImpl ::performCmd_Step_RELATIVE(
Fw::Time& currentTime) {
490 this->performCmd_Step_ABSOLUTE(currentTime);
493 void CmdSequencerComponentImpl ::performCmd_Step_ABSOLUTE(
Fw::Time& currentTime) {
494 if (currentTime >= this->m_record.
m_timeTag) {
496 this->setCmdTimeout(currentTime);
498 this->m_cmdTimer.set(this->m_record.
m_timeTag);
502 void CmdSequencerComponentImpl ::pingIn_handler(
FwIndexType portNum,
509 void CmdSequencerComponentImpl ::setCmdTimeout(
const Fw::Time& currentTime) {
511 if ((this->m_timeout > 0) and (AUTO == this->m_stepMode)) {
513 expTime.
add(this->m_timeout, 0);
514 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