F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TlmPacketizerComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title TlmPacketizerComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for TlmPacketizer 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 TLMPACKETIZER_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
20 RUN_SCHED,
21 PINGIN_PING,
22 CMD_SET_LEVEL,
23 CMD_SEND_PKT,
24 };
25
26 // Get the max size by doing a union of the input and internal port serialization sizes
27 union BuffUnion {
32 };
33
34 // Define a message buffer class large enough to handle all the
35 // asynchronous inputs to the component
36 class ComponentIpcSerializableBuffer :
38 {
39
40 public:
41
42 enum {
43 // Max. message size = size of data + message id + port
44 SERIALIZATION_SIZE =
45 sizeof(BuffUnion) +
46 sizeof(NATIVE_INT_TYPE) +
47 sizeof(NATIVE_INT_TYPE)
48 };
49
50 NATIVE_UINT_TYPE getBuffCapacity() const {
51 return sizeof(m_buff);
52 }
53
54 U8* getBuffAddr() {
55 return m_buff;
56 }
57
58 const U8* getBuffAddr() const {
59 return m_buff;
60 }
61
62 private:
63 // Should be the max of all the input ports serialized sizes...
64 U8 m_buff[SERIALIZATION_SIZE];
65
66 };
67 }
68
69 // ----------------------------------------------------------------------
70 // Component initialization
71 // ----------------------------------------------------------------------
72
73 void TlmPacketizerComponentBase ::
74 init(
75 NATIVE_INT_TYPE queueDepth,
76 NATIVE_INT_TYPE instance
77 )
78 {
79 // Initialize base class
81
82 // Connect input port cmdIn
83 for (
84 PlatformIntType port = 0;
85 port < static_cast<PlatformIntType>(this->getNum_cmdIn_InputPorts());
86 port++
87 ) {
88 this->m_cmdIn_InputPort[port].init();
89 this->m_cmdIn_InputPort[port].addCallComp(
90 this,
91 m_p_cmdIn_in
92 );
93 this->m_cmdIn_InputPort[port].setPortNum(port);
94
95#if FW_OBJECT_NAMES == 1
96 char portName[120];
97 (void) snprintf(
98 portName,
99 sizeof(portName),
100 "%s_cmdIn_InputPort[%" PRI_PlatformIntType "]",
101 this->m_objName,
102 port
103 );
104 this->m_cmdIn_InputPort[port].setObjName(portName);
105#endif
106 }
107
108 // Connect input port Run
109 for (
110 PlatformIntType port = 0;
111 port < static_cast<PlatformIntType>(this->getNum_Run_InputPorts());
112 port++
113 ) {
114 this->m_Run_InputPort[port].init();
115 this->m_Run_InputPort[port].addCallComp(
116 this,
117 m_p_Run_in
118 );
119 this->m_Run_InputPort[port].setPortNum(port);
120
121#if FW_OBJECT_NAMES == 1
122 char portName[120];
123 (void) snprintf(
124 portName,
125 sizeof(portName),
126 "%s_Run_InputPort[%" PRI_PlatformIntType "]",
127 this->m_objName,
128 port
129 );
130 this->m_Run_InputPort[port].setObjName(portName);
131#endif
132 }
133
134 // Connect input port TlmRecv
135 for (
136 PlatformIntType port = 0;
137 port < static_cast<PlatformIntType>(this->getNum_TlmRecv_InputPorts());
138 port++
139 ) {
140 this->m_TlmRecv_InputPort[port].init();
141 this->m_TlmRecv_InputPort[port].addCallComp(
142 this,
143 m_p_TlmRecv_in
144 );
145 this->m_TlmRecv_InputPort[port].setPortNum(port);
146
147#if FW_OBJECT_NAMES == 1
148 char portName[120];
149 (void) snprintf(
150 portName,
151 sizeof(portName),
152 "%s_TlmRecv_InputPort[%" PRI_PlatformIntType "]",
153 this->m_objName,
154 port
155 );
156 this->m_TlmRecv_InputPort[port].setObjName(portName);
157#endif
158 }
159
160 // Connect input port pingIn
161 for (
162 PlatformIntType port = 0;
163 port < static_cast<PlatformIntType>(this->getNum_pingIn_InputPorts());
164 port++
165 ) {
166 this->m_pingIn_InputPort[port].init();
167 this->m_pingIn_InputPort[port].addCallComp(
168 this,
169 m_p_pingIn_in
170 );
171 this->m_pingIn_InputPort[port].setPortNum(port);
172
173#if FW_OBJECT_NAMES == 1
174 char portName[120];
175 (void) snprintf(
176 portName,
177 sizeof(portName),
178 "%s_pingIn_InputPort[%" PRI_PlatformIntType "]",
179 this->m_objName,
180 port
181 );
182 this->m_pingIn_InputPort[port].setObjName(portName);
183#endif
184 }
185
186 // Connect output port cmdRegOut
187 for (
188 PlatformIntType port = 0;
189 port < static_cast<PlatformIntType>(this->getNum_cmdRegOut_OutputPorts());
190 port++
191 ) {
192 this->m_cmdRegOut_OutputPort[port].init();
193
194#if FW_OBJECT_NAMES == 1
195 char portName[120];
196 (void) snprintf(
197 portName,
198 sizeof(portName),
199 "%s_cmdRegOut_OutputPort[%" PRI_PlatformIntType "]",
200 this->m_objName,
201 port
202 );
203 this->m_cmdRegOut_OutputPort[port].setObjName(portName);
204#endif
205 }
206
207 // Connect output port cmdResponseOut
208 for (
209 PlatformIntType port = 0;
210 port < static_cast<PlatformIntType>(this->getNum_cmdResponseOut_OutputPorts());
211 port++
212 ) {
213 this->m_cmdResponseOut_OutputPort[port].init();
214
215#if FW_OBJECT_NAMES == 1
216 char portName[120];
217 (void) snprintf(
218 portName,
219 sizeof(portName),
220 "%s_cmdResponseOut_OutputPort[%" PRI_PlatformIntType "]",
221 this->m_objName,
222 port
223 );
224 this->m_cmdResponseOut_OutputPort[port].setObjName(portName);
225#endif
226 }
227
228 // Connect output port eventOut
229 for (
230 PlatformIntType port = 0;
231 port < static_cast<PlatformIntType>(this->getNum_eventOut_OutputPorts());
232 port++
233 ) {
234 this->m_eventOut_OutputPort[port].init();
235
236#if FW_OBJECT_NAMES == 1
237 char portName[120];
238 (void) snprintf(
239 portName,
240 sizeof(portName),
241 "%s_eventOut_OutputPort[%" PRI_PlatformIntType "]",
242 this->m_objName,
243 port
244 );
245 this->m_eventOut_OutputPort[port].setObjName(portName);
246#endif
247 }
248
249#if FW_ENABLE_TEXT_LOGGING == 1
250 // Connect output port textEventOut
251 for (
252 PlatformIntType port = 0;
253 port < static_cast<PlatformIntType>(this->getNum_textEventOut_OutputPorts());
254 port++
255 ) {
256 this->m_textEventOut_OutputPort[port].init();
257
258#if FW_OBJECT_NAMES == 1
259 char portName[120];
260 (void) snprintf(
261 portName,
262 sizeof(portName),
263 "%s_textEventOut_OutputPort[%" PRI_PlatformIntType "]",
264 this->m_objName,
265 port
266 );
267 this->m_textEventOut_OutputPort[port].setObjName(portName);
268#endif
269 }
270#endif
271
272 // Connect output port timeGetOut
273 for (
274 PlatformIntType port = 0;
275 port < static_cast<PlatformIntType>(this->getNum_timeGetOut_OutputPorts());
276 port++
277 ) {
278 this->m_timeGetOut_OutputPort[port].init();
279
280#if FW_OBJECT_NAMES == 1
281 char portName[120];
282 (void) snprintf(
283 portName,
284 sizeof(portName),
285 "%s_timeGetOut_OutputPort[%" PRI_PlatformIntType "]",
286 this->m_objName,
287 port
288 );
289 this->m_timeGetOut_OutputPort[port].setObjName(portName);
290#endif
291 }
292
293 // Connect output port tlmOut
294 for (
295 PlatformIntType port = 0;
296 port < static_cast<PlatformIntType>(this->getNum_tlmOut_OutputPorts());
297 port++
298 ) {
299 this->m_tlmOut_OutputPort[port].init();
300
301#if FW_OBJECT_NAMES == 1
302 char portName[120];
303 (void) snprintf(
304 portName,
305 sizeof(portName),
306 "%s_tlmOut_OutputPort[%" PRI_PlatformIntType "]",
307 this->m_objName,
308 port
309 );
310 this->m_tlmOut_OutputPort[port].setObjName(portName);
311#endif
312 }
313
314 // Connect output port PktSend
315 for (
316 PlatformIntType port = 0;
317 port < static_cast<PlatformIntType>(this->getNum_PktSend_OutputPorts());
318 port++
319 ) {
320 this->m_PktSend_OutputPort[port].init();
321
322#if FW_OBJECT_NAMES == 1
323 char portName[120];
324 (void) snprintf(
325 portName,
326 sizeof(portName),
327 "%s_PktSend_OutputPort[%" PRI_PlatformIntType "]",
328 this->m_objName,
329 port
330 );
331 this->m_PktSend_OutputPort[port].setObjName(portName);
332#endif
333 }
334
335 // Connect output port pingOut
336 for (
337 PlatformIntType port = 0;
338 port < static_cast<PlatformIntType>(this->getNum_pingOut_OutputPorts());
339 port++
340 ) {
341 this->m_pingOut_OutputPort[port].init();
342
343#if FW_OBJECT_NAMES == 1
344 char portName[120];
345 (void) snprintf(
346 portName,
347 sizeof(portName),
348 "%s_pingOut_OutputPort[%" PRI_PlatformIntType "]",
349 this->m_objName,
350 port
351 );
352 this->m_pingOut_OutputPort[port].setObjName(portName);
353#endif
354 }
355
356 Os::Queue::QueueStatus qStat = this->createQueue(
357 queueDepth,
358 ComponentIpcSerializableBuffer::SERIALIZATION_SIZE
359 );
360 FW_ASSERT(
361 Os::Queue::QUEUE_OK == qStat,
362 static_cast<FwAssertArgType>(qStat)
363 );
364 }
365
366 // ----------------------------------------------------------------------
367 // Getters for special input ports
368 // ----------------------------------------------------------------------
369
370 Fw::InputCmdPort* TlmPacketizerComponentBase ::
371 get_cmdIn_InputPort(NATIVE_INT_TYPE portNum)
372 {
373 FW_ASSERT(
374 portNum < this->getNum_cmdIn_InputPorts(),
375 static_cast<FwAssertArgType>(portNum)
376 );
377
378 return &this->m_cmdIn_InputPort[portNum];
379 }
380
381 // ----------------------------------------------------------------------
382 // Getters for typed input ports
383 // ----------------------------------------------------------------------
384
385 Svc::InputSchedPort* TlmPacketizerComponentBase ::
386 get_Run_InputPort(NATIVE_INT_TYPE portNum)
387 {
388 FW_ASSERT(
389 portNum < this->getNum_Run_InputPorts(),
390 static_cast<FwAssertArgType>(portNum)
391 );
392
393 return &this->m_Run_InputPort[portNum];
394 }
395
396 Fw::InputTlmPort* TlmPacketizerComponentBase ::
397 get_TlmRecv_InputPort(NATIVE_INT_TYPE portNum)
398 {
399 FW_ASSERT(
400 portNum < this->getNum_TlmRecv_InputPorts(),
401 static_cast<FwAssertArgType>(portNum)
402 );
403
404 return &this->m_TlmRecv_InputPort[portNum];
405 }
406
407 Svc::InputPingPort* TlmPacketizerComponentBase ::
408 get_pingIn_InputPort(NATIVE_INT_TYPE portNum)
409 {
410 FW_ASSERT(
411 portNum < this->getNum_pingIn_InputPorts(),
412 static_cast<FwAssertArgType>(portNum)
413 );
414
415 return &this->m_pingIn_InputPort[portNum];
416 }
417
418 // ----------------------------------------------------------------------
419 // Connect special input ports to special output ports
420 // ----------------------------------------------------------------------
421
422 void TlmPacketizerComponentBase ::
423 set_cmdRegOut_OutputPort(
424 NATIVE_INT_TYPE portNum,
426 )
427 {
428 FW_ASSERT(
429 portNum < this->getNum_cmdRegOut_OutputPorts(),
430 static_cast<FwAssertArgType>(portNum)
431 );
432
433 this->m_cmdRegOut_OutputPort[portNum].addCallPort(port);
434 }
435
436 void TlmPacketizerComponentBase ::
437 set_cmdResponseOut_OutputPort(
438 NATIVE_INT_TYPE portNum,
440 )
441 {
442 FW_ASSERT(
443 portNum < this->getNum_cmdResponseOut_OutputPorts(),
444 static_cast<FwAssertArgType>(portNum)
445 );
446
447 this->m_cmdResponseOut_OutputPort[portNum].addCallPort(port);
448 }
449
450 void TlmPacketizerComponentBase ::
451 set_eventOut_OutputPort(
452 NATIVE_INT_TYPE portNum,
453 Fw::InputLogPort* port
454 )
455 {
456 FW_ASSERT(
457 portNum < this->getNum_eventOut_OutputPorts(),
458 static_cast<FwAssertArgType>(portNum)
459 );
460
461 this->m_eventOut_OutputPort[portNum].addCallPort(port);
462 }
463
464#if FW_ENABLE_TEXT_LOGGING == 1
465
466 void TlmPacketizerComponentBase ::
467 set_textEventOut_OutputPort(
468 NATIVE_INT_TYPE portNum,
470 )
471 {
472 FW_ASSERT(
473 portNum < this->getNum_textEventOut_OutputPorts(),
474 static_cast<FwAssertArgType>(portNum)
475 );
476
477 this->m_textEventOut_OutputPort[portNum].addCallPort(port);
478 }
479
480#endif
481
482 void TlmPacketizerComponentBase ::
483 set_timeGetOut_OutputPort(
484 NATIVE_INT_TYPE portNum,
486 )
487 {
488 FW_ASSERT(
489 portNum < this->getNum_timeGetOut_OutputPorts(),
490 static_cast<FwAssertArgType>(portNum)
491 );
492
493 this->m_timeGetOut_OutputPort[portNum].addCallPort(port);
494 }
495
496 void TlmPacketizerComponentBase ::
497 set_tlmOut_OutputPort(
498 NATIVE_INT_TYPE portNum,
499 Fw::InputTlmPort* port
500 )
501 {
502 FW_ASSERT(
503 portNum < this->getNum_tlmOut_OutputPorts(),
504 static_cast<FwAssertArgType>(portNum)
505 );
506
507 this->m_tlmOut_OutputPort[portNum].addCallPort(port);
508 }
509
510 // ----------------------------------------------------------------------
511 // Connect typed input ports to typed output ports
512 // ----------------------------------------------------------------------
513
514 void TlmPacketizerComponentBase ::
515 set_PktSend_OutputPort(
516 NATIVE_INT_TYPE portNum,
517 Fw::InputComPort* port
518 )
519 {
520 FW_ASSERT(
521 portNum < this->getNum_PktSend_OutputPorts(),
522 static_cast<FwAssertArgType>(portNum)
523 );
524
525 this->m_PktSend_OutputPort[portNum].addCallPort(port);
526 }
527
528 void TlmPacketizerComponentBase ::
529 set_pingOut_OutputPort(
530 NATIVE_INT_TYPE portNum,
532 )
533 {
534 FW_ASSERT(
535 portNum < this->getNum_pingOut_OutputPorts(),
536 static_cast<FwAssertArgType>(portNum)
537 );
538
539 this->m_pingOut_OutputPort[portNum].addCallPort(port);
540 }
541
542#if FW_PORT_SERIALIZATION
543
544 // ----------------------------------------------------------------------
545 // Connect serial input ports to special output ports
546 // ----------------------------------------------------------------------
547
548 void TlmPacketizerComponentBase ::
549 set_cmdRegOut_OutputPort(
550 NATIVE_INT_TYPE portNum,
551 Fw::InputSerializePort* port
552 )
553 {
554 FW_ASSERT(
555 portNum < this->getNum_cmdRegOut_OutputPorts(),
556 static_cast<FwAssertArgType>(portNum)
557 );
558
559 this->m_cmdRegOut_OutputPort[portNum].registerSerialPort(port);
560 }
561
562 void TlmPacketizerComponentBase ::
563 set_cmdResponseOut_OutputPort(
564 NATIVE_INT_TYPE portNum,
565 Fw::InputSerializePort* port
566 )
567 {
568 FW_ASSERT(
569 portNum < this->getNum_cmdResponseOut_OutputPorts(),
570 static_cast<FwAssertArgType>(portNum)
571 );
572
573 this->m_cmdResponseOut_OutputPort[portNum].registerSerialPort(port);
574 }
575
576 void TlmPacketizerComponentBase ::
577 set_eventOut_OutputPort(
578 NATIVE_INT_TYPE portNum,
579 Fw::InputSerializePort* port
580 )
581 {
582 FW_ASSERT(
583 portNum < this->getNum_eventOut_OutputPorts(),
584 static_cast<FwAssertArgType>(portNum)
585 );
586
587 this->m_eventOut_OutputPort[portNum].registerSerialPort(port);
588 }
589
590#if FW_ENABLE_TEXT_LOGGING == 1
591
592 void TlmPacketizerComponentBase ::
593 set_textEventOut_OutputPort(
594 NATIVE_INT_TYPE portNum,
595 Fw::InputSerializePort* port
596 )
597 {
598 FW_ASSERT(
599 portNum < this->getNum_textEventOut_OutputPorts(),
600 static_cast<FwAssertArgType>(portNum)
601 );
602
603 this->m_textEventOut_OutputPort[portNum].registerSerialPort(port);
604 }
605
606#endif
607
608 void TlmPacketizerComponentBase ::
609 set_timeGetOut_OutputPort(
610 NATIVE_INT_TYPE portNum,
611 Fw::InputSerializePort* port
612 )
613 {
614 FW_ASSERT(
615 portNum < this->getNum_timeGetOut_OutputPorts(),
616 static_cast<FwAssertArgType>(portNum)
617 );
618
619 this->m_timeGetOut_OutputPort[portNum].registerSerialPort(port);
620 }
621
622 void TlmPacketizerComponentBase ::
623 set_tlmOut_OutputPort(
624 NATIVE_INT_TYPE portNum,
625 Fw::InputSerializePort* port
626 )
627 {
628 FW_ASSERT(
629 portNum < this->getNum_tlmOut_OutputPorts(),
630 static_cast<FwAssertArgType>(portNum)
631 );
632
633 this->m_tlmOut_OutputPort[portNum].registerSerialPort(port);
634 }
635
636#endif
637
638#if FW_PORT_SERIALIZATION
639
640 // ----------------------------------------------------------------------
641 // Connect serial input ports to typed output ports
642 // ----------------------------------------------------------------------
643
644 void TlmPacketizerComponentBase ::
645 set_PktSend_OutputPort(
646 NATIVE_INT_TYPE portNum,
647 Fw::InputSerializePort* port
648 )
649 {
650 FW_ASSERT(
651 portNum < this->getNum_PktSend_OutputPorts(),
652 static_cast<FwAssertArgType>(portNum)
653 );
654
655 this->m_PktSend_OutputPort[portNum].registerSerialPort(port);
656 }
657
658 void TlmPacketizerComponentBase ::
659 set_pingOut_OutputPort(
660 NATIVE_INT_TYPE portNum,
661 Fw::InputSerializePort* port
662 )
663 {
664 FW_ASSERT(
665 portNum < this->getNum_pingOut_OutputPorts(),
666 static_cast<FwAssertArgType>(portNum)
667 );
668
669 this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
670 }
671
672#endif
673
674 // ----------------------------------------------------------------------
675 // Command registration
676 // ----------------------------------------------------------------------
677
678 void TlmPacketizerComponentBase ::
679 regCommands()
680 {
681 FW_ASSERT(this->m_cmdRegOut_OutputPort[0].isConnected());
682
683 this->m_cmdRegOut_OutputPort[0].invoke(
684 this->getIdBase() + OPCODE_SET_LEVEL
685 );
686
687 this->m_cmdRegOut_OutputPort[0].invoke(
688 this->getIdBase() + OPCODE_SEND_PKT
689 );
690 }
691
692 // ----------------------------------------------------------------------
693 // Component construction and destruction
694 // ----------------------------------------------------------------------
695
696 TlmPacketizerComponentBase ::
697 TlmPacketizerComponentBase(const char* compName) :
698 Fw::ActiveComponentBase(compName)
699 {
700
701 }
702
703 TlmPacketizerComponentBase ::
704 ~TlmPacketizerComponentBase()
705 {
706
707 }
708
709 // ----------------------------------------------------------------------
710 // Getters for numbers of special input ports
711 // ----------------------------------------------------------------------
712
713 NATIVE_INT_TYPE TlmPacketizerComponentBase ::
714 getNum_cmdIn_InputPorts()
715 {
716 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdIn_InputPort));
717 }
718
719 // ----------------------------------------------------------------------
720 // Getters for numbers of typed input ports
721 // ----------------------------------------------------------------------
722
723 NATIVE_INT_TYPE TlmPacketizerComponentBase ::
724 getNum_Run_InputPorts()
725 {
726 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Run_InputPort));
727 }
728
729 NATIVE_INT_TYPE TlmPacketizerComponentBase ::
730 getNum_TlmRecv_InputPorts()
731 {
732 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_TlmRecv_InputPort));
733 }
734
735 NATIVE_INT_TYPE TlmPacketizerComponentBase ::
736 getNum_pingIn_InputPorts()
737 {
738 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_pingIn_InputPort));
739 }
740
741 // ----------------------------------------------------------------------
742 // Getters for numbers of special output ports
743 // ----------------------------------------------------------------------
744
745 NATIVE_INT_TYPE TlmPacketizerComponentBase ::
746 getNum_cmdRegOut_OutputPorts()
747 {
748 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdRegOut_OutputPort));
749 }
750
751 NATIVE_INT_TYPE TlmPacketizerComponentBase ::
752 getNum_cmdResponseOut_OutputPorts()
753 {
754 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdResponseOut_OutputPort));
755 }
756
757 NATIVE_INT_TYPE TlmPacketizerComponentBase ::
758 getNum_eventOut_OutputPorts()
759 {
760 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_eventOut_OutputPort));
761 }
762
763#if FW_ENABLE_TEXT_LOGGING == 1
764
765 NATIVE_INT_TYPE TlmPacketizerComponentBase ::
766 getNum_textEventOut_OutputPorts()
767 {
768 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_textEventOut_OutputPort));
769 }
770
771#endif
772
773 NATIVE_INT_TYPE TlmPacketizerComponentBase ::
774 getNum_timeGetOut_OutputPorts()
775 {
776 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_timeGetOut_OutputPort));
777 }
778
779 NATIVE_INT_TYPE TlmPacketizerComponentBase ::
780 getNum_tlmOut_OutputPorts()
781 {
782 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_tlmOut_OutputPort));
783 }
784
785 // ----------------------------------------------------------------------
786 // Getters for numbers of typed output ports
787 // ----------------------------------------------------------------------
788
789 NATIVE_INT_TYPE TlmPacketizerComponentBase ::
790 getNum_PktSend_OutputPorts()
791 {
792 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_PktSend_OutputPort));
793 }
794
795 NATIVE_INT_TYPE TlmPacketizerComponentBase ::
796 getNum_pingOut_OutputPorts()
797 {
798 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_pingOut_OutputPort));
799 }
800
801 // ----------------------------------------------------------------------
802 // Connection status queries for special output ports
803 // ----------------------------------------------------------------------
804
805 bool TlmPacketizerComponentBase ::
806 isConnected_cmdRegOut_OutputPort(NATIVE_INT_TYPE portNum)
807 {
808 FW_ASSERT(
809 portNum < this->getNum_cmdRegOut_OutputPorts(),
810 static_cast<FwAssertArgType>(portNum)
811 );
812
813 return this->m_cmdRegOut_OutputPort[portNum].isConnected();
814 }
815
816 bool TlmPacketizerComponentBase ::
817 isConnected_cmdResponseOut_OutputPort(NATIVE_INT_TYPE portNum)
818 {
819 FW_ASSERT(
820 portNum < this->getNum_cmdResponseOut_OutputPorts(),
821 static_cast<FwAssertArgType>(portNum)
822 );
823
824 return this->m_cmdResponseOut_OutputPort[portNum].isConnected();
825 }
826
827 bool TlmPacketizerComponentBase ::
828 isConnected_eventOut_OutputPort(NATIVE_INT_TYPE portNum)
829 {
830 FW_ASSERT(
831 portNum < this->getNum_eventOut_OutputPorts(),
832 static_cast<FwAssertArgType>(portNum)
833 );
834
835 return this->m_eventOut_OutputPort[portNum].isConnected();
836 }
837
838#if FW_ENABLE_TEXT_LOGGING == 1
839
840 bool TlmPacketizerComponentBase ::
841 isConnected_textEventOut_OutputPort(NATIVE_INT_TYPE portNum)
842 {
843 FW_ASSERT(
844 portNum < this->getNum_textEventOut_OutputPorts(),
845 static_cast<FwAssertArgType>(portNum)
846 );
847
848 return this->m_textEventOut_OutputPort[portNum].isConnected();
849 }
850
851#endif
852
853 bool TlmPacketizerComponentBase ::
854 isConnected_timeGetOut_OutputPort(NATIVE_INT_TYPE portNum)
855 {
856 FW_ASSERT(
857 portNum < this->getNum_timeGetOut_OutputPorts(),
858 static_cast<FwAssertArgType>(portNum)
859 );
860
861 return this->m_timeGetOut_OutputPort[portNum].isConnected();
862 }
863
864 bool TlmPacketizerComponentBase ::
865 isConnected_tlmOut_OutputPort(NATIVE_INT_TYPE portNum)
866 {
867 FW_ASSERT(
868 portNum < this->getNum_tlmOut_OutputPorts(),
869 static_cast<FwAssertArgType>(portNum)
870 );
871
872 return this->m_tlmOut_OutputPort[portNum].isConnected();
873 }
874
875 // ----------------------------------------------------------------------
876 // Connection status queries for typed output ports
877 // ----------------------------------------------------------------------
878
879 bool TlmPacketizerComponentBase ::
880 isConnected_PktSend_OutputPort(NATIVE_INT_TYPE portNum)
881 {
882 FW_ASSERT(
883 portNum < this->getNum_PktSend_OutputPorts(),
884 static_cast<FwAssertArgType>(portNum)
885 );
886
887 return this->m_PktSend_OutputPort[portNum].isConnected();
888 }
889
890 bool TlmPacketizerComponentBase ::
891 isConnected_pingOut_OutputPort(NATIVE_INT_TYPE portNum)
892 {
893 FW_ASSERT(
894 portNum < this->getNum_pingOut_OutputPorts(),
895 static_cast<FwAssertArgType>(portNum)
896 );
897
898 return this->m_pingOut_OutputPort[portNum].isConnected();
899 }
900
901 // ----------------------------------------------------------------------
902 // Port handler base-class functions for typed input ports
903 //
904 // Call these functions directly to bypass the corresponding ports
905 // ----------------------------------------------------------------------
906
907 void TlmPacketizerComponentBase ::
908 Run_handlerBase(
909 NATIVE_INT_TYPE portNum,
910 NATIVE_UINT_TYPE context
911 )
912 {
913 // Make sure port number is valid
914 FW_ASSERT(
915 portNum < this->getNum_Run_InputPorts(),
916 static_cast<FwAssertArgType>(portNum)
917 );
918
919 // Call pre-message hook
920 Run_preMsgHook(
921 portNum,
922 context
923 );
924 ComponentIpcSerializableBuffer msg;
926
927 // Serialize message ID
928 _status = msg.serialize(
929 static_cast<NATIVE_INT_TYPE>(RUN_SCHED)
930 );
931 FW_ASSERT(
932 _status == Fw::FW_SERIALIZE_OK,
933 static_cast<FwAssertArgType>(_status)
934 );
935
936 // Serialize port number
937 _status = msg.serialize(portNum);
938 FW_ASSERT(
939 _status == Fw::FW_SERIALIZE_OK,
940 static_cast<FwAssertArgType>(_status)
941 );
942
943 // Serialize argument context
944 _status = msg.serialize(context);
945 FW_ASSERT(
946 _status == Fw::FW_SERIALIZE_OK,
947 static_cast<FwAssertArgType>(_status)
948 );
949
950 // Send message
952 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
953
954 FW_ASSERT(
955 qStatus == Os::Queue::QUEUE_OK,
956 static_cast<FwAssertArgType>(qStatus)
957 );
958 }
959
960 void TlmPacketizerComponentBase ::
961 TlmRecv_handlerBase(
962 NATIVE_INT_TYPE portNum,
963 FwChanIdType id,
964 Fw::Time& timeTag,
965 Fw::TlmBuffer& val
966 )
967 {
968 // Make sure port number is valid
969 FW_ASSERT(
970 portNum < this->getNum_TlmRecv_InputPorts(),
971 static_cast<FwAssertArgType>(portNum)
972 );
973
974 // Down call to pure virtual handler method implemented in Impl class
975 this->TlmRecv_handler(
976 portNum,
977 id,
978 timeTag,
979 val
980 );
981 }
982
983 void TlmPacketizerComponentBase ::
984 pingIn_handlerBase(
985 NATIVE_INT_TYPE portNum,
986 U32 key
987 )
988 {
989 // Make sure port number is valid
990 FW_ASSERT(
991 portNum < this->getNum_pingIn_InputPorts(),
992 static_cast<FwAssertArgType>(portNum)
993 );
994
995 // Call pre-message hook
996 pingIn_preMsgHook(
997 portNum,
998 key
999 );
1000 ComponentIpcSerializableBuffer msg;
1002
1003 // Serialize message ID
1004 _status = msg.serialize(
1005 static_cast<NATIVE_INT_TYPE>(PINGIN_PING)
1006 );
1007 FW_ASSERT(
1008 _status == Fw::FW_SERIALIZE_OK,
1009 static_cast<FwAssertArgType>(_status)
1010 );
1011
1012 // Serialize port number
1013 _status = msg.serialize(portNum);
1014 FW_ASSERT(
1015 _status == Fw::FW_SERIALIZE_OK,
1016 static_cast<FwAssertArgType>(_status)
1017 );
1018
1019 // Serialize argument key
1020 _status = msg.serialize(key);
1021 FW_ASSERT(
1022 _status == Fw::FW_SERIALIZE_OK,
1023 static_cast<FwAssertArgType>(_status)
1024 );
1025
1026 // Send message
1028 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1029
1030 FW_ASSERT(
1031 qStatus == Os::Queue::QUEUE_OK,
1032 static_cast<FwAssertArgType>(qStatus)
1033 );
1034 }
1035
1036 // ----------------------------------------------------------------------
1037 // Pre-message hooks for typed async input ports
1038 //
1039 // Each of these functions is invoked just before processing a message
1040 // on the corresponding port. By default, they do nothing. You can
1041 // override them to provide specific pre-message behavior.
1042 // ----------------------------------------------------------------------
1043
1044 void TlmPacketizerComponentBase ::
1045 Run_preMsgHook(
1046 NATIVE_INT_TYPE portNum,
1047 NATIVE_UINT_TYPE context
1048 )
1049 {
1050 // Default: no-op
1051 }
1052
1053 void TlmPacketizerComponentBase ::
1054 pingIn_preMsgHook(
1055 NATIVE_INT_TYPE portNum,
1056 U32 key
1057 )
1058 {
1059 // Default: no-op
1060 }
1061
1062 // ----------------------------------------------------------------------
1063 // Invocation functions for typed output ports
1064 // ----------------------------------------------------------------------
1065
1066 void TlmPacketizerComponentBase ::
1067 PktSend_out(
1068 NATIVE_INT_TYPE portNum,
1069 Fw::ComBuffer& data,
1070 U32 context
1071 )
1072 {
1073 FW_ASSERT(
1074 portNum < this->getNum_PktSend_OutputPorts(),
1075 static_cast<FwAssertArgType>(portNum)
1076 );
1077 this->m_PktSend_OutputPort[portNum].invoke(
1078 data,
1079 context
1080 );
1081 }
1082
1083 void TlmPacketizerComponentBase ::
1084 pingOut_out(
1085 NATIVE_INT_TYPE portNum,
1086 U32 key
1087 )
1088 {
1089 FW_ASSERT(
1090 portNum < this->getNum_pingOut_OutputPorts(),
1091 static_cast<FwAssertArgType>(portNum)
1092 );
1093 this->m_pingOut_OutputPort[portNum].invoke(
1094 key
1095 );
1096 }
1097
1098 // ----------------------------------------------------------------------
1099 // Command response
1100 // ----------------------------------------------------------------------
1101
1102 void TlmPacketizerComponentBase ::
1103 cmdResponse_out(
1104 FwOpcodeType opCode,
1105 U32 cmdSeq,
1106 Fw::CmdResponse response
1107 )
1108 {
1109 FW_ASSERT(this->m_cmdResponseOut_OutputPort[0].isConnected());
1110 this->m_cmdResponseOut_OutputPort[0].invoke(opCode, cmdSeq, response);
1111 }
1112
1113 // ----------------------------------------------------------------------
1114 // Command handler base-class functions
1115 //
1116 // Call these functions directly to bypass the command input port
1117 // ----------------------------------------------------------------------
1118
1119 void TlmPacketizerComponentBase ::
1120 SET_LEVEL_cmdHandlerBase(
1121 FwOpcodeType opCode,
1122 U32 cmdSeq,
1123 Fw::CmdArgBuffer& args
1124 )
1125 {
1126 // Call pre-message hook
1127 this->SET_LEVEL_preMsgHook(opCode,cmdSeq);
1128
1129 // Defer deserializing arguments to the message dispatcher
1130 // to avoid deserializing and reserializing just for IPC
1131 ComponentIpcSerializableBuffer msg;
1133
1134 // Serialize for IPC
1135 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_SET_LEVEL));
1136 FW_ASSERT (
1137 _status == Fw::FW_SERIALIZE_OK,
1138 static_cast<FwAssertArgType>(_status)
1139 );
1140
1141 // Fake port number to make message dequeue work
1142 NATIVE_INT_TYPE port = 0;
1143
1144 _status = msg.serialize(port);
1145 FW_ASSERT (
1146 _status == Fw::FW_SERIALIZE_OK,
1147 static_cast<FwAssertArgType>(_status)
1148 );
1149
1150 _status = msg.serialize(opCode);
1151 FW_ASSERT (
1152 _status == Fw::FW_SERIALIZE_OK,
1153 static_cast<FwAssertArgType>(_status)
1154 );
1155
1156 _status = msg.serialize(cmdSeq);
1157 FW_ASSERT (
1158 _status == Fw::FW_SERIALIZE_OK,
1159 static_cast<FwAssertArgType>(_status)
1160 );
1161
1162 _status = msg.serialize(args);
1163 FW_ASSERT (
1164 _status == Fw::FW_SERIALIZE_OK,
1165 static_cast<FwAssertArgType>(_status)
1166 );
1167
1168 // Send message
1170 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1171
1172 FW_ASSERT(
1173 qStatus == Os::Queue::QUEUE_OK,
1174 static_cast<FwAssertArgType>(qStatus)
1175 );
1176 }
1177
1178 void TlmPacketizerComponentBase ::
1179 SEND_PKT_cmdHandlerBase(
1180 FwOpcodeType opCode,
1181 U32 cmdSeq,
1182 Fw::CmdArgBuffer& args
1183 )
1184 {
1185 // Call pre-message hook
1186 this->SEND_PKT_preMsgHook(opCode,cmdSeq);
1187
1188 // Defer deserializing arguments to the message dispatcher
1189 // to avoid deserializing and reserializing just for IPC
1190 ComponentIpcSerializableBuffer msg;
1192
1193 // Serialize for IPC
1194 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_SEND_PKT));
1195 FW_ASSERT (
1196 _status == Fw::FW_SERIALIZE_OK,
1197 static_cast<FwAssertArgType>(_status)
1198 );
1199
1200 // Fake port number to make message dequeue work
1201 NATIVE_INT_TYPE port = 0;
1202
1203 _status = msg.serialize(port);
1204 FW_ASSERT (
1205 _status == Fw::FW_SERIALIZE_OK,
1206 static_cast<FwAssertArgType>(_status)
1207 );
1208
1209 _status = msg.serialize(opCode);
1210 FW_ASSERT (
1211 _status == Fw::FW_SERIALIZE_OK,
1212 static_cast<FwAssertArgType>(_status)
1213 );
1214
1215 _status = msg.serialize(cmdSeq);
1216 FW_ASSERT (
1217 _status == Fw::FW_SERIALIZE_OK,
1218 static_cast<FwAssertArgType>(_status)
1219 );
1220
1221 _status = msg.serialize(args);
1222 FW_ASSERT (
1223 _status == Fw::FW_SERIALIZE_OK,
1224 static_cast<FwAssertArgType>(_status)
1225 );
1226
1227 // Send message
1229 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1230
1231 FW_ASSERT(
1232 qStatus == Os::Queue::QUEUE_OK,
1233 static_cast<FwAssertArgType>(qStatus)
1234 );
1235 }
1236
1237 // ----------------------------------------------------------------------
1238 // Pre-message hooks for async commands
1239 //
1240 // Each of these functions is invoked just before processing the
1241 // corresponding command. By default they do nothing. You can
1242 // override them to provide specific pre-command behavior.
1243 // ----------------------------------------------------------------------
1244
1245 void TlmPacketizerComponentBase ::
1246 SET_LEVEL_preMsgHook(
1247 FwOpcodeType opCode,
1248 U32 cmdSeq
1249 )
1250 {
1251 // Defaults to no-op; can be overridden
1252 }
1253
1254 void TlmPacketizerComponentBase ::
1255 SEND_PKT_preMsgHook(
1256 FwOpcodeType opCode,
1257 U32 cmdSeq
1258 )
1259 {
1260 // Defaults to no-op; can be overridden
1261 }
1262
1263 // ----------------------------------------------------------------------
1264 // Event logging functions
1265 // ----------------------------------------------------------------------
1266
1267 void TlmPacketizerComponentBase ::
1268 log_WARNING_LO_NoChan(U32 Id)
1269 {
1270 // Get the time
1271 Fw::Time _logTime;
1272 if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1273 this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1274 }
1275
1276 FwEventIdType _id = static_cast<FwEventIdType>(0);
1277
1278 _id = this->getIdBase() + EVENTID_NOCHAN;
1279
1280 // Emit the event on the log port
1281 if (this->m_eventOut_OutputPort[0].isConnected()) {
1282 Fw::LogBuffer _logBuff;
1284
1285#if FW_AMPCS_COMPATIBLE
1286 // Serialize the number of arguments
1287 _status = _logBuff.serialize(static_cast<U8>(1));
1288 FW_ASSERT(
1289 _status == Fw::FW_SERIALIZE_OK,
1290 static_cast<FwAssertArgType>(_status)
1291 );
1292#endif
1293
1294#if FW_AMPCS_COMPATIBLE
1295 // Serialize the argument size
1296 _status = _logBuff.serialize(
1297 static_cast<U8>(sizeof(U32))
1298 );
1299 FW_ASSERT(
1300 _status == Fw::FW_SERIALIZE_OK,
1301 static_cast<FwAssertArgType>(_status)
1302 );
1303#endif
1304 _status = _logBuff.serialize(Id);
1305 FW_ASSERT(
1306 _status == Fw::FW_SERIALIZE_OK,
1307 static_cast<FwAssertArgType>(_status)
1308 );
1309
1310 this->m_eventOut_OutputPort[0].invoke(
1311 _id,
1312 _logTime,
1314 _logBuff
1315 );
1316 }
1317
1318 // Emit the event on the text log port
1319#if FW_ENABLE_TEXT_LOGGING
1320 if (this->m_textEventOut_OutputPort[0].isConnected()) {
1321#if FW_OBJECT_NAMES == 1
1322 const char* _formatString =
1323 "(%s) %s: Telemetry ID 0x%" PRIx32 " not packetized";
1324#else
1325 const char* _formatString =
1326 "%s: Telemetry ID 0x%" PRIx32 " not packetized";
1327#endif
1328
1329 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1330
1331 (void) snprintf(
1332 _textBuffer,
1334 _formatString,
1335#if FW_OBJECT_NAMES == 1
1336 this->m_objName,
1337#endif
1338 "NoChan ",
1339 Id
1340 );
1341
1342 // Null terminate
1343 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1344 Fw::TextLogString _logString = _textBuffer;
1345 this->m_textEventOut_OutputPort[0].invoke(
1346 _id,
1347 _logTime,
1349 _logString
1350 );
1351 }
1352#endif
1353 }
1354
1355 void TlmPacketizerComponentBase ::
1356 log_ACTIVITY_HI_LevelSet(U32 id)
1357 {
1358 // Get the time
1359 Fw::Time _logTime;
1360 if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1361 this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1362 }
1363
1364 FwEventIdType _id = static_cast<FwEventIdType>(0);
1365
1366 _id = this->getIdBase() + EVENTID_LEVELSET;
1367
1368 // Emit the event on the log port
1369 if (this->m_eventOut_OutputPort[0].isConnected()) {
1370 Fw::LogBuffer _logBuff;
1372
1373#if FW_AMPCS_COMPATIBLE
1374 // Serialize the number of arguments
1375 _status = _logBuff.serialize(static_cast<U8>(1));
1376 FW_ASSERT(
1377 _status == Fw::FW_SERIALIZE_OK,
1378 static_cast<FwAssertArgType>(_status)
1379 );
1380#endif
1381
1382#if FW_AMPCS_COMPATIBLE
1383 // Serialize the argument size
1384 _status = _logBuff.serialize(
1385 static_cast<U8>(sizeof(U32))
1386 );
1387 FW_ASSERT(
1388 _status == Fw::FW_SERIALIZE_OK,
1389 static_cast<FwAssertArgType>(_status)
1390 );
1391#endif
1392 _status = _logBuff.serialize(id);
1393 FW_ASSERT(
1394 _status == Fw::FW_SERIALIZE_OK,
1395 static_cast<FwAssertArgType>(_status)
1396 );
1397
1398 this->m_eventOut_OutputPort[0].invoke(
1399 _id,
1400 _logTime,
1402 _logBuff
1403 );
1404 }
1405
1406 // Emit the event on the text log port
1407#if FW_ENABLE_TEXT_LOGGING
1408 if (this->m_textEventOut_OutputPort[0].isConnected()) {
1409#if FW_OBJECT_NAMES == 1
1410 const char* _formatString =
1411 "(%s) %s: Telemetry send level to %" PRIu32 "";
1412#else
1413 const char* _formatString =
1414 "%s: Telemetry send level to %" PRIu32 "";
1415#endif
1416
1417 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1418
1419 (void) snprintf(
1420 _textBuffer,
1422 _formatString,
1423#if FW_OBJECT_NAMES == 1
1424 this->m_objName,
1425#endif
1426 "LevelSet ",
1427 id
1428 );
1429
1430 // Null terminate
1431 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1432 Fw::TextLogString _logString = _textBuffer;
1433 this->m_textEventOut_OutputPort[0].invoke(
1434 _id,
1435 _logTime,
1437 _logString
1438 );
1439 }
1440#endif
1441 }
1442
1443 void TlmPacketizerComponentBase ::
1444 log_WARNING_LO_MaxLevelExceed(
1445 U32 level,
1446 U32 max
1447 )
1448 {
1449 // Get the time
1450 Fw::Time _logTime;
1451 if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1452 this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1453 }
1454
1455 FwEventIdType _id = static_cast<FwEventIdType>(0);
1456
1457 _id = this->getIdBase() + EVENTID_MAXLEVELEXCEED;
1458
1459 // Emit the event on the log port
1460 if (this->m_eventOut_OutputPort[0].isConnected()) {
1461 Fw::LogBuffer _logBuff;
1463
1464#if FW_AMPCS_COMPATIBLE
1465 // Serialize the number of arguments
1466 _status = _logBuff.serialize(static_cast<U8>(2));
1467 FW_ASSERT(
1468 _status == Fw::FW_SERIALIZE_OK,
1469 static_cast<FwAssertArgType>(_status)
1470 );
1471#endif
1472
1473#if FW_AMPCS_COMPATIBLE
1474 // Serialize the argument size
1475 _status = _logBuff.serialize(
1476 static_cast<U8>(sizeof(U32))
1477 );
1478 FW_ASSERT(
1479 _status == Fw::FW_SERIALIZE_OK,
1480 static_cast<FwAssertArgType>(_status)
1481 );
1482#endif
1483 _status = _logBuff.serialize(level);
1484 FW_ASSERT(
1485 _status == Fw::FW_SERIALIZE_OK,
1486 static_cast<FwAssertArgType>(_status)
1487 );
1488
1489#if FW_AMPCS_COMPATIBLE
1490 // Serialize the argument size
1491 _status = _logBuff.serialize(
1492 static_cast<U8>(sizeof(U32))
1493 );
1494 FW_ASSERT(
1495 _status == Fw::FW_SERIALIZE_OK,
1496 static_cast<FwAssertArgType>(_status)
1497 );
1498#endif
1499 _status = _logBuff.serialize(max);
1500 FW_ASSERT(
1501 _status == Fw::FW_SERIALIZE_OK,
1502 static_cast<FwAssertArgType>(_status)
1503 );
1504
1505 this->m_eventOut_OutputPort[0].invoke(
1506 _id,
1507 _logTime,
1509 _logBuff
1510 );
1511 }
1512
1513 // Emit the event on the text log port
1514#if FW_ENABLE_TEXT_LOGGING
1515 if (this->m_textEventOut_OutputPort[0].isConnected()) {
1516#if FW_OBJECT_NAMES == 1
1517 const char* _formatString =
1518 "(%s) %s: Requested send level %" PRIu32 " higher than max packet level of %" PRIu32 "";
1519#else
1520 const char* _formatString =
1521 "%s: Requested send level %" PRIu32 " higher than max packet level of %" PRIu32 "";
1522#endif
1523
1524 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1525
1526 (void) snprintf(
1527 _textBuffer,
1529 _formatString,
1530#if FW_OBJECT_NAMES == 1
1531 this->m_objName,
1532#endif
1533 "MaxLevelExceed ",
1534 level,
1535 max
1536 );
1537
1538 // Null terminate
1539 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1540 Fw::TextLogString _logString = _textBuffer;
1541 this->m_textEventOut_OutputPort[0].invoke(
1542 _id,
1543 _logTime,
1545 _logString
1546 );
1547 }
1548#endif
1549 }
1550
1551 void TlmPacketizerComponentBase ::
1552 log_ACTIVITY_LO_PacketSent(U32 id)
1553 {
1554 // Get the time
1555 Fw::Time _logTime;
1556 if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1557 this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1558 }
1559
1560 FwEventIdType _id = static_cast<FwEventIdType>(0);
1561
1562 _id = this->getIdBase() + EVENTID_PACKETSENT;
1563
1564 // Emit the event on the log port
1565 if (this->m_eventOut_OutputPort[0].isConnected()) {
1566 Fw::LogBuffer _logBuff;
1568
1569#if FW_AMPCS_COMPATIBLE
1570 // Serialize the number of arguments
1571 _status = _logBuff.serialize(static_cast<U8>(1));
1572 FW_ASSERT(
1573 _status == Fw::FW_SERIALIZE_OK,
1574 static_cast<FwAssertArgType>(_status)
1575 );
1576#endif
1577
1578#if FW_AMPCS_COMPATIBLE
1579 // Serialize the argument size
1580 _status = _logBuff.serialize(
1581 static_cast<U8>(sizeof(U32))
1582 );
1583 FW_ASSERT(
1584 _status == Fw::FW_SERIALIZE_OK,
1585 static_cast<FwAssertArgType>(_status)
1586 );
1587#endif
1588 _status = _logBuff.serialize(id);
1589 FW_ASSERT(
1590 _status == Fw::FW_SERIALIZE_OK,
1591 static_cast<FwAssertArgType>(_status)
1592 );
1593
1594 this->m_eventOut_OutputPort[0].invoke(
1595 _id,
1596 _logTime,
1598 _logBuff
1599 );
1600 }
1601
1602 // Emit the event on the text log port
1603#if FW_ENABLE_TEXT_LOGGING
1604 if (this->m_textEventOut_OutputPort[0].isConnected()) {
1605#if FW_OBJECT_NAMES == 1
1606 const char* _formatString =
1607 "(%s) %s: Sent packet ID %" PRIu32 "";
1608#else
1609 const char* _formatString =
1610 "%s: Sent packet ID %" PRIu32 "";
1611#endif
1612
1613 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1614
1615 (void) snprintf(
1616 _textBuffer,
1618 _formatString,
1619#if FW_OBJECT_NAMES == 1
1620 this->m_objName,
1621#endif
1622 "PacketSent ",
1623 id
1624 );
1625
1626 // Null terminate
1627 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1628 Fw::TextLogString _logString = _textBuffer;
1629 this->m_textEventOut_OutputPort[0].invoke(
1630 _id,
1631 _logTime,
1633 _logString
1634 );
1635 }
1636#endif
1637 }
1638
1639 void TlmPacketizerComponentBase ::
1640 log_WARNING_LO_PacketNotFound(U32 id)
1641 {
1642 // Get the time
1643 Fw::Time _logTime;
1644 if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1645 this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1646 }
1647
1648 FwEventIdType _id = static_cast<FwEventIdType>(0);
1649
1650 _id = this->getIdBase() + EVENTID_PACKETNOTFOUND;
1651
1652 // Emit the event on the log port
1653 if (this->m_eventOut_OutputPort[0].isConnected()) {
1654 Fw::LogBuffer _logBuff;
1656
1657#if FW_AMPCS_COMPATIBLE
1658 // Serialize the number of arguments
1659 _status = _logBuff.serialize(static_cast<U8>(1));
1660 FW_ASSERT(
1661 _status == Fw::FW_SERIALIZE_OK,
1662 static_cast<FwAssertArgType>(_status)
1663 );
1664#endif
1665
1666#if FW_AMPCS_COMPATIBLE
1667 // Serialize the argument size
1668 _status = _logBuff.serialize(
1669 static_cast<U8>(sizeof(U32))
1670 );
1671 FW_ASSERT(
1672 _status == Fw::FW_SERIALIZE_OK,
1673 static_cast<FwAssertArgType>(_status)
1674 );
1675#endif
1676 _status = _logBuff.serialize(id);
1677 FW_ASSERT(
1678 _status == Fw::FW_SERIALIZE_OK,
1679 static_cast<FwAssertArgType>(_status)
1680 );
1681
1682 this->m_eventOut_OutputPort[0].invoke(
1683 _id,
1684 _logTime,
1686 _logBuff
1687 );
1688 }
1689
1690 // Emit the event on the text log port
1691#if FW_ENABLE_TEXT_LOGGING
1692 if (this->m_textEventOut_OutputPort[0].isConnected()) {
1693#if FW_OBJECT_NAMES == 1
1694 const char* _formatString =
1695 "(%s) %s: Could not find packet ID %" PRIu32 "";
1696#else
1697 const char* _formatString =
1698 "%s: Could not find packet ID %" PRIu32 "";
1699#endif
1700
1701 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1702
1703 (void) snprintf(
1704 _textBuffer,
1706 _formatString,
1707#if FW_OBJECT_NAMES == 1
1708 this->m_objName,
1709#endif
1710 "PacketNotFound ",
1711 id
1712 );
1713
1714 // Null terminate
1715 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1716 Fw::TextLogString _logString = _textBuffer;
1717 this->m_textEventOut_OutputPort[0].invoke(
1718 _id,
1719 _logTime,
1721 _logString
1722 );
1723 }
1724#endif
1725 }
1726
1727 // ----------------------------------------------------------------------
1728 // Telemetry write functions
1729 // ----------------------------------------------------------------------
1730
1731 void TlmPacketizerComponentBase ::
1732 tlmWrite_SendLevel(
1733 U32 arg,
1734 Fw::Time _tlmTime
1735 )
1736 {
1737 if (this->m_tlmOut_OutputPort[0].isConnected()) {
1738 if (
1739 this->m_timeGetOut_OutputPort[0].isConnected() &&
1740 (_tlmTime == Fw::ZERO_TIME)
1741 ) {
1742 this->m_timeGetOut_OutputPort[0].invoke(_tlmTime);
1743 }
1744
1745 Fw::TlmBuffer _tlmBuff;
1746 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
1747 FW_ASSERT(
1748 _stat == Fw::FW_SERIALIZE_OK,
1749 static_cast<FwAssertArgType>(_stat)
1750 );
1751
1752 FwChanIdType _id;
1753
1754 _id = this->getIdBase() + CHANNELID_SENDLEVEL;
1755
1756 this->m_tlmOut_OutputPort[0].invoke(
1757 _id,
1758 _tlmTime,
1759 _tlmBuff
1760 );
1761 }
1762 }
1763
1764 // ----------------------------------------------------------------------
1765 // Time
1766 // ----------------------------------------------------------------------
1767
1768 Fw::Time TlmPacketizerComponentBase ::
1769 getTime()
1770 {
1771 if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1772 Fw::Time _time;
1773 this->m_timeGetOut_OutputPort[0].invoke(_time);
1774 return _time;
1775 }
1776 else {
1777 return Fw::Time(TB_NONE, 0, 0);
1778 }
1779 }
1780
1781 // ----------------------------------------------------------------------
1782 // Message dispatch functions
1783 // ----------------------------------------------------------------------
1784
1785 Fw::QueuedComponentBase::MsgDispatchStatus TlmPacketizerComponentBase ::
1786 doDispatch()
1787 {
1788 ComponentIpcSerializableBuffer msg;
1789 NATIVE_INT_TYPE priority = 0;
1790
1791 Os::Queue::QueueStatus msgStatus = this->m_queue.receive(
1792 msg,
1793 priority,
1795 );
1796 FW_ASSERT(
1797 msgStatus == Os::Queue::QUEUE_OK,
1798 static_cast<FwAssertArgType>(msgStatus)
1799 );
1800
1801 // Reset to beginning of buffer
1802 msg.resetDeser();
1803
1804 NATIVE_INT_TYPE desMsg = 0;
1805 Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
1806 FW_ASSERT(
1807 deserStatus == Fw::FW_SERIALIZE_OK,
1808 static_cast<FwAssertArgType>(deserStatus)
1809 );
1810
1811 MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
1812
1813 if (msgType == TLMPACKETIZER_COMPONENT_EXIT) {
1814 return MSG_DISPATCH_EXIT;
1815 }
1816
1817 NATIVE_INT_TYPE portNum = 0;
1818 deserStatus = msg.deserialize(portNum);
1819 FW_ASSERT(
1820 deserStatus == Fw::FW_SERIALIZE_OK,
1821 static_cast<FwAssertArgType>(deserStatus)
1822 );
1823
1824 switch (msgType) {
1825 // Handle async input port Run
1826 case RUN_SCHED: {
1827 // Deserialize argument context
1828 NATIVE_UINT_TYPE context;
1829 deserStatus = msg.deserialize(context);
1830 FW_ASSERT(
1831 deserStatus == Fw::FW_SERIALIZE_OK,
1832 static_cast<FwAssertArgType>(deserStatus)
1833 );
1834 // Call handler function
1835 this->Run_handler(
1836 portNum,
1837 context
1838 );
1839
1840 break;
1841 }
1842
1843 // Handle async input port pingIn
1844 case PINGIN_PING: {
1845 // Deserialize argument key
1846 U32 key;
1847 deserStatus = msg.deserialize(key);
1848 FW_ASSERT(
1849 deserStatus == Fw::FW_SERIALIZE_OK,
1850 static_cast<FwAssertArgType>(deserStatus)
1851 );
1852 // Call handler function
1853 this->pingIn_handler(
1854 portNum,
1855 key
1856 );
1857
1858 break;
1859 }
1860
1861 // Handle command SET_LEVEL
1862 case CMD_SET_LEVEL: {
1863 // Deserialize opcode
1864 FwOpcodeType opCode = 0;
1865 deserStatus = msg.deserialize(opCode);
1866 FW_ASSERT (
1867 deserStatus == Fw::FW_SERIALIZE_OK,
1868 static_cast<FwAssertArgType>(deserStatus)
1869 );
1870
1871 // Deserialize command sequence
1872 U32 cmdSeq = 0;
1873 deserStatus = msg.deserialize(cmdSeq);
1874 FW_ASSERT (
1875 deserStatus == Fw::FW_SERIALIZE_OK,
1876 static_cast<FwAssertArgType>(deserStatus)
1877 );
1878
1879 // Deserialize command argument buffer
1880 Fw::CmdArgBuffer args;
1881 deserStatus = msg.deserialize(args);
1882 FW_ASSERT (
1883 deserStatus == Fw::FW_SERIALIZE_OK,
1884 static_cast<FwAssertArgType>(deserStatus)
1885 );
1886
1887 // Reset buffer
1888 args.resetDeser();
1889
1890 // Deserialize argument level
1891 U32 level;
1892 deserStatus = args.deserialize(level);
1893 if (deserStatus != Fw::FW_SERIALIZE_OK) {
1894 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
1895 this->cmdResponse_out(
1896 opCode,
1897 cmdSeq,
1899 );
1900 }
1901 // Don't crash the task if bad arguments were passed from the ground
1902 break;
1903 }
1904
1905 // Make sure there was no data left over.
1906 // That means the argument buffer size was incorrect.
1907#if FW_CMD_CHECK_RESIDUAL
1908 if (args.getBuffLeft() != 0) {
1909 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
1910 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
1911 }
1912 // Don't crash the task if bad arguments were passed from the ground
1913 break;
1914 }
1915#endif
1916
1917 // Call handler function
1918 this->SET_LEVEL_cmdHandler(
1919 opCode, cmdSeq,
1920 level
1921 );
1922
1923 break;
1924 }
1925
1926 // Handle command SEND_PKT
1927 case CMD_SEND_PKT: {
1928 // Deserialize opcode
1929 FwOpcodeType opCode = 0;
1930 deserStatus = msg.deserialize(opCode);
1931 FW_ASSERT (
1932 deserStatus == Fw::FW_SERIALIZE_OK,
1933 static_cast<FwAssertArgType>(deserStatus)
1934 );
1935
1936 // Deserialize command sequence
1937 U32 cmdSeq = 0;
1938 deserStatus = msg.deserialize(cmdSeq);
1939 FW_ASSERT (
1940 deserStatus == Fw::FW_SERIALIZE_OK,
1941 static_cast<FwAssertArgType>(deserStatus)
1942 );
1943
1944 // Deserialize command argument buffer
1945 Fw::CmdArgBuffer args;
1946 deserStatus = msg.deserialize(args);
1947 FW_ASSERT (
1948 deserStatus == Fw::FW_SERIALIZE_OK,
1949 static_cast<FwAssertArgType>(deserStatus)
1950 );
1951
1952 // Reset buffer
1953 args.resetDeser();
1954
1955 // Deserialize argument id
1956 U32 id;
1957 deserStatus = args.deserialize(id);
1958 if (deserStatus != Fw::FW_SERIALIZE_OK) {
1959 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
1960 this->cmdResponse_out(
1961 opCode,
1962 cmdSeq,
1964 );
1965 }
1966 // Don't crash the task if bad arguments were passed from the ground
1967 break;
1968 }
1969
1970 // Make sure there was no data left over.
1971 // That means the argument buffer size was incorrect.
1972#if FW_CMD_CHECK_RESIDUAL
1973 if (args.getBuffLeft() != 0) {
1974 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
1975 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
1976 }
1977 // Don't crash the task if bad arguments were passed from the ground
1978 break;
1979 }
1980#endif
1981
1982 // Call handler function
1983 this->SEND_PKT_cmdHandler(
1984 opCode, cmdSeq,
1985 id
1986 );
1987
1988 break;
1989 }
1990
1991 default:
1992 return MSG_DISPATCH_ERROR;
1993 }
1994
1995 return MSG_DISPATCH_OK;
1996 }
1997
1998 // ----------------------------------------------------------------------
1999 // Calls for messages received on special input ports
2000 // ----------------------------------------------------------------------
2001
2002 void TlmPacketizerComponentBase ::
2003 m_p_cmdIn_in(
2004 Fw::PassiveComponentBase* callComp,
2005 NATIVE_INT_TYPE portNum,
2006 FwOpcodeType opCode,
2007 U32 cmdSeq,
2008 Fw::CmdArgBuffer& args
2009 )
2010 {
2011 FW_ASSERT(callComp);
2012 TlmPacketizerComponentBase* compPtr = static_cast<TlmPacketizerComponentBase*>(callComp);
2013
2014 const U32 idBase = callComp->getIdBase();
2015 FW_ASSERT(opCode >= idBase, opCode, idBase);
2016
2017 // Select base class function based on opcode
2018 switch (opCode - idBase) {
2019 case OPCODE_SET_LEVEL: {
2020 compPtr->SET_LEVEL_cmdHandlerBase(
2021 opCode,
2022 cmdSeq,
2023 args
2024 );
2025 break;
2026 }
2027
2028 case OPCODE_SEND_PKT: {
2029 compPtr->SEND_PKT_cmdHandlerBase(
2030 opCode,
2031 cmdSeq,
2032 args
2033 );
2034 break;
2035 }
2036 }
2037 }
2038
2039 // ----------------------------------------------------------------------
2040 // Calls for messages received on typed input ports
2041 // ----------------------------------------------------------------------
2042
2043 void TlmPacketizerComponentBase ::
2044 m_p_Run_in(
2045 Fw::PassiveComponentBase* callComp,
2046 NATIVE_INT_TYPE portNum,
2047 NATIVE_UINT_TYPE context
2048 )
2049 {
2050 FW_ASSERT(callComp);
2051 TlmPacketizerComponentBase* compPtr = static_cast<TlmPacketizerComponentBase*>(callComp);
2052 compPtr->Run_handlerBase(
2053 portNum,
2054 context
2055 );
2056 }
2057
2058 void TlmPacketizerComponentBase ::
2059 m_p_TlmRecv_in(
2060 Fw::PassiveComponentBase* callComp,
2061 NATIVE_INT_TYPE portNum,
2062 FwChanIdType id,
2063 Fw::Time& timeTag,
2064 Fw::TlmBuffer& val
2065 )
2066 {
2067 FW_ASSERT(callComp);
2068 TlmPacketizerComponentBase* compPtr = static_cast<TlmPacketizerComponentBase*>(callComp);
2069 compPtr->TlmRecv_handlerBase(
2070 portNum,
2071 id,
2072 timeTag,
2073 val
2074 );
2075 }
2076
2077 void TlmPacketizerComponentBase ::
2078 m_p_pingIn_in(
2079 Fw::PassiveComponentBase* callComp,
2080 NATIVE_INT_TYPE portNum,
2081 U32 key
2082 )
2083 {
2084 FW_ASSERT(callComp);
2085 TlmPacketizerComponentBase* compPtr = static_cast<TlmPacketizerComponentBase*>(callComp);
2086 compPtr->pingIn_handlerBase(
2087 portNum,
2088 key
2089 );
2090 }
2091
2092}
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
U8 BYTE
byte type
Definition BasicTypes.h:27
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:291
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects)
Definition FpConfig.h:82
@ 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 representations of the port arguments.
Definition CmdPortAc.hpp:37
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition TlmPortAc.hpp:38
@ ACTIVITY_HI
Important informational events.
@ WARNING_LO
A less serious but recoverable event.
@ ACTIVITY_LO
Less important informational events.
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
@ 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.
@ 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