28 m_FPrimeSequence(*this),
29 m_sequence(&this->m_FPrimeSequence),
36 m_totalExecutedCount(0),
37 m_sequencesCompletedCount(0),
53 this->m_timeout = timeout;
59 this->m_sequence = &sequence;
75 FW_ASSERT(this->m_runMode == STOPPED, this->m_runMode);
76 if (not this->loadFile(fileName)) {
77 this->m_sequence->
clear();
95 void CmdSequencerComponentImpl::CS_RUN_cmdHandler(
101 if (not this->requireRunMode(STOPPED)) {
102 if (m_join_waiting) {
110 this->m_blockState = block.
e;
111 this->m_cmdSeq = cmdSeq;
112 this->m_opCode = opCode;
115 if (not this->loadFile(fileName)) {
120 this->m_executedCount = 0;
123 if (AUTO == this->m_stepMode) {
124 this->m_runMode = RUNNING;
125 this->performCmd_Step();
133 void CmdSequencerComponentImpl::CS_VALIDATE_cmdHandler(
139 if (!this->requireRunMode(STOPPED)) {
145 if (not this->loadFile(fileName)) {
151 this->m_sequence->
clear();
160 void CmdSequencerComponentImpl::seqRunIn_handler(
165 if (!this->requireRunMode(STOPPED)) {
172 if (filename !=
"") {
174 const bool status = this->loadFile(cmdStr);
188 this->m_executedCount = 0;
191 if (AUTO == this->m_stepMode) {
192 this->m_runMode = RUNNING;
193 this->performCmd_Step();
199 void CmdSequencerComponentImpl ::
203 if (RUNNING == this->m_runMode) {
204 this->performCmd_Cancel();
206 ++this->m_cancelCmdCount;
213 void CmdSequencerComponentImpl::CS_CANCEL_cmdHandler(
215 if (RUNNING == this->m_runMode) {
216 this->performCmd_Cancel();
218 ++this->m_cancelCmdCount;
226 void CmdSequencerComponentImpl::CS_JOIN_WAIT_cmdHandler(
230 if (m_runMode != RUNNING) {
235 m_join_waiting =
true;
247 bool CmdSequencerComponentImpl ::
250 const bool status = this->m_sequence->
loadFile(fileName);
254 ++this->m_loadCmdCount;
260 void CmdSequencerComponentImpl::error() {
261 ++this->m_errorCount;
265 void CmdSequencerComponentImpl::performCmd_Cancel() {
266 this->m_sequence->
reset();
267 this->m_runMode = STOPPED;
268 this->m_cmdTimer.clear();
269 this->m_cmdTimeoutTimer.clear();
270 this->m_executedCount = 0;
278 this->m_join_waiting =
false;
285 void CmdSequencerComponentImpl ::
286 cmdResponseIn_handler(
293 if (this->m_runMode == STOPPED) {
298 this->m_cmdTimeoutTimer.clear();
300 this->commandError(this->m_executedCount, opcode, response.
e);
301 this->performCmd_Cancel();
302 }
else if (this->m_runMode == RUNNING && this->m_stepMode == AUTO) {
304 this->commandComplete(opcode);
307 this->m_runMode = STOPPED;
308 this->sequenceComplete();
310 this->performCmd_Step();
314 this->commandComplete(opcode);
316 this->m_runMode = STOPPED;
317 this->sequenceComplete();
323 void CmdSequencerComponentImpl ::
329 if (this->m_cmdTimer.isExpiredAt(currTime)) {
331 this->m_cmdTimer.clear();
333 this->setCmdTimeout(currTime);
334 }
else if (this->m_cmdTimeoutTimer.isExpiredAt(this->getTime())) {
337 this->m_executedCount
340 this->performCmd_Cancel();
344 void CmdSequencerComponentImpl ::
353 if (!this->requireRunMode(STOPPED)) {
359 this->m_runMode = RUNNING;
360 this->performCmd_Step();
365 void CmdSequencerComponentImpl ::
368 if (this->requireRunMode(RUNNING)) {
369 this->performCmd_Step();
371 if (this->m_runMode != STOPPED) {
374 this->m_executedCount
383 void CmdSequencerComponentImpl ::
386 if (this->requireRunMode(STOPPED)) {
387 this->m_stepMode = AUTO;
395 void CmdSequencerComponentImpl ::
398 if (this->requireRunMode(STOPPED)) {
399 this->m_stepMode = MANUAL;
411 bool CmdSequencerComponentImpl::requireRunMode(RunMode mode) {
412 if (this->m_runMode == mode) {
420 void CmdSequencerComponentImpl ::
436 void CmdSequencerComponentImpl::performCmd_Step() {
440 const Sequence::Header& header = this->m_sequence->
getHeader();
447 this->m_runMode = STOPPED;
448 this->sequenceComplete();
451 this->performCmd_Step_RELATIVE(currentTime);
454 this->performCmd_Step_ABSOLUTE(currentTime);
461 void CmdSequencerComponentImpl::sequenceComplete() {
462 ++this->m_sequencesCompletedCount;
464 this->m_sequence->
clear();
467 this->m_executedCount = 0;
477 m_join_waiting =
false;
482 void CmdSequencerComponentImpl::commandComplete(
const U32 opcode) {
485 this->m_executedCount,
488 ++this->m_executedCount;
489 ++this->m_totalExecutedCount;
493 void CmdSequencerComponentImpl ::
494 performCmd_Step_RELATIVE(
Fw::Time& currentTime)
497 this->performCmd_Step_ABSOLUTE(currentTime);
500 void CmdSequencerComponentImpl ::
501 performCmd_Step_ABSOLUTE(
Fw::Time& currentTime)
503 if (currentTime >= this->m_record.
m_timeTag) {
505 this->setCmdTimeout(currentTime);
507 this->m_cmdTimer.set(this->m_record.
m_timeTag);
511 void CmdSequencerComponentImpl ::
521 void CmdSequencerComponentImpl ::
522 setCmdTimeout(
const Fw::Time ¤tTime)
525 if ((this->m_timeout > 0) and (AUTO == this->m_stepMode)) {
527 expTime.
add(this->m_timeout,0);
528 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.
void init()
Object initializer.
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()
void comCmdOut_out(NATIVE_INT_TYPE portNum, Fw::ComBuffer &data, U32 context)
Invoke output port comCmdOut.
void log_WARNING_HI_CS_CommandError(const Fw::LogStringArg &fileName, U32 recordNumber, U32 opCode, U32 errorStatus)
void tlmWrite_CS_CancelCommands(U32 arg, Fw::Time _tlmTime=Fw::Time())
void log_ACTIVITY_HI_CS_SequenceComplete(const Fw::LogStringArg &fileName)
bool isConnected_seqDone_OutputPort(NATIVE_INT_TYPE portNum)
void tlmWrite_CS_CommandsExecuted(U32 arg, Fw::Time _tlmTime=Fw::Time())
void log_WARNING_HI_CS_InvalidMode()
void log_ACTIVITY_LO_CS_SequenceLoaded(const Fw::LogStringArg &fileName)
void seqDone_out(NATIVE_INT_TYPE portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Invoke output port seqDone.
void tlmWrite_CS_Errors(U32 arg, Fw::Time _tlmTime=Fw::Time())
void log_ACTIVITY_HI_CS_ModeSwitched(Svc::CmdSequencer_SeqMode mode)
void pingOut_out(NATIVE_INT_TYPE portNum, U32 key)
Invoke output port pingOut.
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
void log_ACTIVITY_LO_CS_CommandComplete(const Fw::LogStringArg &fileName, U32 recordNumber, U32 opCode)
void log_WARNING_HI_CS_SequenceTimeout(const Fw::LogStringArg &filename, U32 command)
void log_ACTIVITY_HI_CS_SequenceCanceled(const Fw::LogStringArg &fileName)
void log_ACTIVITY_HI_CS_CmdStarted(const Fw::LogStringArg &filename)
void log_ACTIVITY_HI_CS_PortSequenceStarted(const Fw::LogStringArg &filename)
void log_WARNING_LO_CS_NoSequenceActive()
void log_WARNING_HI_CS_UnexpectedCompletion(U32 opcode)
void log_ACTIVITY_HI_CS_CmdStepped(const Fw::LogStringArg &filename, U32 command)
void log_ACTIVITY_HI_CS_JoinWaiting(const Fw::LogStringArg &filename, U32 recordNumber, U32 opCode)
void tlmWrite_CS_LoadCommands(U32 arg, Fw::Time _tlmTime=Fw::Time())
void log_ACTIVITY_HI_CS_SequenceValid(const Fw::LogStringArg &filename)
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.
virtual void nextRecord(Record &record)=0
void deallocateBuffer(Fw::MemAllocator &allocator)
Deallocate the buffer.
virtual bool hasMoreRecords() const =0
virtual bool loadFile(const Fw::CmdStringArg &fileName)=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 setSequenceFormat(Sequence &sequence)
void loadSequence(const Fw::String &fileName)
void allocateBuffer(const NATIVE_INT_TYPE identifier, Fw::MemAllocator &allocator, const NATIVE_UINT_TYPE bytes)