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
HealthComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title HealthComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for Health 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 {
20 PINGRETURN_PING,
21 CMD_HLTH_ENABLE,
22 CMD_HLTH_PING_ENABLE,
23 CMD_HLTH_CHNG_PING,
24 };
25
26 // Get the max size by doing a union of the input and internal port serialization sizes
27 union BuffUnion {
28 BYTE PingReturnPortSize[Svc::InputPingPort::SERIALIZED_SIZE];
31 };
32
33 // Define a message buffer class large enough to handle all the
34 // asynchronous inputs to the component
35 class ComponentIpcSerializableBuffer :
37 {
38
39 public:
40
41 enum {
42 // Max. message size = size of data + message id + port
43 SERIALIZATION_SIZE =
44 sizeof(BuffUnion) +
45 sizeof(NATIVE_INT_TYPE) +
46 sizeof(NATIVE_INT_TYPE)
47 };
48
49 NATIVE_UINT_TYPE getBuffCapacity() const {
50 return sizeof(m_buff);
51 }
52
53 U8* getBuffAddr() {
54 return m_buff;
55 }
56
57 const U8* getBuffAddr() const {
58 return m_buff;
59 }
60
61 private:
62 // Should be the max of all the input ports serialized sizes...
63 U8 m_buff[SERIALIZATION_SIZE];
64
65 };
66 }
67
68 // ----------------------------------------------------------------------
69 // Component initialization
70 // ----------------------------------------------------------------------
71
72 void HealthComponentBase ::
73 init(
74 NATIVE_INT_TYPE queueDepth,
75 NATIVE_INT_TYPE instance
76 )
77 {
78 // Initialize base class
80
81 // Connect input port CmdDisp
82 for (
83 PlatformIntType port = 0;
84 port < static_cast<PlatformIntType>(this->getNum_CmdDisp_InputPorts());
85 port++
86 ) {
87 this->m_CmdDisp_InputPort[port].init();
88 this->m_CmdDisp_InputPort[port].addCallComp(
89 this,
90 m_p_CmdDisp_in
91 );
92 this->m_CmdDisp_InputPort[port].setPortNum(port);
93
94#if FW_OBJECT_NAMES == 1
95 char portName[120];
96 (void) snprintf(
97 portName,
98 sizeof(portName),
99 "%s_CmdDisp_InputPort[%" PRI_PlatformIntType "]",
100 this->m_objName,
101 port
102 );
103 this->m_CmdDisp_InputPort[port].setObjName(portName);
104#endif
105 }
106
107 // Connect input port PingReturn
108 for (
109 PlatformIntType port = 0;
110 port < static_cast<PlatformIntType>(this->getNum_PingReturn_InputPorts());
111 port++
112 ) {
113 this->m_PingReturn_InputPort[port].init();
114 this->m_PingReturn_InputPort[port].addCallComp(
115 this,
116 m_p_PingReturn_in
117 );
118 this->m_PingReturn_InputPort[port].setPortNum(port);
119
120#if FW_OBJECT_NAMES == 1
121 char portName[120];
122 (void) snprintf(
123 portName,
124 sizeof(portName),
125 "%s_PingReturn_InputPort[%" PRI_PlatformIntType "]",
126 this->m_objName,
127 port
128 );
129 this->m_PingReturn_InputPort[port].setObjName(portName);
130#endif
131 }
132
133 // Connect input port Run
134 for (
135 PlatformIntType port = 0;
136 port < static_cast<PlatformIntType>(this->getNum_Run_InputPorts());
137 port++
138 ) {
139 this->m_Run_InputPort[port].init();
140 this->m_Run_InputPort[port].addCallComp(
141 this,
142 m_p_Run_in
143 );
144 this->m_Run_InputPort[port].setPortNum(port);
145
146#if FW_OBJECT_NAMES == 1
147 char portName[120];
148 (void) snprintf(
149 portName,
150 sizeof(portName),
151 "%s_Run_InputPort[%" PRI_PlatformIntType "]",
152 this->m_objName,
153 port
154 );
155 this->m_Run_InputPort[port].setObjName(portName);
156#endif
157 }
158
159 // Connect output port CmdReg
160 for (
161 PlatformIntType port = 0;
162 port < static_cast<PlatformIntType>(this->getNum_CmdReg_OutputPorts());
163 port++
164 ) {
165 this->m_CmdReg_OutputPort[port].init();
166
167#if FW_OBJECT_NAMES == 1
168 char portName[120];
169 (void) snprintf(
170 portName,
171 sizeof(portName),
172 "%s_CmdReg_OutputPort[%" PRI_PlatformIntType "]",
173 this->m_objName,
174 port
175 );
176 this->m_CmdReg_OutputPort[port].setObjName(portName);
177#endif
178 }
179
180 // Connect output port CmdStatus
181 for (
182 PlatformIntType port = 0;
183 port < static_cast<PlatformIntType>(this->getNum_CmdStatus_OutputPorts());
184 port++
185 ) {
186 this->m_CmdStatus_OutputPort[port].init();
187
188#if FW_OBJECT_NAMES == 1
189 char portName[120];
190 (void) snprintf(
191 portName,
192 sizeof(portName),
193 "%s_CmdStatus_OutputPort[%" PRI_PlatformIntType "]",
194 this->m_objName,
195 port
196 );
197 this->m_CmdStatus_OutputPort[port].setObjName(portName);
198#endif
199 }
200
201 // Connect output port Log
202 for (
203 PlatformIntType port = 0;
204 port < static_cast<PlatformIntType>(this->getNum_Log_OutputPorts());
205 port++
206 ) {
207 this->m_Log_OutputPort[port].init();
208
209#if FW_OBJECT_NAMES == 1
210 char portName[120];
211 (void) snprintf(
212 portName,
213 sizeof(portName),
214 "%s_Log_OutputPort[%" PRI_PlatformIntType "]",
215 this->m_objName,
216 port
217 );
218 this->m_Log_OutputPort[port].setObjName(portName);
219#endif
220 }
221
222#if FW_ENABLE_TEXT_LOGGING == 1
223 // Connect output port LogText
224 for (
225 PlatformIntType port = 0;
226 port < static_cast<PlatformIntType>(this->getNum_LogText_OutputPorts());
227 port++
228 ) {
229 this->m_LogText_OutputPort[port].init();
230
231#if FW_OBJECT_NAMES == 1
232 char portName[120];
233 (void) snprintf(
234 portName,
235 sizeof(portName),
236 "%s_LogText_OutputPort[%" PRI_PlatformIntType "]",
237 this->m_objName,
238 port
239 );
240 this->m_LogText_OutputPort[port].setObjName(portName);
241#endif
242 }
243#endif
244
245 // Connect output port Time
246 for (
247 PlatformIntType port = 0;
248 port < static_cast<PlatformIntType>(this->getNum_Time_OutputPorts());
249 port++
250 ) {
251 this->m_Time_OutputPort[port].init();
252
253#if FW_OBJECT_NAMES == 1
254 char portName[120];
255 (void) snprintf(
256 portName,
257 sizeof(portName),
258 "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
259 this->m_objName,
260 port
261 );
262 this->m_Time_OutputPort[port].setObjName(portName);
263#endif
264 }
265
266 // Connect output port Tlm
267 for (
268 PlatformIntType port = 0;
269 port < static_cast<PlatformIntType>(this->getNum_Tlm_OutputPorts());
270 port++
271 ) {
272 this->m_Tlm_OutputPort[port].init();
273
274#if FW_OBJECT_NAMES == 1
275 char portName[120];
276 (void) snprintf(
277 portName,
278 sizeof(portName),
279 "%s_Tlm_OutputPort[%" PRI_PlatformIntType "]",
280 this->m_objName,
281 port
282 );
283 this->m_Tlm_OutputPort[port].setObjName(portName);
284#endif
285 }
286
287 // Connect output port PingSend
288 for (
289 PlatformIntType port = 0;
290 port < static_cast<PlatformIntType>(this->getNum_PingSend_OutputPorts());
291 port++
292 ) {
293 this->m_PingSend_OutputPort[port].init();
294
295#if FW_OBJECT_NAMES == 1
296 char portName[120];
297 (void) snprintf(
298 portName,
299 sizeof(portName),
300 "%s_PingSend_OutputPort[%" PRI_PlatformIntType "]",
301 this->m_objName,
302 port
303 );
304 this->m_PingSend_OutputPort[port].setObjName(portName);
305#endif
306 }
307
308 // Connect output port WdogStroke
309 for (
310 PlatformIntType port = 0;
311 port < static_cast<PlatformIntType>(this->getNum_WdogStroke_OutputPorts());
312 port++
313 ) {
314 this->m_WdogStroke_OutputPort[port].init();
315
316#if FW_OBJECT_NAMES == 1
317 char portName[120];
318 (void) snprintf(
319 portName,
320 sizeof(portName),
321 "%s_WdogStroke_OutputPort[%" PRI_PlatformIntType "]",
322 this->m_objName,
323 port
324 );
325 this->m_WdogStroke_OutputPort[port].setObjName(portName);
326#endif
327 }
328
329 Os::Queue::QueueStatus qStat = this->createQueue(
330 queueDepth,
331 ComponentIpcSerializableBuffer::SERIALIZATION_SIZE
332 );
333 FW_ASSERT(
334 Os::Queue::QUEUE_OK == qStat,
335 static_cast<FwAssertArgType>(qStat)
336 );
337 }
338
339 // ----------------------------------------------------------------------
340 // Getters for special input ports
341 // ----------------------------------------------------------------------
342
343 Fw::InputCmdPort* HealthComponentBase ::
344 get_CmdDisp_InputPort(NATIVE_INT_TYPE portNum)
345 {
346 FW_ASSERT(
347 portNum < this->getNum_CmdDisp_InputPorts(),
348 static_cast<FwAssertArgType>(portNum)
349 );
350
351 return &this->m_CmdDisp_InputPort[portNum];
352 }
353
354 // ----------------------------------------------------------------------
355 // Getters for typed input ports
356 // ----------------------------------------------------------------------
357
358 Svc::InputPingPort* HealthComponentBase ::
359 get_PingReturn_InputPort(NATIVE_INT_TYPE portNum)
360 {
361 FW_ASSERT(
362 portNum < this->getNum_PingReturn_InputPorts(),
363 static_cast<FwAssertArgType>(portNum)
364 );
365
366 return &this->m_PingReturn_InputPort[portNum];
367 }
368
369 Svc::InputSchedPort* HealthComponentBase ::
370 get_Run_InputPort(NATIVE_INT_TYPE portNum)
371 {
372 FW_ASSERT(
373 portNum < this->getNum_Run_InputPorts(),
374 static_cast<FwAssertArgType>(portNum)
375 );
376
377 return &this->m_Run_InputPort[portNum];
378 }
379
380 // ----------------------------------------------------------------------
381 // Connect special input ports to special output ports
382 // ----------------------------------------------------------------------
383
384 void HealthComponentBase ::
385 set_CmdReg_OutputPort(
386 NATIVE_INT_TYPE portNum,
388 )
389 {
390 FW_ASSERT(
391 portNum < this->getNum_CmdReg_OutputPorts(),
392 static_cast<FwAssertArgType>(portNum)
393 );
394
395 this->m_CmdReg_OutputPort[portNum].addCallPort(port);
396 }
397
398 void HealthComponentBase ::
399 set_CmdStatus_OutputPort(
400 NATIVE_INT_TYPE portNum,
402 )
403 {
404 FW_ASSERT(
405 portNum < this->getNum_CmdStatus_OutputPorts(),
406 static_cast<FwAssertArgType>(portNum)
407 );
408
409 this->m_CmdStatus_OutputPort[portNum].addCallPort(port);
410 }
411
412 void HealthComponentBase ::
413 set_Log_OutputPort(
414 NATIVE_INT_TYPE portNum,
415 Fw::InputLogPort* port
416 )
417 {
418 FW_ASSERT(
419 portNum < this->getNum_Log_OutputPorts(),
420 static_cast<FwAssertArgType>(portNum)
421 );
422
423 this->m_Log_OutputPort[portNum].addCallPort(port);
424 }
425
426#if FW_ENABLE_TEXT_LOGGING == 1
427
428 void HealthComponentBase ::
429 set_LogText_OutputPort(
430 NATIVE_INT_TYPE portNum,
432 )
433 {
434 FW_ASSERT(
435 portNum < this->getNum_LogText_OutputPorts(),
436 static_cast<FwAssertArgType>(portNum)
437 );
438
439 this->m_LogText_OutputPort[portNum].addCallPort(port);
440 }
441
442#endif
443
444 void HealthComponentBase ::
445 set_Time_OutputPort(
446 NATIVE_INT_TYPE portNum,
448 )
449 {
450 FW_ASSERT(
451 portNum < this->getNum_Time_OutputPorts(),
452 static_cast<FwAssertArgType>(portNum)
453 );
454
455 this->m_Time_OutputPort[portNum].addCallPort(port);
456 }
457
458 void HealthComponentBase ::
459 set_Tlm_OutputPort(
460 NATIVE_INT_TYPE portNum,
461 Fw::InputTlmPort* port
462 )
463 {
464 FW_ASSERT(
465 portNum < this->getNum_Tlm_OutputPorts(),
466 static_cast<FwAssertArgType>(portNum)
467 );
468
469 this->m_Tlm_OutputPort[portNum].addCallPort(port);
470 }
471
472 // ----------------------------------------------------------------------
473 // Connect typed input ports to typed output ports
474 // ----------------------------------------------------------------------
475
476 void HealthComponentBase ::
477 set_PingSend_OutputPort(
478 NATIVE_INT_TYPE portNum,
480 )
481 {
482 FW_ASSERT(
483 portNum < this->getNum_PingSend_OutputPorts(),
484 static_cast<FwAssertArgType>(portNum)
485 );
486
487 this->m_PingSend_OutputPort[portNum].addCallPort(port);
488 }
489
490 void HealthComponentBase ::
491 set_WdogStroke_OutputPort(
492 NATIVE_INT_TYPE portNum,
494 )
495 {
496 FW_ASSERT(
497 portNum < this->getNum_WdogStroke_OutputPorts(),
498 static_cast<FwAssertArgType>(portNum)
499 );
500
501 this->m_WdogStroke_OutputPort[portNum].addCallPort(port);
502 }
503
504#if FW_PORT_SERIALIZATION
505
506 // ----------------------------------------------------------------------
507 // Connect serial input ports to special output ports
508 // ----------------------------------------------------------------------
509
510 void HealthComponentBase ::
511 set_CmdReg_OutputPort(
512 NATIVE_INT_TYPE portNum,
513 Fw::InputSerializePort* port
514 )
515 {
516 FW_ASSERT(
517 portNum < this->getNum_CmdReg_OutputPorts(),
518 static_cast<FwAssertArgType>(portNum)
519 );
520
521 this->m_CmdReg_OutputPort[portNum].registerSerialPort(port);
522 }
523
524 void HealthComponentBase ::
525 set_CmdStatus_OutputPort(
526 NATIVE_INT_TYPE portNum,
527 Fw::InputSerializePort* port
528 )
529 {
530 FW_ASSERT(
531 portNum < this->getNum_CmdStatus_OutputPorts(),
532 static_cast<FwAssertArgType>(portNum)
533 );
534
535 this->m_CmdStatus_OutputPort[portNum].registerSerialPort(port);
536 }
537
538 void HealthComponentBase ::
539 set_Log_OutputPort(
540 NATIVE_INT_TYPE portNum,
541 Fw::InputSerializePort* port
542 )
543 {
544 FW_ASSERT(
545 portNum < this->getNum_Log_OutputPorts(),
546 static_cast<FwAssertArgType>(portNum)
547 );
548
549 this->m_Log_OutputPort[portNum].registerSerialPort(port);
550 }
551
552#if FW_ENABLE_TEXT_LOGGING == 1
553
554 void HealthComponentBase ::
555 set_LogText_OutputPort(
556 NATIVE_INT_TYPE portNum,
557 Fw::InputSerializePort* port
558 )
559 {
560 FW_ASSERT(
561 portNum < this->getNum_LogText_OutputPorts(),
562 static_cast<FwAssertArgType>(portNum)
563 );
564
565 this->m_LogText_OutputPort[portNum].registerSerialPort(port);
566 }
567
568#endif
569
570 void HealthComponentBase ::
571 set_Time_OutputPort(
572 NATIVE_INT_TYPE portNum,
573 Fw::InputSerializePort* port
574 )
575 {
576 FW_ASSERT(
577 portNum < this->getNum_Time_OutputPorts(),
578 static_cast<FwAssertArgType>(portNum)
579 );
580
581 this->m_Time_OutputPort[portNum].registerSerialPort(port);
582 }
583
584 void HealthComponentBase ::
585 set_Tlm_OutputPort(
586 NATIVE_INT_TYPE portNum,
587 Fw::InputSerializePort* port
588 )
589 {
590 FW_ASSERT(
591 portNum < this->getNum_Tlm_OutputPorts(),
592 static_cast<FwAssertArgType>(portNum)
593 );
594
595 this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
596 }
597
598#endif
599
600#if FW_PORT_SERIALIZATION
601
602 // ----------------------------------------------------------------------
603 // Connect serial input ports to typed output ports
604 // ----------------------------------------------------------------------
605
606 void HealthComponentBase ::
607 set_PingSend_OutputPort(
608 NATIVE_INT_TYPE portNum,
609 Fw::InputSerializePort* port
610 )
611 {
612 FW_ASSERT(
613 portNum < this->getNum_PingSend_OutputPorts(),
614 static_cast<FwAssertArgType>(portNum)
615 );
616
617 this->m_PingSend_OutputPort[portNum].registerSerialPort(port);
618 }
619
620 void HealthComponentBase ::
621 set_WdogStroke_OutputPort(
622 NATIVE_INT_TYPE portNum,
623 Fw::InputSerializePort* port
624 )
625 {
626 FW_ASSERT(
627 portNum < this->getNum_WdogStroke_OutputPorts(),
628 static_cast<FwAssertArgType>(portNum)
629 );
630
631 this->m_WdogStroke_OutputPort[portNum].registerSerialPort(port);
632 }
633
634#endif
635
636 // ----------------------------------------------------------------------
637 // Command registration
638 // ----------------------------------------------------------------------
639
640 void HealthComponentBase ::
641 regCommands()
642 {
643 FW_ASSERT(this->m_CmdReg_OutputPort[0].isConnected());
644
645 this->m_CmdReg_OutputPort[0].invoke(
646 this->getIdBase() + OPCODE_HLTH_ENABLE
647 );
648
649 this->m_CmdReg_OutputPort[0].invoke(
650 this->getIdBase() + OPCODE_HLTH_PING_ENABLE
651 );
652
653 this->m_CmdReg_OutputPort[0].invoke(
654 this->getIdBase() + OPCODE_HLTH_CHNG_PING
655 );
656 }
657
658 // ----------------------------------------------------------------------
659 // Component construction and destruction
660 // ----------------------------------------------------------------------
661
662 HealthComponentBase ::
663 HealthComponentBase(const char* compName) :
664 Fw::QueuedComponentBase(compName)
665 {
666
667 }
668
669 HealthComponentBase ::
670 ~HealthComponentBase()
671 {
672
673 }
674
675 // ----------------------------------------------------------------------
676 // Getters for numbers of special input ports
677 // ----------------------------------------------------------------------
678
679 NATIVE_INT_TYPE HealthComponentBase ::
680 getNum_CmdDisp_InputPorts()
681 {
682 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdDisp_InputPort));
683 }
684
685 // ----------------------------------------------------------------------
686 // Getters for numbers of typed input ports
687 // ----------------------------------------------------------------------
688
689 NATIVE_INT_TYPE HealthComponentBase ::
690 getNum_PingReturn_InputPorts()
691 {
692 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_PingReturn_InputPort));
693 }
694
695 NATIVE_INT_TYPE HealthComponentBase ::
696 getNum_Run_InputPorts()
697 {
698 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Run_InputPort));
699 }
700
701 // ----------------------------------------------------------------------
702 // Getters for numbers of special output ports
703 // ----------------------------------------------------------------------
704
705 NATIVE_INT_TYPE HealthComponentBase ::
706 getNum_CmdReg_OutputPorts()
707 {
708 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdReg_OutputPort));
709 }
710
711 NATIVE_INT_TYPE HealthComponentBase ::
712 getNum_CmdStatus_OutputPorts()
713 {
714 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdStatus_OutputPort));
715 }
716
717 NATIVE_INT_TYPE HealthComponentBase ::
718 getNum_Log_OutputPorts()
719 {
720 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Log_OutputPort));
721 }
722
723#if FW_ENABLE_TEXT_LOGGING == 1
724
725 NATIVE_INT_TYPE HealthComponentBase ::
726 getNum_LogText_OutputPorts()
727 {
728 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
729 }
730
731#endif
732
733 NATIVE_INT_TYPE HealthComponentBase ::
734 getNum_Time_OutputPorts()
735 {
736 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
737 }
738
739 NATIVE_INT_TYPE HealthComponentBase ::
740 getNum_Tlm_OutputPorts()
741 {
742 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Tlm_OutputPort));
743 }
744
745 // ----------------------------------------------------------------------
746 // Getters for numbers of typed output ports
747 // ----------------------------------------------------------------------
748
749 NATIVE_INT_TYPE HealthComponentBase ::
750 getNum_PingSend_OutputPorts()
751 {
752 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_PingSend_OutputPort));
753 }
754
755 NATIVE_INT_TYPE HealthComponentBase ::
756 getNum_WdogStroke_OutputPorts()
757 {
758 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_WdogStroke_OutputPort));
759 }
760
761 // ----------------------------------------------------------------------
762 // Connection status queries for special output ports
763 // ----------------------------------------------------------------------
764
765 bool HealthComponentBase ::
766 isConnected_CmdReg_OutputPort(NATIVE_INT_TYPE portNum)
767 {
768 FW_ASSERT(
769 portNum < this->getNum_CmdReg_OutputPorts(),
770 static_cast<FwAssertArgType>(portNum)
771 );
772
773 return this->m_CmdReg_OutputPort[portNum].isConnected();
774 }
775
776 bool HealthComponentBase ::
777 isConnected_CmdStatus_OutputPort(NATIVE_INT_TYPE portNum)
778 {
779 FW_ASSERT(
780 portNum < this->getNum_CmdStatus_OutputPorts(),
781 static_cast<FwAssertArgType>(portNum)
782 );
783
784 return this->m_CmdStatus_OutputPort[portNum].isConnected();
785 }
786
787 bool HealthComponentBase ::
788 isConnected_Log_OutputPort(NATIVE_INT_TYPE portNum)
789 {
790 FW_ASSERT(
791 portNum < this->getNum_Log_OutputPorts(),
792 static_cast<FwAssertArgType>(portNum)
793 );
794
795 return this->m_Log_OutputPort[portNum].isConnected();
796 }
797
798#if FW_ENABLE_TEXT_LOGGING == 1
799
800 bool HealthComponentBase ::
801 isConnected_LogText_OutputPort(NATIVE_INT_TYPE portNum)
802 {
803 FW_ASSERT(
804 portNum < this->getNum_LogText_OutputPorts(),
805 static_cast<FwAssertArgType>(portNum)
806 );
807
808 return this->m_LogText_OutputPort[portNum].isConnected();
809 }
810
811#endif
812
813 bool HealthComponentBase ::
814 isConnected_Time_OutputPort(NATIVE_INT_TYPE portNum)
815 {
816 FW_ASSERT(
817 portNum < this->getNum_Time_OutputPorts(),
818 static_cast<FwAssertArgType>(portNum)
819 );
820
821 return this->m_Time_OutputPort[portNum].isConnected();
822 }
823
824 bool HealthComponentBase ::
825 isConnected_Tlm_OutputPort(NATIVE_INT_TYPE portNum)
826 {
827 FW_ASSERT(
828 portNum < this->getNum_Tlm_OutputPorts(),
829 static_cast<FwAssertArgType>(portNum)
830 );
831
832 return this->m_Tlm_OutputPort[portNum].isConnected();
833 }
834
835 // ----------------------------------------------------------------------
836 // Connection status queries for typed output ports
837 // ----------------------------------------------------------------------
838
839 bool HealthComponentBase ::
840 isConnected_PingSend_OutputPort(NATIVE_INT_TYPE portNum)
841 {
842 FW_ASSERT(
843 portNum < this->getNum_PingSend_OutputPorts(),
844 static_cast<FwAssertArgType>(portNum)
845 );
846
847 return this->m_PingSend_OutputPort[portNum].isConnected();
848 }
849
850 bool HealthComponentBase ::
851 isConnected_WdogStroke_OutputPort(NATIVE_INT_TYPE portNum)
852 {
853 FW_ASSERT(
854 portNum < this->getNum_WdogStroke_OutputPorts(),
855 static_cast<FwAssertArgType>(portNum)
856 );
857
858 return this->m_WdogStroke_OutputPort[portNum].isConnected();
859 }
860
861 // ----------------------------------------------------------------------
862 // Port handler base-class functions for typed input ports
863 //
864 // Call these functions directly to bypass the corresponding ports
865 // ----------------------------------------------------------------------
866
867 void HealthComponentBase ::
868 PingReturn_handlerBase(
869 NATIVE_INT_TYPE portNum,
870 U32 key
871 )
872 {
873 // Make sure port number is valid
874 FW_ASSERT(
875 portNum < this->getNum_PingReturn_InputPorts(),
876 static_cast<FwAssertArgType>(portNum)
877 );
878
879 // Call pre-message hook
880 PingReturn_preMsgHook(
881 portNum,
882 key
883 );
884 ComponentIpcSerializableBuffer msg;
886
887 // Serialize message ID
888 _status = msg.serialize(
889 static_cast<NATIVE_INT_TYPE>(PINGRETURN_PING)
890 );
891 FW_ASSERT(
892 _status == Fw::FW_SERIALIZE_OK,
893 static_cast<FwAssertArgType>(_status)
894 );
895
896 // Serialize port number
897 _status = msg.serialize(portNum);
898 FW_ASSERT(
899 _status == Fw::FW_SERIALIZE_OK,
900 static_cast<FwAssertArgType>(_status)
901 );
902
903 // Serialize argument key
904 _status = msg.serialize(key);
905 FW_ASSERT(
906 _status == Fw::FW_SERIALIZE_OK,
907 static_cast<FwAssertArgType>(_status)
908 );
909
910 // Send message
912 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
913
914 FW_ASSERT(
915 qStatus == Os::Queue::QUEUE_OK,
916 static_cast<FwAssertArgType>(qStatus)
917 );
918 }
919
920 void HealthComponentBase ::
921 Run_handlerBase(
922 NATIVE_INT_TYPE portNum,
923 NATIVE_UINT_TYPE context
924 )
925 {
926 // Make sure port number is valid
927 FW_ASSERT(
928 portNum < this->getNum_Run_InputPorts(),
929 static_cast<FwAssertArgType>(portNum)
930 );
931
932 // Down call to pure virtual handler method implemented in Impl class
933 this->Run_handler(
934 portNum,
935 context
936 );
937 }
938
939 // ----------------------------------------------------------------------
940 // Pre-message hooks for typed async input ports
941 //
942 // Each of these functions is invoked just before processing a message
943 // on the corresponding port. By default, they do nothing. You can
944 // override them to provide specific pre-message behavior.
945 // ----------------------------------------------------------------------
946
947 void HealthComponentBase ::
948 PingReturn_preMsgHook(
949 NATIVE_INT_TYPE portNum,
950 U32 key
951 )
952 {
953 // Default: no-op
954 }
955
956 // ----------------------------------------------------------------------
957 // Invocation functions for typed output ports
958 // ----------------------------------------------------------------------
959
960 void HealthComponentBase ::
961 PingSend_out(
962 NATIVE_INT_TYPE portNum,
963 U32 key
964 )
965 {
966 FW_ASSERT(
967 portNum < this->getNum_PingSend_OutputPorts(),
968 static_cast<FwAssertArgType>(portNum)
969 );
970 this->m_PingSend_OutputPort[portNum].invoke(
971 key
972 );
973 }
974
975 void HealthComponentBase ::
976 WdogStroke_out(
977 NATIVE_INT_TYPE portNum,
978 U32 code
979 )
980 {
981 FW_ASSERT(
982 portNum < this->getNum_WdogStroke_OutputPorts(),
983 static_cast<FwAssertArgType>(portNum)
984 );
985 this->m_WdogStroke_OutputPort[portNum].invoke(
986 code
987 );
988 }
989
990 // ----------------------------------------------------------------------
991 // Command response
992 // ----------------------------------------------------------------------
993
994 void HealthComponentBase ::
995 cmdResponse_out(
996 FwOpcodeType opCode,
997 U32 cmdSeq,
998 Fw::CmdResponse response
999 )
1000 {
1001 FW_ASSERT(this->m_CmdStatus_OutputPort[0].isConnected());
1002 this->m_CmdStatus_OutputPort[0].invoke(opCode, cmdSeq, response);
1003 }
1004
1005 // ----------------------------------------------------------------------
1006 // Command handler base-class functions
1007 //
1008 // Call these functions directly to bypass the command input port
1009 // ----------------------------------------------------------------------
1010
1011 void HealthComponentBase ::
1012 HLTH_ENABLE_cmdHandlerBase(
1013 FwOpcodeType opCode,
1014 U32 cmdSeq,
1015 Fw::CmdArgBuffer& args
1016 )
1017 {
1018 // Call pre-message hook
1019 this->HLTH_ENABLE_preMsgHook(opCode,cmdSeq);
1020
1021 // Defer deserializing arguments to the message dispatcher
1022 // to avoid deserializing and reserializing just for IPC
1023 ComponentIpcSerializableBuffer msg;
1025
1026 // Serialize for IPC
1027 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_HLTH_ENABLE));
1028 FW_ASSERT (
1029 _status == Fw::FW_SERIALIZE_OK,
1030 static_cast<FwAssertArgType>(_status)
1031 );
1032
1033 // Fake port number to make message dequeue work
1034 NATIVE_INT_TYPE port = 0;
1035
1036 _status = msg.serialize(port);
1037 FW_ASSERT (
1038 _status == Fw::FW_SERIALIZE_OK,
1039 static_cast<FwAssertArgType>(_status)
1040 );
1041
1042 _status = msg.serialize(opCode);
1043 FW_ASSERT (
1044 _status == Fw::FW_SERIALIZE_OK,
1045 static_cast<FwAssertArgType>(_status)
1046 );
1047
1048 _status = msg.serialize(cmdSeq);
1049 FW_ASSERT (
1050 _status == Fw::FW_SERIALIZE_OK,
1051 static_cast<FwAssertArgType>(_status)
1052 );
1053
1054 _status = msg.serialize(args);
1055 FW_ASSERT (
1056 _status == Fw::FW_SERIALIZE_OK,
1057 static_cast<FwAssertArgType>(_status)
1058 );
1059
1060 // Send message
1062 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1063
1064 FW_ASSERT(
1065 qStatus == Os::Queue::QUEUE_OK,
1066 static_cast<FwAssertArgType>(qStatus)
1067 );
1068 }
1069
1070 void HealthComponentBase ::
1071 HLTH_PING_ENABLE_cmdHandlerBase(
1072 FwOpcodeType opCode,
1073 U32 cmdSeq,
1074 Fw::CmdArgBuffer& args
1075 )
1076 {
1077 // Call pre-message hook
1078 this->HLTH_PING_ENABLE_preMsgHook(opCode,cmdSeq);
1079
1080 // Defer deserializing arguments to the message dispatcher
1081 // to avoid deserializing and reserializing just for IPC
1082 ComponentIpcSerializableBuffer msg;
1084
1085 // Serialize for IPC
1086 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_HLTH_PING_ENABLE));
1087 FW_ASSERT (
1088 _status == Fw::FW_SERIALIZE_OK,
1089 static_cast<FwAssertArgType>(_status)
1090 );
1091
1092 // Fake port number to make message dequeue work
1093 NATIVE_INT_TYPE port = 0;
1094
1095 _status = msg.serialize(port);
1096 FW_ASSERT (
1097 _status == Fw::FW_SERIALIZE_OK,
1098 static_cast<FwAssertArgType>(_status)
1099 );
1100
1101 _status = msg.serialize(opCode);
1102 FW_ASSERT (
1103 _status == Fw::FW_SERIALIZE_OK,
1104 static_cast<FwAssertArgType>(_status)
1105 );
1106
1107 _status = msg.serialize(cmdSeq);
1108 FW_ASSERT (
1109 _status == Fw::FW_SERIALIZE_OK,
1110 static_cast<FwAssertArgType>(_status)
1111 );
1112
1113 _status = msg.serialize(args);
1114 FW_ASSERT (
1115 _status == Fw::FW_SERIALIZE_OK,
1116 static_cast<FwAssertArgType>(_status)
1117 );
1118
1119 // Send message
1121 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1122
1123 FW_ASSERT(
1124 qStatus == Os::Queue::QUEUE_OK,
1125 static_cast<FwAssertArgType>(qStatus)
1126 );
1127 }
1128
1129 void HealthComponentBase ::
1130 HLTH_CHNG_PING_cmdHandlerBase(
1131 FwOpcodeType opCode,
1132 U32 cmdSeq,
1133 Fw::CmdArgBuffer& args
1134 )
1135 {
1136 // Call pre-message hook
1137 this->HLTH_CHNG_PING_preMsgHook(opCode,cmdSeq);
1138
1139 // Defer deserializing arguments to the message dispatcher
1140 // to avoid deserializing and reserializing just for IPC
1141 ComponentIpcSerializableBuffer msg;
1143
1144 // Serialize for IPC
1145 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_HLTH_CHNG_PING));
1146 FW_ASSERT (
1147 _status == Fw::FW_SERIALIZE_OK,
1148 static_cast<FwAssertArgType>(_status)
1149 );
1150
1151 // Fake port number to make message dequeue work
1152 NATIVE_INT_TYPE port = 0;
1153
1154 _status = msg.serialize(port);
1155 FW_ASSERT (
1156 _status == Fw::FW_SERIALIZE_OK,
1157 static_cast<FwAssertArgType>(_status)
1158 );
1159
1160 _status = msg.serialize(opCode);
1161 FW_ASSERT (
1162 _status == Fw::FW_SERIALIZE_OK,
1163 static_cast<FwAssertArgType>(_status)
1164 );
1165
1166 _status = msg.serialize(cmdSeq);
1167 FW_ASSERT (
1168 _status == Fw::FW_SERIALIZE_OK,
1169 static_cast<FwAssertArgType>(_status)
1170 );
1171
1172 _status = msg.serialize(args);
1173 FW_ASSERT (
1174 _status == Fw::FW_SERIALIZE_OK,
1175 static_cast<FwAssertArgType>(_status)
1176 );
1177
1178 // Send message
1180 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1181
1182 FW_ASSERT(
1183 qStatus == Os::Queue::QUEUE_OK,
1184 static_cast<FwAssertArgType>(qStatus)
1185 );
1186 }
1187
1188 // ----------------------------------------------------------------------
1189 // Pre-message hooks for async commands
1190 //
1191 // Each of these functions is invoked just before processing the
1192 // corresponding command. By default they do nothing. You can
1193 // override them to provide specific pre-command behavior.
1194 // ----------------------------------------------------------------------
1195
1196 void HealthComponentBase ::
1197 HLTH_ENABLE_preMsgHook(
1198 FwOpcodeType opCode,
1199 U32 cmdSeq
1200 )
1201 {
1202 // Defaults to no-op; can be overridden
1203 }
1204
1205 void HealthComponentBase ::
1206 HLTH_PING_ENABLE_preMsgHook(
1207 FwOpcodeType opCode,
1208 U32 cmdSeq
1209 )
1210 {
1211 // Defaults to no-op; can be overridden
1212 }
1213
1214 void HealthComponentBase ::
1215 HLTH_CHNG_PING_preMsgHook(
1216 FwOpcodeType opCode,
1217 U32 cmdSeq
1218 )
1219 {
1220 // Defaults to no-op; can be overridden
1221 }
1222
1223 // ----------------------------------------------------------------------
1224 // Event logging functions
1225 // ----------------------------------------------------------------------
1226
1227 void HealthComponentBase ::
1228 log_WARNING_HI_HLTH_PING_WARN(const Fw::LogStringArg& entry)
1229 {
1230 // Get the time
1231 Fw::Time _logTime;
1232 if (this->m_Time_OutputPort[0].isConnected()) {
1233 this->m_Time_OutputPort[0].invoke(_logTime);
1234 }
1235
1236 FwEventIdType _id = static_cast<FwEventIdType>(0);
1237
1238 _id = this->getIdBase() + EVENTID_HLTH_PING_WARN;
1239
1240 // Emit the event on the log port
1241 if (this->m_Log_OutputPort[0].isConnected()) {
1242 Fw::LogBuffer _logBuff;
1244
1245#if FW_AMPCS_COMPATIBLE
1246 // Serialize the number of arguments
1247 _status = _logBuff.serialize(static_cast<U8>(1));
1248 FW_ASSERT(
1249 _status == Fw::FW_SERIALIZE_OK,
1250 static_cast<FwAssertArgType>(_status)
1251 );
1252#endif
1253
1254 _status = entry.serialize(_logBuff, 40);
1255 FW_ASSERT(
1256 _status == Fw::FW_SERIALIZE_OK,
1257 static_cast<FwAssertArgType>(_status)
1258 );
1259
1260 this->m_Log_OutputPort[0].invoke(
1261 _id,
1262 _logTime,
1264 _logBuff
1265 );
1266 }
1267
1268 // Emit the event on the text log port
1269#if FW_ENABLE_TEXT_LOGGING
1270 if (this->m_LogText_OutputPort[0].isConnected()) {
1271#if FW_OBJECT_NAMES == 1
1272 const char* _formatString =
1273 "(%s) %s: Ping entry %s late warning";
1274#else
1275 const char* _formatString =
1276 "%s: Ping entry %s late warning";
1277#endif
1278
1279 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1280
1281 (void) snprintf(
1282 _textBuffer,
1284 _formatString,
1285#if FW_OBJECT_NAMES == 1
1286 this->m_objName,
1287#endif
1288 "HLTH_PING_WARN ",
1289 entry.toChar()
1290 );
1291
1292 // Null terminate
1293 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1294 Fw::TextLogString _logString = _textBuffer;
1295 this->m_LogText_OutputPort[0].invoke(
1296 _id,
1297 _logTime,
1299 _logString
1300 );
1301 }
1302#endif
1303 }
1304
1305 void HealthComponentBase ::
1306 log_FATAL_HLTH_PING_LATE(const Fw::LogStringArg& entry)
1307 {
1308 // Get the time
1309 Fw::Time _logTime;
1310 if (this->m_Time_OutputPort[0].isConnected()) {
1311 this->m_Time_OutputPort[0].invoke(_logTime);
1312 }
1313
1314 FwEventIdType _id = static_cast<FwEventIdType>(0);
1315
1316 _id = this->getIdBase() + EVENTID_HLTH_PING_LATE;
1317
1318 // Emit the event on the log port
1319 if (this->m_Log_OutputPort[0].isConnected()) {
1320 Fw::LogBuffer _logBuff;
1322
1323#if FW_AMPCS_COMPATIBLE
1324 // Serialize the number of arguments
1325 _status = _logBuff.serialize(static_cast<U8>(1 + 1));
1326 FW_ASSERT(
1327 _status == Fw::FW_SERIALIZE_OK,
1328 static_cast<FwAssertArgType>(_status)
1329 );
1330
1331 // For FATAL, add stack size of 4 and a dummy entry. No support for stacks yet.
1332 _status = _logBuff.serialize(static_cast<U8>(4));
1333 FW_ASSERT(
1334 _status == Fw::FW_SERIALIZE_OK,
1335 static_cast<FwAssertArgType>(_status)
1336 );
1337
1338 _status = _logBuff.serialize(static_cast<U32>(0));
1339 FW_ASSERT(
1340 _status == Fw::FW_SERIALIZE_OK,
1341 static_cast<FwAssertArgType>(_status)
1342 );
1343#endif
1344
1345 _status = entry.serialize(_logBuff, 40);
1346 FW_ASSERT(
1347 _status == Fw::FW_SERIALIZE_OK,
1348 static_cast<FwAssertArgType>(_status)
1349 );
1350
1351 this->m_Log_OutputPort[0].invoke(
1352 _id,
1353 _logTime,
1355 _logBuff
1356 );
1357 }
1358
1359 // Emit the event on the text log port
1360#if FW_ENABLE_TEXT_LOGGING
1361 if (this->m_LogText_OutputPort[0].isConnected()) {
1362#if FW_OBJECT_NAMES == 1
1363 const char* _formatString =
1364 "(%s) %s: Ping entry %s did not respond";
1365#else
1366 const char* _formatString =
1367 "%s: Ping entry %s did not respond";
1368#endif
1369
1370 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1371
1372 (void) snprintf(
1373 _textBuffer,
1375 _formatString,
1376#if FW_OBJECT_NAMES == 1
1377 this->m_objName,
1378#endif
1379 "HLTH_PING_LATE ",
1380 entry.toChar()
1381 );
1382
1383 // Null terminate
1384 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1385 Fw::TextLogString _logString = _textBuffer;
1386 this->m_LogText_OutputPort[0].invoke(
1387 _id,
1388 _logTime,
1390 _logString
1391 );
1392 }
1393#endif
1394 }
1395
1396 void HealthComponentBase ::
1397 log_FATAL_HLTH_PING_WRONG_KEY(
1398 const Fw::LogStringArg& entry,
1399 U32 badKey
1400 )
1401 {
1402 // Get the time
1403 Fw::Time _logTime;
1404 if (this->m_Time_OutputPort[0].isConnected()) {
1405 this->m_Time_OutputPort[0].invoke(_logTime);
1406 }
1407
1408 FwEventIdType _id = static_cast<FwEventIdType>(0);
1409
1410 _id = this->getIdBase() + EVENTID_HLTH_PING_WRONG_KEY;
1411
1412 // Emit the event on the log port
1413 if (this->m_Log_OutputPort[0].isConnected()) {
1414 Fw::LogBuffer _logBuff;
1416
1417#if FW_AMPCS_COMPATIBLE
1418 // Serialize the number of arguments
1419 _status = _logBuff.serialize(static_cast<U8>(2 + 1));
1420 FW_ASSERT(
1421 _status == Fw::FW_SERIALIZE_OK,
1422 static_cast<FwAssertArgType>(_status)
1423 );
1424
1425 // For FATAL, add stack size of 4 and a dummy entry. No support for stacks yet.
1426 _status = _logBuff.serialize(static_cast<U8>(4));
1427 FW_ASSERT(
1428 _status == Fw::FW_SERIALIZE_OK,
1429 static_cast<FwAssertArgType>(_status)
1430 );
1431
1432 _status = _logBuff.serialize(static_cast<U32>(0));
1433 FW_ASSERT(
1434 _status == Fw::FW_SERIALIZE_OK,
1435 static_cast<FwAssertArgType>(_status)
1436 );
1437#endif
1438
1439 _status = entry.serialize(_logBuff, 40);
1440 FW_ASSERT(
1441 _status == Fw::FW_SERIALIZE_OK,
1442 static_cast<FwAssertArgType>(_status)
1443 );
1444
1445#if FW_AMPCS_COMPATIBLE
1446 // Serialize the argument size
1447 _status = _logBuff.serialize(
1448 static_cast<U8>(sizeof(U32))
1449 );
1450 FW_ASSERT(
1451 _status == Fw::FW_SERIALIZE_OK,
1452 static_cast<FwAssertArgType>(_status)
1453 );
1454#endif
1455 _status = _logBuff.serialize(badKey);
1456 FW_ASSERT(
1457 _status == Fw::FW_SERIALIZE_OK,
1458 static_cast<FwAssertArgType>(_status)
1459 );
1460
1461 this->m_Log_OutputPort[0].invoke(
1462 _id,
1463 _logTime,
1465 _logBuff
1466 );
1467 }
1468
1469 // Emit the event on the text log port
1470#if FW_ENABLE_TEXT_LOGGING
1471 if (this->m_LogText_OutputPort[0].isConnected()) {
1472#if FW_OBJECT_NAMES == 1
1473 const char* _formatString =
1474 "(%s) %s: Ping entry %s responded with wrong key 0x%" PRIx32 "";
1475#else
1476 const char* _formatString =
1477 "%s: Ping entry %s responded with wrong key 0x%" PRIx32 "";
1478#endif
1479
1480 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1481
1482 (void) snprintf(
1483 _textBuffer,
1485 _formatString,
1486#if FW_OBJECT_NAMES == 1
1487 this->m_objName,
1488#endif
1489 "HLTH_PING_WRONG_KEY ",
1490 entry.toChar(),
1491 badKey
1492 );
1493
1494 // Null terminate
1495 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1496 Fw::TextLogString _logString = _textBuffer;
1497 this->m_LogText_OutputPort[0].invoke(
1498 _id,
1499 _logTime,
1501 _logString
1502 );
1503 }
1504#endif
1505 }
1506
1507 void HealthComponentBase ::
1508 log_ACTIVITY_HI_HLTH_CHECK_ENABLE(Fw::Enabled enabled)
1509 {
1510 // Get the time
1511 Fw::Time _logTime;
1512 if (this->m_Time_OutputPort[0].isConnected()) {
1513 this->m_Time_OutputPort[0].invoke(_logTime);
1514 }
1515
1516 FwEventIdType _id = static_cast<FwEventIdType>(0);
1517
1518 _id = this->getIdBase() + EVENTID_HLTH_CHECK_ENABLE;
1519
1520 // Emit the event on the log port
1521 if (this->m_Log_OutputPort[0].isConnected()) {
1522 Fw::LogBuffer _logBuff;
1524
1525#if FW_AMPCS_COMPATIBLE
1526 // Serialize the number of arguments
1527 _status = _logBuff.serialize(static_cast<U8>(1));
1528 FW_ASSERT(
1529 _status == Fw::FW_SERIALIZE_OK,
1530 static_cast<FwAssertArgType>(_status)
1531 );
1532#endif
1533
1534#if FW_AMPCS_COMPATIBLE
1535 // Serialize the argument size
1536 _status = _logBuff.serialize(
1537 static_cast<U8>(Fw::Enabled::SERIALIZED_SIZE)
1538 );
1539 FW_ASSERT(
1540 _status == Fw::FW_SERIALIZE_OK,
1541 static_cast<FwAssertArgType>(_status)
1542 );
1543#endif
1544 _status = _logBuff.serialize(enabled);
1545 FW_ASSERT(
1546 _status == Fw::FW_SERIALIZE_OK,
1547 static_cast<FwAssertArgType>(_status)
1548 );
1549
1550 this->m_Log_OutputPort[0].invoke(
1551 _id,
1552 _logTime,
1554 _logBuff
1555 );
1556 }
1557
1558 // Emit the event on the text log port
1559#if FW_ENABLE_TEXT_LOGGING
1560 if (this->m_LogText_OutputPort[0].isConnected()) {
1561#if FW_OBJECT_NAMES == 1
1562 const char* _formatString =
1563 "(%s) %s: Health checking set to %s";
1564#else
1565 const char* _formatString =
1566 "%s: Health checking set to %s";
1567#endif
1568
1569 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1570
1571 Fw::String enabledStr;
1572 enabled.toString(enabledStr);
1573
1574 (void) snprintf(
1575 _textBuffer,
1577 _formatString,
1578#if FW_OBJECT_NAMES == 1
1579 this->m_objName,
1580#endif
1581 "HLTH_CHECK_ENABLE ",
1582 enabledStr.toChar()
1583 );
1584
1585 // Null terminate
1586 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1587 Fw::TextLogString _logString = _textBuffer;
1588 this->m_LogText_OutputPort[0].invoke(
1589 _id,
1590 _logTime,
1592 _logString
1593 );
1594 }
1595#endif
1596 }
1597
1598 void HealthComponentBase ::
1599 log_ACTIVITY_HI_HLTH_CHECK_PING(
1600 Fw::Enabled enabled,
1601 const Fw::LogStringArg& entry
1602 )
1603 {
1604 // Get the time
1605 Fw::Time _logTime;
1606 if (this->m_Time_OutputPort[0].isConnected()) {
1607 this->m_Time_OutputPort[0].invoke(_logTime);
1608 }
1609
1610 FwEventIdType _id = static_cast<FwEventIdType>(0);
1611
1612 _id = this->getIdBase() + EVENTID_HLTH_CHECK_PING;
1613
1614 // Emit the event on the log port
1615 if (this->m_Log_OutputPort[0].isConnected()) {
1616 Fw::LogBuffer _logBuff;
1618
1619#if FW_AMPCS_COMPATIBLE
1620 // Serialize the number of arguments
1621 _status = _logBuff.serialize(static_cast<U8>(2));
1622 FW_ASSERT(
1623 _status == Fw::FW_SERIALIZE_OK,
1624 static_cast<FwAssertArgType>(_status)
1625 );
1626#endif
1627
1628#if FW_AMPCS_COMPATIBLE
1629 // Serialize the argument size
1630 _status = _logBuff.serialize(
1631 static_cast<U8>(Fw::Enabled::SERIALIZED_SIZE)
1632 );
1633 FW_ASSERT(
1634 _status == Fw::FW_SERIALIZE_OK,
1635 static_cast<FwAssertArgType>(_status)
1636 );
1637#endif
1638 _status = _logBuff.serialize(enabled);
1639 FW_ASSERT(
1640 _status == Fw::FW_SERIALIZE_OK,
1641 static_cast<FwAssertArgType>(_status)
1642 );
1643
1644 _status = entry.serialize(_logBuff, 40);
1645 FW_ASSERT(
1646 _status == Fw::FW_SERIALIZE_OK,
1647 static_cast<FwAssertArgType>(_status)
1648 );
1649
1650 this->m_Log_OutputPort[0].invoke(
1651 _id,
1652 _logTime,
1654 _logBuff
1655 );
1656 }
1657
1658 // Emit the event on the text log port
1659#if FW_ENABLE_TEXT_LOGGING
1660 if (this->m_LogText_OutputPort[0].isConnected()) {
1661#if FW_OBJECT_NAMES == 1
1662 const char* _formatString =
1663 "(%s) %s: Health checking set to %s for %s";
1664#else
1665 const char* _formatString =
1666 "%s: Health checking set to %s for %s";
1667#endif
1668
1669 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1670
1671 Fw::String enabledStr;
1672 enabled.toString(enabledStr);
1673
1674 (void) snprintf(
1675 _textBuffer,
1677 _formatString,
1678#if FW_OBJECT_NAMES == 1
1679 this->m_objName,
1680#endif
1681 "HLTH_CHECK_PING ",
1682 enabledStr.toChar(),
1683 entry.toChar()
1684 );
1685
1686 // Null terminate
1687 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1688 Fw::TextLogString _logString = _textBuffer;
1689 this->m_LogText_OutputPort[0].invoke(
1690 _id,
1691 _logTime,
1693 _logString
1694 );
1695 }
1696#endif
1697 }
1698
1699 void HealthComponentBase ::
1700 log_WARNING_LO_HLTH_CHECK_LOOKUP_ERROR(const Fw::LogStringArg& entry)
1701 {
1702 // Get the time
1703 Fw::Time _logTime;
1704 if (this->m_Time_OutputPort[0].isConnected()) {
1705 this->m_Time_OutputPort[0].invoke(_logTime);
1706 }
1707
1708 FwEventIdType _id = static_cast<FwEventIdType>(0);
1709
1710 _id = this->getIdBase() + EVENTID_HLTH_CHECK_LOOKUP_ERROR;
1711
1712 // Emit the event on the log port
1713 if (this->m_Log_OutputPort[0].isConnected()) {
1714 Fw::LogBuffer _logBuff;
1716
1717#if FW_AMPCS_COMPATIBLE
1718 // Serialize the number of arguments
1719 _status = _logBuff.serialize(static_cast<U8>(1));
1720 FW_ASSERT(
1721 _status == Fw::FW_SERIALIZE_OK,
1722 static_cast<FwAssertArgType>(_status)
1723 );
1724#endif
1725
1726 _status = entry.serialize(_logBuff, 40);
1727 FW_ASSERT(
1728 _status == Fw::FW_SERIALIZE_OK,
1729 static_cast<FwAssertArgType>(_status)
1730 );
1731
1732 this->m_Log_OutputPort[0].invoke(
1733 _id,
1734 _logTime,
1736 _logBuff
1737 );
1738 }
1739
1740 // Emit the event on the text log port
1741#if FW_ENABLE_TEXT_LOGGING
1742 if (this->m_LogText_OutputPort[0].isConnected()) {
1743#if FW_OBJECT_NAMES == 1
1744 const char* _formatString =
1745 "(%s) %s: Couldn't find entry %s";
1746#else
1747 const char* _formatString =
1748 "%s: Couldn't find entry %s";
1749#endif
1750
1751 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1752
1753 (void) snprintf(
1754 _textBuffer,
1756 _formatString,
1757#if FW_OBJECT_NAMES == 1
1758 this->m_objName,
1759#endif
1760 "HLTH_CHECK_LOOKUP_ERROR ",
1761 entry.toChar()
1762 );
1763
1764 // Null terminate
1765 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1766 Fw::TextLogString _logString = _textBuffer;
1767 this->m_LogText_OutputPort[0].invoke(
1768 _id,
1769 _logTime,
1771 _logString
1772 );
1773 }
1774#endif
1775 }
1776
1777 void HealthComponentBase ::
1778 log_ACTIVITY_HI_HLTH_PING_UPDATED(
1779 const Fw::LogStringArg& entry,
1780 U32 warn,
1781 U32 fatal
1782 )
1783 {
1784 // Get the time
1785 Fw::Time _logTime;
1786 if (this->m_Time_OutputPort[0].isConnected()) {
1787 this->m_Time_OutputPort[0].invoke(_logTime);
1788 }
1789
1790 FwEventIdType _id = static_cast<FwEventIdType>(0);
1791
1792 _id = this->getIdBase() + EVENTID_HLTH_PING_UPDATED;
1793
1794 // Emit the event on the log port
1795 if (this->m_Log_OutputPort[0].isConnected()) {
1796 Fw::LogBuffer _logBuff;
1798
1799#if FW_AMPCS_COMPATIBLE
1800 // Serialize the number of arguments
1801 _status = _logBuff.serialize(static_cast<U8>(3));
1802 FW_ASSERT(
1803 _status == Fw::FW_SERIALIZE_OK,
1804 static_cast<FwAssertArgType>(_status)
1805 );
1806#endif
1807
1808 _status = entry.serialize(_logBuff, 40);
1809 FW_ASSERT(
1810 _status == Fw::FW_SERIALIZE_OK,
1811 static_cast<FwAssertArgType>(_status)
1812 );
1813
1814#if FW_AMPCS_COMPATIBLE
1815 // Serialize the argument size
1816 _status = _logBuff.serialize(
1817 static_cast<U8>(sizeof(U32))
1818 );
1819 FW_ASSERT(
1820 _status == Fw::FW_SERIALIZE_OK,
1821 static_cast<FwAssertArgType>(_status)
1822 );
1823#endif
1824 _status = _logBuff.serialize(warn);
1825 FW_ASSERT(
1826 _status == Fw::FW_SERIALIZE_OK,
1827 static_cast<FwAssertArgType>(_status)
1828 );
1829
1830#if FW_AMPCS_COMPATIBLE
1831 // Serialize the argument size
1832 _status = _logBuff.serialize(
1833 static_cast<U8>(sizeof(U32))
1834 );
1835 FW_ASSERT(
1836 _status == Fw::FW_SERIALIZE_OK,
1837 static_cast<FwAssertArgType>(_status)
1838 );
1839#endif
1840 _status = _logBuff.serialize(fatal);
1841 FW_ASSERT(
1842 _status == Fw::FW_SERIALIZE_OK,
1843 static_cast<FwAssertArgType>(_status)
1844 );
1845
1846 this->m_Log_OutputPort[0].invoke(
1847 _id,
1848 _logTime,
1850 _logBuff
1851 );
1852 }
1853
1854 // Emit the event on the text log port
1855#if FW_ENABLE_TEXT_LOGGING
1856 if (this->m_LogText_OutputPort[0].isConnected()) {
1857#if FW_OBJECT_NAMES == 1
1858 const char* _formatString =
1859 "(%s) %s: Health ping for %s changed to WARN %" PRIu32 " FATAL %" PRIu32 "";
1860#else
1861 const char* _formatString =
1862 "%s: Health ping for %s changed to WARN %" PRIu32 " FATAL %" PRIu32 "";
1863#endif
1864
1865 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1866
1867 (void) snprintf(
1868 _textBuffer,
1870 _formatString,
1871#if FW_OBJECT_NAMES == 1
1872 this->m_objName,
1873#endif
1874 "HLTH_PING_UPDATED ",
1875 entry.toChar(),
1876 warn,
1877 fatal
1878 );
1879
1880 // Null terminate
1881 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1882 Fw::TextLogString _logString = _textBuffer;
1883 this->m_LogText_OutputPort[0].invoke(
1884 _id,
1885 _logTime,
1887 _logString
1888 );
1889 }
1890#endif
1891 }
1892
1893 void HealthComponentBase ::
1894 log_WARNING_HI_HLTH_PING_INVALID_VALUES(
1895 const Fw::LogStringArg& entry,
1896 U32 warn,
1897 U32 fatal
1898 )
1899 {
1900 // Get the time
1901 Fw::Time _logTime;
1902 if (this->m_Time_OutputPort[0].isConnected()) {
1903 this->m_Time_OutputPort[0].invoke(_logTime);
1904 }
1905
1906 FwEventIdType _id = static_cast<FwEventIdType>(0);
1907
1908 _id = this->getIdBase() + EVENTID_HLTH_PING_INVALID_VALUES;
1909
1910 // Emit the event on the log port
1911 if (this->m_Log_OutputPort[0].isConnected()) {
1912 Fw::LogBuffer _logBuff;
1914
1915#if FW_AMPCS_COMPATIBLE
1916 // Serialize the number of arguments
1917 _status = _logBuff.serialize(static_cast<U8>(3));
1918 FW_ASSERT(
1919 _status == Fw::FW_SERIALIZE_OK,
1920 static_cast<FwAssertArgType>(_status)
1921 );
1922#endif
1923
1924 _status = entry.serialize(_logBuff, 40);
1925 FW_ASSERT(
1926 _status == Fw::FW_SERIALIZE_OK,
1927 static_cast<FwAssertArgType>(_status)
1928 );
1929
1930#if FW_AMPCS_COMPATIBLE
1931 // Serialize the argument size
1932 _status = _logBuff.serialize(
1933 static_cast<U8>(sizeof(U32))
1934 );
1935 FW_ASSERT(
1936 _status == Fw::FW_SERIALIZE_OK,
1937 static_cast<FwAssertArgType>(_status)
1938 );
1939#endif
1940 _status = _logBuff.serialize(warn);
1941 FW_ASSERT(
1942 _status == Fw::FW_SERIALIZE_OK,
1943 static_cast<FwAssertArgType>(_status)
1944 );
1945
1946#if FW_AMPCS_COMPATIBLE
1947 // Serialize the argument size
1948 _status = _logBuff.serialize(
1949 static_cast<U8>(sizeof(U32))
1950 );
1951 FW_ASSERT(
1952 _status == Fw::FW_SERIALIZE_OK,
1953 static_cast<FwAssertArgType>(_status)
1954 );
1955#endif
1956 _status = _logBuff.serialize(fatal);
1957 FW_ASSERT(
1958 _status == Fw::FW_SERIALIZE_OK,
1959 static_cast<FwAssertArgType>(_status)
1960 );
1961
1962 this->m_Log_OutputPort[0].invoke(
1963 _id,
1964 _logTime,
1966 _logBuff
1967 );
1968 }
1969
1970 // Emit the event on the text log port
1971#if FW_ENABLE_TEXT_LOGGING
1972 if (this->m_LogText_OutputPort[0].isConnected()) {
1973#if FW_OBJECT_NAMES == 1
1974 const char* _formatString =
1975 "(%s) %s: Health ping for %s invalid values: WARN %" PRIu32 " FATAL %" PRIu32 "";
1976#else
1977 const char* _formatString =
1978 "%s: Health ping for %s invalid values: WARN %" PRIu32 " FATAL %" PRIu32 "";
1979#endif
1980
1981 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1982
1983 (void) snprintf(
1984 _textBuffer,
1986 _formatString,
1987#if FW_OBJECT_NAMES == 1
1988 this->m_objName,
1989#endif
1990 "HLTH_PING_INVALID_VALUES ",
1991 entry.toChar(),
1992 warn,
1993 fatal
1994 );
1995
1996 // Null terminate
1997 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1998 Fw::TextLogString _logString = _textBuffer;
1999 this->m_LogText_OutputPort[0].invoke(
2000 _id,
2001 _logTime,
2003 _logString
2004 );
2005 }
2006#endif
2007 }
2008
2009 // ----------------------------------------------------------------------
2010 // Telemetry write functions
2011 // ----------------------------------------------------------------------
2012
2013 void HealthComponentBase ::
2014 tlmWrite_PingLateWarnings(
2015 U32 arg,
2016 Fw::Time _tlmTime
2017 )
2018 {
2019 if (this->m_Tlm_OutputPort[0].isConnected()) {
2020 if (
2021 this->m_Time_OutputPort[0].isConnected() &&
2022 (_tlmTime == Fw::ZERO_TIME)
2023 ) {
2024 this->m_Time_OutputPort[0].invoke(_tlmTime);
2025 }
2026
2027 Fw::TlmBuffer _tlmBuff;
2028 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
2029 FW_ASSERT(
2030 _stat == Fw::FW_SERIALIZE_OK,
2031 static_cast<FwAssertArgType>(_stat)
2032 );
2033
2034 FwChanIdType _id;
2035
2036 _id = this->getIdBase() + CHANNELID_PINGLATEWARNINGS;
2037
2038 this->m_Tlm_OutputPort[0].invoke(
2039 _id,
2040 _tlmTime,
2041 _tlmBuff
2042 );
2043 }
2044 }
2045
2046 // ----------------------------------------------------------------------
2047 // Time
2048 // ----------------------------------------------------------------------
2049
2050 Fw::Time HealthComponentBase ::
2051 getTime()
2052 {
2053 if (this->m_Time_OutputPort[0].isConnected()) {
2054 Fw::Time _time;
2055 this->m_Time_OutputPort[0].invoke(_time);
2056 return _time;
2057 }
2058 else {
2059 return Fw::Time(TB_NONE, 0, 0);
2060 }
2061 }
2062
2063 // ----------------------------------------------------------------------
2064 // Message dispatch functions
2065 // ----------------------------------------------------------------------
2066
2068 doDispatch()
2069 {
2070 ComponentIpcSerializableBuffer msg;
2071 NATIVE_INT_TYPE priority = 0;
2072
2073 Os::Queue::QueueStatus msgStatus = this->m_queue.receive(
2074 msg,
2075 priority,
2077 );
2078 if (Os::Queue::QUEUE_NO_MORE_MSGS == msgStatus) {
2080 }
2081 else {
2082 FW_ASSERT(
2083 msgStatus == Os::Queue::QUEUE_OK,
2084 static_cast<FwAssertArgType>(msgStatus)
2085 );
2086 }
2087
2088 // Reset to beginning of buffer
2089 msg.resetDeser();
2090
2091 NATIVE_INT_TYPE desMsg = 0;
2092 Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
2093 FW_ASSERT(
2094 deserStatus == Fw::FW_SERIALIZE_OK,
2095 static_cast<FwAssertArgType>(deserStatus)
2096 );
2097
2098 MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
2099
2100 if (msgType == HEALTH_COMPONENT_EXIT) {
2101 return MSG_DISPATCH_EXIT;
2102 }
2103
2104 NATIVE_INT_TYPE portNum = 0;
2105 deserStatus = msg.deserialize(portNum);
2106 FW_ASSERT(
2107 deserStatus == Fw::FW_SERIALIZE_OK,
2108 static_cast<FwAssertArgType>(deserStatus)
2109 );
2110
2111 switch (msgType) {
2112 // Handle async input port PingReturn
2113 case PINGRETURN_PING: {
2114 // Deserialize argument key
2115 U32 key;
2116 deserStatus = msg.deserialize(key);
2117 FW_ASSERT(
2118 deserStatus == Fw::FW_SERIALIZE_OK,
2119 static_cast<FwAssertArgType>(deserStatus)
2120 );
2121 // Call handler function
2122 this->PingReturn_handler(
2123 portNum,
2124 key
2125 );
2126
2127 break;
2128 }
2129
2130 // Handle command HLTH_ENABLE
2131 case CMD_HLTH_ENABLE: {
2132 // Deserialize opcode
2133 FwOpcodeType opCode = 0;
2134 deserStatus = msg.deserialize(opCode);
2135 FW_ASSERT (
2136 deserStatus == Fw::FW_SERIALIZE_OK,
2137 static_cast<FwAssertArgType>(deserStatus)
2138 );
2139
2140 // Deserialize command sequence
2141 U32 cmdSeq = 0;
2142 deserStatus = msg.deserialize(cmdSeq);
2143 FW_ASSERT (
2144 deserStatus == Fw::FW_SERIALIZE_OK,
2145 static_cast<FwAssertArgType>(deserStatus)
2146 );
2147
2148 // Deserialize command argument buffer
2149 Fw::CmdArgBuffer args;
2150 deserStatus = msg.deserialize(args);
2151 FW_ASSERT (
2152 deserStatus == Fw::FW_SERIALIZE_OK,
2153 static_cast<FwAssertArgType>(deserStatus)
2154 );
2155
2156 // Reset buffer
2157 args.resetDeser();
2158
2159 // Deserialize argument enable
2160 Fw::Enabled enable;
2161 deserStatus = args.deserialize(enable);
2162 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2163 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2164 this->cmdResponse_out(
2165 opCode,
2166 cmdSeq,
2168 );
2169 }
2170 // Don't crash the task if bad arguments were passed from the ground
2171 break;
2172 }
2173
2174 // Make sure there was no data left over.
2175 // That means the argument buffer size was incorrect.
2176#if FW_CMD_CHECK_RESIDUAL
2177 if (args.getBuffLeft() != 0) {
2178 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2179 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2180 }
2181 // Don't crash the task if bad arguments were passed from the ground
2182 break;
2183 }
2184#endif
2185
2186 // Call handler function
2187 this->HLTH_ENABLE_cmdHandler(
2188 opCode, cmdSeq,
2189 enable
2190 );
2191
2192 break;
2193 }
2194
2195 // Handle command HLTH_PING_ENABLE
2196 case CMD_HLTH_PING_ENABLE: {
2197 // Deserialize opcode
2198 FwOpcodeType opCode = 0;
2199 deserStatus = msg.deserialize(opCode);
2200 FW_ASSERT (
2201 deserStatus == Fw::FW_SERIALIZE_OK,
2202 static_cast<FwAssertArgType>(deserStatus)
2203 );
2204
2205 // Deserialize command sequence
2206 U32 cmdSeq = 0;
2207 deserStatus = msg.deserialize(cmdSeq);
2208 FW_ASSERT (
2209 deserStatus == Fw::FW_SERIALIZE_OK,
2210 static_cast<FwAssertArgType>(deserStatus)
2211 );
2212
2213 // Deserialize command argument buffer
2214 Fw::CmdArgBuffer args;
2215 deserStatus = msg.deserialize(args);
2216 FW_ASSERT (
2217 deserStatus == Fw::FW_SERIALIZE_OK,
2218 static_cast<FwAssertArgType>(deserStatus)
2219 );
2220
2221 // Reset buffer
2222 args.resetDeser();
2223
2224 // Deserialize argument entry
2225 Fw::CmdStringArg entry;
2226 deserStatus = args.deserialize(entry);
2227 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2228 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2229 this->cmdResponse_out(
2230 opCode,
2231 cmdSeq,
2233 );
2234 }
2235 // Don't crash the task if bad arguments were passed from the ground
2236 break;
2237 }
2238
2239 // Deserialize argument enable
2240 Fw::Enabled enable;
2241 deserStatus = args.deserialize(enable);
2242 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2243 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2244 this->cmdResponse_out(
2245 opCode,
2246 cmdSeq,
2248 );
2249 }
2250 // Don't crash the task if bad arguments were passed from the ground
2251 break;
2252 }
2253
2254 // Make sure there was no data left over.
2255 // That means the argument buffer size was incorrect.
2256#if FW_CMD_CHECK_RESIDUAL
2257 if (args.getBuffLeft() != 0) {
2258 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2259 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2260 }
2261 // Don't crash the task if bad arguments were passed from the ground
2262 break;
2263 }
2264#endif
2265
2266 // Call handler function
2267 this->HLTH_PING_ENABLE_cmdHandler(
2268 opCode, cmdSeq,
2269 entry,
2270 enable
2271 );
2272
2273 break;
2274 }
2275
2276 // Handle command HLTH_CHNG_PING
2277 case CMD_HLTH_CHNG_PING: {
2278 // Deserialize opcode
2279 FwOpcodeType opCode = 0;
2280 deserStatus = msg.deserialize(opCode);
2281 FW_ASSERT (
2282 deserStatus == Fw::FW_SERIALIZE_OK,
2283 static_cast<FwAssertArgType>(deserStatus)
2284 );
2285
2286 // Deserialize command sequence
2287 U32 cmdSeq = 0;
2288 deserStatus = msg.deserialize(cmdSeq);
2289 FW_ASSERT (
2290 deserStatus == Fw::FW_SERIALIZE_OK,
2291 static_cast<FwAssertArgType>(deserStatus)
2292 );
2293
2294 // Deserialize command argument buffer
2295 Fw::CmdArgBuffer args;
2296 deserStatus = msg.deserialize(args);
2297 FW_ASSERT (
2298 deserStatus == Fw::FW_SERIALIZE_OK,
2299 static_cast<FwAssertArgType>(deserStatus)
2300 );
2301
2302 // Reset buffer
2303 args.resetDeser();
2304
2305 // Deserialize argument entry
2306 Fw::CmdStringArg entry;
2307 deserStatus = args.deserialize(entry);
2308 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2309 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2310 this->cmdResponse_out(
2311 opCode,
2312 cmdSeq,
2314 );
2315 }
2316 // Don't crash the task if bad arguments were passed from the ground
2317 break;
2318 }
2319
2320 // Deserialize argument warningValue
2321 U32 warningValue;
2322 deserStatus = args.deserialize(warningValue);
2323 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2324 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2325 this->cmdResponse_out(
2326 opCode,
2327 cmdSeq,
2329 );
2330 }
2331 // Don't crash the task if bad arguments were passed from the ground
2332 break;
2333 }
2334
2335 // Deserialize argument fatalValue
2336 U32 fatalValue;
2337 deserStatus = args.deserialize(fatalValue);
2338 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2339 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2340 this->cmdResponse_out(
2341 opCode,
2342 cmdSeq,
2344 );
2345 }
2346 // Don't crash the task if bad arguments were passed from the ground
2347 break;
2348 }
2349
2350 // Make sure there was no data left over.
2351 // That means the argument buffer size was incorrect.
2352#if FW_CMD_CHECK_RESIDUAL
2353 if (args.getBuffLeft() != 0) {
2354 if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2355 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2356 }
2357 // Don't crash the task if bad arguments were passed from the ground
2358 break;
2359 }
2360#endif
2361
2362 // Call handler function
2363 this->HLTH_CHNG_PING_cmdHandler(
2364 opCode, cmdSeq,
2365 entry,
2366 warningValue,
2367 fatalValue
2368 );
2369
2370 break;
2371 }
2372
2373 default:
2374 return MSG_DISPATCH_ERROR;
2375 }
2376
2377 return MSG_DISPATCH_OK;
2378 }
2379
2380 // ----------------------------------------------------------------------
2381 // Calls for messages received on special input ports
2382 // ----------------------------------------------------------------------
2383
2384 void HealthComponentBase ::
2385 m_p_CmdDisp_in(
2386 Fw::PassiveComponentBase* callComp,
2387 NATIVE_INT_TYPE portNum,
2388 FwOpcodeType opCode,
2389 U32 cmdSeq,
2390 Fw::CmdArgBuffer& args
2391 )
2392 {
2393 FW_ASSERT(callComp);
2394 HealthComponentBase* compPtr = static_cast<HealthComponentBase*>(callComp);
2395
2396 const U32 idBase = callComp->getIdBase();
2397 FW_ASSERT(opCode >= idBase, opCode, idBase);
2398
2399 // Select base class function based on opcode
2400 switch (opCode - idBase) {
2401 case OPCODE_HLTH_ENABLE: {
2403 opCode,
2404 cmdSeq,
2405 args
2406 );
2407 break;
2408 }
2409
2410 case OPCODE_HLTH_PING_ENABLE: {
2412 opCode,
2413 cmdSeq,
2414 args
2415 );
2416 break;
2417 }
2418
2419 case OPCODE_HLTH_CHNG_PING: {
2421 opCode,
2422 cmdSeq,
2423 args
2424 );
2425 break;
2426 }
2427 }
2428 }
2429
2430 // ----------------------------------------------------------------------
2431 // Calls for messages received on typed input ports
2432 // ----------------------------------------------------------------------
2433
2434 void HealthComponentBase ::
2435 m_p_PingReturn_in(
2436 Fw::PassiveComponentBase* callComp,
2437 NATIVE_INT_TYPE portNum,
2438 U32 key
2439 )
2440 {
2441 FW_ASSERT(callComp);
2442 HealthComponentBase* compPtr = static_cast<HealthComponentBase*>(callComp);
2443 compPtr->PingReturn_handlerBase(
2444 portNum,
2445 key
2446 );
2447 }
2448
2449 void HealthComponentBase ::
2450 m_p_Run_in(
2451 Fw::PassiveComponentBase* callComp,
2452 NATIVE_INT_TYPE portNum,
2453 NATIVE_UINT_TYPE context
2454 )
2455 {
2456 FW_ASSERT(callComp);
2457 HealthComponentBase* compPtr = static_cast<HealthComponentBase*>(callComp);
2458 compPtr->Run_handlerBase(
2459 portNum,
2460 context
2461 );
2462 }
2463
2464}
#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.
Enabled and disabled states.
@ SERIALIZED_SIZE
The size of the serial representation.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition CmdPortAc.hpp:37
@ WARNING_HI
A serious but recoverable event.
@ ACTIVITY_HI
Important informational events.
@ FATAL
A fatal non-recoverable event.
@ WARNING_LO
A less serious but recoverable event.
const char * toChar() const override
Definition LogString.cpp:49
SerializeStatus serialize(SerializeBufferBase &buffer) const override
serialization function
Definition LogString.cpp:57
void init()
Object initializer.
Definition ObjBase.cpp:27
@ MSG_DISPATCH_EMPTY
No more messages in the queue.
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
void resetDeser()
reset deserialization to beginning
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
const char * toChar() const
gets char buffer
Definition String.cpp:48
@ QUEUE_NO_MORE_MSGS
If non-blocking, all the messages have been drained.
Definition Queue.hpp:29
@ QUEUE_OK
message sent/received okay
Definition Queue.hpp:28
QueueBlocking
Definition Queue.hpp:40
@ QUEUE_NONBLOCKING
Queue receive always returns even if there is no message.
Definition Queue.hpp:42
Auto-generated base for Health component.
void PingReturn_handlerBase(NATIVE_INT_TYPE portNum, U32 key)
Handler base-class function for input port PingReturn.
void HLTH_PING_ENABLE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
void HLTH_CHNG_PING_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
void HLTH_ENABLE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
@ 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