27 m_FPrimeSequence(*this),
28 m_sequence(&this->m_FPrimeSequence),
35 m_totalExecutedCount(0),
36 m_sequencesCompletedCount(0),
41 m_join_waiting(false) {}
44 this->m_timeout = timeout;
48 this->m_sequence = &sequence;
58 FW_ASSERT(this->m_runMode == STOPPED, this->m_runMode);
59 if (not this->loadFile(fileName)) {
60 this->m_sequence->
clear();
74 void CmdSequencerComponentImpl::CS_RUN_cmdHandler(
FwOpcodeType opCode,
78 if (not this->requireRunMode(STOPPED)) {
87 this->m_blockState = block.
e;
88 this->m_cmdSeq = cmdSeq;
89 this->m_opCode = opCode;
92 if (not this->loadFile(fileName)) {
97 this->m_executedCount = 0;
100 if (AUTO == this->m_stepMode) {
101 this->m_runMode = RUNNING;
108 this->performCmd_Step();
116 void CmdSequencerComponentImpl::CS_VALIDATE_cmdHandler(
FwOpcodeType opCode,
119 if (!this->requireRunMode(STOPPED)) {
125 if (not this->loadFile(fileName)) {
131 this->m_sequence->
clear();
139 void CmdSequencerComponentImpl::doSequenceRun(
const Fw::StringBase& filename) {
140 if (!this->requireRunMode(STOPPED)) {
147 if (filename !=
"") {
149 const bool status = this->loadFile(cmdStr);
162 this->m_executedCount = 0;
165 if (AUTO == this->m_stepMode) {
166 this->m_runMode = RUNNING;
173 this->performCmd_Step();
179 void CmdSequencerComponentImpl::seqRunIn_handler(
FwIndexType portNum,
183 this->doSequenceRun(filename);
187 this->doSequenceRun(file_name);
190 void CmdSequencerComponentImpl ::seqCancelIn_handler(
const FwIndexType portNum) {
191 if (RUNNING == this->m_runMode) {
192 this->performCmd_Cancel();
194 ++this->m_cancelCmdCount;
201 void CmdSequencerComponentImpl::CS_CANCEL_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq) {
202 if (RUNNING == this->m_runMode) {
203 this->performCmd_Cancel();
205 ++this->m_cancelCmdCount;
213 void CmdSequencerComponentImpl::CS_JOIN_WAIT_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq) {
215 if (m_runMode != RUNNING) {
220 m_join_waiting =
true;
233 const bool status = this->m_sequence->
loadFile(fileName);
237 ++this->m_loadCmdCount;
243 void CmdSequencerComponentImpl::error() {
244 ++this->m_errorCount;
248 void CmdSequencerComponentImpl::performCmd_Cancel() {
249 this->m_sequence->
reset();
250 this->m_runMode = STOPPED;
251 this->m_cmdTimer.clear();
252 this->m_cmdTimeoutTimer.clear();
253 this->m_executedCount = 0;
261 this->m_join_waiting =
false;
268 void CmdSequencerComponentImpl ::cmdResponseIn_handler(
FwIndexType portNum,
272 if (this->m_runMode == STOPPED) {
277 this->m_cmdTimeoutTimer.clear();
279 this->commandError(this->m_executedCount, opcode, response.
e);
280 this->performCmd_Cancel();
281 }
else if (this->m_runMode == RUNNING && this->m_stepMode == AUTO) {
283 this->commandComplete(opcode);
286 this->m_runMode = STOPPED;
287 this->sequenceComplete();
289 this->performCmd_Step();
293 this->commandComplete(opcode);
295 this->m_runMode = STOPPED;
296 this->sequenceComplete();
302 void CmdSequencerComponentImpl ::schedIn_handler(
FwIndexType portNum, U32 order) {
305 if (this->m_cmdTimer.isExpiredAt(currTime)) {
307 this->m_cmdTimer.clear();
309 this->setCmdTimeout(currTime);
310 }
else if (this->m_cmdTimeoutTimer.isExpiredAt(this->getTime())) {
313 this->performCmd_Cancel();
317 void CmdSequencerComponentImpl ::CS_START_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
324 if (!this->requireRunMode(STOPPED)) {
330 this->m_runMode = RUNNING;
331 this->performCmd_Step();
341 void CmdSequencerComponentImpl ::CS_STEP_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
342 if (this->requireRunMode(RUNNING)) {
343 this->performCmd_Step();
345 if (this->m_runMode != STOPPED) {
354 void CmdSequencerComponentImpl ::CS_AUTO_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
355 if (this->requireRunMode(STOPPED)) {
356 this->m_stepMode = AUTO;
364 void CmdSequencerComponentImpl ::CS_MANUAL_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
365 if (this->requireRunMode(STOPPED)) {
366 this->m_stepMode = MANUAL;
378 bool CmdSequencerComponentImpl::requireRunMode(RunMode mode) {
379 if (this->m_runMode == mode) {
387 void CmdSequencerComponentImpl ::commandError(
const U32 number,
const FwOpcodeType opCode,
const U32 error) {
392 void CmdSequencerComponentImpl::performCmd_Step() {
395 const Sequence::Header& header = this->m_sequence->
getHeader();
402 this->m_runMode = STOPPED;
403 this->sequenceComplete();
406 this->performCmd_Step_RELATIVE(currentTime);
409 this->performCmd_Step_ABSOLUTE(currentTime);
416 void CmdSequencerComponentImpl::sequenceComplete() {
417 ++this->m_sequencesCompletedCount;
419 this->m_sequence->
clear();
422 this->m_executedCount = 0;
432 m_join_waiting =
false;
436 void CmdSequencerComponentImpl::commandComplete(
const FwOpcodeType opcode) {
438 ++this->m_executedCount;
439 ++this->m_totalExecutedCount;
443 void CmdSequencerComponentImpl ::performCmd_Step_RELATIVE(
Fw::Time& currentTime) {
445 this->performCmd_Step_ABSOLUTE(currentTime);
448 void CmdSequencerComponentImpl ::performCmd_Step_ABSOLUTE(
Fw::Time& currentTime) {
449 if (currentTime >= this->m_record.
m_timeTag) {
451 this->setCmdTimeout(currentTime);
453 this->m_cmdTimer.set(this->m_record.
m_timeTag);
457 void CmdSequencerComponentImpl ::pingIn_handler(
FwIndexType portNum,
464 void CmdSequencerComponentImpl ::setCmdTimeout(
const Fw::Time& currentTime) {
466 if ((this->m_timeout > 0) and (AUTO == this->m_stepMode)) {
468 expTime.
add(this->m_timeout, 0);
469 this->m_cmdTimeoutTimer.set(expTime);
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.
void log_ACTIVITY_HI_CS_ModeSwitched(Svc::CmdSequencer_SeqMode mode) const
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 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.
void setTimeBase(TimeBase timeBase)
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
enum T e
The raw enum value.
Sequencer blocking state.
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
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