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