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;
105 this->performCmd_Step();
113 void CmdSequencerComponentImpl::CS_VALIDATE_cmdHandler(
FwOpcodeType opCode,
116 if (!this->requireRunMode(STOPPED)) {
122 if (not this->loadFile(fileName)) {
128 this->m_sequence->
clear();
136 void CmdSequencerComponentImpl::doSequenceRun(
const Fw::StringBase& filename) {
137 if (!this->requireRunMode(STOPPED)) {
144 if (filename !=
"") {
146 const bool status = this->loadFile(cmdStr);
159 this->m_executedCount = 0;
162 if (AUTO == this->m_stepMode) {
163 this->m_runMode = RUNNING;
167 this->performCmd_Step();
174 this->doSequenceRun(filename);
178 this->doSequenceRun(file_name);
181 void CmdSequencerComponentImpl ::seqCancelIn_handler(
const FwIndexType portNum) {
182 if (RUNNING == this->m_runMode) {
183 this->performCmd_Cancel();
185 ++this->m_cancelCmdCount;
192 void CmdSequencerComponentImpl::CS_CANCEL_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq) {
193 if (RUNNING == this->m_runMode) {
194 this->performCmd_Cancel();
196 ++this->m_cancelCmdCount;
204 void CmdSequencerComponentImpl::CS_JOIN_WAIT_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq) {
206 if (m_runMode != RUNNING) {
211 m_join_waiting =
true;
224 const bool status = this->m_sequence->
loadFile(fileName);
228 ++this->m_loadCmdCount;
234 void CmdSequencerComponentImpl::error() {
235 ++this->m_errorCount;
239 void CmdSequencerComponentImpl::performCmd_Cancel() {
240 this->m_sequence->
reset();
241 this->m_runMode = STOPPED;
242 this->m_cmdTimer.clear();
243 this->m_cmdTimeoutTimer.clear();
244 this->m_executedCount = 0;
252 this->m_join_waiting =
false;
259 void CmdSequencerComponentImpl ::cmdResponseIn_handler(
FwIndexType portNum,
263 if (this->m_runMode == STOPPED) {
268 this->m_cmdTimeoutTimer.clear();
270 this->commandError(this->m_executedCount, opcode, response.
e);
271 this->performCmd_Cancel();
272 }
else if (this->m_runMode == RUNNING && this->m_stepMode == AUTO) {
274 this->commandComplete(opcode);
277 this->m_runMode = STOPPED;
278 this->sequenceComplete();
280 this->performCmd_Step();
284 this->commandComplete(opcode);
286 this->m_runMode = STOPPED;
287 this->sequenceComplete();
293 void CmdSequencerComponentImpl ::schedIn_handler(
FwIndexType portNum, U32 order) {
296 if (this->m_cmdTimer.isExpiredAt(currTime)) {
298 this->m_cmdTimer.clear();
300 this->setCmdTimeout(currTime);
301 }
else if (this->m_cmdTimeoutTimer.isExpiredAt(this->getTime())) {
304 this->performCmd_Cancel();
308 void CmdSequencerComponentImpl ::CS_START_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
315 if (!this->requireRunMode(STOPPED)) {
321 this->m_runMode = RUNNING;
322 this->performCmd_Step();
330 void CmdSequencerComponentImpl ::CS_STEP_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
331 if (this->requireRunMode(RUNNING)) {
332 this->performCmd_Step();
334 if (this->m_runMode != STOPPED) {
343 void CmdSequencerComponentImpl ::CS_AUTO_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
344 if (this->requireRunMode(STOPPED)) {
345 this->m_stepMode = AUTO;
353 void CmdSequencerComponentImpl ::CS_MANUAL_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
354 if (this->requireRunMode(STOPPED)) {
355 this->m_stepMode = MANUAL;
367 bool CmdSequencerComponentImpl::requireRunMode(RunMode mode) {
368 if (this->m_runMode == mode) {
376 void CmdSequencerComponentImpl ::commandError(
const U32 number,
const FwOpcodeType opCode,
const U32 error) {
381 void CmdSequencerComponentImpl::performCmd_Step() {
384 const Sequence::Header& header = this->m_sequence->
getHeader();
391 this->m_runMode = STOPPED;
392 this->sequenceComplete();
395 this->performCmd_Step_RELATIVE(currentTime);
398 this->performCmd_Step_ABSOLUTE(currentTime);
405 void CmdSequencerComponentImpl::sequenceComplete() {
406 ++this->m_sequencesCompletedCount;
408 this->m_sequence->
clear();
411 this->m_executedCount = 0;
421 m_join_waiting =
false;
425 void CmdSequencerComponentImpl::commandComplete(
const FwOpcodeType opcode) {
427 ++this->m_executedCount;
428 ++this->m_totalExecutedCount;
432 void CmdSequencerComponentImpl ::performCmd_Step_RELATIVE(
Fw::Time& currentTime) {
434 this->performCmd_Step_ABSOLUTE(currentTime);
437 void CmdSequencerComponentImpl ::performCmd_Step_ABSOLUTE(
Fw::Time& currentTime) {
438 if (currentTime >= this->m_record.
m_timeTag) {
440 this->setCmdTimeout(currentTime);
442 this->m_cmdTimer.set(this->m_record.
m_timeTag);
446 void CmdSequencerComponentImpl ::pingIn_handler(
FwIndexType portNum,
453 void CmdSequencerComponentImpl ::setCmdTimeout(
const Fw::Time& currentTime) {
455 if ((this->m_timeout > 0) and (AUTO == this->m_stepMode)) {
457 expTime.
add(this->m_timeout, 0);
458 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
Fw::Time m_timeTag
The time tag. NOTE: timeBase and context not filled in.
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
void log_ACTIVITY_HI_CS_CmdStarted(const Fw::StringBase &filename) const
void comCmdOut_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port comCmdOut.
void seqDone_out(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Invoke output port seqDone.
Enum representing a command response.
void log_WARNING_LO_CS_NoSequenceActive() const
void log_WARNING_HI_CS_SequenceTimeout(const Fw::StringBase &filename, U32 command) const
void allocateBuffer(FwEnumStoreType identifier, Fw::MemAllocator &allocator, FwSizeType bytes)
Give the sequence representation a memory buffer.
void seqStartOut_out(FwIndexType portNum, const Fw::StringBase &filename)
Invoke output port seqStartOut.
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 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.
bool isConnected_seqStartOut_OutputPort(FwIndexType portNum)
void deallocateBuffer(Fw::MemAllocator &allocator)
Deallocate the buffer.
void setTimeBase(TimeBase timeBase)
void setTimeout(const U32 seconds)
Command successfully executed.
bool isConnected_seqDone_OutputPort(FwIndexType portNum)
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.
RateGroupDivider component implementation.
virtual void nextRecord(Record &record)=0
void log_ACTIVITY_HI_CS_SequenceComplete(const Fw::StringBase &fileName) const
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
Sequencer blocking state.
Fw::String & getStringFileName()
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