28 m_FPrimeSequence(*this),
29 m_sequence(&this->m_FPrimeSequence),
36 m_totalExecutedCount(0),
37 m_sequencesCompletedCount(0),
48 this->m_timeout = timeout;
54 this->m_sequence = &sequence;
70 FW_ASSERT(this->m_runMode == STOPPED, this->m_runMode);
71 if (not this->loadFile(fileName)) {
72 this->m_sequence->
clear();
90 void CmdSequencerComponentImpl::CS_RUN_cmdHandler(
96 if (not this->requireRunMode(STOPPED)) {
105 this->m_blockState = block.
e;
106 this->m_cmdSeq = cmdSeq;
107 this->m_opCode = opCode;
110 if (not this->loadFile(fileName)) {
115 this->m_executedCount = 0;
118 if (AUTO == this->m_stepMode) {
119 this->m_runMode = RUNNING;
123 this->performCmd_Step();
131 void CmdSequencerComponentImpl::CS_VALIDATE_cmdHandler(
137 if (!this->requireRunMode(STOPPED)) {
143 if (not this->loadFile(fileName)) {
149 this->m_sequence->
clear();
158 void CmdSequencerComponentImpl::seqRunIn_handler(
163 if (!this->requireRunMode(STOPPED)) {
170 if (filename !=
"") {
172 const bool status = this->loadFile(cmdStr);
186 this->m_executedCount = 0;
189 if (AUTO == this->m_stepMode) {
190 this->m_runMode = RUNNING;
194 this->performCmd_Step();
200 void CmdSequencerComponentImpl ::
204 if (RUNNING == this->m_runMode) {
205 this->performCmd_Cancel();
207 ++this->m_cancelCmdCount;
214 void CmdSequencerComponentImpl::CS_CANCEL_cmdHandler(
216 if (RUNNING == this->m_runMode) {
217 this->performCmd_Cancel();
219 ++this->m_cancelCmdCount;
227 void CmdSequencerComponentImpl::CS_JOIN_WAIT_cmdHandler(
231 if (m_runMode != RUNNING) {
236 m_join_waiting =
true;
248 bool CmdSequencerComponentImpl ::
251 const bool status = this->m_sequence->
loadFile(fileName);
255 ++this->m_loadCmdCount;
261 void CmdSequencerComponentImpl::error() {
262 ++this->m_errorCount;
266 void CmdSequencerComponentImpl::performCmd_Cancel() {
267 this->m_sequence->
reset();
268 this->m_runMode = STOPPED;
269 this->m_cmdTimer.clear();
270 this->m_cmdTimeoutTimer.clear();
271 this->m_executedCount = 0;
279 this->m_join_waiting =
false;
286 void CmdSequencerComponentImpl ::
287 cmdResponseIn_handler(
294 if (this->m_runMode == STOPPED) {
299 this->m_cmdTimeoutTimer.clear();
301 this->commandError(this->m_executedCount, opcode, response.
e);
302 this->performCmd_Cancel();
303 }
else if (this->m_runMode == RUNNING && this->m_stepMode == AUTO) {
305 this->commandComplete(opcode);
308 this->m_runMode = STOPPED;
309 this->sequenceComplete();
311 this->performCmd_Step();
315 this->commandComplete(opcode);
317 this->m_runMode = STOPPED;
318 this->sequenceComplete();
324 void CmdSequencerComponentImpl ::
330 if (this->m_cmdTimer.isExpiredAt(currTime)) {
332 this->m_cmdTimer.clear();
334 this->setCmdTimeout(currTime);
335 }
else if (this->m_cmdTimeoutTimer.isExpiredAt(this->getTime())) {
338 this->m_executedCount
341 this->performCmd_Cancel();
345 void CmdSequencerComponentImpl ::
354 if (!this->requireRunMode(STOPPED)) {
360 this->m_runMode = RUNNING;
361 this->performCmd_Step();
369 void CmdSequencerComponentImpl ::
372 if (this->requireRunMode(RUNNING)) {
373 this->performCmd_Step();
375 if (this->m_runMode != STOPPED) {
378 this->m_executedCount
387 void CmdSequencerComponentImpl ::
390 if (this->requireRunMode(STOPPED)) {
391 this->m_stepMode = AUTO;
399 void CmdSequencerComponentImpl ::
402 if (this->requireRunMode(STOPPED)) {
403 this->m_stepMode = MANUAL;
415 bool CmdSequencerComponentImpl::requireRunMode(RunMode mode) {
416 if (this->m_runMode == mode) {
424 void CmdSequencerComponentImpl ::
440 void CmdSequencerComponentImpl::performCmd_Step() {
444 const Sequence::Header& header = this->m_sequence->
getHeader();
451 this->m_runMode = STOPPED;
452 this->sequenceComplete();
455 this->performCmd_Step_RELATIVE(currentTime);
458 this->performCmd_Step_ABSOLUTE(currentTime);
465 void CmdSequencerComponentImpl::sequenceComplete() {
466 ++this->m_sequencesCompletedCount;
468 this->m_sequence->
clear();
471 this->m_executedCount = 0;
481 m_join_waiting =
false;
486 void CmdSequencerComponentImpl::commandComplete(
const U32 opcode) {
489 this->m_executedCount,
492 ++this->m_executedCount;
493 ++this->m_totalExecutedCount;
497 void CmdSequencerComponentImpl ::
498 performCmd_Step_RELATIVE(
Fw::Time& currentTime)
501 this->performCmd_Step_ABSOLUTE(currentTime);
504 void CmdSequencerComponentImpl ::
505 performCmd_Step_ABSOLUTE(
Fw::Time& currentTime)
507 if (currentTime >= this->m_record.
m_timeTag) {
509 this->setCmdTimeout(currentTime);
511 this->m_cmdTimer.set(this->m_record.
m_timeTag);
515 void CmdSequencerComponentImpl ::
525 void CmdSequencerComponentImpl ::
526 setCmdTimeout(
const Fw::Time ¤tTime)
529 if ((this->m_timeout > 0) and (AUTO == this->m_stepMode)) {
531 expTime.
add(this->m_timeout,0);
532 this->m_cmdTimeoutTimer.set(expTime);
PlatformIntType NATIVE_INT_TYPE
PlatformUIntType NATIVE_UINT_TYPE
Enum representing a command response.
@ EXECUTION_ERROR
Command had execution error.
@ OK
Command successfully executed.
static Time add(const Time &a, const Time &b)
void setTimeContext(FwTimeContextStoreType context)
void setTimeBase(TimeBase timeBase)
Sequencer blocking state.
Auto-generated base for CmdSequencer component.
void log_WARNING_HI_CS_JoinWaitingNotComplete()
bool isConnected_seqStartOut_OutputPort(FwIndexType portNum)
void log_ACTIVITY_HI_CS_CmdStepped(const Fw::StringBase &filename, U32 command)
void tlmWrite_CS_CancelCommands(U32 arg, Fw::Time _tlmTime=Fw::Time())
void seqDone_out(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Invoke output port seqDone.
void tlmWrite_CS_CommandsExecuted(U32 arg, Fw::Time _tlmTime=Fw::Time())
void log_WARNING_HI_CS_InvalidMode()
void seqStartOut_out(FwIndexType portNum, const Fw::StringBase &filename)
Invoke output port seqStartOut.
void log_ACTIVITY_LO_CS_CommandComplete(const Fw::StringBase &fileName, U32 recordNumber, U32 opCode)
bool isConnected_seqDone_OutputPort(FwIndexType portNum)
void log_ACTIVITY_HI_CS_SequenceComplete(const Fw::StringBase &fileName)
void log_WARNING_HI_CS_SequenceTimeout(const Fw::StringBase &filename, U32 command)
void tlmWrite_CS_Errors(U32 arg, Fw::Time _tlmTime=Fw::Time())
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
void log_ACTIVITY_HI_CS_ModeSwitched(Svc::CmdSequencer_SeqMode mode)
void log_ACTIVITY_HI_CS_SequenceCanceled(const Fw::StringBase &fileName)
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
void log_ACTIVITY_HI_CS_PortSequenceStarted(const Fw::StringBase &filename)
void log_ACTIVITY_HI_CS_SequenceValid(const Fw::StringBase &filename)
void comCmdOut_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port comCmdOut.
void log_WARNING_LO_CS_NoSequenceActive()
void log_ACTIVITY_LO_CS_SequenceLoaded(const Fw::StringBase &fileName)
void log_WARNING_HI_CS_UnexpectedCompletion(U32 opcode)
void log_ACTIVITY_HI_CS_JoinWaiting(const Fw::StringBase &filename, U32 recordNumber, U32 opCode)
void log_WARNING_HI_CS_CommandError(const Fw::StringBase &fileName, U32 recordNumber, U32 opCode, U32 errorStatus)
void log_ACTIVITY_HI_CS_CmdStarted(const Fw::StringBase &filename)
void tlmWrite_CS_LoadCommands(U32 arg, Fw::Time _tlmTime=Fw::Time())
void tlmWrite_CS_SequencesCompleted(U32 arg, Fw::Time _tlmTime=Fw::Time())
@ END_OF_SEQUENCE
end of sequence
Fw::ComBuffer m_command
The command.
Descriptor m_descriptor
The descriptor.
Fw::Time m_timeTag
The time tag. NOTE: timeBase and context not filled in.
A sequence with unspecified binary format.
void allocateBuffer(NATIVE_INT_TYPE identifier, Fw::MemAllocator &allocator, NATIVE_UINT_TYPE bytes)
Give the sequence representation a memory buffer.
Fw::String & getStringFileName()
virtual bool loadFile(const Fw::StringBase &fileName)=0
virtual void nextRecord(Record &record)=0
void deallocateBuffer(Fw::MemAllocator &allocator)
Deallocate the buffer.
virtual bool hasMoreRecords() const =0
const Header & getHeader() const
Get the sequence header.
Fw::LogStringArg & getLogFileName()
~CmdSequencerComponentImpl()
Destroy a CmdDispatcherComponentBase.
void deallocateBuffer(Fw::MemAllocator &allocator)
Return allocated buffer. Call during shutdown.
CmdSequencerComponentImpl(const char *compName)
Construct a CmdSequencer.
void setTimeout(const NATIVE_UINT_TYPE seconds)
void loadSequence(const Fw::StringBase &fileName)
void setSequenceFormat(Sequence &sequence)
void allocateBuffer(const NATIVE_INT_TYPE identifier, Fw::MemAllocator &allocator, const NATIVE_UINT_TYPE bytes)