25 m_FPrimeSequence(*this),
26 m_sequence(&this->m_FPrimeSequence),
33 m_totalExecutedCount(0),
34 m_sequencesCompletedCount(0),
39 m_join_waiting(false) {}
42 this->m_timeout = timeout;
46 this->m_sequence = &sequence;
56 FW_ASSERT(this->m_runMode == STOPPED, this->m_runMode);
57 if (not this->loadFile(fileName)) {
58 this->m_sequence->
clear();
72 void CmdSequencerComponentImpl::CS_RUN_cmdHandler(
FwOpcodeType opCode,
76 if (not this->requireRunMode(STOPPED)) {
85 this->m_blockState = block.
e;
86 this->m_cmdSeq = cmdSeq;
87 this->m_opCode = opCode;
90 if (not this->loadFile(fileName)) {
95 this->m_executedCount = 0;
98 if (AUTO == this->m_stepMode) {
99 this->m_runMode = RUNNING;
106 this->performCmd_Step();
114 void CmdSequencerComponentImpl::CS_VALIDATE_cmdHandler(
FwOpcodeType opCode,
117 if (!this->requireRunMode(STOPPED)) {
123 if (not this->loadFile(fileName)) {
129 this->m_sequence->
clear();
137 void CmdSequencerComponentImpl::doSequenceRun(
const Fw::StringBase& filename) {
138 if (!this->requireRunMode(STOPPED)) {
145 if (filename !=
"") {
147 const bool status = this->loadFile(cmdStr);
160 this->m_executedCount = 0;
163 if (AUTO == this->m_stepMode) {
164 this->m_runMode = RUNNING;
171 this->performCmd_Step();
177 void CmdSequencerComponentImpl::seqRunIn_handler(
FwIndexType portNum,
181 this->doSequenceRun(filename);
185 this->doSequenceRun(file_name);
188 void CmdSequencerComponentImpl ::seqCancelIn_handler(
const FwIndexType portNum) {
189 if (RUNNING == this->m_runMode) {
190 this->performCmd_Cancel();
192 ++this->m_cancelCmdCount;
199 void CmdSequencerComponentImpl::CS_CANCEL_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq) {
200 if (RUNNING == this->m_runMode) {
201 this->performCmd_Cancel();
203 ++this->m_cancelCmdCount;
211 void CmdSequencerComponentImpl::CS_JOIN_WAIT_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq) {
213 if (m_runMode != RUNNING) {
218 m_join_waiting =
true;
231 const bool status = this->m_sequence->
loadFile(fileName);
235 ++this->m_loadCmdCount;
246 this->m_sequence->
clear();
251 void CmdSequencerComponentImpl::error() {
252 ++this->m_errorCount;
256 void CmdSequencerComponentImpl::performCmd_Cancel() {
257 this->m_sequence->
reset();
258 this->m_runMode = STOPPED;
259 this->m_cmdTimer.clear();
260 this->m_cmdTimeoutTimer.clear();
261 this->m_executedCount = 0;
269 this->m_join_waiting =
false;
276 void CmdSequencerComponentImpl ::cmdResponseIn_handler(
FwIndexType portNum,
280 if (this->m_runMode == STOPPED) {
285 this->m_cmdTimeoutTimer.clear();
287 this->commandError(this->m_executedCount, opcode, response.
e);
288 this->performCmd_Cancel();
289 }
else if (this->m_runMode == RUNNING && this->m_stepMode == AUTO) {
291 this->commandComplete(opcode);
294 this->m_runMode = STOPPED;
295 this->sequenceComplete();
297 this->performCmd_Step();
301 this->commandComplete(opcode);
303 this->m_runMode = STOPPED;
304 this->sequenceComplete();
310 void CmdSequencerComponentImpl ::schedIn_handler(
FwIndexType portNum, U32 order) {
313 if (this->m_cmdTimer.isExpiredAt(currTime)) {
315 this->m_cmdTimer.clear();
317 this->setCmdTimeout(currTime);
318 }
else if (this->m_cmdTimeoutTimer.isExpiredAt(this->getTime())) {
321 this->performCmd_Cancel();
325 void CmdSequencerComponentImpl ::CS_START_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
332 if (!this->requireRunMode(STOPPED)) {
338 this->m_runMode = RUNNING;
339 this->performCmd_Step();
349 void CmdSequencerComponentImpl ::CS_STEP_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
350 if (this->requireRunMode(RUNNING)) {
351 this->performCmd_Step();
353 if (this->m_runMode != STOPPED) {
362 void CmdSequencerComponentImpl ::CS_AUTO_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
363 if (this->requireRunMode(STOPPED)) {
364 this->m_stepMode = AUTO;
372 void CmdSequencerComponentImpl ::CS_MANUAL_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
373 if (this->requireRunMode(STOPPED)) {
374 this->m_stepMode = MANUAL;
386 bool CmdSequencerComponentImpl::requireRunMode(RunMode mode) {
387 if (this->m_runMode == mode) {
395 void CmdSequencerComponentImpl ::commandError(
const U32 number,
const FwOpcodeType opCode,
const U32 error) {
400 void CmdSequencerComponentImpl::performCmd_Step() {
403 const Sequence::Header& header = this->m_sequence->
getHeader();
410 this->m_runMode = STOPPED;
411 this->sequenceComplete();
414 this->performCmd_Step_RELATIVE(currentTime);
417 this->performCmd_Step_ABSOLUTE(currentTime);
424 void CmdSequencerComponentImpl::sequenceComplete() {
425 ++this->m_sequencesCompletedCount;
427 this->m_sequence->
clear();
430 this->m_executedCount = 0;
440 m_join_waiting =
false;
444 void CmdSequencerComponentImpl::commandComplete(
const FwOpcodeType opcode) {
446 ++this->m_executedCount;
447 ++this->m_totalExecutedCount;
451 void CmdSequencerComponentImpl ::performCmd_Step_RELATIVE(
Fw::Time& currentTime) {
453 this->performCmd_Step_ABSOLUTE(currentTime);
456 void CmdSequencerComponentImpl ::performCmd_Step_ABSOLUTE(
Fw::Time& currentTime) {
457 if (currentTime >= this->m_record.
m_timeTag) {
459 this->setCmdTimeout(currentTime);
461 this->m_cmdTimer.set(this->m_record.
m_timeTag);
465 void CmdSequencerComponentImpl ::pingIn_handler(
FwIndexType portNum,
472 void CmdSequencerComponentImpl ::setCmdTimeout(
const Fw::Time& currentTime) {
474 if ((this->m_timeout > 0) and (AUTO == this->m_stepMode)) {
476 expTime.
add(this->m_timeout, 0);
477 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.
Sequencer blocking state.
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
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
enum T e
The raw enum value.
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