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