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