15 CommandDispatcherComponentBase(name),
17 m_numCmdsDispatched(0),
20 memset(this->m_entryTable,0,
sizeof(this->m_entryTable));
21 memset(this->m_sequenceTracker,0,
sizeof(this->m_sequenceTracker));
31 CommandDispatcherComponentBase::init(queueDepth);
36 bool slotFound =
false;
38 if ((not this->m_entryTable[slot].used) and (not slotFound)) {
39 this->m_entryTable[slot].opcode = opCode;
40 this->m_entryTable[slot].port = portNum;
41 this->m_entryTable[slot].used =
true;
42 this->log_DIAGNOSTIC_OpCodeRegistered(opCode,portNum,slot);
44 }
else if ((this->m_entryTable[slot].used) &&
45 (this->m_entryTable[slot].opcode == opCode) &&
46 (this->m_entryTable[slot].port == portNum) &&
49 this->log_DIAGNOSTIC_OpCodeReregistered(opCode,portNum);
50 }
else if (this->m_entryTable[slot].used) {
51 FW_ASSERT(this->m_entryTable[slot].opcode != opCode, opCode);
57 void CommandDispatcherImpl::compCmdStat_handler(
NATIVE_INT_TYPE portNum,
FwOpcodeType opCode, U32 cmdSeq,
const Fw::CmdResponse &response) {
59 if (Fw::CmdResponse::OK == response.e) {
60 this->log_COMMAND_OpCodeCompleted(opCode);
62 this->m_numCmdErrors++;
63 this->tlmWrite_CommandErrors(this->m_numCmdErrors);
64 FW_ASSERT(response.e != Fw::CmdResponse::OK);
65 this->log_COMMAND_OpCodeError(opCode,response);
72 (this->m_sequenceTracker[pending].seq == cmdSeq) &&
73 (this->m_sequenceTracker[pending].used)
75 portToCall = this->m_sequenceTracker[pending].callerPort;
76 context = this->m_sequenceTracker[pending].context;
77 FW_ASSERT(opCode == this->m_sequenceTracker[pending].opCode);
78 FW_ASSERT(portToCall < this->getNum_seqCmdStatus_OutputPorts());
79 this->m_sequenceTracker[pending].used =
false;
84 if (portToCall != -1) {
86 if (this->isConnected_seqCmdStatus_OutputPort(portToCall)) {
87 this->seqCmdStatus_out(portToCall,opCode,context,response);
98 Fw::DeserialStatus serErr(
static_cast<Fw::DeserialStatus::t
>(stat));
99 this->log_WARNING_HI_MalformedCommand(serErr);
100 if (this->isConnected_seqCmdStatus_OutputPort(portNum)) {
101 this->seqCmdStatus_out(portNum,cmdPkt.
getOpCode(),context,Fw::CmdResponse::VALIDATION_ERROR);
108 bool entryFound =
false;
111 if ((this->m_entryTable[entry].used) and (cmdPkt.
getOpCode() == this->m_entryTable[entry].opcode)) {
116 if (entryFound and this->isConnected_compCmdSend_OutputPort(this->m_entryTable[entry].port)) {
118 if (this->isConnected_seqCmdStatus_OutputPort(portNum)) {
119 bool pendingFound =
false;
122 if (not this->m_sequenceTracker[pending].used) {
124 this->m_sequenceTracker[pending].used =
true;
125 this->m_sequenceTracker[pending].opCode = cmdPkt.
getOpCode();
126 this->m_sequenceTracker[pending].seq = this->m_seq;
127 this->m_sequenceTracker[pending].context = context;
128 this->m_sequenceTracker[pending].callerPort = portNum;
134 if (not pendingFound) {
135 this->log_WARNING_HI_TooManyCommands(cmdPkt.
getOpCode());
136 if (this->isConnected_seqCmdStatus_OutputPort(portNum)) {
137 this->seqCmdStatus_out(portNum,cmdPkt.
getOpCode(),context,Fw::CmdResponse::EXECUTION_ERROR);
143 this->compCmdSend_out(this->m_entryTable[entry].port,cmdPkt.
getOpCode(),this->m_seq,cmdPkt.
getArgBuffer());
145 this->log_COMMAND_OpCodeDispatched(cmdPkt.
getOpCode(),this->m_entryTable[entry].port);
148 this->m_numCmdsDispatched++;
150 this->tlmWrite_CommandsDispatched(this->m_numCmdsDispatched);
152 this->log_WARNING_HI_InvalidCommand(cmdPkt.
getOpCode());
153 this->m_numCmdErrors++;
155 if (this->isConnected_seqCmdStatus_OutputPort(portNum)) {
156 this->seqCmdStatus_out(portNum,cmdPkt.
getOpCode(),context,Fw::CmdResponse::INVALID_OPCODE);
158 this->tlmWrite_CommandErrors(this->m_numCmdErrors);
165 void CommandDispatcherImpl::CMD_NO_OP_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq) {
168 this->log_ACTIVITY_HI_NoOpReceived();
169 this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
175 this->log_ACTIVITY_HI_NoOpStringReceived(msg);
176 this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
179 void CommandDispatcherImpl::CMD_TEST_CMD_1_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq, I32 arg1,
F32 arg2,
U8 arg3) {
180 this->log_ACTIVITY_HI_TestCmd1Args(arg1,arg2,arg3);
181 this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
184 void CommandDispatcherImpl::CMD_CLEAR_TRACKING_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq) {
187 this->m_sequenceTracker[entry].used =
false;
189 this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
192 void CommandDispatcherImpl::pingIn_handler(
NATIVE_INT_TYPE portNum, U32 key) {
194 this->pingOut_out(0,key);
PlatformIntType NATIVE_INT_TYPE
float F32
32-bit floating point
uint8_t U8
8-bit unsigned integer
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Component responsible for dispatching incoming commands to registered components.
@ CMD_DISPATCHER_SEQUENCER_TABLE_SIZE
FwOpcodeType getOpCode() const
SerializeStatus deserialize(SerializeBufferBase &buffer)
deserialize to contents
CmdArgBuffer & getArgBuffer()
const char * toChar() const
void init(NATIVE_INT_TYPE queueDepth, NATIVE_INT_TYPE instance)
Component initialization routine.
CommandDispatcherImpl(const char *name)
Command Dispatcher constructor.
virtual ~CommandDispatcherImpl()
Component destructor.
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.