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();
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();
173 void CmdSequencerComponentImpl ::seqCancelIn_handler(
const FwIndexType portNum) {
174 if (RUNNING == this->m_runMode) {
175 this->performCmd_Cancel();
177 ++this->m_cancelCmdCount;
184 void CmdSequencerComponentImpl::CS_CANCEL_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq) {
185 if (RUNNING == this->m_runMode) {
186 this->performCmd_Cancel();
188 ++this->m_cancelCmdCount;
196 void CmdSequencerComponentImpl::CS_JOIN_WAIT_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq) {
198 if (m_runMode != RUNNING) {
203 m_join_waiting =
true;
215 bool CmdSequencerComponentImpl ::loadFile(
const Fw::StringBase& fileName) {
216 const bool status = this->m_sequence->
loadFile(fileName);
220 ++this->m_loadCmdCount;
226 void CmdSequencerComponentImpl::error() {
227 ++this->m_errorCount;
231 void CmdSequencerComponentImpl::performCmd_Cancel() {
232 this->m_sequence->
reset();
233 this->m_runMode = STOPPED;
234 this->m_cmdTimer.clear();
235 this->m_cmdTimeoutTimer.clear();
236 this->m_executedCount = 0;
244 this->m_join_waiting =
false;
251 void CmdSequencerComponentImpl ::cmdResponseIn_handler(
FwIndexType portNum,
255 if (this->m_runMode == STOPPED) {
260 this->m_cmdTimeoutTimer.clear();
262 this->commandError(this->m_executedCount, opcode, response.
e);
263 this->performCmd_Cancel();
264 }
else if (this->m_runMode == RUNNING && this->m_stepMode == AUTO) {
266 this->commandComplete(opcode);
269 this->m_runMode = STOPPED;
270 this->sequenceComplete();
272 this->performCmd_Step();
276 this->commandComplete(opcode);
278 this->m_runMode = STOPPED;
279 this->sequenceComplete();
285 void CmdSequencerComponentImpl ::schedIn_handler(
FwIndexType portNum, U32 order) {
288 if (this->m_cmdTimer.isExpiredAt(currTime)) {
290 this->m_cmdTimer.clear();
292 this->setCmdTimeout(currTime);
293 }
else if (this->m_cmdTimeoutTimer.isExpiredAt(this->getTime())) {
296 this->performCmd_Cancel();
300 void CmdSequencerComponentImpl ::CS_START_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
307 if (!this->requireRunMode(STOPPED)) {
313 this->m_runMode = RUNNING;
314 this->performCmd_Step();
322 void CmdSequencerComponentImpl ::CS_STEP_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
323 if (this->requireRunMode(RUNNING)) {
324 this->performCmd_Step();
326 if (this->m_runMode != STOPPED) {
335 void CmdSequencerComponentImpl ::CS_AUTO_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
336 if (this->requireRunMode(STOPPED)) {
337 this->m_stepMode = AUTO;
345 void CmdSequencerComponentImpl ::CS_MANUAL_cmdHandler(
FwOpcodeType opcode, U32 cmdSeq) {
346 if (this->requireRunMode(STOPPED)) {
347 this->m_stepMode = MANUAL;
359 bool CmdSequencerComponentImpl::requireRunMode(RunMode mode) {
360 if (this->m_runMode == mode) {
368 void CmdSequencerComponentImpl ::commandError(
const U32 number,
const FwOpcodeType opCode,
const U32 error) {
373 void CmdSequencerComponentImpl::performCmd_Step() {
376 const Sequence::Header& header = this->m_sequence->
getHeader();
383 this->m_runMode = STOPPED;
384 this->sequenceComplete();
387 this->performCmd_Step_RELATIVE(currentTime);
390 this->performCmd_Step_ABSOLUTE(currentTime);
397 void CmdSequencerComponentImpl::sequenceComplete() {
398 ++this->m_sequencesCompletedCount;
400 this->m_sequence->
clear();
403 this->m_executedCount = 0;
413 m_join_waiting =
false;
417 void CmdSequencerComponentImpl::commandComplete(
const FwOpcodeType opcode) {
419 ++this->m_executedCount;
420 ++this->m_totalExecutedCount;
424 void CmdSequencerComponentImpl ::performCmd_Step_RELATIVE(
Fw::Time& currentTime) {
426 this->performCmd_Step_ABSOLUTE(currentTime);
429 void CmdSequencerComponentImpl ::performCmd_Step_ABSOLUTE(
Fw::Time& currentTime) {
430 if (currentTime >= this->m_record.
m_timeTag) {
432 this->setCmdTimeout(currentTime);
434 this->m_cmdTimer.set(this->m_record.
m_timeTag);
438 void CmdSequencerComponentImpl ::pingIn_handler(
FwIndexType portNum,
445 void CmdSequencerComponentImpl ::setCmdTimeout(
const Fw::Time& currentTime) {
447 if ((this->m_timeout > 0) and (AUTO == this->m_stepMode)) {
449 expTime.
add(this->m_timeout, 0);
450 this->m_cmdTimeoutTimer.set(expTime);
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)
Command had execution error.
static Time add(const Time &a, const Time &b)
void deallocateBuffer(Fw::MemAllocator &allocator)
Return allocated buffer. Call during shutdown.
virtual bool loadFile(const Fw::StringBase &fileName)=0
Fw::LogStringArg & getLogFileName()
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 loadSequence(const Fw::StringBase &fileName)
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