28 m_FPrimeSequence(*this),
29 m_sequence(&this->m_FPrimeSequence),
36 m_totalExecutedCount(0),
37 m_sequencesCompletedCount(0),
48 this->m_timeout = timeout;
51 void CmdSequencerComponentImpl ::
52 setSequenceFormat(
Sequence& sequence)
54 this->m_sequence = &sequence;
57 void CmdSequencerComponentImpl ::
67 void CmdSequencerComponentImpl ::
70 FW_ASSERT(this->m_runMode == STOPPED, this->m_runMode);
71 if (not this->loadFile(fileName)) {
72 this->m_sequence->clear();
76 void CmdSequencerComponentImpl ::
79 this->m_sequence->deallocateBuffer(allocator);
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();
206 this->log_ACTIVITY_HI_CS_SequenceCanceled(this->m_sequence->getLogFileName());
207 ++this->m_cancelCmdCount;
208 this->tlmWrite_CS_CancelCommands(this->m_cancelCmdCount);
210 this->log_WARNING_LO_CS_NoSequenceActive();
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);
254 this->log_ACTIVITY_LO_CS_SequenceLoaded(logFileName);
255 ++this->m_loadCmdCount;
256 this->tlmWrite_CS_LoadCommands(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) {
296 this->log_WARNING_HI_CS_UnexpectedCompletion(opcode);
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);
306 if (not this->m_sequence->hasMoreRecords()) {
308 this->m_runMode = STOPPED;
309 this->sequenceComplete();
311 this->performCmd_Step();
315 this->commandComplete(opcode);
316 if (not this->m_sequence->hasMoreRecords()) {
317 this->m_runMode = STOPPED;
318 this->sequenceComplete();
324 void CmdSequencerComponentImpl ::
328 Fw::Time currTime = this->getTime();
330 if (this->m_cmdTimer.isExpiredAt(currTime)) {
331 this->comCmdOut_out(0, m_record.m_command, 0);
332 this->m_cmdTimer.clear();
334 this->setCmdTimeout(currTime);
335 }
else if (this->m_cmdTimeoutTimer.isExpiredAt(this->getTime())) {
336 this->log_WARNING_HI_CS_SequenceTimeout(
337 m_sequence->getLogFileName(),
338 this->m_executedCount
341 this->performCmd_Cancel();
345 void CmdSequencerComponentImpl ::
348 if (not this->m_sequence->hasMoreRecords()) {
350 this->log_WARNING_LO_CS_NoSequenceActive();
354 if (!this->requireRunMode(STOPPED)) {
360 this->m_runMode = RUNNING;
361 this->performCmd_Step();
362 this->log_ACTIVITY_HI_CS_CmdStarted(this->m_sequence->getLogFileName());
363 if(this->isConnected_seqStartOut_OutputPort(0)) {
364 this->seqStartOut_out(0, this->m_sequence->getStringFileName());
369 void CmdSequencerComponentImpl ::
372 if (this->requireRunMode(RUNNING)) {
373 this->performCmd_Step();
375 if (this->m_runMode != STOPPED) {
376 this->log_ACTIVITY_HI_CS_CmdStepped(
377 this->m_sequence->getLogFileName(),
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 ::
431 this->log_WARNING_HI_CS_CommandError(
432 this->m_sequence->getLogFileName(),
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) {
508 this->comCmdOut_out(0, m_record.m_command, 0);
509 this->setCmdTimeout(currentTime);
511 this->m_cmdTimer.set(this->m_record.m_timeTag);
515 void CmdSequencerComponentImpl ::
522 this->pingOut_out(0,key);
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 set(U32 seconds, U32 useconds)
void setTimeContext(FwTimeContextStoreType context)
void setTimeBase(TimeBase timeBase)
Sequencer blocking state.
Auto-generated base for CmdSequencer component.
bool isConnected_seqStartOut_OutputPort(FwIndexType portNum)
void tlmWrite_CS_CancelCommands(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void log_WARNING_LO_CS_NoSequenceActive() const
void log_ACTIVITY_HI_CS_SequenceComplete(const Fw::StringBase &fileName) const
void log_WARNING_HI_CS_JoinWaitingNotComplete() const
void seqDone_out(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Invoke output port seqDone.
void log_ACTIVITY_HI_CS_SequenceCanceled(const Fw::StringBase &fileName) const
void log_WARNING_HI_CS_InvalidMode() const
void seqStartOut_out(FwIndexType portNum, const Fw::StringBase &filename)
Invoke output port seqStartOut.
bool isConnected_seqDone_OutputPort(FwIndexType portNum)
void tlmWrite_CS_Errors(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void log_ACTIVITY_LO_CS_CommandComplete(const Fw::StringBase &fileName, U32 recordNumber, U32 opCode) const
void log_ACTIVITY_HI_CS_SequenceValid(const Fw::StringBase &filename) const
void log_ACTIVITY_HI_CS_JoinWaiting(const Fw::StringBase &filename, U32 recordNumber, U32 opCode) const
void tlmWrite_CS_SequencesCompleted(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
void log_ACTIVITY_HI_CS_PortSequenceStarted(const Fw::StringBase &filename) const
void tlmWrite_CS_CommandsExecuted(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
@ END_OF_SEQUENCE
end of sequence
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 void nextRecord(Record &record)=0
virtual bool hasMoreRecords() const =0
const Header & getHeader() const
Get the sequence header.
Fw::LogStringArg & getLogFileName()
~CmdSequencerComponentImpl()
Destroy a CmdDispatcherComponentBase.
CmdSequencerComponentImpl(const char *compName)
Construct a CmdSequencer.
void setTimeout(const NATIVE_UINT_TYPE seconds)