F´ Flight Software - C/C++ Documentation devel
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CommandDispatcherComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title CommandDispatcherComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for CommandDispatcher component base class
5// ======================================================================
6
7#include <cstdio>
8
10#include "Fw/Types/Assert.hpp"
11#if FW_ENABLE_TEXT_LOGGING
12#include "Fw/Types/String.hpp"
13#endif
14
15namespace Svc {
16
17 namespace {
18 enum MsgTypeEnum {
19 COMMANDDISPATCHER_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
20 COMPCMDSTAT_CMDRESPONSE,
21 PINGIN_PING,
22 SEQCMDBUFF_COM,
23 CMD_CMD_NO_OP,
24 CMD_CMD_NO_OP_STRING,
25 CMD_CMD_TEST_CMD_1,
26 CMD_CMD_CLEAR_TRACKING,
27 };
28
29 // Get the max size by constructing a union of the async input, command, and
30 // internal port serialization sizes
31 union BuffUnion {
34 BYTE seqCmdBuffPortSize[Fw::InputComPort::SERIALIZED_SIZE];
36 };
37
38 // Define a message buffer class large enough to handle all the
39 // asynchronous inputs to the component
40 class ComponentIpcSerializableBuffer :
42 {
43
44 public:
45
46 enum {
47 // Max. message size = size of data + message id + port
48 SERIALIZATION_SIZE =
49 sizeof(BuffUnion) +
50 sizeof(NATIVE_INT_TYPE) +
51 sizeof(NATIVE_INT_TYPE)
52 };
53
54 NATIVE_UINT_TYPE getBuffCapacity() const {
55 return sizeof(m_buff);
56 }
57
58 U8* getBuffAddr() {
59 return m_buff;
60 }
61
62 const U8* getBuffAddr() const {
63 return m_buff;
64 }
65
66 private:
67 // Should be the max of all the input ports serialized sizes...
68 U8 m_buff[SERIALIZATION_SIZE];
69
70 };
71 }
72
73 // ----------------------------------------------------------------------
74 // Component initialization
75 // ----------------------------------------------------------------------
76
77 void CommandDispatcherComponentBase ::
78 init(
79 NATIVE_INT_TYPE queueDepth,
80 NATIVE_INT_TYPE instance
81 )
82 {
83 // Initialize base class
85
86 // Connect input port CmdDisp
87 for (
88 PlatformIntType port = 0;
89 port < static_cast<PlatformIntType>(this->getNum_CmdDisp_InputPorts());
90 port++
91 ) {
92 this->m_CmdDisp_InputPort[port].init();
93 this->m_CmdDisp_InputPort[port].addCallComp(
94 this,
95 m_p_CmdDisp_in
96 );
97 this->m_CmdDisp_InputPort[port].setPortNum(port);
98
99#if FW_OBJECT_NAMES == 1
100 // The port name consists of this->m_objName and some extra info.
101 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
102 // However, the compiler may assume that this->m_objName fills
103 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
104 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
105 // bytes to cover the extra info.
106 char portName[2*FW_OBJ_NAME_MAX_SIZE];
107 (void) snprintf(
108 portName,
109 sizeof(portName),
110 "%s_CmdDisp_InputPort[%" PRI_PlatformIntType "]",
111 this->m_objName,
112 port
113 );
114 this->m_CmdDisp_InputPort[port].setObjName(portName);
115#endif
116 }
117
118 // Connect input port compCmdReg
119 for (
120 PlatformIntType port = 0;
121 port < static_cast<PlatformIntType>(this->getNum_compCmdReg_InputPorts());
122 port++
123 ) {
124 this->m_compCmdReg_InputPort[port].init();
125 this->m_compCmdReg_InputPort[port].addCallComp(
126 this,
127 m_p_compCmdReg_in
128 );
129 this->m_compCmdReg_InputPort[port].setPortNum(port);
130
131#if FW_OBJECT_NAMES == 1
132 // The port name consists of this->m_objName and some extra info.
133 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
134 // However, the compiler may assume that this->m_objName fills
135 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
136 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
137 // bytes to cover the extra info.
138 char portName[2*FW_OBJ_NAME_MAX_SIZE];
139 (void) snprintf(
140 portName,
141 sizeof(portName),
142 "%s_compCmdReg_InputPort[%" PRI_PlatformIntType "]",
143 this->m_objName,
144 port
145 );
146 this->m_compCmdReg_InputPort[port].setObjName(portName);
147#endif
148 }
149
150 // Connect input port compCmdStat
151 for (
152 PlatformIntType port = 0;
153 port < static_cast<PlatformIntType>(this->getNum_compCmdStat_InputPorts());
154 port++
155 ) {
156 this->m_compCmdStat_InputPort[port].init();
157 this->m_compCmdStat_InputPort[port].addCallComp(
158 this,
159 m_p_compCmdStat_in
160 );
161 this->m_compCmdStat_InputPort[port].setPortNum(port);
162
163#if FW_OBJECT_NAMES == 1
164 // The port name consists of this->m_objName and some extra info.
165 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
166 // However, the compiler may assume that this->m_objName fills
167 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
168 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
169 // bytes to cover the extra info.
170 char portName[2*FW_OBJ_NAME_MAX_SIZE];
171 (void) snprintf(
172 portName,
173 sizeof(portName),
174 "%s_compCmdStat_InputPort[%" PRI_PlatformIntType "]",
175 this->m_objName,
176 port
177 );
178 this->m_compCmdStat_InputPort[port].setObjName(portName);
179#endif
180 }
181
182 // Connect input port pingIn
183 for (
184 PlatformIntType port = 0;
185 port < static_cast<PlatformIntType>(this->getNum_pingIn_InputPorts());
186 port++
187 ) {
188 this->m_pingIn_InputPort[port].init();
189 this->m_pingIn_InputPort[port].addCallComp(
190 this,
191 m_p_pingIn_in
192 );
193 this->m_pingIn_InputPort[port].setPortNum(port);
194
195#if FW_OBJECT_NAMES == 1
196 // The port name consists of this->m_objName and some extra info.
197 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
198 // However, the compiler may assume that this->m_objName fills
199 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
200 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
201 // bytes to cover the extra info.
202 char portName[2*FW_OBJ_NAME_MAX_SIZE];
203 (void) snprintf(
204 portName,
205 sizeof(portName),
206 "%s_pingIn_InputPort[%" PRI_PlatformIntType "]",
207 this->m_objName,
208 port
209 );
210 this->m_pingIn_InputPort[port].setObjName(portName);
211#endif
212 }
213
214 // Connect input port seqCmdBuff
215 for (
216 PlatformIntType port = 0;
217 port < static_cast<PlatformIntType>(this->getNum_seqCmdBuff_InputPorts());
218 port++
219 ) {
220 this->m_seqCmdBuff_InputPort[port].init();
221 this->m_seqCmdBuff_InputPort[port].addCallComp(
222 this,
223 m_p_seqCmdBuff_in
224 );
225 this->m_seqCmdBuff_InputPort[port].setPortNum(port);
226
227#if FW_OBJECT_NAMES == 1
228 // The port name consists of this->m_objName and some extra info.
229 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
230 // However, the compiler may assume that this->m_objName fills
231 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
232 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
233 // bytes to cover the extra info.
234 char portName[2*FW_OBJ_NAME_MAX_SIZE];
235 (void) snprintf(
236 portName,
237 sizeof(portName),
238 "%s_seqCmdBuff_InputPort[%" PRI_PlatformIntType "]",
239 this->m_objName,
240 port
241 );
242 this->m_seqCmdBuff_InputPort[port].setObjName(portName);
243#endif
244 }
245
246 // Connect output port CmdReg
247 for (
248 PlatformIntType port = 0;
249 port < static_cast<PlatformIntType>(this->getNum_CmdReg_OutputPorts());
250 port++
251 ) {
252 this->m_CmdReg_OutputPort[port].init();
253
254#if FW_OBJECT_NAMES == 1
255 // The port name consists of this->m_objName and some extra info.
256 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
257 // However, the compiler may assume that this->m_objName fills
258 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
259 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
260 // bytes to cover the extra info.
261 char portName[2*FW_OBJ_NAME_MAX_SIZE];
262 (void) snprintf(
263 portName,
264 sizeof(portName),
265 "%s_CmdReg_OutputPort[%" PRI_PlatformIntType "]",
266 this->m_objName,
267 port
268 );
269 this->m_CmdReg_OutputPort[port].setObjName(portName);
270#endif
271 }
272
273 // Connect output port CmdStatus
274 for (
275 PlatformIntType port = 0;
276 port < static_cast<PlatformIntType>(this->getNum_CmdStatus_OutputPorts());
277 port++
278 ) {
279 this->m_CmdStatus_OutputPort[port].init();
280
281#if FW_OBJECT_NAMES == 1
282 // The port name consists of this->m_objName and some extra info.
283 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
284 // However, the compiler may assume that this->m_objName fills
285 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
286 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
287 // bytes to cover the extra info.
288 char portName[2*FW_OBJ_NAME_MAX_SIZE];
289 (void) snprintf(
290 portName,
291 sizeof(portName),
292 "%s_CmdStatus_OutputPort[%" PRI_PlatformIntType "]",
293 this->m_objName,
294 port
295 );
296 this->m_CmdStatus_OutputPort[port].setObjName(portName);
297#endif
298 }
299
300 // Connect output port Log
301 for (
302 PlatformIntType port = 0;
303 port < static_cast<PlatformIntType>(this->getNum_Log_OutputPorts());
304 port++
305 ) {
306 this->m_Log_OutputPort[port].init();
307
308#if FW_OBJECT_NAMES == 1
309 // The port name consists of this->m_objName and some extra info.
310 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
311 // However, the compiler may assume that this->m_objName fills
312 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
313 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
314 // bytes to cover the extra info.
315 char portName[2*FW_OBJ_NAME_MAX_SIZE];
316 (void) snprintf(
317 portName,
318 sizeof(portName),
319 "%s_Log_OutputPort[%" PRI_PlatformIntType "]",
320 this->m_objName,
321 port
322 );
323 this->m_Log_OutputPort[port].setObjName(portName);
324#endif
325 }
326
327#if FW_ENABLE_TEXT_LOGGING == 1
328 // Connect output port LogText
329 for (
330 PlatformIntType port = 0;
331 port < static_cast<PlatformIntType>(this->getNum_LogText_OutputPorts());
332 port++
333 ) {
334 this->m_LogText_OutputPort[port].init();
335
336#if FW_OBJECT_NAMES == 1
337 // The port name consists of this->m_objName and some extra info.
338 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
339 // However, the compiler may assume that this->m_objName fills
340 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
341 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
342 // bytes to cover the extra info.
343 char portName[2*FW_OBJ_NAME_MAX_SIZE];
344 (void) snprintf(
345 portName,
346 sizeof(portName),
347 "%s_LogText_OutputPort[%" PRI_PlatformIntType "]",
348 this->m_objName,
349 port
350 );
351 this->m_LogText_OutputPort[port].setObjName(portName);
352#endif
353 }
354#endif
355
356 // Connect output port Time
357 for (
358 PlatformIntType port = 0;
359 port < static_cast<PlatformIntType>(this->getNum_Time_OutputPorts());
360 port++
361 ) {
362 this->m_Time_OutputPort[port].init();
363
364#if FW_OBJECT_NAMES == 1
365 // The port name consists of this->m_objName and some extra info.
366 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
367 // However, the compiler may assume that this->m_objName fills
368 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
369 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
370 // bytes to cover the extra info.
371 char portName[2*FW_OBJ_NAME_MAX_SIZE];
372 (void) snprintf(
373 portName,
374 sizeof(portName),
375 "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
376 this->m_objName,
377 port
378 );
379 this->m_Time_OutputPort[port].setObjName(portName);
380#endif
381 }
382
383 // Connect output port Tlm
384 for (
385 PlatformIntType port = 0;
386 port < static_cast<PlatformIntType>(this->getNum_Tlm_OutputPorts());
387 port++
388 ) {
389 this->m_Tlm_OutputPort[port].init();
390
391#if FW_OBJECT_NAMES == 1
392 // The port name consists of this->m_objName and some extra info.
393 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
394 // However, the compiler may assume that this->m_objName fills
395 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
396 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
397 // bytes to cover the extra info.
398 char portName[2*FW_OBJ_NAME_MAX_SIZE];
399 (void) snprintf(
400 portName,
401 sizeof(portName),
402 "%s_Tlm_OutputPort[%" PRI_PlatformIntType "]",
403 this->m_objName,
404 port
405 );
406 this->m_Tlm_OutputPort[port].setObjName(portName);
407#endif
408 }
409
410 // Connect output port compCmdSend
411 for (
412 PlatformIntType port = 0;
413 port < static_cast<PlatformIntType>(this->getNum_compCmdSend_OutputPorts());
414 port++
415 ) {
416 this->m_compCmdSend_OutputPort[port].init();
417
418#if FW_OBJECT_NAMES == 1
419 // The port name consists of this->m_objName and some extra info.
420 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
421 // However, the compiler may assume that this->m_objName fills
422 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
423 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
424 // bytes to cover the extra info.
425 char portName[2*FW_OBJ_NAME_MAX_SIZE];
426 (void) snprintf(
427 portName,
428 sizeof(portName),
429 "%s_compCmdSend_OutputPort[%" PRI_PlatformIntType "]",
430 this->m_objName,
431 port
432 );
433 this->m_compCmdSend_OutputPort[port].setObjName(portName);
434#endif
435 }
436
437 // Connect output port pingOut
438 for (
439 PlatformIntType port = 0;
440 port < static_cast<PlatformIntType>(this->getNum_pingOut_OutputPorts());
441 port++
442 ) {
443 this->m_pingOut_OutputPort[port].init();
444
445#if FW_OBJECT_NAMES == 1
446 // The port name consists of this->m_objName and some extra info.
447 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
448 // However, the compiler may assume that this->m_objName fills
449 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
450 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
451 // bytes to cover the extra info.
452 char portName[2*FW_OBJ_NAME_MAX_SIZE];
453 (void) snprintf(
454 portName,
455 sizeof(portName),
456 "%s_pingOut_OutputPort[%" PRI_PlatformIntType "]",
457 this->m_objName,
458 port
459 );
460 this->m_pingOut_OutputPort[port].setObjName(portName);
461#endif
462 }
463
464 // Connect output port seqCmdStatus
465 for (
466 PlatformIntType port = 0;
467 port < static_cast<PlatformIntType>(this->getNum_seqCmdStatus_OutputPorts());
468 port++
469 ) {
470 this->m_seqCmdStatus_OutputPort[port].init();
471
472#if FW_OBJECT_NAMES == 1
473 // The port name consists of this->m_objName and some extra info.
474 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
475 // However, the compiler may assume that this->m_objName fills
476 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
477 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
478 // bytes to cover the extra info.
479 char portName[2*FW_OBJ_NAME_MAX_SIZE];
480 (void) snprintf(
481 portName,
482 sizeof(portName),
483 "%s_seqCmdStatus_OutputPort[%" PRI_PlatformIntType "]",
484 this->m_objName,
485 port
486 );
487 this->m_seqCmdStatus_OutputPort[port].setObjName(portName);
488#endif
489 }
490
491 Os::Queue::QueueStatus qStat = this->createQueue(
492 queueDepth,
493 ComponentIpcSerializableBuffer::SERIALIZATION_SIZE
494 );
495 FW_ASSERT(
496 Os::Queue::QUEUE_OK == qStat,
497 static_cast<FwAssertArgType>(qStat)
498 );
499 }
500
501 // ----------------------------------------------------------------------
502 // Getters for special input ports
503 // ----------------------------------------------------------------------
504
505 Fw::InputCmdPort* CommandDispatcherComponentBase ::
506 get_CmdDisp_InputPort(NATIVE_INT_TYPE portNum)
507 {
508 FW_ASSERT(
509 portNum < this->getNum_CmdDisp_InputPorts(),
510 static_cast<FwAssertArgType>(portNum)
511 );
512
513 return &this->m_CmdDisp_InputPort[portNum];
514 }
515
516 // ----------------------------------------------------------------------
517 // Getters for typed input ports
518 // ----------------------------------------------------------------------
519
520 Fw::InputCmdRegPort* CommandDispatcherComponentBase ::
521 get_compCmdReg_InputPort(NATIVE_INT_TYPE portNum)
522 {
523 FW_ASSERT(
524 portNum < this->getNum_compCmdReg_InputPorts(),
525 static_cast<FwAssertArgType>(portNum)
526 );
527
528 return &this->m_compCmdReg_InputPort[portNum];
529 }
530
531 Fw::InputCmdResponsePort* CommandDispatcherComponentBase ::
532 get_compCmdStat_InputPort(NATIVE_INT_TYPE portNum)
533 {
534 FW_ASSERT(
535 portNum < this->getNum_compCmdStat_InputPorts(),
536 static_cast<FwAssertArgType>(portNum)
537 );
538
539 return &this->m_compCmdStat_InputPort[portNum];
540 }
541
542 Svc::InputPingPort* CommandDispatcherComponentBase ::
543 get_pingIn_InputPort(NATIVE_INT_TYPE portNum)
544 {
545 FW_ASSERT(
546 portNum < this->getNum_pingIn_InputPorts(),
547 static_cast<FwAssertArgType>(portNum)
548 );
549
550 return &this->m_pingIn_InputPort[portNum];
551 }
552
553 Fw::InputComPort* CommandDispatcherComponentBase ::
554 get_seqCmdBuff_InputPort(NATIVE_INT_TYPE portNum)
555 {
556 FW_ASSERT(
557 portNum < this->getNum_seqCmdBuff_InputPorts(),
558 static_cast<FwAssertArgType>(portNum)
559 );
560
561 return &this->m_seqCmdBuff_InputPort[portNum];
562 }
563
564 // ----------------------------------------------------------------------
565 // Connect input ports to special output ports
566 // ----------------------------------------------------------------------
567
568 void CommandDispatcherComponentBase ::
569 set_CmdReg_OutputPort(
570 NATIVE_INT_TYPE portNum,
572 )
573 {
574 FW_ASSERT(
575 portNum < this->getNum_CmdReg_OutputPorts(),
576 static_cast<FwAssertArgType>(portNum)
577 );
578
579 this->m_CmdReg_OutputPort[portNum].addCallPort(port);
580 }
581
582 void CommandDispatcherComponentBase ::
583 set_CmdStatus_OutputPort(
584 NATIVE_INT_TYPE portNum,
586 )
587 {
588 FW_ASSERT(
589 portNum < this->getNum_CmdStatus_OutputPorts(),
590 static_cast<FwAssertArgType>(portNum)
591 );
592
593 this->m_CmdStatus_OutputPort[portNum].addCallPort(port);
594 }
595
596 void CommandDispatcherComponentBase ::
597 set_Log_OutputPort(
598 NATIVE_INT_TYPE portNum,
599 Fw::InputLogPort* port
600 )
601 {
602 FW_ASSERT(
603 portNum < this->getNum_Log_OutputPorts(),
604 static_cast<FwAssertArgType>(portNum)
605 );
606
607 this->m_Log_OutputPort[portNum].addCallPort(port);
608 }
609
610#if FW_ENABLE_TEXT_LOGGING == 1
611
612 void CommandDispatcherComponentBase ::
613 set_LogText_OutputPort(
614 NATIVE_INT_TYPE portNum,
616 )
617 {
618 FW_ASSERT(
619 portNum < this->getNum_LogText_OutputPorts(),
620 static_cast<FwAssertArgType>(portNum)
621 );
622
623 this->m_LogText_OutputPort[portNum].addCallPort(port);
624 }
625
626#endif
627
628 void CommandDispatcherComponentBase ::
629 set_Time_OutputPort(
630 NATIVE_INT_TYPE portNum,
632 )
633 {
634 FW_ASSERT(
635 portNum < this->getNum_Time_OutputPorts(),
636 static_cast<FwAssertArgType>(portNum)
637 );
638
639 this->m_Time_OutputPort[portNum].addCallPort(port);
640 }
641
642 void CommandDispatcherComponentBase ::
643 set_Tlm_OutputPort(
644 NATIVE_INT_TYPE portNum,
645 Fw::InputTlmPort* port
646 )
647 {
648 FW_ASSERT(
649 portNum < this->getNum_Tlm_OutputPorts(),
650 static_cast<FwAssertArgType>(portNum)
651 );
652
653 this->m_Tlm_OutputPort[portNum].addCallPort(port);
654 }
655
656 // ----------------------------------------------------------------------
657 // Connect typed input ports to typed output ports
658 // ----------------------------------------------------------------------
659
660 void CommandDispatcherComponentBase ::
661 set_compCmdSend_OutputPort(
662 NATIVE_INT_TYPE portNum,
663 Fw::InputCmdPort* port
664 )
665 {
666 FW_ASSERT(
667 portNum < this->getNum_compCmdSend_OutputPorts(),
668 static_cast<FwAssertArgType>(portNum)
669 );
670
671 this->m_compCmdSend_OutputPort[portNum].addCallPort(port);
672 }
673
674 void CommandDispatcherComponentBase ::
675 set_pingOut_OutputPort(
676 NATIVE_INT_TYPE portNum,
678 )
679 {
680 FW_ASSERT(
681 portNum < this->getNum_pingOut_OutputPorts(),
682 static_cast<FwAssertArgType>(portNum)
683 );
684
685 this->m_pingOut_OutputPort[portNum].addCallPort(port);
686 }
687
688 void CommandDispatcherComponentBase ::
689 set_seqCmdStatus_OutputPort(
690 NATIVE_INT_TYPE portNum,
692 )
693 {
694 FW_ASSERT(
695 portNum < this->getNum_seqCmdStatus_OutputPorts(),
696 static_cast<FwAssertArgType>(portNum)
697 );
698
699 this->m_seqCmdStatus_OutputPort[portNum].addCallPort(port);
700 }
701
702#if FW_PORT_SERIALIZATION
703
704 // ----------------------------------------------------------------------
705 // Connect serial input ports to special output ports
706 // ----------------------------------------------------------------------
707
708 void CommandDispatcherComponentBase ::
709 set_CmdReg_OutputPort(
710 NATIVE_INT_TYPE portNum,
711 Fw::InputSerializePort* port
712 )
713 {
714 FW_ASSERT(
715 portNum < this->getNum_CmdReg_OutputPorts(),
716 static_cast<FwAssertArgType>(portNum)
717 );
718
719 this->m_CmdReg_OutputPort[portNum].registerSerialPort(port);
720 }
721
722 void CommandDispatcherComponentBase ::
723 set_CmdStatus_OutputPort(
724 NATIVE_INT_TYPE portNum,
725 Fw::InputSerializePort* port
726 )
727 {
728 FW_ASSERT(
729 portNum < this->getNum_CmdStatus_OutputPorts(),
730 static_cast<FwAssertArgType>(portNum)
731 );
732
733 this->m_CmdStatus_OutputPort[portNum].registerSerialPort(port);
734 }
735
736 void CommandDispatcherComponentBase ::
737 set_Log_OutputPort(
738 NATIVE_INT_TYPE portNum,
739 Fw::InputSerializePort* port
740 )
741 {
742 FW_ASSERT(
743 portNum < this->getNum_Log_OutputPorts(),
744 static_cast<FwAssertArgType>(portNum)
745 );
746
747 this->m_Log_OutputPort[portNum].registerSerialPort(port);
748 }
749
750#if FW_ENABLE_TEXT_LOGGING == 1
751
752 void CommandDispatcherComponentBase ::
753 set_LogText_OutputPort(
754 NATIVE_INT_TYPE portNum,
755 Fw::InputSerializePort* port
756 )
757 {
758 FW_ASSERT(
759 portNum < this->getNum_LogText_OutputPorts(),
760 static_cast<FwAssertArgType>(portNum)
761 );
762
763 this->m_LogText_OutputPort[portNum].registerSerialPort(port);
764 }
765
766#endif
767
768 void CommandDispatcherComponentBase ::
769 set_Time_OutputPort(
770 NATIVE_INT_TYPE portNum,
771 Fw::InputSerializePort* port
772 )
773 {
774 FW_ASSERT(
775 portNum < this->getNum_Time_OutputPorts(),
776 static_cast<FwAssertArgType>(portNum)
777 );
778
779 this->m_Time_OutputPort[portNum].registerSerialPort(port);
780 }
781
782 void CommandDispatcherComponentBase ::
783 set_Tlm_OutputPort(
784 NATIVE_INT_TYPE portNum,
785 Fw::InputSerializePort* port
786 )
787 {
788 FW_ASSERT(
789 portNum < this->getNum_Tlm_OutputPorts(),
790 static_cast<FwAssertArgType>(portNum)
791 );
792
793 this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
794 }
795
796#endif
797
798#if FW_PORT_SERIALIZATION
799
800 // ----------------------------------------------------------------------
801 // Connect serial input ports to typed output ports
802 // ----------------------------------------------------------------------
803
804 void CommandDispatcherComponentBase ::
805 set_compCmdSend_OutputPort(
806 NATIVE_INT_TYPE portNum,
807 Fw::InputSerializePort* port
808 )
809 {
810 FW_ASSERT(
811 portNum < this->getNum_compCmdSend_OutputPorts(),
812 static_cast<FwAssertArgType>(portNum)
813 );
814
815 this->m_compCmdSend_OutputPort[portNum].registerSerialPort(port);
816 }
817
818 void CommandDispatcherComponentBase ::
819 set_pingOut_OutputPort(
820 NATIVE_INT_TYPE portNum,
821 Fw::InputSerializePort* port
822 )
823 {
824 FW_ASSERT(
825 portNum < this->getNum_pingOut_OutputPorts(),
826 static_cast<FwAssertArgType>(portNum)
827 );
828
829 this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
830 }
831
832 void CommandDispatcherComponentBase ::
833 set_seqCmdStatus_OutputPort(
834 NATIVE_INT_TYPE portNum,
835 Fw::InputSerializePort* port
836 )
837 {
838 FW_ASSERT(
839 portNum < this->getNum_seqCmdStatus_OutputPorts(),
840 static_cast<FwAssertArgType>(portNum)
841 );
842
843 this->m_seqCmdStatus_OutputPort[portNum].registerSerialPort(port);
844 }
845
846#endif
847
848 // ----------------------------------------------------------------------
849 // Command registration
850 // ----------------------------------------------------------------------
851
852 void CommandDispatcherComponentBase ::
853 regCommands()
854 {
855 FW_ASSERT(this->m_CmdReg_OutputPort[0].isConnected());
856
857 this->m_CmdReg_OutputPort[0].invoke(
858 this->getIdBase() + OPCODE_CMD_NO_OP
859 );
860
861 this->m_CmdReg_OutputPort[0].invoke(
862 this->getIdBase() + OPCODE_CMD_NO_OP_STRING
863 );
864
865 this->m_CmdReg_OutputPort[0].invoke(
866 this->getIdBase() + OPCODE_CMD_TEST_CMD_1
867 );
868
869 this->m_CmdReg_OutputPort[0].invoke(
870 this->getIdBase() + OPCODE_CMD_CLEAR_TRACKING
871 );
872 }
873
874 // ----------------------------------------------------------------------
875 // Component construction and destruction
876 // ----------------------------------------------------------------------
877
878 CommandDispatcherComponentBase ::
879 CommandDispatcherComponentBase(const char* compName) :
880 Fw::ActiveComponentBase(compName)
881 {
882 // Write telemetry channel CommandsDispatched
883 this->m_first_update_CommandsDispatched = true;
884 this->m_last_CommandsDispatched = 0;
885
886 // Write telemetry channel CommandErrors
887 this->m_first_update_CommandErrors = true;
888 this->m_last_CommandErrors = 0;
889 }
890
891 CommandDispatcherComponentBase ::
892 ~CommandDispatcherComponentBase()
893 {
894
895 }
896
897 // ----------------------------------------------------------------------
898 // Getters for numbers of special input ports
899 // ----------------------------------------------------------------------
900
901 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
902 getNum_CmdDisp_InputPorts() const
903 {
904 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdDisp_InputPort));
905 }
906
907 // ----------------------------------------------------------------------
908 // Getters for numbers of typed input ports
909 // ----------------------------------------------------------------------
910
911 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
912 getNum_compCmdReg_InputPorts() const
913 {
914 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_compCmdReg_InputPort));
915 }
916
917 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
918 getNum_compCmdStat_InputPorts() const
919 {
920 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_compCmdStat_InputPort));
921 }
922
923 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
924 getNum_pingIn_InputPorts() const
925 {
926 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_pingIn_InputPort));
927 }
928
929 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
930 getNum_seqCmdBuff_InputPorts() const
931 {
932 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_seqCmdBuff_InputPort));
933 }
934
935 // ----------------------------------------------------------------------
936 // Getters for numbers of special output ports
937 // ----------------------------------------------------------------------
938
939 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
940 getNum_CmdReg_OutputPorts() const
941 {
942 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdReg_OutputPort));
943 }
944
945 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
946 getNum_CmdStatus_OutputPorts() const
947 {
948 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdStatus_OutputPort));
949 }
950
951 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
952 getNum_Log_OutputPorts() const
953 {
954 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Log_OutputPort));
955 }
956
957#if FW_ENABLE_TEXT_LOGGING == 1
958
959 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
960 getNum_LogText_OutputPorts() const
961 {
962 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
963 }
964
965#endif
966
967 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
968 getNum_Time_OutputPorts() const
969 {
970 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
971 }
972
973 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
974 getNum_Tlm_OutputPorts() const
975 {
976 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Tlm_OutputPort));
977 }
978
979 // ----------------------------------------------------------------------
980 // Getters for numbers of typed output ports
981 // ----------------------------------------------------------------------
982
983 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
984 getNum_compCmdSend_OutputPorts() const
985 {
986 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_compCmdSend_OutputPort));
987 }
988
989 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
990 getNum_pingOut_OutputPorts() const
991 {
992 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_pingOut_OutputPort));
993 }
994
995 NATIVE_INT_TYPE CommandDispatcherComponentBase ::
996 getNum_seqCmdStatus_OutputPorts() const
997 {
998 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_seqCmdStatus_OutputPort));
999 }
1000
1001 // ----------------------------------------------------------------------
1002 // Connection status queries for special output ports
1003 // ----------------------------------------------------------------------
1004
1005 bool CommandDispatcherComponentBase ::
1006 isConnected_CmdReg_OutputPort(NATIVE_INT_TYPE portNum)
1007 {
1008 FW_ASSERT(
1009 portNum < this->getNum_CmdReg_OutputPorts(),
1010 static_cast<FwAssertArgType>(portNum)
1011 );
1012
1013 return this->m_CmdReg_OutputPort[portNum].isConnected();
1014 }
1015
1016 bool CommandDispatcherComponentBase ::
1017 isConnected_CmdStatus_OutputPort(NATIVE_INT_TYPE portNum)
1018 {
1019 FW_ASSERT(
1020 portNum < this->getNum_CmdStatus_OutputPorts(),
1021 static_cast<FwAssertArgType>(portNum)
1022 );
1023
1024 return this->m_CmdStatus_OutputPort[portNum].isConnected();
1025 }
1026
1027 bool CommandDispatcherComponentBase ::
1028 isConnected_Log_OutputPort(NATIVE_INT_TYPE portNum)
1029 {
1030 FW_ASSERT(
1031 portNum < this->getNum_Log_OutputPorts(),
1032 static_cast<FwAssertArgType>(portNum)
1033 );
1034
1035 return this->m_Log_OutputPort[portNum].isConnected();
1036 }
1037
1038#if FW_ENABLE_TEXT_LOGGING == 1
1039
1040 bool CommandDispatcherComponentBase ::
1041 isConnected_LogText_OutputPort(NATIVE_INT_TYPE portNum)
1042 {
1043 FW_ASSERT(
1044 portNum < this->getNum_LogText_OutputPorts(),
1045 static_cast<FwAssertArgType>(portNum)
1046 );
1047
1048 return this->m_LogText_OutputPort[portNum].isConnected();
1049 }
1050
1051#endif
1052
1053 bool CommandDispatcherComponentBase ::
1054 isConnected_Time_OutputPort(NATIVE_INT_TYPE portNum)
1055 {
1056 FW_ASSERT(
1057 portNum < this->getNum_Time_OutputPorts(),
1058 static_cast<FwAssertArgType>(portNum)
1059 );
1060
1061 return this->m_Time_OutputPort[portNum].isConnected();
1062 }
1063
1064 bool CommandDispatcherComponentBase ::
1065 isConnected_Tlm_OutputPort(NATIVE_INT_TYPE portNum)
1066 {
1067 FW_ASSERT(
1068 portNum < this->getNum_Tlm_OutputPorts(),
1069 static_cast<FwAssertArgType>(portNum)
1070 );
1071
1072 return this->m_Tlm_OutputPort[portNum].isConnected();
1073 }
1074
1075 // ----------------------------------------------------------------------
1076 // Connection status queries for typed output ports
1077 // ----------------------------------------------------------------------
1078
1079 bool CommandDispatcherComponentBase ::
1080 isConnected_compCmdSend_OutputPort(NATIVE_INT_TYPE portNum)
1081 {
1082 FW_ASSERT(
1083 portNum < this->getNum_compCmdSend_OutputPorts(),
1084 static_cast<FwAssertArgType>(portNum)
1085 );
1086
1087 return this->m_compCmdSend_OutputPort[portNum].isConnected();
1088 }
1089
1090 bool CommandDispatcherComponentBase ::
1091 isConnected_pingOut_OutputPort(NATIVE_INT_TYPE portNum)
1092 {
1093 FW_ASSERT(
1094 portNum < this->getNum_pingOut_OutputPorts(),
1095 static_cast<FwAssertArgType>(portNum)
1096 );
1097
1098 return this->m_pingOut_OutputPort[portNum].isConnected();
1099 }
1100
1101 bool CommandDispatcherComponentBase ::
1102 isConnected_seqCmdStatus_OutputPort(NATIVE_INT_TYPE portNum)
1103 {
1104 FW_ASSERT(
1105 portNum < this->getNum_seqCmdStatus_OutputPorts(),
1106 static_cast<FwAssertArgType>(portNum)
1107 );
1108
1109 return this->m_seqCmdStatus_OutputPort[portNum].isConnected();
1110 }
1111
1112 // ----------------------------------------------------------------------
1113 // Port handler base-class functions for typed input ports
1114 //
1115 // Call these functions directly to bypass the corresponding ports
1116 // ----------------------------------------------------------------------
1117
1118 void CommandDispatcherComponentBase ::
1119 compCmdReg_handlerBase(
1120 NATIVE_INT_TYPE portNum,
1121 FwOpcodeType opCode
1122 )
1123 {
1124 // Make sure port number is valid
1125 FW_ASSERT(
1126 portNum < this->getNum_compCmdReg_InputPorts(),
1127 static_cast<FwAssertArgType>(portNum)
1128 );
1129
1130 // Lock guard mutex before calling
1131 this->lock();
1132
1133 // Call handler function
1134 this->compCmdReg_handler(
1135 portNum,
1136 opCode
1137 );
1138
1139 // Unlock guard mutex
1140 this->unLock();
1141 }
1142
1143 void CommandDispatcherComponentBase ::
1144 compCmdStat_handlerBase(
1145 NATIVE_INT_TYPE portNum,
1146 FwOpcodeType opCode,
1147 U32 cmdSeq,
1148 const Fw::CmdResponse& response
1149 )
1150 {
1151 // Make sure port number is valid
1152 FW_ASSERT(
1153 portNum < this->getNum_compCmdStat_InputPorts(),
1154 static_cast<FwAssertArgType>(portNum)
1155 );
1156
1157 // Call pre-message hook
1158 compCmdStat_preMsgHook(
1159 portNum,
1160 opCode,
1161 cmdSeq,
1162 response
1163 );
1164 ComponentIpcSerializableBuffer msg;
1166
1167 // Serialize message ID
1168 _status = msg.serialize(
1169 static_cast<NATIVE_INT_TYPE>(COMPCMDSTAT_CMDRESPONSE)
1170 );
1171 FW_ASSERT(
1172 _status == Fw::FW_SERIALIZE_OK,
1173 static_cast<FwAssertArgType>(_status)
1174 );
1175
1176 // Serialize port number
1177 _status = msg.serialize(portNum);
1178 FW_ASSERT(
1179 _status == Fw::FW_SERIALIZE_OK,
1180 static_cast<FwAssertArgType>(_status)
1181 );
1182
1183 // Serialize argument opCode
1184 _status = msg.serialize(opCode);
1185 FW_ASSERT(
1186 _status == Fw::FW_SERIALIZE_OK,
1187 static_cast<FwAssertArgType>(_status)
1188 );
1189
1190 // Serialize argument cmdSeq
1191 _status = msg.serialize(cmdSeq);
1192 FW_ASSERT(
1193 _status == Fw::FW_SERIALIZE_OK,
1194 static_cast<FwAssertArgType>(_status)
1195 );
1196
1197 // Serialize argument response
1198 _status = msg.serialize(response);
1199 FW_ASSERT(
1200 _status == Fw::FW_SERIALIZE_OK,
1201 static_cast<FwAssertArgType>(_status)
1202 );
1203
1204 // Send message
1206 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1207
1208 FW_ASSERT(
1209 qStatus == Os::Queue::QUEUE_OK,
1210 static_cast<FwAssertArgType>(qStatus)
1211 );
1212 }
1213
1214 void CommandDispatcherComponentBase ::
1215 pingIn_handlerBase(
1216 NATIVE_INT_TYPE portNum,
1217 U32 key
1218 )
1219 {
1220 // Make sure port number is valid
1221 FW_ASSERT(
1222 portNum < this->getNum_pingIn_InputPorts(),
1223 static_cast<FwAssertArgType>(portNum)
1224 );
1225
1226 // Call pre-message hook
1227 pingIn_preMsgHook(
1228 portNum,
1229 key
1230 );
1231 ComponentIpcSerializableBuffer msg;
1233
1234 // Serialize message ID
1235 _status = msg.serialize(
1236 static_cast<NATIVE_INT_TYPE>(PINGIN_PING)
1237 );
1238 FW_ASSERT(
1239 _status == Fw::FW_SERIALIZE_OK,
1240 static_cast<FwAssertArgType>(_status)
1241 );
1242
1243 // Serialize port number
1244 _status = msg.serialize(portNum);
1245 FW_ASSERT(
1246 _status == Fw::FW_SERIALIZE_OK,
1247 static_cast<FwAssertArgType>(_status)
1248 );
1249
1250 // Serialize argument key
1251 _status = msg.serialize(key);
1252 FW_ASSERT(
1253 _status == Fw::FW_SERIALIZE_OK,
1254 static_cast<FwAssertArgType>(_status)
1255 );
1256
1257 // Send message
1259 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1260
1261 FW_ASSERT(
1262 qStatus == Os::Queue::QUEUE_OK,
1263 static_cast<FwAssertArgType>(qStatus)
1264 );
1265 }
1266
1267 void CommandDispatcherComponentBase ::
1268 seqCmdBuff_handlerBase(
1269 NATIVE_INT_TYPE portNum,
1270 Fw::ComBuffer& data,
1271 U32 context
1272 )
1273 {
1274 // Make sure port number is valid
1275 FW_ASSERT(
1276 portNum < this->getNum_seqCmdBuff_InputPorts(),
1277 static_cast<FwAssertArgType>(portNum)
1278 );
1279
1280 // Call pre-message hook
1281 seqCmdBuff_preMsgHook(
1282 portNum,
1283 data,
1284 context
1285 );
1286 ComponentIpcSerializableBuffer msg;
1288
1289 // Serialize message ID
1290 _status = msg.serialize(
1291 static_cast<NATIVE_INT_TYPE>(SEQCMDBUFF_COM)
1292 );
1293 FW_ASSERT(
1294 _status == Fw::FW_SERIALIZE_OK,
1295 static_cast<FwAssertArgType>(_status)
1296 );
1297
1298 // Serialize port number
1299 _status = msg.serialize(portNum);
1300 FW_ASSERT(
1301 _status == Fw::FW_SERIALIZE_OK,
1302 static_cast<FwAssertArgType>(_status)
1303 );
1304
1305 // Serialize argument data
1306 _status = msg.serialize(data);
1307 FW_ASSERT(
1308 _status == Fw::FW_SERIALIZE_OK,
1309 static_cast<FwAssertArgType>(_status)
1310 );
1311
1312 // Serialize argument context
1313 _status = msg.serialize(context);
1314 FW_ASSERT(
1315 _status == Fw::FW_SERIALIZE_OK,
1316 static_cast<FwAssertArgType>(_status)
1317 );
1318
1319 // Send message
1321 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1322
1323 FW_ASSERT(
1324 qStatus == Os::Queue::QUEUE_OK,
1325 static_cast<FwAssertArgType>(qStatus)
1326 );
1327 }
1328
1329 // ----------------------------------------------------------------------
1330 // Pre-message hooks for typed async input ports
1331 //
1332 // Each of these functions is invoked just before processing a message
1333 // on the corresponding port. By default, they do nothing. You can
1334 // override them to provide specific pre-message behavior.
1335 // ----------------------------------------------------------------------
1336
1337 void CommandDispatcherComponentBase ::
1338 compCmdStat_preMsgHook(
1339 NATIVE_INT_TYPE portNum,
1340 FwOpcodeType opCode,
1341 U32 cmdSeq,
1342 const Fw::CmdResponse& response
1343 )
1344 {
1345 // Default: no-op
1346 }
1347
1348 void CommandDispatcherComponentBase ::
1349 pingIn_preMsgHook(
1350 NATIVE_INT_TYPE portNum,
1351 U32 key
1352 )
1353 {
1354 // Default: no-op
1355 }
1356
1357 void CommandDispatcherComponentBase ::
1358 seqCmdBuff_preMsgHook(
1359 NATIVE_INT_TYPE portNum,
1360 Fw::ComBuffer& data,
1361 U32 context
1362 )
1363 {
1364 // Default: no-op
1365 }
1366
1367 // ----------------------------------------------------------------------
1368 // Invocation functions for typed output ports
1369 // ----------------------------------------------------------------------
1370
1371 void CommandDispatcherComponentBase ::
1372 compCmdSend_out(
1373 NATIVE_INT_TYPE portNum,
1374 FwOpcodeType opCode,
1375 U32 cmdSeq,
1376 Fw::CmdArgBuffer& args
1377 )
1378 {
1379 FW_ASSERT(
1380 portNum < this->getNum_compCmdSend_OutputPorts(),
1381 static_cast<FwAssertArgType>(portNum)
1382 );
1383 this->m_compCmdSend_OutputPort[portNum].invoke(
1384 opCode,
1385 cmdSeq,
1386 args
1387 );
1388 }
1389
1390 void CommandDispatcherComponentBase ::
1391 pingOut_out(
1392 NATIVE_INT_TYPE portNum,
1393 U32 key
1394 )
1395 {
1396 FW_ASSERT(
1397 portNum < this->getNum_pingOut_OutputPorts(),
1398 static_cast<FwAssertArgType>(portNum)
1399 );
1400 this->m_pingOut_OutputPort[portNum].invoke(
1401 key
1402 );
1403 }
1404
1405 void CommandDispatcherComponentBase ::
1406 seqCmdStatus_out(
1407 NATIVE_INT_TYPE portNum,
1408 FwOpcodeType opCode,
1409 U32 cmdSeq,
1410 const Fw::CmdResponse& response
1411 )
1412 {
1413 FW_ASSERT(
1414 portNum < this->getNum_seqCmdStatus_OutputPorts(),
1415 static_cast<FwAssertArgType>(portNum)
1416 );
1417 this->m_seqCmdStatus_OutputPort[portNum].invoke(
1418 opCode,
1419 cmdSeq,
1420 response
1421 );
1422 }
1423
1424 // ----------------------------------------------------------------------
1425 // Command response
1426 // ----------------------------------------------------------------------
1427
1428 void CommandDispatcherComponentBase ::
1429 cmdResponse_out(
1430 FwOpcodeType opCode,
1431 U32 cmdSeq,
1432 Fw::CmdResponse response
1433 )
1434 {
1435 FW_ASSERT(this->m_CmdStatus_OutputPort[0].isConnected());
1436 this->m_CmdStatus_OutputPort[0].invoke(opCode, cmdSeq, response);
1437 }
1438
1439 // ----------------------------------------------------------------------
1440 // Command handler base-class functions
1441 //
1442 // Call these functions directly to bypass the command input port
1443 // ----------------------------------------------------------------------
1444
1445 void CommandDispatcherComponentBase ::
1446 CMD_NO_OP_cmdHandlerBase(
1447 FwOpcodeType opCode,
1448 U32 cmdSeq,
1449 Fw::CmdArgBuffer& args
1450 )
1451 {
1452 // Call pre-message hook
1453 this->CMD_NO_OP_preMsgHook(opCode,cmdSeq);
1454
1455 // Defer deserializing arguments to the message dispatcher
1456 // to avoid deserializing and reserializing just for IPC
1457 ComponentIpcSerializableBuffer msg;
1459
1460 // Serialize for IPC
1461 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_CMD_NO_OP));
1462 FW_ASSERT (
1463 _status == Fw::FW_SERIALIZE_OK,
1464 static_cast<FwAssertArgType>(_status)
1465 );
1466
1467 // Fake port number to make message dequeue work
1468 NATIVE_INT_TYPE port = 0;
1469
1470 _status = msg.serialize(port);
1471 FW_ASSERT (
1472 _status == Fw::FW_SERIALIZE_OK,
1473 static_cast<FwAssertArgType>(_status)
1474 );
1475
1476 _status = msg.serialize(opCode);
1477 FW_ASSERT (
1478 _status == Fw::FW_SERIALIZE_OK,
1479 static_cast<FwAssertArgType>(_status)
1480 );
1481
1482 _status = msg.serialize(cmdSeq);
1483 FW_ASSERT (
1484 _status == Fw::FW_SERIALIZE_OK,
1485 static_cast<FwAssertArgType>(_status)
1486 );
1487
1488 _status = msg.serialize(args);
1489 FW_ASSERT (
1490 _status == Fw::FW_SERIALIZE_OK,
1491 static_cast<FwAssertArgType>(_status)
1492 );
1493
1494 // Send message
1496 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1497
1498 FW_ASSERT(
1499 qStatus == Os::Queue::QUEUE_OK,
1500 static_cast<FwAssertArgType>(qStatus)
1501 );
1502 }
1503
1504 void CommandDispatcherComponentBase ::
1505 CMD_NO_OP_STRING_cmdHandlerBase(
1506 FwOpcodeType opCode,
1507 U32 cmdSeq,
1508 Fw::CmdArgBuffer& args
1509 )
1510 {
1511 // Call pre-message hook
1512 this->CMD_NO_OP_STRING_preMsgHook(opCode,cmdSeq);
1513
1514 // Defer deserializing arguments to the message dispatcher
1515 // to avoid deserializing and reserializing just for IPC
1516 ComponentIpcSerializableBuffer msg;
1518
1519 // Serialize for IPC
1520 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_CMD_NO_OP_STRING));
1521 FW_ASSERT (
1522 _status == Fw::FW_SERIALIZE_OK,
1523 static_cast<FwAssertArgType>(_status)
1524 );
1525
1526 // Fake port number to make message dequeue work
1527 NATIVE_INT_TYPE port = 0;
1528
1529 _status = msg.serialize(port);
1530 FW_ASSERT (
1531 _status == Fw::FW_SERIALIZE_OK,
1532 static_cast<FwAssertArgType>(_status)
1533 );
1534
1535 _status = msg.serialize(opCode);
1536 FW_ASSERT (
1537 _status == Fw::FW_SERIALIZE_OK,
1538 static_cast<FwAssertArgType>(_status)
1539 );
1540
1541 _status = msg.serialize(cmdSeq);
1542 FW_ASSERT (
1543 _status == Fw::FW_SERIALIZE_OK,
1544 static_cast<FwAssertArgType>(_status)
1545 );
1546
1547 _status = msg.serialize(args);
1548 FW_ASSERT (
1549 _status == Fw::FW_SERIALIZE_OK,
1550 static_cast<FwAssertArgType>(_status)
1551 );
1552
1553 // Send message
1555 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1556
1557 FW_ASSERT(
1558 qStatus == Os::Queue::QUEUE_OK,
1559 static_cast<FwAssertArgType>(qStatus)
1560 );
1561 }
1562
1563 void CommandDispatcherComponentBase ::
1564 CMD_TEST_CMD_1_cmdHandlerBase(
1565 FwOpcodeType opCode,
1566 U32 cmdSeq,
1567 Fw::CmdArgBuffer& args
1568 )
1569 {
1570 // Call pre-message hook
1571 this->CMD_TEST_CMD_1_preMsgHook(opCode,cmdSeq);
1572
1573 // Defer deserializing arguments to the message dispatcher
1574 // to avoid deserializing and reserializing just for IPC
1575 ComponentIpcSerializableBuffer msg;
1577
1578 // Serialize for IPC
1579 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_CMD_TEST_CMD_1));
1580 FW_ASSERT (
1581 _status == Fw::FW_SERIALIZE_OK,
1582 static_cast<FwAssertArgType>(_status)
1583 );
1584
1585 // Fake port number to make message dequeue work
1586 NATIVE_INT_TYPE port = 0;
1587
1588 _status = msg.serialize(port);
1589 FW_ASSERT (
1590 _status == Fw::FW_SERIALIZE_OK,
1591 static_cast<FwAssertArgType>(_status)
1592 );
1593
1594 _status = msg.serialize(opCode);
1595 FW_ASSERT (
1596 _status == Fw::FW_SERIALIZE_OK,
1597 static_cast<FwAssertArgType>(_status)
1598 );
1599
1600 _status = msg.serialize(cmdSeq);
1601 FW_ASSERT (
1602 _status == Fw::FW_SERIALIZE_OK,
1603 static_cast<FwAssertArgType>(_status)
1604 );
1605
1606 _status = msg.serialize(args);
1607 FW_ASSERT (
1608 _status == Fw::FW_SERIALIZE_OK,
1609 static_cast<FwAssertArgType>(_status)
1610 );
1611
1612 // Send message
1614 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1615
1616 FW_ASSERT(
1617 qStatus == Os::Queue::QUEUE_OK,
1618 static_cast<FwAssertArgType>(qStatus)
1619 );
1620 }
1621
1622 void CommandDispatcherComponentBase ::
1623 CMD_CLEAR_TRACKING_cmdHandlerBase(
1624 FwOpcodeType opCode,
1625 U32 cmdSeq,
1626 Fw::CmdArgBuffer& args
1627 )
1628 {
1629 // Call pre-message hook
1630 this->CMD_CLEAR_TRACKING_preMsgHook(opCode,cmdSeq);
1631
1632 // Defer deserializing arguments to the message dispatcher
1633 // to avoid deserializing and reserializing just for IPC
1634 ComponentIpcSerializableBuffer msg;
1636
1637 // Serialize for IPC
1638 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_CMD_CLEAR_TRACKING));
1639 FW_ASSERT (
1640 _status == Fw::FW_SERIALIZE_OK,
1641 static_cast<FwAssertArgType>(_status)
1642 );
1643
1644 // Fake port number to make message dequeue work
1645 NATIVE_INT_TYPE port = 0;
1646
1647 _status = msg.serialize(port);
1648 FW_ASSERT (
1649 _status == Fw::FW_SERIALIZE_OK,
1650 static_cast<FwAssertArgType>(_status)
1651 );
1652
1653 _status = msg.serialize(opCode);
1654 FW_ASSERT (
1655 _status == Fw::FW_SERIALIZE_OK,
1656 static_cast<FwAssertArgType>(_status)
1657 );
1658
1659 _status = msg.serialize(cmdSeq);
1660 FW_ASSERT (
1661 _status == Fw::FW_SERIALIZE_OK,
1662 static_cast<FwAssertArgType>(_status)
1663 );
1664
1665 _status = msg.serialize(args);
1666 FW_ASSERT (
1667 _status == Fw::FW_SERIALIZE_OK,
1668 static_cast<FwAssertArgType>(_status)
1669 );
1670
1671 // Send message
1673 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1674
1675 FW_ASSERT(
1676 qStatus == Os::Queue::QUEUE_OK,
1677 static_cast<FwAssertArgType>(qStatus)
1678 );
1679 }
1680
1681 // ----------------------------------------------------------------------
1682 // Pre-message hooks for async commands
1683 //
1684 // Each of these functions is invoked just before processing the
1685 // corresponding command. By default they do nothing. You can
1686 // override them to provide specific pre-command behavior.
1687 // ----------------------------------------------------------------------
1688
1689 void CommandDispatcherComponentBase ::
1690 CMD_NO_OP_preMsgHook(
1691 FwOpcodeType opCode,
1692 U32 cmdSeq
1693 )
1694 {
1695 // Defaults to no-op; can be overridden
1696 (void) opCode;
1697 (void) cmdSeq;
1698 }
1699
1700 void CommandDispatcherComponentBase ::
1701 CMD_NO_OP_STRING_preMsgHook(
1702 FwOpcodeType opCode,
1703 U32 cmdSeq
1704 )
1705 {
1706 // Defaults to no-op; can be overridden
1707 (void) opCode;
1708 (void) cmdSeq;
1709 }
1710
1711 void CommandDispatcherComponentBase ::
1712 CMD_TEST_CMD_1_preMsgHook(
1713 FwOpcodeType opCode,
1714 U32 cmdSeq
1715 )
1716 {
1717 // Defaults to no-op; can be overridden
1718 (void) opCode;
1719 (void) cmdSeq;
1720 }
1721
1722 void CommandDispatcherComponentBase ::
1723 CMD_CLEAR_TRACKING_preMsgHook(
1724 FwOpcodeType opCode,
1725 U32 cmdSeq
1726 )
1727 {
1728 // Defaults to no-op; can be overridden
1729 (void) opCode;
1730 (void) cmdSeq;
1731 }
1732
1733 // ----------------------------------------------------------------------
1734 // Event logging functions
1735 // ----------------------------------------------------------------------
1736
1737 void CommandDispatcherComponentBase ::
1738 log_DIAGNOSTIC_OpCodeRegistered(
1739 U32 Opcode,
1740 I32 port,
1741 I32 slot
1742 )
1743 {
1744 // Get the time
1745 Fw::Time _logTime;
1746 if (this->m_Time_OutputPort[0].isConnected()) {
1747 this->m_Time_OutputPort[0].invoke(_logTime);
1748 }
1749
1750 FwEventIdType _id = static_cast<FwEventIdType>(0);
1751
1752 _id = this->getIdBase() + EVENTID_OPCODEREGISTERED;
1753
1754 // Emit the event on the log port
1755 if (this->m_Log_OutputPort[0].isConnected()) {
1756 Fw::LogBuffer _logBuff;
1758
1759#if FW_AMPCS_COMPATIBLE
1760 // Serialize the number of arguments
1761 _status = _logBuff.serialize(static_cast<U8>(3));
1762 FW_ASSERT(
1763 _status == Fw::FW_SERIALIZE_OK,
1764 static_cast<FwAssertArgType>(_status)
1765 );
1766#endif
1767
1768#if FW_AMPCS_COMPATIBLE
1769 // Serialize the argument size
1770 _status = _logBuff.serialize(
1771 static_cast<U8>(sizeof(U32))
1772 );
1773 FW_ASSERT(
1774 _status == Fw::FW_SERIALIZE_OK,
1775 static_cast<FwAssertArgType>(_status)
1776 );
1777#endif
1778 _status = _logBuff.serialize(Opcode);
1779 FW_ASSERT(
1780 _status == Fw::FW_SERIALIZE_OK,
1781 static_cast<FwAssertArgType>(_status)
1782 );
1783
1784#if FW_AMPCS_COMPATIBLE
1785 // Serialize the argument size
1786 _status = _logBuff.serialize(
1787 static_cast<U8>(sizeof(I32))
1788 );
1789 FW_ASSERT(
1790 _status == Fw::FW_SERIALIZE_OK,
1791 static_cast<FwAssertArgType>(_status)
1792 );
1793#endif
1794 _status = _logBuff.serialize(port);
1795 FW_ASSERT(
1796 _status == Fw::FW_SERIALIZE_OK,
1797 static_cast<FwAssertArgType>(_status)
1798 );
1799
1800#if FW_AMPCS_COMPATIBLE
1801 // Serialize the argument size
1802 _status = _logBuff.serialize(
1803 static_cast<U8>(sizeof(I32))
1804 );
1805 FW_ASSERT(
1806 _status == Fw::FW_SERIALIZE_OK,
1807 static_cast<FwAssertArgType>(_status)
1808 );
1809#endif
1810 _status = _logBuff.serialize(slot);
1811 FW_ASSERT(
1812 _status == Fw::FW_SERIALIZE_OK,
1813 static_cast<FwAssertArgType>(_status)
1814 );
1815
1816 this->m_Log_OutputPort[0].invoke(
1817 _id,
1818 _logTime,
1820 _logBuff
1821 );
1822 }
1823
1824 // Emit the event on the text log port
1825#if FW_ENABLE_TEXT_LOGGING
1826 if (this->m_LogText_OutputPort[0].isConnected()) {
1827#if FW_OBJECT_NAMES == 1
1828 const char* _formatString =
1829 "(%s) %s: Opcode 0x%" PRIx32 " registered to port %" PRIi32 " slot %" PRIi32 "";
1830#else
1831 const char* _formatString =
1832 "%s: Opcode 0x%" PRIx32 " registered to port %" PRIi32 " slot %" PRIi32 "";
1833#endif
1834
1835 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1836
1837 (void) snprintf(
1838 _textBuffer,
1840 _formatString,
1841#if FW_OBJECT_NAMES == 1
1842 this->m_objName,
1843#endif
1844 "OpCodeRegistered ",
1845 Opcode,
1846 port,
1847 slot
1848 );
1849
1850 // Null terminate
1851 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1852 Fw::TextLogString _logString = _textBuffer;
1853 this->m_LogText_OutputPort[0].invoke(
1854 _id,
1855 _logTime,
1857 _logString
1858 );
1859 }
1860#endif
1861 }
1862
1863 void CommandDispatcherComponentBase ::
1864 log_COMMAND_OpCodeDispatched(
1865 U32 Opcode,
1866 I32 port
1867 )
1868 {
1869 // Get the time
1870 Fw::Time _logTime;
1871 if (this->m_Time_OutputPort[0].isConnected()) {
1872 this->m_Time_OutputPort[0].invoke(_logTime);
1873 }
1874
1875 FwEventIdType _id = static_cast<FwEventIdType>(0);
1876
1877 _id = this->getIdBase() + EVENTID_OPCODEDISPATCHED;
1878
1879 // Emit the event on the log port
1880 if (this->m_Log_OutputPort[0].isConnected()) {
1881 Fw::LogBuffer _logBuff;
1883
1884#if FW_AMPCS_COMPATIBLE
1885 // Serialize the number of arguments
1886 _status = _logBuff.serialize(static_cast<U8>(2));
1887 FW_ASSERT(
1888 _status == Fw::FW_SERIALIZE_OK,
1889 static_cast<FwAssertArgType>(_status)
1890 );
1891#endif
1892
1893#if FW_AMPCS_COMPATIBLE
1894 // Serialize the argument size
1895 _status = _logBuff.serialize(
1896 static_cast<U8>(sizeof(U32))
1897 );
1898 FW_ASSERT(
1899 _status == Fw::FW_SERIALIZE_OK,
1900 static_cast<FwAssertArgType>(_status)
1901 );
1902#endif
1903 _status = _logBuff.serialize(Opcode);
1904 FW_ASSERT(
1905 _status == Fw::FW_SERIALIZE_OK,
1906 static_cast<FwAssertArgType>(_status)
1907 );
1908
1909#if FW_AMPCS_COMPATIBLE
1910 // Serialize the argument size
1911 _status = _logBuff.serialize(
1912 static_cast<U8>(sizeof(I32))
1913 );
1914 FW_ASSERT(
1915 _status == Fw::FW_SERIALIZE_OK,
1916 static_cast<FwAssertArgType>(_status)
1917 );
1918#endif
1919 _status = _logBuff.serialize(port);
1920 FW_ASSERT(
1921 _status == Fw::FW_SERIALIZE_OK,
1922 static_cast<FwAssertArgType>(_status)
1923 );
1924
1925 this->m_Log_OutputPort[0].invoke(
1926 _id,
1927 _logTime,
1929 _logBuff
1930 );
1931 }
1932
1933 // Emit the event on the text log port
1934#if FW_ENABLE_TEXT_LOGGING
1935 if (this->m_LogText_OutputPort[0].isConnected()) {
1936#if FW_OBJECT_NAMES == 1
1937 const char* _formatString =
1938 "(%s) %s: Opcode 0x%" PRIx32 " dispatched to port %" PRIi32 "";
1939#else
1940 const char* _formatString =
1941 "%s: Opcode 0x%" PRIx32 " dispatched to port %" PRIi32 "";
1942#endif
1943
1944 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1945
1946 (void) snprintf(
1947 _textBuffer,
1949 _formatString,
1950#if FW_OBJECT_NAMES == 1
1951 this->m_objName,
1952#endif
1953 "OpCodeDispatched ",
1954 Opcode,
1955 port
1956 );
1957
1958 // Null terminate
1959 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1960 Fw::TextLogString _logString = _textBuffer;
1961 this->m_LogText_OutputPort[0].invoke(
1962 _id,
1963 _logTime,
1965 _logString
1966 );
1967 }
1968#endif
1969 }
1970
1971 void CommandDispatcherComponentBase ::
1972 log_COMMAND_OpCodeCompleted(U32 Opcode)
1973 {
1974 // Get the time
1975 Fw::Time _logTime;
1976 if (this->m_Time_OutputPort[0].isConnected()) {
1977 this->m_Time_OutputPort[0].invoke(_logTime);
1978 }
1979
1980 FwEventIdType _id = static_cast<FwEventIdType>(0);
1981
1982 _id = this->getIdBase() + EVENTID_OPCODECOMPLETED;
1983
1984 // Emit the event on the log port
1985 if (this->m_Log_OutputPort[0].isConnected()) {
1986 Fw::LogBuffer _logBuff;
1988
1989#if FW_AMPCS_COMPATIBLE
1990 // Serialize the number of arguments
1991 _status = _logBuff.serialize(static_cast<U8>(1));
1992 FW_ASSERT(
1993 _status == Fw::FW_SERIALIZE_OK,
1994 static_cast<FwAssertArgType>(_status)
1995 );
1996#endif
1997
1998#if FW_AMPCS_COMPATIBLE
1999 // Serialize the argument size
2000 _status = _logBuff.serialize(
2001 static_cast<U8>(sizeof(U32))
2002 );
2003 FW_ASSERT(
2004 _status == Fw::FW_SERIALIZE_OK,
2005 static_cast<FwAssertArgType>(_status)
2006 );
2007#endif
2008 _status = _logBuff.serialize(Opcode);
2009 FW_ASSERT(
2010 _status == Fw::FW_SERIALIZE_OK,
2011 static_cast<FwAssertArgType>(_status)
2012 );
2013
2014 this->m_Log_OutputPort[0].invoke(
2015 _id,
2016 _logTime,
2018 _logBuff
2019 );
2020 }
2021
2022 // Emit the event on the text log port
2023#if FW_ENABLE_TEXT_LOGGING
2024 if (this->m_LogText_OutputPort[0].isConnected()) {
2025#if FW_OBJECT_NAMES == 1
2026 const char* _formatString =
2027 "(%s) %s: Opcode 0x%" PRIx32 " completed";
2028#else
2029 const char* _formatString =
2030 "%s: Opcode 0x%" PRIx32 " completed";
2031#endif
2032
2033 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2034
2035 (void) snprintf(
2036 _textBuffer,
2038 _formatString,
2039#if FW_OBJECT_NAMES == 1
2040 this->m_objName,
2041#endif
2042 "OpCodeCompleted ",
2043 Opcode
2044 );
2045
2046 // Null terminate
2047 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2048 Fw::TextLogString _logString = _textBuffer;
2049 this->m_LogText_OutputPort[0].invoke(
2050 _id,
2051 _logTime,
2053 _logString
2054 );
2055 }
2056#endif
2057 }
2058
2059 void CommandDispatcherComponentBase ::
2060 log_COMMAND_OpCodeError(
2061 U32 Opcode,
2062 Fw::CmdResponse error
2063 )
2064 {
2065 // Get the time
2066 Fw::Time _logTime;
2067 if (this->m_Time_OutputPort[0].isConnected()) {
2068 this->m_Time_OutputPort[0].invoke(_logTime);
2069 }
2070
2071 FwEventIdType _id = static_cast<FwEventIdType>(0);
2072
2073 _id = this->getIdBase() + EVENTID_OPCODEERROR;
2074
2075 // Emit the event on the log port
2076 if (this->m_Log_OutputPort[0].isConnected()) {
2077 Fw::LogBuffer _logBuff;
2079
2080#if FW_AMPCS_COMPATIBLE
2081 // Serialize the number of arguments
2082 _status = _logBuff.serialize(static_cast<U8>(2));
2083 FW_ASSERT(
2084 _status == Fw::FW_SERIALIZE_OK,
2085 static_cast<FwAssertArgType>(_status)
2086 );
2087#endif
2088
2089#if FW_AMPCS_COMPATIBLE
2090 // Serialize the argument size
2091 _status = _logBuff.serialize(
2092 static_cast<U8>(sizeof(U32))
2093 );
2094 FW_ASSERT(
2095 _status == Fw::FW_SERIALIZE_OK,
2096 static_cast<FwAssertArgType>(_status)
2097 );
2098#endif
2099 _status = _logBuff.serialize(Opcode);
2100 FW_ASSERT(
2101 _status == Fw::FW_SERIALIZE_OK,
2102 static_cast<FwAssertArgType>(_status)
2103 );
2104
2105#if FW_AMPCS_COMPATIBLE
2106 // Serialize the argument size
2107 _status = _logBuff.serialize(
2109 );
2110 FW_ASSERT(
2111 _status == Fw::FW_SERIALIZE_OK,
2112 static_cast<FwAssertArgType>(_status)
2113 );
2114#endif
2115 _status = _logBuff.serialize(error);
2116 FW_ASSERT(
2117 _status == Fw::FW_SERIALIZE_OK,
2118 static_cast<FwAssertArgType>(_status)
2119 );
2120
2121 this->m_Log_OutputPort[0].invoke(
2122 _id,
2123 _logTime,
2125 _logBuff
2126 );
2127 }
2128
2129 // Emit the event on the text log port
2130#if FW_ENABLE_TEXT_LOGGING
2131 if (this->m_LogText_OutputPort[0].isConnected()) {
2132#if FW_OBJECT_NAMES == 1
2133 const char* _formatString =
2134 "(%s) %s: Opcode 0x%" PRIx32 " completed with error %s";
2135#else
2136 const char* _formatString =
2137 "%s: Opcode 0x%" PRIx32 " completed with error %s";
2138#endif
2139
2140 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2141
2142 Fw::String errorStr;
2143 error.toString(errorStr);
2144
2145 (void) snprintf(
2146 _textBuffer,
2148 _formatString,
2149#if FW_OBJECT_NAMES == 1
2150 this->m_objName,
2151#endif
2152 "OpCodeError ",
2153 Opcode,
2154 errorStr.toChar()
2155 );
2156
2157 // Null terminate
2158 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2159 Fw::TextLogString _logString = _textBuffer;
2160 this->m_LogText_OutputPort[0].invoke(
2161 _id,
2162 _logTime,
2164 _logString
2165 );
2166 }
2167#endif
2168 }
2169
2170 void CommandDispatcherComponentBase ::
2171 log_WARNING_HI_MalformedCommand(Fw::DeserialStatus Status)
2172 {
2173 // Get the time
2174 Fw::Time _logTime;
2175 if (this->m_Time_OutputPort[0].isConnected()) {
2176 this->m_Time_OutputPort[0].invoke(_logTime);
2177 }
2178
2179 FwEventIdType _id = static_cast<FwEventIdType>(0);
2180
2181 _id = this->getIdBase() + EVENTID_MALFORMEDCOMMAND;
2182
2183 // Emit the event on the log port
2184 if (this->m_Log_OutputPort[0].isConnected()) {
2185 Fw::LogBuffer _logBuff;
2187
2188#if FW_AMPCS_COMPATIBLE
2189 // Serialize the number of arguments
2190 _status = _logBuff.serialize(static_cast<U8>(1));
2191 FW_ASSERT(
2192 _status == Fw::FW_SERIALIZE_OK,
2193 static_cast<FwAssertArgType>(_status)
2194 );
2195#endif
2196
2197#if FW_AMPCS_COMPATIBLE
2198 // Serialize the argument size
2199 _status = _logBuff.serialize(
2201 );
2202 FW_ASSERT(
2203 _status == Fw::FW_SERIALIZE_OK,
2204 static_cast<FwAssertArgType>(_status)
2205 );
2206#endif
2207 _status = _logBuff.serialize(Status);
2208 FW_ASSERT(
2209 _status == Fw::FW_SERIALIZE_OK,
2210 static_cast<FwAssertArgType>(_status)
2211 );
2212
2213 this->m_Log_OutputPort[0].invoke(
2214 _id,
2215 _logTime,
2217 _logBuff
2218 );
2219 }
2220
2221 // Emit the event on the text log port
2222#if FW_ENABLE_TEXT_LOGGING
2223 if (this->m_LogText_OutputPort[0].isConnected()) {
2224#if FW_OBJECT_NAMES == 1
2225 const char* _formatString =
2226 "(%s) %s: Received malformed command packet. Status: %s";
2227#else
2228 const char* _formatString =
2229 "%s: Received malformed command packet. Status: %s";
2230#endif
2231
2232 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2233
2234 Fw::String StatusStr;
2235 Status.toString(StatusStr);
2236
2237 (void) snprintf(
2238 _textBuffer,
2240 _formatString,
2241#if FW_OBJECT_NAMES == 1
2242 this->m_objName,
2243#endif
2244 "MalformedCommand ",
2245 StatusStr.toChar()
2246 );
2247
2248 // Null terminate
2249 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2250 Fw::TextLogString _logString = _textBuffer;
2251 this->m_LogText_OutputPort[0].invoke(
2252 _id,
2253 _logTime,
2255 _logString
2256 );
2257 }
2258#endif
2259 }
2260
2261 void CommandDispatcherComponentBase ::
2262 log_WARNING_HI_InvalidCommand(U32 Opcode)
2263 {
2264 // Get the time
2265 Fw::Time _logTime;
2266 if (this->m_Time_OutputPort[0].isConnected()) {
2267 this->m_Time_OutputPort[0].invoke(_logTime);
2268 }
2269
2270 FwEventIdType _id = static_cast<FwEventIdType>(0);
2271
2272 _id = this->getIdBase() + EVENTID_INVALIDCOMMAND;
2273
2274 // Emit the event on the log port
2275 if (this->m_Log_OutputPort[0].isConnected()) {
2276 Fw::LogBuffer _logBuff;
2278
2279#if FW_AMPCS_COMPATIBLE
2280 // Serialize the number of arguments
2281 _status = _logBuff.serialize(static_cast<U8>(1));
2282 FW_ASSERT(
2283 _status == Fw::FW_SERIALIZE_OK,
2284 static_cast<FwAssertArgType>(_status)
2285 );
2286#endif
2287
2288#if FW_AMPCS_COMPATIBLE
2289 // Serialize the argument size
2290 _status = _logBuff.serialize(
2291 static_cast<U8>(sizeof(U32))
2292 );
2293 FW_ASSERT(
2294 _status == Fw::FW_SERIALIZE_OK,
2295 static_cast<FwAssertArgType>(_status)
2296 );
2297#endif
2298 _status = _logBuff.serialize(Opcode);
2299 FW_ASSERT(
2300 _status == Fw::FW_SERIALIZE_OK,
2301 static_cast<FwAssertArgType>(_status)
2302 );
2303
2304 this->m_Log_OutputPort[0].invoke(
2305 _id,
2306 _logTime,
2308 _logBuff
2309 );
2310 }
2311
2312 // Emit the event on the text log port
2313#if FW_ENABLE_TEXT_LOGGING
2314 if (this->m_LogText_OutputPort[0].isConnected()) {
2315#if FW_OBJECT_NAMES == 1
2316 const char* _formatString =
2317 "(%s) %s: Invalid opcode 0x%" PRIx32 " received";
2318#else
2319 const char* _formatString =
2320 "%s: Invalid opcode 0x%" PRIx32 " received";
2321#endif
2322
2323 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2324
2325 (void) snprintf(
2326 _textBuffer,
2328 _formatString,
2329#if FW_OBJECT_NAMES == 1
2330 this->m_objName,
2331#endif
2332 "InvalidCommand ",
2333 Opcode
2334 );
2335
2336 // Null terminate
2337 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2338 Fw::TextLogString _logString = _textBuffer;
2339 this->m_LogText_OutputPort[0].invoke(
2340 _id,
2341 _logTime,
2343 _logString
2344 );
2345 }
2346#endif
2347 }
2348
2349 void CommandDispatcherComponentBase ::
2350 log_WARNING_HI_TooManyCommands(U32 Opcode)
2351 {
2352 // Get the time
2353 Fw::Time _logTime;
2354 if (this->m_Time_OutputPort[0].isConnected()) {
2355 this->m_Time_OutputPort[0].invoke(_logTime);
2356 }
2357
2358 FwEventIdType _id = static_cast<FwEventIdType>(0);
2359
2360 _id = this->getIdBase() + EVENTID_TOOMANYCOMMANDS;
2361
2362 // Emit the event on the log port
2363 if (this->m_Log_OutputPort[0].isConnected()) {
2364 Fw::LogBuffer _logBuff;
2366
2367#if FW_AMPCS_COMPATIBLE
2368 // Serialize the number of arguments
2369 _status = _logBuff.serialize(static_cast<U8>(1));
2370 FW_ASSERT(
2371 _status == Fw::FW_SERIALIZE_OK,
2372 static_cast<FwAssertArgType>(_status)
2373 );
2374#endif
2375
2376#if FW_AMPCS_COMPATIBLE
2377 // Serialize the argument size
2378 _status = _logBuff.serialize(
2379 static_cast<U8>(sizeof(U32))
2380 );
2381 FW_ASSERT(
2382 _status == Fw::FW_SERIALIZE_OK,
2383 static_cast<FwAssertArgType>(_status)
2384 );
2385#endif
2386 _status = _logBuff.serialize(Opcode);
2387 FW_ASSERT(
2388 _status == Fw::FW_SERIALIZE_OK,
2389 static_cast<FwAssertArgType>(_status)
2390 );
2391
2392 this->m_Log_OutputPort[0].invoke(
2393 _id,
2394 _logTime,
2396 _logBuff
2397 );
2398 }
2399
2400 // Emit the event on the text log port
2401#if FW_ENABLE_TEXT_LOGGING
2402 if (this->m_LogText_OutputPort[0].isConnected()) {
2403#if FW_OBJECT_NAMES == 1
2404 const char* _formatString =
2405 "(%s) %s: Too many outstanding commands. opcode=0x%" PRIx32 "";
2406#else
2407 const char* _formatString =
2408 "%s: Too many outstanding commands. opcode=0x%" PRIx32 "";
2409#endif
2410
2411 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2412
2413 (void) snprintf(
2414 _textBuffer,
2416 _formatString,
2417#if FW_OBJECT_NAMES == 1
2418 this->m_objName,
2419#endif
2420 "TooManyCommands ",
2421 Opcode
2422 );
2423
2424 // Null terminate
2425 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2426 Fw::TextLogString _logString = _textBuffer;
2427 this->m_LogText_OutputPort[0].invoke(
2428 _id,
2429 _logTime,
2431 _logString
2432 );
2433 }
2434#endif
2435 }
2436
2437 void CommandDispatcherComponentBase ::
2438 log_ACTIVITY_HI_NoOpReceived()
2439 {
2440 // Get the time
2441 Fw::Time _logTime;
2442 if (this->m_Time_OutputPort[0].isConnected()) {
2443 this->m_Time_OutputPort[0].invoke(_logTime);
2444 }
2445
2446 FwEventIdType _id = static_cast<FwEventIdType>(0);
2447
2448 _id = this->getIdBase() + EVENTID_NOOPRECEIVED;
2449
2450 // Emit the event on the log port
2451 if (this->m_Log_OutputPort[0].isConnected()) {
2452 Fw::LogBuffer _logBuff;
2453
2454#if FW_AMPCS_COMPATIBLE
2456 // Serialize the number of arguments
2457 _status = _logBuff.serialize(static_cast<U8>(0));
2458 FW_ASSERT(
2459 _status == Fw::FW_SERIALIZE_OK,
2460 static_cast<FwAssertArgType>(_status)
2461 );
2462#endif
2463
2464 this->m_Log_OutputPort[0].invoke(
2465 _id,
2466 _logTime,
2468 _logBuff
2469 );
2470 }
2471
2472 // Emit the event on the text log port
2473#if FW_ENABLE_TEXT_LOGGING
2474 if (this->m_LogText_OutputPort[0].isConnected()) {
2475#if FW_OBJECT_NAMES == 1
2476 const char* _formatString =
2477 "(%s) %s: Received a NO-OP command";
2478#else
2479 const char* _formatString =
2480 "%s: Received a NO-OP command";
2481#endif
2482
2483 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2484
2485 (void) snprintf(
2486 _textBuffer,
2488 _formatString,
2489#if FW_OBJECT_NAMES == 1
2490 this->m_objName,
2491#endif
2492 "NoOpReceived "
2493 );
2494
2495 // Null terminate
2496 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2497 Fw::TextLogString _logString = _textBuffer;
2498 this->m_LogText_OutputPort[0].invoke(
2499 _id,
2500 _logTime,
2502 _logString
2503 );
2504 }
2505#endif
2506 }
2507
2508 void CommandDispatcherComponentBase ::
2509 log_ACTIVITY_HI_NoOpStringReceived(const Fw::LogStringArg& message)
2510 {
2511 // Get the time
2512 Fw::Time _logTime;
2513 if (this->m_Time_OutputPort[0].isConnected()) {
2514 this->m_Time_OutputPort[0].invoke(_logTime);
2515 }
2516
2517 FwEventIdType _id = static_cast<FwEventIdType>(0);
2518
2519 _id = this->getIdBase() + EVENTID_NOOPSTRINGRECEIVED;
2520
2521 // Emit the event on the log port
2522 if (this->m_Log_OutputPort[0].isConnected()) {
2523 Fw::LogBuffer _logBuff;
2525
2526#if FW_AMPCS_COMPATIBLE
2527 // Serialize the number of arguments
2528 _status = _logBuff.serialize(static_cast<U8>(1));
2529 FW_ASSERT(
2530 _status == Fw::FW_SERIALIZE_OK,
2531 static_cast<FwAssertArgType>(_status)
2532 );
2533#endif
2534
2535 _status = message.serialize(_logBuff, 40);
2536 FW_ASSERT(
2537 _status == Fw::FW_SERIALIZE_OK,
2538 static_cast<FwAssertArgType>(_status)
2539 );
2540
2541 this->m_Log_OutputPort[0].invoke(
2542 _id,
2543 _logTime,
2545 _logBuff
2546 );
2547 }
2548
2549 // Emit the event on the text log port
2550#if FW_ENABLE_TEXT_LOGGING
2551 if (this->m_LogText_OutputPort[0].isConnected()) {
2552#if FW_OBJECT_NAMES == 1
2553 const char* _formatString =
2554 "(%s) %s: Received a NO-OP string=%s";
2555#else
2556 const char* _formatString =
2557 "%s: Received a NO-OP string=%s";
2558#endif
2559
2560 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2561
2562 (void) snprintf(
2563 _textBuffer,
2565 _formatString,
2566#if FW_OBJECT_NAMES == 1
2567 this->m_objName,
2568#endif
2569 "NoOpStringReceived ",
2570 message.toChar()
2571 );
2572
2573 // Null terminate
2574 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2575 Fw::TextLogString _logString = _textBuffer;
2576 this->m_LogText_OutputPort[0].invoke(
2577 _id,
2578 _logTime,
2580 _logString
2581 );
2582 }
2583#endif
2584 }
2585
2586 void CommandDispatcherComponentBase ::
2587 log_ACTIVITY_HI_TestCmd1Args(
2588 I32 arg1,
2589 F32 arg2,
2590 U8 arg3
2591 )
2592 {
2593 // Get the time
2594 Fw::Time _logTime;
2595 if (this->m_Time_OutputPort[0].isConnected()) {
2596 this->m_Time_OutputPort[0].invoke(_logTime);
2597 }
2598
2599 FwEventIdType _id = static_cast<FwEventIdType>(0);
2600
2601 _id = this->getIdBase() + EVENTID_TESTCMD1ARGS;
2602
2603 // Emit the event on the log port
2604 if (this->m_Log_OutputPort[0].isConnected()) {
2605 Fw::LogBuffer _logBuff;
2607
2608#if FW_AMPCS_COMPATIBLE
2609 // Serialize the number of arguments
2610 _status = _logBuff.serialize(static_cast<U8>(3));
2611 FW_ASSERT(
2612 _status == Fw::FW_SERIALIZE_OK,
2613 static_cast<FwAssertArgType>(_status)
2614 );
2615#endif
2616
2617#if FW_AMPCS_COMPATIBLE
2618 // Serialize the argument size
2619 _status = _logBuff.serialize(
2620 static_cast<U8>(sizeof(I32))
2621 );
2622 FW_ASSERT(
2623 _status == Fw::FW_SERIALIZE_OK,
2624 static_cast<FwAssertArgType>(_status)
2625 );
2626#endif
2627 _status = _logBuff.serialize(arg1);
2628 FW_ASSERT(
2629 _status == Fw::FW_SERIALIZE_OK,
2630 static_cast<FwAssertArgType>(_status)
2631 );
2632
2633#if FW_AMPCS_COMPATIBLE
2634 // Serialize the argument size
2635 _status = _logBuff.serialize(
2636 static_cast<U8>(sizeof(F32))
2637 );
2638 FW_ASSERT(
2639 _status == Fw::FW_SERIALIZE_OK,
2640 static_cast<FwAssertArgType>(_status)
2641 );
2642#endif
2643 _status = _logBuff.serialize(arg2);
2644 FW_ASSERT(
2645 _status == Fw::FW_SERIALIZE_OK,
2646 static_cast<FwAssertArgType>(_status)
2647 );
2648
2649#if FW_AMPCS_COMPATIBLE
2650 // Serialize the argument size
2651 _status = _logBuff.serialize(
2652 static_cast<U8>(sizeof(U8))
2653 );
2654 FW_ASSERT(
2655 _status == Fw::FW_SERIALIZE_OK,
2656 static_cast<FwAssertArgType>(_status)
2657 );
2658#endif
2659 _status = _logBuff.serialize(arg3);
2660 FW_ASSERT(
2661 _status == Fw::FW_SERIALIZE_OK,
2662 static_cast<FwAssertArgType>(_status)
2663 );
2664
2665 this->m_Log_OutputPort[0].invoke(
2666 _id,
2667 _logTime,
2669 _logBuff
2670 );
2671 }
2672
2673 // Emit the event on the text log port
2674#if FW_ENABLE_TEXT_LOGGING
2675 if (this->m_LogText_OutputPort[0].isConnected()) {
2676#if FW_OBJECT_NAMES == 1
2677 const char* _formatString =
2678 "(%s) %s: TEST_CMD_1 args: I32: %" PRIi32 ", F32: %f, U8: %" PRIu8 "";
2679#else
2680 const char* _formatString =
2681 "%s: TEST_CMD_1 args: I32: %" PRIi32 ", F32: %f, U8: %" PRIu8 "";
2682#endif
2683
2684 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2685
2686 (void) snprintf(
2687 _textBuffer,
2689 _formatString,
2690#if FW_OBJECT_NAMES == 1
2691 this->m_objName,
2692#endif
2693 "TestCmd1Args ",
2694 arg1,
2695 arg2,
2696 arg3
2697 );
2698
2699 // Null terminate
2700 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2701 Fw::TextLogString _logString = _textBuffer;
2702 this->m_LogText_OutputPort[0].invoke(
2703 _id,
2704 _logTime,
2706 _logString
2707 );
2708 }
2709#endif
2710 }
2711
2712 void CommandDispatcherComponentBase ::
2713 log_DIAGNOSTIC_OpCodeReregistered(
2714 U32 Opcode,
2715 I32 port
2716 )
2717 {
2718 // Get the time
2719 Fw::Time _logTime;
2720 if (this->m_Time_OutputPort[0].isConnected()) {
2721 this->m_Time_OutputPort[0].invoke(_logTime);
2722 }
2723
2724 FwEventIdType _id = static_cast<FwEventIdType>(0);
2725
2726 _id = this->getIdBase() + EVENTID_OPCODEREREGISTERED;
2727
2728 // Emit the event on the log port
2729 if (this->m_Log_OutputPort[0].isConnected()) {
2730 Fw::LogBuffer _logBuff;
2732
2733#if FW_AMPCS_COMPATIBLE
2734 // Serialize the number of arguments
2735 _status = _logBuff.serialize(static_cast<U8>(2));
2736 FW_ASSERT(
2737 _status == Fw::FW_SERIALIZE_OK,
2738 static_cast<FwAssertArgType>(_status)
2739 );
2740#endif
2741
2742#if FW_AMPCS_COMPATIBLE
2743 // Serialize the argument size
2744 _status = _logBuff.serialize(
2745 static_cast<U8>(sizeof(U32))
2746 );
2747 FW_ASSERT(
2748 _status == Fw::FW_SERIALIZE_OK,
2749 static_cast<FwAssertArgType>(_status)
2750 );
2751#endif
2752 _status = _logBuff.serialize(Opcode);
2753 FW_ASSERT(
2754 _status == Fw::FW_SERIALIZE_OK,
2755 static_cast<FwAssertArgType>(_status)
2756 );
2757
2758#if FW_AMPCS_COMPATIBLE
2759 // Serialize the argument size
2760 _status = _logBuff.serialize(
2761 static_cast<U8>(sizeof(I32))
2762 );
2763 FW_ASSERT(
2764 _status == Fw::FW_SERIALIZE_OK,
2765 static_cast<FwAssertArgType>(_status)
2766 );
2767#endif
2768 _status = _logBuff.serialize(port);
2769 FW_ASSERT(
2770 _status == Fw::FW_SERIALIZE_OK,
2771 static_cast<FwAssertArgType>(_status)
2772 );
2773
2774 this->m_Log_OutputPort[0].invoke(
2775 _id,
2776 _logTime,
2778 _logBuff
2779 );
2780 }
2781
2782 // Emit the event on the text log port
2783#if FW_ENABLE_TEXT_LOGGING
2784 if (this->m_LogText_OutputPort[0].isConnected()) {
2785#if FW_OBJECT_NAMES == 1
2786 const char* _formatString =
2787 "(%s) %s: Opcode 0x%" PRIx32 " is already registered to port %" PRIi32 "";
2788#else
2789 const char* _formatString =
2790 "%s: Opcode 0x%" PRIx32 " is already registered to port %" PRIi32 "";
2791#endif
2792
2793 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2794
2795 (void) snprintf(
2796 _textBuffer,
2798 _formatString,
2799#if FW_OBJECT_NAMES == 1
2800 this->m_objName,
2801#endif
2802 "OpCodeReregistered ",
2803 Opcode,
2804 port
2805 );
2806
2807 // Null terminate
2808 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2809 Fw::TextLogString _logString = _textBuffer;
2810 this->m_LogText_OutputPort[0].invoke(
2811 _id,
2812 _logTime,
2814 _logString
2815 );
2816 }
2817#endif
2818 }
2819
2820 // ----------------------------------------------------------------------
2821 // Telemetry write functions
2822 // ----------------------------------------------------------------------
2823
2824 void CommandDispatcherComponentBase ::
2825 tlmWrite_CommandsDispatched(
2826 U32 arg,
2827 Fw::Time _tlmTime
2828 )
2829 {
2830 // Check to see if it is the first time
2831 if (not this->m_first_update_CommandsDispatched) {
2832 // Check to see if value has changed. If not, don't write it.
2833 if (arg == this->m_last_CommandsDispatched) {
2834 return;
2835 }
2836 else {
2837 this->m_last_CommandsDispatched = arg;
2838 }
2839 }
2840 else {
2841 this->m_first_update_CommandsDispatched = false;
2842 this->m_last_CommandsDispatched = arg;
2843 }
2844
2845 if (this->m_Tlm_OutputPort[0].isConnected()) {
2846 if (
2847 this->m_Time_OutputPort[0].isConnected() &&
2848 (_tlmTime == Fw::ZERO_TIME)
2849 ) {
2850 this->m_Time_OutputPort[0].invoke(_tlmTime);
2851 }
2852
2853 Fw::TlmBuffer _tlmBuff;
2854 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
2855 FW_ASSERT(
2856 _stat == Fw::FW_SERIALIZE_OK,
2857 static_cast<FwAssertArgType>(_stat)
2858 );
2859
2860 FwChanIdType _id;
2861
2862 _id = this->getIdBase() + CHANNELID_COMMANDSDISPATCHED;
2863
2864 this->m_Tlm_OutputPort[0].invoke(
2865 _id,
2866 _tlmTime,
2867 _tlmBuff
2868 );
2869 }
2870 }
2871
2872 void CommandDispatcherComponentBase ::
2873 tlmWrite_CommandErrors(
2874 U32 arg,
2875 Fw::Time _tlmTime
2876 )
2877 {
2878 // Check to see if it is the first time
2879 if (not this->m_first_update_CommandErrors) {
2880 // Check to see if value has changed. If not, don't write it.
2881 if (arg == this->m_last_CommandErrors) {
2882 return;
2883 }
2884 else {
2885 this->m_last_CommandErrors = arg;
2886 }
2887 }
2888 else {
2889 this->m_first_update_CommandErrors = false;
2890 this->m_last_CommandErrors = arg;
2891 }
2892
2893 if (this->m_Tlm_OutputPort[0].isConnected()) {
2894 if (
2895 this->m_Time_OutputPort[0].isConnected() &&
2896 (_tlmTime == Fw::ZERO_TIME)
2897 ) {
2898 this->m_Time_OutputPort[0].invoke(_tlmTime);
2899 }
2900
2901 Fw::TlmBuffer _tlmBuff;
2902 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
2903 FW_ASSERT(
2904 _stat == Fw::FW_SERIALIZE_OK,
2905 static_cast<FwAssertArgType>(_stat)
2906 );
2907
2908 FwChanIdType _id;
2909
2910 _id = this->getIdBase() + CHANNELID_COMMANDERRORS;
2911
2912 this->m_Tlm_OutputPort[0].invoke(
2913 _id,
2914 _tlmTime,
2915 _tlmBuff
2916 );
2917 }
2918 }
2919
2920 // ----------------------------------------------------------------------
2921 // Time
2922 // ----------------------------------------------------------------------
2923
2924 Fw::Time CommandDispatcherComponentBase ::
2925 getTime()
2926 {
2927 if (this->m_Time_OutputPort[0].isConnected()) {
2928 Fw::Time _time;
2929 this->m_Time_OutputPort[0].invoke(_time);
2930 return _time;
2931 }
2932 else {
2933 return Fw::Time(TB_NONE, 0, 0);
2934 }
2935 }
2936
2937 // ----------------------------------------------------------------------
2938 // Mutex operations for guarded ports
2939 //
2940 // You can override these operations to provide more sophisticated
2941 // synchronization
2942 // ----------------------------------------------------------------------
2943
2944 void CommandDispatcherComponentBase ::
2945 lock()
2946 {
2947 this->m_guardedPortMutex.lock();
2948 }
2949
2950 void CommandDispatcherComponentBase ::
2951 unLock()
2952 {
2953 this->m_guardedPortMutex.unLock();
2954 }
2955
2956 // ----------------------------------------------------------------------
2957 // Message dispatch functions
2958 // ----------------------------------------------------------------------
2959
2960 Fw::QueuedComponentBase::MsgDispatchStatus CommandDispatcherComponentBase ::
2961 doDispatch()
2962 {
2963 ComponentIpcSerializableBuffer msg;
2964 NATIVE_INT_TYPE priority = 0;
2965
2966 Os::Queue::QueueStatus msgStatus = this->m_queue.receive(
2967 msg,
2968 priority,
2970 );
2971 FW_ASSERT(
2972 msgStatus == Os::Queue::QUEUE_OK,
2973 static_cast<FwAssertArgType>(msgStatus)
2974 );
2975
2976 // Reset to beginning of buffer
2977 msg.resetDeser();
2978
2979 NATIVE_INT_TYPE desMsg = 0;
2980 Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
2981 FW_ASSERT(
2982 deserStatus == Fw::FW_SERIALIZE_OK,
2983 static_cast<FwAssertArgType>(deserStatus)
2984 );
2985
2986 MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
2987
2988 if (msgType == COMMANDDISPATCHER_COMPONENT_EXIT) {
2989 return MSG_DISPATCH_EXIT;
2990 }
2991
2992 NATIVE_INT_TYPE portNum = 0;
2993 deserStatus = msg.deserialize(portNum);
2994 FW_ASSERT(
2995 deserStatus == Fw::FW_SERIALIZE_OK,
2996 static_cast<FwAssertArgType>(deserStatus)
2997 );
2998
2999 switch (msgType) {
3000 // Handle async input port compCmdStat
3001 case COMPCMDSTAT_CMDRESPONSE: {
3002 // Deserialize argument opCode
3003 FwOpcodeType opCode;
3004 deserStatus = msg.deserialize(opCode);
3005 FW_ASSERT(
3006 deserStatus == Fw::FW_SERIALIZE_OK,
3007 static_cast<FwAssertArgType>(deserStatus)
3008 );
3009
3010 // Deserialize argument cmdSeq
3011 U32 cmdSeq;
3012 deserStatus = msg.deserialize(cmdSeq);
3013 FW_ASSERT(
3014 deserStatus == Fw::FW_SERIALIZE_OK,
3015 static_cast<FwAssertArgType>(deserStatus)
3016 );
3017
3018 // Deserialize argument response
3019 Fw::CmdResponse response;
3020 deserStatus = msg.deserialize(response);
3021 FW_ASSERT(
3022 deserStatus == Fw::FW_SERIALIZE_OK,
3023 static_cast<FwAssertArgType>(deserStatus)
3024 );
3025 // Call handler function
3026 this->compCmdStat_handler(
3027 portNum,
3028 opCode,
3029 cmdSeq,
3030 response
3031 );
3032
3033 break;
3034 }
3035
3036 // Handle async input port pingIn
3037 case PINGIN_PING: {
3038 // Deserialize argument key
3039 U32 key;
3040 deserStatus = msg.deserialize(key);
3041 FW_ASSERT(
3042 deserStatus == Fw::FW_SERIALIZE_OK,
3043 static_cast<FwAssertArgType>(deserStatus)
3044 );
3045 // Call handler function
3046 this->pingIn_handler(
3047 portNum,
3048 key
3049 );
3050
3051 break;
3052 }
3053
3054 // Handle async input port seqCmdBuff
3055 case SEQCMDBUFF_COM: {
3056 // Deserialize argument data
3057 Fw::ComBuffer data;
3058 deserStatus = msg.deserialize(data);
3059 FW_ASSERT(
3060 deserStatus == Fw::FW_SERIALIZE_OK,
3061 static_cast<FwAssertArgType>(deserStatus)
3062 );
3063
3064 // Deserialize argument context
3065 U32 context;
3066 deserStatus = msg.deserialize(context);
3067 FW_ASSERT(
3068 deserStatus == Fw::FW_SERIALIZE_OK,
3069 static_cast<FwAssertArgType>(deserStatus)
3070 );
3071 // Call handler function
3072 this->seqCmdBuff_handler(
3073 portNum,
3074 data,
3075 context
3076 );
3077
3078 break;
3079 }
3080
3081 // Handle command CMD_NO_OP
3082 case CMD_CMD_NO_OP: {
3083 // Deserialize opcode
3084 FwOpcodeType opCode = 0;
3085 deserStatus = msg.deserialize(opCode);
3086 FW_ASSERT (
3087 deserStatus == Fw::FW_SERIALIZE_OK,
3088 static_cast<FwAssertArgType>(deserStatus)
3089 );
3090
3091 // Deserialize command sequence
3092 U32 cmdSeq = 0;
3093 deserStatus = msg.deserialize(cmdSeq);
3094 FW_ASSERT (
3095 deserStatus == Fw::FW_SERIALIZE_OK,
3096 static_cast<FwAssertArgType>(deserStatus)
3097 );
3098
3099 // Deserialize command argument buffer
3100 Fw::CmdArgBuffer args;
3101 deserStatus = msg.deserialize(args);
3102 FW_ASSERT (
3103 deserStatus == Fw::FW_SERIALIZE_OK,
3104 static_cast<FwAssertArgType>(deserStatus)
3105 );
3106
3107 // Reset buffer
3108 args.resetDeser();
3109
3110 // Make sure there was no data left over.
3111 // That means the argument buffer size was incorrect.
3112#if FW_CMD_CHECK_RESIDUAL
3113 if (args.getBuffLeft() != 0) {
3114 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
3115 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
3116 }
3117 // Don't crash the task if bad arguments were passed from the ground
3118 break;
3119 }
3120#endif
3121
3122 // Call handler function
3123 this->CMD_NO_OP_cmdHandler(opCode, cmdSeq);
3124
3125 break;
3126 }
3127
3128 // Handle command CMD_NO_OP_STRING
3129 case CMD_CMD_NO_OP_STRING: {
3130 // Deserialize opcode
3131 FwOpcodeType opCode = 0;
3132 deserStatus = msg.deserialize(opCode);
3133 FW_ASSERT (
3134 deserStatus == Fw::FW_SERIALIZE_OK,
3135 static_cast<FwAssertArgType>(deserStatus)
3136 );
3137
3138 // Deserialize command sequence
3139 U32 cmdSeq = 0;
3140 deserStatus = msg.deserialize(cmdSeq);
3141 FW_ASSERT (
3142 deserStatus == Fw::FW_SERIALIZE_OK,
3143 static_cast<FwAssertArgType>(deserStatus)
3144 );
3145
3146 // Deserialize command argument buffer
3147 Fw::CmdArgBuffer args;
3148 deserStatus = msg.deserialize(args);
3149 FW_ASSERT (
3150 deserStatus == Fw::FW_SERIALIZE_OK,
3151 static_cast<FwAssertArgType>(deserStatus)
3152 );
3153
3154 // Reset buffer
3155 args.resetDeser();
3156
3157 // Deserialize argument arg1
3158 Fw::CmdStringArg arg1;
3159 deserStatus = args.deserialize(arg1);
3160 if (deserStatus != Fw::FW_SERIALIZE_OK) {
3161 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
3162 this->cmdResponse_out(
3163 opCode,
3164 cmdSeq,
3166 );
3167 }
3168 // Don't crash the task if bad arguments were passed from the ground
3169 break;
3170 }
3171
3172 // Make sure there was no data left over.
3173 // That means the argument buffer size was incorrect.
3174#if FW_CMD_CHECK_RESIDUAL
3175 if (args.getBuffLeft() != 0) {
3176 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
3177 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
3178 }
3179 // Don't crash the task if bad arguments were passed from the ground
3180 break;
3181 }
3182#endif
3183
3184 // Call handler function
3185 this->CMD_NO_OP_STRING_cmdHandler(
3186 opCode, cmdSeq,
3187 arg1
3188 );
3189
3190 break;
3191 }
3192
3193 // Handle command CMD_TEST_CMD_1
3194 case CMD_CMD_TEST_CMD_1: {
3195 // Deserialize opcode
3196 FwOpcodeType opCode = 0;
3197 deserStatus = msg.deserialize(opCode);
3198 FW_ASSERT (
3199 deserStatus == Fw::FW_SERIALIZE_OK,
3200 static_cast<FwAssertArgType>(deserStatus)
3201 );
3202
3203 // Deserialize command sequence
3204 U32 cmdSeq = 0;
3205 deserStatus = msg.deserialize(cmdSeq);
3206 FW_ASSERT (
3207 deserStatus == Fw::FW_SERIALIZE_OK,
3208 static_cast<FwAssertArgType>(deserStatus)
3209 );
3210
3211 // Deserialize command argument buffer
3212 Fw::CmdArgBuffer args;
3213 deserStatus = msg.deserialize(args);
3214 FW_ASSERT (
3215 deserStatus == Fw::FW_SERIALIZE_OK,
3216 static_cast<FwAssertArgType>(deserStatus)
3217 );
3218
3219 // Reset buffer
3220 args.resetDeser();
3221
3222 // Deserialize argument arg1
3223 I32 arg1;
3224 deserStatus = args.deserialize(arg1);
3225 if (deserStatus != Fw::FW_SERIALIZE_OK) {
3226 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
3227 this->cmdResponse_out(
3228 opCode,
3229 cmdSeq,
3231 );
3232 }
3233 // Don't crash the task if bad arguments were passed from the ground
3234 break;
3235 }
3236
3237 // Deserialize argument arg2
3238 F32 arg2;
3239 deserStatus = args.deserialize(arg2);
3240 if (deserStatus != Fw::FW_SERIALIZE_OK) {
3241 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
3242 this->cmdResponse_out(
3243 opCode,
3244 cmdSeq,
3246 );
3247 }
3248 // Don't crash the task if bad arguments were passed from the ground
3249 break;
3250 }
3251
3252 // Deserialize argument arg3
3253 U8 arg3;
3254 deserStatus = args.deserialize(arg3);
3255 if (deserStatus != Fw::FW_SERIALIZE_OK) {
3256 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
3257 this->cmdResponse_out(
3258 opCode,
3259 cmdSeq,
3261 );
3262 }
3263 // Don't crash the task if bad arguments were passed from the ground
3264 break;
3265 }
3266
3267 // Make sure there was no data left over.
3268 // That means the argument buffer size was incorrect.
3269#if FW_CMD_CHECK_RESIDUAL
3270 if (args.getBuffLeft() != 0) {
3271 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
3272 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
3273 }
3274 // Don't crash the task if bad arguments were passed from the ground
3275 break;
3276 }
3277#endif
3278
3279 // Call handler function
3280 this->CMD_TEST_CMD_1_cmdHandler(
3281 opCode, cmdSeq,
3282 arg1,
3283 arg2,
3284 arg3
3285 );
3286
3287 break;
3288 }
3289
3290 // Handle command CMD_CLEAR_TRACKING
3291 case CMD_CMD_CLEAR_TRACKING: {
3292 // Deserialize opcode
3293 FwOpcodeType opCode = 0;
3294 deserStatus = msg.deserialize(opCode);
3295 FW_ASSERT (
3296 deserStatus == Fw::FW_SERIALIZE_OK,
3297 static_cast<FwAssertArgType>(deserStatus)
3298 );
3299
3300 // Deserialize command sequence
3301 U32 cmdSeq = 0;
3302 deserStatus = msg.deserialize(cmdSeq);
3303 FW_ASSERT (
3304 deserStatus == Fw::FW_SERIALIZE_OK,
3305 static_cast<FwAssertArgType>(deserStatus)
3306 );
3307
3308 // Deserialize command argument buffer
3309 Fw::CmdArgBuffer args;
3310 deserStatus = msg.deserialize(args);
3311 FW_ASSERT (
3312 deserStatus == Fw::FW_SERIALIZE_OK,
3313 static_cast<FwAssertArgType>(deserStatus)
3314 );
3315
3316 // Reset buffer
3317 args.resetDeser();
3318
3319 // Make sure there was no data left over.
3320 // That means the argument buffer size was incorrect.
3321#if FW_CMD_CHECK_RESIDUAL
3322 if (args.getBuffLeft() != 0) {
3323 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
3324 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
3325 }
3326 // Don't crash the task if bad arguments were passed from the ground
3327 break;
3328 }
3329#endif
3330
3331 // Call handler function
3332 this->CMD_CLEAR_TRACKING_cmdHandler(opCode, cmdSeq);
3333
3334 break;
3335 }
3336
3337 default:
3338 return MSG_DISPATCH_ERROR;
3339 }
3340
3341 return MSG_DISPATCH_OK;
3342 }
3343
3344 // ----------------------------------------------------------------------
3345 // Calls for messages received on special input ports
3346 // ----------------------------------------------------------------------
3347
3348 void CommandDispatcherComponentBase ::
3349 m_p_CmdDisp_in(
3350 Fw::PassiveComponentBase* callComp,
3351 NATIVE_INT_TYPE portNum,
3352 FwOpcodeType opCode,
3353 U32 cmdSeq,
3354 Fw::CmdArgBuffer& args
3355 )
3356 {
3357 FW_ASSERT(callComp);
3358 CommandDispatcherComponentBase* compPtr = static_cast<CommandDispatcherComponentBase*>(callComp);
3359
3360 const U32 idBase = callComp->getIdBase();
3361 FW_ASSERT(opCode >= idBase, opCode, idBase);
3362
3363 // Select base class function based on opcode
3364 switch (opCode - idBase) {
3365 case OPCODE_CMD_NO_OP: {
3366 compPtr->CMD_NO_OP_cmdHandlerBase(
3367 opCode,
3368 cmdSeq,
3369 args
3370 );
3371 break;
3372 }
3373
3374 case OPCODE_CMD_NO_OP_STRING: {
3375 compPtr->CMD_NO_OP_STRING_cmdHandlerBase(
3376 opCode,
3377 cmdSeq,
3378 args
3379 );
3380 break;
3381 }
3382
3383 case OPCODE_CMD_TEST_CMD_1: {
3384 compPtr->CMD_TEST_CMD_1_cmdHandlerBase(
3385 opCode,
3386 cmdSeq,
3387 args
3388 );
3389 break;
3390 }
3391
3392 case OPCODE_CMD_CLEAR_TRACKING: {
3393 compPtr->CMD_CLEAR_TRACKING_cmdHandlerBase(
3394 opCode,
3395 cmdSeq,
3396 args
3397 );
3398 break;
3399 }
3400 }
3401 }
3402
3403 // ----------------------------------------------------------------------
3404 // Calls for messages received on typed input ports
3405 // ----------------------------------------------------------------------
3406
3407 void CommandDispatcherComponentBase ::
3408 m_p_compCmdReg_in(
3409 Fw::PassiveComponentBase* callComp,
3410 NATIVE_INT_TYPE portNum,
3411 FwOpcodeType opCode
3412 )
3413 {
3414 FW_ASSERT(callComp);
3415 CommandDispatcherComponentBase* compPtr = static_cast<CommandDispatcherComponentBase*>(callComp);
3416 compPtr->compCmdReg_handlerBase(
3417 portNum,
3418 opCode
3419 );
3420 }
3421
3422 void CommandDispatcherComponentBase ::
3423 m_p_compCmdStat_in(
3424 Fw::PassiveComponentBase* callComp,
3425 NATIVE_INT_TYPE portNum,
3426 FwOpcodeType opCode,
3427 U32 cmdSeq,
3428 const Fw::CmdResponse& response
3429 )
3430 {
3431 FW_ASSERT(callComp);
3432 CommandDispatcherComponentBase* compPtr = static_cast<CommandDispatcherComponentBase*>(callComp);
3433 compPtr->compCmdStat_handlerBase(
3434 portNum,
3435 opCode,
3436 cmdSeq,
3437 response
3438 );
3439 }
3440
3441 void CommandDispatcherComponentBase ::
3442 m_p_pingIn_in(
3443 Fw::PassiveComponentBase* callComp,
3444 NATIVE_INT_TYPE portNum,
3445 U32 key
3446 )
3447 {
3448 FW_ASSERT(callComp);
3449 CommandDispatcherComponentBase* compPtr = static_cast<CommandDispatcherComponentBase*>(callComp);
3450 compPtr->pingIn_handlerBase(
3451 portNum,
3452 key
3453 );
3454 }
3455
3456 void CommandDispatcherComponentBase ::
3457 m_p_seqCmdBuff_in(
3458 Fw::PassiveComponentBase* callComp,
3459 NATIVE_INT_TYPE portNum,
3460 Fw::ComBuffer& data,
3461 U32 context
3462 )
3463 {
3464 FW_ASSERT(callComp);
3465 CommandDispatcherComponentBase* compPtr = static_cast<CommandDispatcherComponentBase*>(callComp);
3466 compPtr->seqCmdBuff_handlerBase(
3467 portNum,
3468 data,
3469 context
3470 );
3471 }
3472
3473}
#define FW_ASSERT(...)
Definition Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
U8 BYTE
byte type
Definition BasicTypes.h:27
float F32
32-bit floating point
Definition BasicTypes.h:45
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition BasicTypes.h:66
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
#define PRI_PlatformIntType
@ TB_NONE
No time base has been established.
Definition FpConfig.h:39
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:21
U32 FwChanIdType
Definition FpConfig.h:59
U32 FwEventIdType
Definition FpConfig.h:62
U32 FwOpcodeType
Definition FpConfig.h:56
#define FW_LOG_TEXT_BUFFER_SIZE
Max size of string for text log message.
Definition FpConfig.h:299
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects)
Definition FpConfig.h:88
@ ACTIVE_COMPONENT_EXIT
message to exit active component task
Enum representing a command response.
@ FORMAT_ERROR
Command failed to deserialize.
@ SERIALIZED_SIZE
The size of the serial representation.
Deserialization status.
@ SERIALIZED_SIZE
The size of the serial representation.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition CmdPortAc.hpp:37
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition ComPortAc.hpp:37
@ WARNING_HI
A serious but recoverable event.
@ ACTIVITY_HI
Important informational events.
@ DIAGNOSTIC
Software diagnostic events.
@ COMMAND
An activity related to commanding.
const char * toChar() const override
Definition LogString.cpp:49
SerializeStatus serialize(SerializeBufferBase &buffer) const override
serialization function
Definition LogString.cpp:57
void init()
Object initializer.
Definition ObjBase.cpp:27
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
void resetDeser()
reset deserialization to beginning
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
const char * toChar() const
gets char buffer
Definition String.cpp:48
@ QUEUE_OK
message sent/received okay
Definition Queue.hpp:28
QueueBlocking
Definition Queue.hpp:40
@ QUEUE_BLOCKING
Queue receive blocks until a message arrives.
Definition Queue.hpp:41
@ QUEUE_NONBLOCKING
Queue receive always returns even if there is no message.
Definition Queue.hpp:42
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
const Time ZERO_TIME
Definition Time.cpp:5