F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
BufferLoggerComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title BufferLoggerComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for BufferLogger 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 {
18 BUFFERLOGGER_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19 BUFFERSENDIN_BUFFERSEND,
20 COMIN_COM,
21 PINGIN_PING,
22 SCHEDIN_SCHED,
23 CMD_BL_OPENFILE,
24 CMD_BL_CLOSEFILE,
25 CMD_BL_SETLOGGING,
26 CMD_BL_FLUSHFILE,
27 };
28
29 // Get the max size by constructing a union of the async input, command, and
30 // internal port serialization sizes
31 union BuffUnion {
37 };
38
39 // Define a message buffer class large enough to handle all the
40 // asynchronous inputs to the component
41 class ComponentIpcSerializableBuffer :
43 {
44
45 public:
46
47 enum {
48 // Offset into data in buffer: Size of message ID and port number
49 DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
50 // Max data size
51 MAX_DATA_SIZE = sizeof(BuffUnion),
52 // Max message size: Size of message id + size of port + max data size
53 SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
54 };
55
56 Fw::Serializable::SizeType getBuffCapacity() const {
57 return sizeof(m_buff);
58 }
59
60 U8* getBuffAddr() {
61 return m_buff;
62 }
63
64 const U8* getBuffAddr() const {
65 return m_buff;
66 }
67
68 private:
69 // Should be the max of all the input ports serialized sizes...
70 U8 m_buff[SERIALIZATION_SIZE];
71
72 };
73 }
74
75 // ----------------------------------------------------------------------
76 // Component initialization
77 // ----------------------------------------------------------------------
78
79 void BufferLoggerComponentBase ::
80 init(
81 FwSizeType queueDepth,
82 FwEnumStoreType instance
83 )
84 {
85 // Initialize base class
87
88 // Connect input port cmdIn
89 for (
90 FwIndexType port = 0;
91 port < static_cast<FwIndexType>(this->getNum_cmdIn_InputPorts());
92 port++
93 ) {
94 this->m_cmdIn_InputPort[port].init();
95 this->m_cmdIn_InputPort[port].addCallComp(
96 this,
97 m_p_cmdIn_in
98 );
99 this->m_cmdIn_InputPort[port].setPortNum(port);
100
101#if FW_OBJECT_NAMES == 1
102 Fw::ObjectName portName;
103 portName.format(
104 "%s_cmdIn_InputPort[%" PRI_PlatformIntType "]",
105 this->m_objName.toChar(),
106 port
107 );
108 this->m_cmdIn_InputPort[port].setObjName(portName.toChar());
109#endif
110 }
111
112 // Connect input port bufferSendIn
113 for (
114 FwIndexType port = 0;
115 port < static_cast<FwIndexType>(this->getNum_bufferSendIn_InputPorts());
116 port++
117 ) {
118 this->m_bufferSendIn_InputPort[port].init();
119 this->m_bufferSendIn_InputPort[port].addCallComp(
120 this,
121 m_p_bufferSendIn_in
122 );
123 this->m_bufferSendIn_InputPort[port].setPortNum(port);
124
125#if FW_OBJECT_NAMES == 1
126 Fw::ObjectName portName;
127 portName.format(
128 "%s_bufferSendIn_InputPort[%" PRI_PlatformIntType "]",
129 this->m_objName.toChar(),
130 port
131 );
132 this->m_bufferSendIn_InputPort[port].setObjName(portName.toChar());
133#endif
134 }
135
136 // Connect input port comIn
137 for (
138 FwIndexType port = 0;
139 port < static_cast<FwIndexType>(this->getNum_comIn_InputPorts());
140 port++
141 ) {
142 this->m_comIn_InputPort[port].init();
143 this->m_comIn_InputPort[port].addCallComp(
144 this,
145 m_p_comIn_in
146 );
147 this->m_comIn_InputPort[port].setPortNum(port);
148
149#if FW_OBJECT_NAMES == 1
150 Fw::ObjectName portName;
151 portName.format(
152 "%s_comIn_InputPort[%" PRI_PlatformIntType "]",
153 this->m_objName.toChar(),
154 port
155 );
156 this->m_comIn_InputPort[port].setObjName(portName.toChar());
157#endif
158 }
159
160 // Connect input port pingIn
161 for (
162 FwIndexType port = 0;
163 port < static_cast<FwIndexType>(this->getNum_pingIn_InputPorts());
164 port++
165 ) {
166 this->m_pingIn_InputPort[port].init();
167 this->m_pingIn_InputPort[port].addCallComp(
168 this,
169 m_p_pingIn_in
170 );
171 this->m_pingIn_InputPort[port].setPortNum(port);
172
173#if FW_OBJECT_NAMES == 1
174 Fw::ObjectName portName;
175 portName.format(
176 "%s_pingIn_InputPort[%" PRI_PlatformIntType "]",
177 this->m_objName.toChar(),
178 port
179 );
180 this->m_pingIn_InputPort[port].setObjName(portName.toChar());
181#endif
182 }
183
184 // Connect input port schedIn
185 for (
186 FwIndexType port = 0;
187 port < static_cast<FwIndexType>(this->getNum_schedIn_InputPorts());
188 port++
189 ) {
190 this->m_schedIn_InputPort[port].init();
191 this->m_schedIn_InputPort[port].addCallComp(
192 this,
193 m_p_schedIn_in
194 );
195 this->m_schedIn_InputPort[port].setPortNum(port);
196
197#if FW_OBJECT_NAMES == 1
198 Fw::ObjectName portName;
199 portName.format(
200 "%s_schedIn_InputPort[%" PRI_PlatformIntType "]",
201 this->m_objName.toChar(),
202 port
203 );
204 this->m_schedIn_InputPort[port].setObjName(portName.toChar());
205#endif
206 }
207
208 // Connect output port cmdRegOut
209 for (
210 FwIndexType port = 0;
211 port < static_cast<FwIndexType>(this->getNum_cmdRegOut_OutputPorts());
212 port++
213 ) {
214 this->m_cmdRegOut_OutputPort[port].init();
215
216#if FW_OBJECT_NAMES == 1
217 Fw::ObjectName portName;
218 portName.format(
219 "%s_cmdRegOut_OutputPort[%" PRI_PlatformIntType "]",
220 this->m_objName.toChar(),
221 port
222 );
223 this->m_cmdRegOut_OutputPort[port].setObjName(portName.toChar());
224#endif
225 }
226
227 // Connect output port cmdResponseOut
228 for (
229 FwIndexType port = 0;
230 port < static_cast<FwIndexType>(this->getNum_cmdResponseOut_OutputPorts());
231 port++
232 ) {
233 this->m_cmdResponseOut_OutputPort[port].init();
234
235#if FW_OBJECT_NAMES == 1
236 Fw::ObjectName portName;
237 portName.format(
238 "%s_cmdResponseOut_OutputPort[%" PRI_PlatformIntType "]",
239 this->m_objName.toChar(),
240 port
241 );
242 this->m_cmdResponseOut_OutputPort[port].setObjName(portName.toChar());
243#endif
244 }
245
246 // Connect output port eventOut
247 for (
248 FwIndexType port = 0;
249 port < static_cast<FwIndexType>(this->getNum_eventOut_OutputPorts());
250 port++
251 ) {
252 this->m_eventOut_OutputPort[port].init();
253
254#if FW_OBJECT_NAMES == 1
255 Fw::ObjectName portName;
256 portName.format(
257 "%s_eventOut_OutputPort[%" PRI_PlatformIntType "]",
258 this->m_objName.toChar(),
259 port
260 );
261 this->m_eventOut_OutputPort[port].setObjName(portName.toChar());
262#endif
263 }
264
265#if FW_ENABLE_TEXT_LOGGING == 1
266 // Connect output port eventOutText
267 for (
268 FwIndexType port = 0;
269 port < static_cast<FwIndexType>(this->getNum_eventOutText_OutputPorts());
270 port++
271 ) {
272 this->m_eventOutText_OutputPort[port].init();
273
274#if FW_OBJECT_NAMES == 1
275 Fw::ObjectName portName;
276 portName.format(
277 "%s_eventOutText_OutputPort[%" PRI_PlatformIntType "]",
278 this->m_objName.toChar(),
279 port
280 );
281 this->m_eventOutText_OutputPort[port].setObjName(portName.toChar());
282#endif
283 }
284#endif
285
286 // Connect output port timeCaller
287 for (
288 FwIndexType port = 0;
289 port < static_cast<FwIndexType>(this->getNum_timeCaller_OutputPorts());
290 port++
291 ) {
292 this->m_timeCaller_OutputPort[port].init();
293
294#if FW_OBJECT_NAMES == 1
295 Fw::ObjectName portName;
296 portName.format(
297 "%s_timeCaller_OutputPort[%" PRI_PlatformIntType "]",
298 this->m_objName.toChar(),
299 port
300 );
301 this->m_timeCaller_OutputPort[port].setObjName(portName.toChar());
302#endif
303 }
304
305 // Connect output port tlmOut
306 for (
307 FwIndexType port = 0;
308 port < static_cast<FwIndexType>(this->getNum_tlmOut_OutputPorts());
309 port++
310 ) {
311 this->m_tlmOut_OutputPort[port].init();
312
313#if FW_OBJECT_NAMES == 1
314 Fw::ObjectName portName;
315 portName.format(
316 "%s_tlmOut_OutputPort[%" PRI_PlatformIntType "]",
317 this->m_objName.toChar(),
318 port
319 );
320 this->m_tlmOut_OutputPort[port].setObjName(portName.toChar());
321#endif
322 }
323
324 // Connect output port bufferSendOut
325 for (
326 FwIndexType port = 0;
327 port < static_cast<FwIndexType>(this->getNum_bufferSendOut_OutputPorts());
328 port++
329 ) {
330 this->m_bufferSendOut_OutputPort[port].init();
331
332#if FW_OBJECT_NAMES == 1
333 Fw::ObjectName portName;
334 portName.format(
335 "%s_bufferSendOut_OutputPort[%" PRI_PlatformIntType "]",
336 this->m_objName.toChar(),
337 port
338 );
339 this->m_bufferSendOut_OutputPort[port].setObjName(portName.toChar());
340#endif
341 }
342
343 // Connect output port pingOut
344 for (
345 FwIndexType port = 0;
346 port < static_cast<FwIndexType>(this->getNum_pingOut_OutputPorts());
347 port++
348 ) {
349 this->m_pingOut_OutputPort[port].init();
350
351#if FW_OBJECT_NAMES == 1
352 Fw::ObjectName portName;
353 portName.format(
354 "%s_pingOut_OutputPort[%" PRI_PlatformIntType "]",
355 this->m_objName.toChar(),
356 port
357 );
358 this->m_pingOut_OutputPort[port].setObjName(portName.toChar());
359#endif
360 }
361
362 // Create the queue
363 Os::Queue::Status qStat = this->createQueue(
364 queueDepth,
365 static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
366 );
367 FW_ASSERT(
369 static_cast<FwAssertArgType>(qStat)
370 );
371 }
372
373 // ----------------------------------------------------------------------
374 // Getters for special input ports
375 // ----------------------------------------------------------------------
376
377 Fw::InputCmdPort* BufferLoggerComponentBase ::
378 get_cmdIn_InputPort(FwIndexType portNum)
379 {
380 FW_ASSERT(
381 portNum < this->getNum_cmdIn_InputPorts(),
382 static_cast<FwAssertArgType>(portNum)
383 );
384
385 return &this->m_cmdIn_InputPort[portNum];
386 }
387
388 // ----------------------------------------------------------------------
389 // Getters for typed input ports
390 // ----------------------------------------------------------------------
391
392 Fw::InputBufferSendPort* BufferLoggerComponentBase ::
393 get_bufferSendIn_InputPort(FwIndexType portNum)
394 {
395 FW_ASSERT(
396 portNum < this->getNum_bufferSendIn_InputPorts(),
397 static_cast<FwAssertArgType>(portNum)
398 );
399
400 return &this->m_bufferSendIn_InputPort[portNum];
401 }
402
403 Fw::InputComPort* BufferLoggerComponentBase ::
404 get_comIn_InputPort(FwIndexType portNum)
405 {
406 FW_ASSERT(
407 portNum < this->getNum_comIn_InputPorts(),
408 static_cast<FwAssertArgType>(portNum)
409 );
410
411 return &this->m_comIn_InputPort[portNum];
412 }
413
414 Svc::InputPingPort* BufferLoggerComponentBase ::
415 get_pingIn_InputPort(FwIndexType portNum)
416 {
417 FW_ASSERT(
418 portNum < this->getNum_pingIn_InputPorts(),
419 static_cast<FwAssertArgType>(portNum)
420 );
421
422 return &this->m_pingIn_InputPort[portNum];
423 }
424
425 Svc::InputSchedPort* BufferLoggerComponentBase ::
426 get_schedIn_InputPort(FwIndexType portNum)
427 {
428 FW_ASSERT(
429 portNum < this->getNum_schedIn_InputPorts(),
430 static_cast<FwAssertArgType>(portNum)
431 );
432
433 return &this->m_schedIn_InputPort[portNum];
434 }
435
436 // ----------------------------------------------------------------------
437 // Connect input ports to special output ports
438 // ----------------------------------------------------------------------
439
440 void BufferLoggerComponentBase ::
441 set_cmdRegOut_OutputPort(
442 FwIndexType portNum,
444 )
445 {
446 FW_ASSERT(
447 portNum < this->getNum_cmdRegOut_OutputPorts(),
448 static_cast<FwAssertArgType>(portNum)
449 );
450
451 this->m_cmdRegOut_OutputPort[portNum].addCallPort(port);
452 }
453
454 void BufferLoggerComponentBase ::
455 set_cmdResponseOut_OutputPort(
456 FwIndexType portNum,
458 )
459 {
460 FW_ASSERT(
461 portNum < this->getNum_cmdResponseOut_OutputPorts(),
462 static_cast<FwAssertArgType>(portNum)
463 );
464
465 this->m_cmdResponseOut_OutputPort[portNum].addCallPort(port);
466 }
467
468 void BufferLoggerComponentBase ::
469 set_eventOut_OutputPort(
470 FwIndexType portNum,
471 Fw::InputLogPort* port
472 )
473 {
474 FW_ASSERT(
475 portNum < this->getNum_eventOut_OutputPorts(),
476 static_cast<FwAssertArgType>(portNum)
477 );
478
479 this->m_eventOut_OutputPort[portNum].addCallPort(port);
480 }
481
482#if FW_ENABLE_TEXT_LOGGING == 1
483
484 void BufferLoggerComponentBase ::
485 set_eventOutText_OutputPort(
486 FwIndexType portNum,
488 )
489 {
490 FW_ASSERT(
491 portNum < this->getNum_eventOutText_OutputPorts(),
492 static_cast<FwAssertArgType>(portNum)
493 );
494
495 this->m_eventOutText_OutputPort[portNum].addCallPort(port);
496 }
497
498#endif
499
500 void BufferLoggerComponentBase ::
501 set_timeCaller_OutputPort(
502 FwIndexType portNum,
504 )
505 {
506 FW_ASSERT(
507 portNum < this->getNum_timeCaller_OutputPorts(),
508 static_cast<FwAssertArgType>(portNum)
509 );
510
511 this->m_timeCaller_OutputPort[portNum].addCallPort(port);
512 }
513
514 void BufferLoggerComponentBase ::
515 set_tlmOut_OutputPort(
516 FwIndexType portNum,
517 Fw::InputTlmPort* port
518 )
519 {
520 FW_ASSERT(
521 portNum < this->getNum_tlmOut_OutputPorts(),
522 static_cast<FwAssertArgType>(portNum)
523 );
524
525 this->m_tlmOut_OutputPort[portNum].addCallPort(port);
526 }
527
528 // ----------------------------------------------------------------------
529 // Connect typed input ports to typed output ports
530 // ----------------------------------------------------------------------
531
532 void BufferLoggerComponentBase ::
533 set_bufferSendOut_OutputPort(
534 FwIndexType portNum,
536 )
537 {
538 FW_ASSERT(
539 portNum < this->getNum_bufferSendOut_OutputPorts(),
540 static_cast<FwAssertArgType>(portNum)
541 );
542
543 this->m_bufferSendOut_OutputPort[portNum].addCallPort(port);
544 }
545
546 void BufferLoggerComponentBase ::
547 set_pingOut_OutputPort(
548 FwIndexType portNum,
550 )
551 {
552 FW_ASSERT(
553 portNum < this->getNum_pingOut_OutputPorts(),
554 static_cast<FwAssertArgType>(portNum)
555 );
556
557 this->m_pingOut_OutputPort[portNum].addCallPort(port);
558 }
559
560#if FW_PORT_SERIALIZATION
561
562 // ----------------------------------------------------------------------
563 // Connect serial input ports to special output ports
564 // ----------------------------------------------------------------------
565
566 void BufferLoggerComponentBase ::
567 set_cmdRegOut_OutputPort(
568 FwIndexType portNum,
569 Fw::InputSerializePort* port
570 )
571 {
572 FW_ASSERT(
573 portNum < this->getNum_cmdRegOut_OutputPorts(),
574 static_cast<FwAssertArgType>(portNum)
575 );
576
577 this->m_cmdRegOut_OutputPort[portNum].registerSerialPort(port);
578 }
579
580 void BufferLoggerComponentBase ::
581 set_cmdResponseOut_OutputPort(
582 FwIndexType portNum,
583 Fw::InputSerializePort* port
584 )
585 {
586 FW_ASSERT(
587 portNum < this->getNum_cmdResponseOut_OutputPorts(),
588 static_cast<FwAssertArgType>(portNum)
589 );
590
591 this->m_cmdResponseOut_OutputPort[portNum].registerSerialPort(port);
592 }
593
594 void BufferLoggerComponentBase ::
595 set_eventOut_OutputPort(
596 FwIndexType portNum,
597 Fw::InputSerializePort* port
598 )
599 {
600 FW_ASSERT(
601 portNum < this->getNum_eventOut_OutputPorts(),
602 static_cast<FwAssertArgType>(portNum)
603 );
604
605 this->m_eventOut_OutputPort[portNum].registerSerialPort(port);
606 }
607
608#if FW_ENABLE_TEXT_LOGGING == 1
609
610 void BufferLoggerComponentBase ::
611 set_eventOutText_OutputPort(
612 FwIndexType portNum,
613 Fw::InputSerializePort* port
614 )
615 {
616 FW_ASSERT(
617 portNum < this->getNum_eventOutText_OutputPorts(),
618 static_cast<FwAssertArgType>(portNum)
619 );
620
621 this->m_eventOutText_OutputPort[portNum].registerSerialPort(port);
622 }
623
624#endif
625
626 void BufferLoggerComponentBase ::
627 set_timeCaller_OutputPort(
628 FwIndexType portNum,
629 Fw::InputSerializePort* port
630 )
631 {
632 FW_ASSERT(
633 portNum < this->getNum_timeCaller_OutputPorts(),
634 static_cast<FwAssertArgType>(portNum)
635 );
636
637 this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
638 }
639
640 void BufferLoggerComponentBase ::
641 set_tlmOut_OutputPort(
642 FwIndexType portNum,
643 Fw::InputSerializePort* port
644 )
645 {
646 FW_ASSERT(
647 portNum < this->getNum_tlmOut_OutputPorts(),
648 static_cast<FwAssertArgType>(portNum)
649 );
650
651 this->m_tlmOut_OutputPort[portNum].registerSerialPort(port);
652 }
653
654#endif
655
656#if FW_PORT_SERIALIZATION
657
658 // ----------------------------------------------------------------------
659 // Connect serial input ports to typed output ports
660 // ----------------------------------------------------------------------
661
662 void BufferLoggerComponentBase ::
663 set_bufferSendOut_OutputPort(
664 FwIndexType portNum,
665 Fw::InputSerializePort* port
666 )
667 {
668 FW_ASSERT(
669 portNum < this->getNum_bufferSendOut_OutputPorts(),
670 static_cast<FwAssertArgType>(portNum)
671 );
672
673 this->m_bufferSendOut_OutputPort[portNum].registerSerialPort(port);
674 }
675
676 void BufferLoggerComponentBase ::
677 set_pingOut_OutputPort(
678 FwIndexType portNum,
679 Fw::InputSerializePort* port
680 )
681 {
682 FW_ASSERT(
683 portNum < this->getNum_pingOut_OutputPorts(),
684 static_cast<FwAssertArgType>(portNum)
685 );
686
687 this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
688 }
689
690#endif
691
692 // ----------------------------------------------------------------------
693 // Command registration
694 // ----------------------------------------------------------------------
695
696 void BufferLoggerComponentBase ::
697 regCommands()
698 {
699 FW_ASSERT(this->m_cmdRegOut_OutputPort[0].isConnected());
700
701 this->m_cmdRegOut_OutputPort[0].invoke(
702 this->getIdBase() + OPCODE_BL_OPENFILE
703 );
704
705 this->m_cmdRegOut_OutputPort[0].invoke(
706 this->getIdBase() + OPCODE_BL_CLOSEFILE
707 );
708
709 this->m_cmdRegOut_OutputPort[0].invoke(
710 this->getIdBase() + OPCODE_BL_SETLOGGING
711 );
712
713 this->m_cmdRegOut_OutputPort[0].invoke(
714 this->getIdBase() + OPCODE_BL_FLUSHFILE
715 );
716 }
717
718 // ----------------------------------------------------------------------
719 // Component construction and destruction
720 // ----------------------------------------------------------------------
721
722 BufferLoggerComponentBase ::
723 BufferLoggerComponentBase(const char* compName) :
724 Fw::ActiveComponentBase(compName)
725 {
726
727 }
728
729 BufferLoggerComponentBase ::
730 ~BufferLoggerComponentBase()
731 {
732
733 }
734
735 // ----------------------------------------------------------------------
736 // Getters for numbers of special input ports
737 // ----------------------------------------------------------------------
738
739 FwIndexType BufferLoggerComponentBase ::
740 getNum_cmdIn_InputPorts() const
741 {
742 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdIn_InputPort));
743 }
744
745 // ----------------------------------------------------------------------
746 // Getters for numbers of typed input ports
747 // ----------------------------------------------------------------------
748
749 FwIndexType BufferLoggerComponentBase ::
750 getNum_bufferSendIn_InputPorts() const
751 {
752 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferSendIn_InputPort));
753 }
754
755 FwIndexType BufferLoggerComponentBase ::
756 getNum_comIn_InputPorts() const
757 {
758 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_comIn_InputPort));
759 }
760
761 FwIndexType BufferLoggerComponentBase ::
762 getNum_pingIn_InputPorts() const
763 {
764 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_pingIn_InputPort));
765 }
766
767 FwIndexType BufferLoggerComponentBase ::
768 getNum_schedIn_InputPorts() const
769 {
770 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_schedIn_InputPort));
771 }
772
773 // ----------------------------------------------------------------------
774 // Getters for numbers of special output ports
775 // ----------------------------------------------------------------------
776
777 FwIndexType BufferLoggerComponentBase ::
778 getNum_cmdRegOut_OutputPorts() const
779 {
780 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdRegOut_OutputPort));
781 }
782
783 FwIndexType BufferLoggerComponentBase ::
784 getNum_cmdResponseOut_OutputPorts() const
785 {
786 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdResponseOut_OutputPort));
787 }
788
789 FwIndexType BufferLoggerComponentBase ::
790 getNum_eventOut_OutputPorts() const
791 {
792 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_eventOut_OutputPort));
793 }
794
795#if FW_ENABLE_TEXT_LOGGING == 1
796
797 FwIndexType BufferLoggerComponentBase ::
798 getNum_eventOutText_OutputPorts() const
799 {
800 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_eventOutText_OutputPort));
801 }
802
803#endif
804
805 FwIndexType BufferLoggerComponentBase ::
806 getNum_timeCaller_OutputPorts() const
807 {
808 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_timeCaller_OutputPort));
809 }
810
811 FwIndexType BufferLoggerComponentBase ::
812 getNum_tlmOut_OutputPorts() const
813 {
814 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_tlmOut_OutputPort));
815 }
816
817 // ----------------------------------------------------------------------
818 // Getters for numbers of typed output ports
819 // ----------------------------------------------------------------------
820
821 FwIndexType BufferLoggerComponentBase ::
822 getNum_bufferSendOut_OutputPorts() const
823 {
824 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferSendOut_OutputPort));
825 }
826
827 FwIndexType BufferLoggerComponentBase ::
828 getNum_pingOut_OutputPorts() const
829 {
830 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_pingOut_OutputPort));
831 }
832
833 // ----------------------------------------------------------------------
834 // Connection status queries for special output ports
835 // ----------------------------------------------------------------------
836
837 bool BufferLoggerComponentBase ::
838 isConnected_cmdRegOut_OutputPort(FwIndexType portNum)
839 {
840 FW_ASSERT(
841 portNum < this->getNum_cmdRegOut_OutputPorts(),
842 static_cast<FwAssertArgType>(portNum)
843 );
844
845 return this->m_cmdRegOut_OutputPort[portNum].isConnected();
846 }
847
848 bool BufferLoggerComponentBase ::
849 isConnected_cmdResponseOut_OutputPort(FwIndexType portNum)
850 {
851 FW_ASSERT(
852 portNum < this->getNum_cmdResponseOut_OutputPorts(),
853 static_cast<FwAssertArgType>(portNum)
854 );
855
856 return this->m_cmdResponseOut_OutputPort[portNum].isConnected();
857 }
858
859 bool BufferLoggerComponentBase ::
860 isConnected_eventOut_OutputPort(FwIndexType portNum)
861 {
862 FW_ASSERT(
863 portNum < this->getNum_eventOut_OutputPorts(),
864 static_cast<FwAssertArgType>(portNum)
865 );
866
867 return this->m_eventOut_OutputPort[portNum].isConnected();
868 }
869
870#if FW_ENABLE_TEXT_LOGGING == 1
871
872 bool BufferLoggerComponentBase ::
873 isConnected_eventOutText_OutputPort(FwIndexType portNum)
874 {
875 FW_ASSERT(
876 portNum < this->getNum_eventOutText_OutputPorts(),
877 static_cast<FwAssertArgType>(portNum)
878 );
879
880 return this->m_eventOutText_OutputPort[portNum].isConnected();
881 }
882
883#endif
884
885 bool BufferLoggerComponentBase ::
886 isConnected_timeCaller_OutputPort(FwIndexType portNum)
887 {
888 FW_ASSERT(
889 portNum < this->getNum_timeCaller_OutputPorts(),
890 static_cast<FwAssertArgType>(portNum)
891 );
892
893 return this->m_timeCaller_OutputPort[portNum].isConnected();
894 }
895
896 bool BufferLoggerComponentBase ::
897 isConnected_tlmOut_OutputPort(FwIndexType portNum)
898 {
899 FW_ASSERT(
900 portNum < this->getNum_tlmOut_OutputPorts(),
901 static_cast<FwAssertArgType>(portNum)
902 );
903
904 return this->m_tlmOut_OutputPort[portNum].isConnected();
905 }
906
907 // ----------------------------------------------------------------------
908 // Connection status queries for typed output ports
909 // ----------------------------------------------------------------------
910
911 bool BufferLoggerComponentBase ::
912 isConnected_bufferSendOut_OutputPort(FwIndexType portNum)
913 {
914 FW_ASSERT(
915 portNum < this->getNum_bufferSendOut_OutputPorts(),
916 static_cast<FwAssertArgType>(portNum)
917 );
918
919 return this->m_bufferSendOut_OutputPort[portNum].isConnected();
920 }
921
922 bool BufferLoggerComponentBase ::
923 isConnected_pingOut_OutputPort(FwIndexType portNum)
924 {
925 FW_ASSERT(
926 portNum < this->getNum_pingOut_OutputPorts(),
927 static_cast<FwAssertArgType>(portNum)
928 );
929
930 return this->m_pingOut_OutputPort[portNum].isConnected();
931 }
932
933 // ----------------------------------------------------------------------
934 // Port handler base-class functions for typed input ports
935 //
936 // Call these functions directly to bypass the corresponding ports
937 // ----------------------------------------------------------------------
938
939 void BufferLoggerComponentBase ::
940 bufferSendIn_handlerBase(
941 FwIndexType portNum,
942 Fw::Buffer& fwBuffer
943 )
944 {
945 // Make sure port number is valid
946 FW_ASSERT(
947 portNum < this->getNum_bufferSendIn_InputPorts(),
948 static_cast<FwAssertArgType>(portNum)
949 );
950
951 // Call pre-message hook
952 bufferSendIn_preMsgHook(
953 portNum,
954 fwBuffer
955 );
956 ComponentIpcSerializableBuffer msg;
958
959 // Serialize message ID
960 _status = msg.serialize(
961 static_cast<FwEnumStoreType>(BUFFERSENDIN_BUFFERSEND)
962 );
963 FW_ASSERT(
964 _status == Fw::FW_SERIALIZE_OK,
965 static_cast<FwAssertArgType>(_status)
966 );
967
968 // Serialize port number
969 _status = msg.serialize(portNum);
970 FW_ASSERT(
971 _status == Fw::FW_SERIALIZE_OK,
972 static_cast<FwAssertArgType>(_status)
973 );
974
975 // Serialize argument fwBuffer
976 _status = msg.serialize(fwBuffer);
977 FW_ASSERT(
978 _status == Fw::FW_SERIALIZE_OK,
979 static_cast<FwAssertArgType>(_status)
980 );
981
982 // Send message
984 Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
985
986 FW_ASSERT(
987 qStatus == Os::Queue::OP_OK,
988 static_cast<FwAssertArgType>(qStatus)
989 );
990 }
991
992 void BufferLoggerComponentBase ::
993 comIn_handlerBase(
994 FwIndexType portNum,
995 Fw::ComBuffer& data,
996 U32 context
997 )
998 {
999 // Make sure port number is valid
1000 FW_ASSERT(
1001 portNum < this->getNum_comIn_InputPorts(),
1002 static_cast<FwAssertArgType>(portNum)
1003 );
1004
1005 // Call pre-message hook
1006 comIn_preMsgHook(
1007 portNum,
1008 data,
1009 context
1010 );
1011 ComponentIpcSerializableBuffer msg;
1013
1014 // Serialize message ID
1015 _status = msg.serialize(
1016 static_cast<FwEnumStoreType>(COMIN_COM)
1017 );
1018 FW_ASSERT(
1019 _status == Fw::FW_SERIALIZE_OK,
1020 static_cast<FwAssertArgType>(_status)
1021 );
1022
1023 // Serialize port number
1024 _status = msg.serialize(portNum);
1025 FW_ASSERT(
1026 _status == Fw::FW_SERIALIZE_OK,
1027 static_cast<FwAssertArgType>(_status)
1028 );
1029
1030 // Serialize argument data
1031 _status = msg.serialize(data);
1032 FW_ASSERT(
1033 _status == Fw::FW_SERIALIZE_OK,
1034 static_cast<FwAssertArgType>(_status)
1035 );
1036
1037 // Serialize argument context
1038 _status = msg.serialize(context);
1039 FW_ASSERT(
1040 _status == Fw::FW_SERIALIZE_OK,
1041 static_cast<FwAssertArgType>(_status)
1042 );
1043
1044 // Send message
1046 Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1047
1048 FW_ASSERT(
1049 qStatus == Os::Queue::OP_OK,
1050 static_cast<FwAssertArgType>(qStatus)
1051 );
1052 }
1053
1054 void BufferLoggerComponentBase ::
1055 pingIn_handlerBase(
1056 FwIndexType portNum,
1057 U32 key
1058 )
1059 {
1060 // Make sure port number is valid
1061 FW_ASSERT(
1062 portNum < this->getNum_pingIn_InputPorts(),
1063 static_cast<FwAssertArgType>(portNum)
1064 );
1065
1066 // Call pre-message hook
1067 pingIn_preMsgHook(
1068 portNum,
1069 key
1070 );
1071 ComponentIpcSerializableBuffer msg;
1073
1074 // Serialize message ID
1075 _status = msg.serialize(
1076 static_cast<FwEnumStoreType>(PINGIN_PING)
1077 );
1078 FW_ASSERT(
1079 _status == Fw::FW_SERIALIZE_OK,
1080 static_cast<FwAssertArgType>(_status)
1081 );
1082
1083 // Serialize port number
1084 _status = msg.serialize(portNum);
1085 FW_ASSERT(
1086 _status == Fw::FW_SERIALIZE_OK,
1087 static_cast<FwAssertArgType>(_status)
1088 );
1089
1090 // Serialize argument key
1091 _status = msg.serialize(key);
1092 FW_ASSERT(
1093 _status == Fw::FW_SERIALIZE_OK,
1094 static_cast<FwAssertArgType>(_status)
1095 );
1096
1097 // Send message
1099 Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1100
1101 FW_ASSERT(
1102 qStatus == Os::Queue::OP_OK,
1103 static_cast<FwAssertArgType>(qStatus)
1104 );
1105 }
1106
1107 void BufferLoggerComponentBase ::
1108 schedIn_handlerBase(
1109 FwIndexType portNum,
1110 U32 context
1111 )
1112 {
1113 // Make sure port number is valid
1114 FW_ASSERT(
1115 portNum < this->getNum_schedIn_InputPorts(),
1116 static_cast<FwAssertArgType>(portNum)
1117 );
1118
1119 // Call pre-message hook
1120 schedIn_preMsgHook(
1121 portNum,
1122 context
1123 );
1124 ComponentIpcSerializableBuffer msg;
1126
1127 // Serialize message ID
1128 _status = msg.serialize(
1129 static_cast<FwEnumStoreType>(SCHEDIN_SCHED)
1130 );
1131 FW_ASSERT(
1132 _status == Fw::FW_SERIALIZE_OK,
1133 static_cast<FwAssertArgType>(_status)
1134 );
1135
1136 // Serialize port number
1137 _status = msg.serialize(portNum);
1138 FW_ASSERT(
1139 _status == Fw::FW_SERIALIZE_OK,
1140 static_cast<FwAssertArgType>(_status)
1141 );
1142
1143 // Serialize argument context
1144 _status = msg.serialize(context);
1145 FW_ASSERT(
1146 _status == Fw::FW_SERIALIZE_OK,
1147 static_cast<FwAssertArgType>(_status)
1148 );
1149
1150 // Send message
1152 Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1153
1154 FW_ASSERT(
1155 qStatus == Os::Queue::OP_OK,
1156 static_cast<FwAssertArgType>(qStatus)
1157 );
1158 }
1159
1160 // ----------------------------------------------------------------------
1161 // Pre-message hooks for typed async input ports
1162 //
1163 // Each of these functions is invoked just before processing a message
1164 // on the corresponding port. By default, they do nothing. You can
1165 // override them to provide specific pre-message behavior.
1166 // ----------------------------------------------------------------------
1167
1168 void BufferLoggerComponentBase ::
1169 bufferSendIn_preMsgHook(
1170 FwIndexType portNum,
1171 Fw::Buffer& fwBuffer
1172 )
1173 {
1174 // Default: no-op
1175 }
1176
1177 void BufferLoggerComponentBase ::
1178 comIn_preMsgHook(
1179 FwIndexType portNum,
1180 Fw::ComBuffer& data,
1181 U32 context
1182 )
1183 {
1184 // Default: no-op
1185 }
1186
1187 void BufferLoggerComponentBase ::
1188 pingIn_preMsgHook(
1189 FwIndexType portNum,
1190 U32 key
1191 )
1192 {
1193 // Default: no-op
1194 }
1195
1196 void BufferLoggerComponentBase ::
1197 schedIn_preMsgHook(
1198 FwIndexType portNum,
1199 U32 context
1200 )
1201 {
1202 // Default: no-op
1203 }
1204
1205 // ----------------------------------------------------------------------
1206 // Invocation functions for typed output ports
1207 // ----------------------------------------------------------------------
1208
1209 void BufferLoggerComponentBase ::
1210 bufferSendOut_out(
1211 FwIndexType portNum,
1212 Fw::Buffer& fwBuffer
1213 )
1214 {
1215 FW_ASSERT(
1216 portNum < this->getNum_bufferSendOut_OutputPorts(),
1217 static_cast<FwAssertArgType>(portNum)
1218 );
1219 this->m_bufferSendOut_OutputPort[portNum].invoke(
1220 fwBuffer
1221 );
1222 }
1223
1224 void BufferLoggerComponentBase ::
1225 pingOut_out(
1226 FwIndexType portNum,
1227 U32 key
1228 )
1229 {
1230 FW_ASSERT(
1231 portNum < this->getNum_pingOut_OutputPorts(),
1232 static_cast<FwAssertArgType>(portNum)
1233 );
1234 this->m_pingOut_OutputPort[portNum].invoke(
1235 key
1236 );
1237 }
1238
1239 // ----------------------------------------------------------------------
1240 // Command response
1241 // ----------------------------------------------------------------------
1242
1243 void BufferLoggerComponentBase ::
1244 cmdResponse_out(
1245 FwOpcodeType opCode,
1246 U32 cmdSeq,
1247 Fw::CmdResponse response
1248 )
1249 {
1250 FW_ASSERT(this->m_cmdResponseOut_OutputPort[0].isConnected());
1251 this->m_cmdResponseOut_OutputPort[0].invoke(opCode, cmdSeq, response);
1252 }
1253
1254 // ----------------------------------------------------------------------
1255 // Command handler base-class functions
1256 //
1257 // Call these functions directly to bypass the command input port
1258 // ----------------------------------------------------------------------
1259
1260 void BufferLoggerComponentBase ::
1261 BL_OpenFile_cmdHandlerBase(
1262 FwOpcodeType opCode,
1263 U32 cmdSeq,
1264 Fw::CmdArgBuffer& args
1265 )
1266 {
1267 // Call pre-message hook
1268 this->BL_OpenFile_preMsgHook(opCode,cmdSeq);
1269
1270 // Defer deserializing arguments to the message dispatcher
1271 // to avoid deserializing and reserializing just for IPC
1272 ComponentIpcSerializableBuffer msg;
1274
1275 // Serialize for IPC
1276 _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_BL_OPENFILE));
1277 FW_ASSERT (
1278 _status == Fw::FW_SERIALIZE_OK,
1279 static_cast<FwAssertArgType>(_status)
1280 );
1281
1282 // Fake port number to make message dequeue work
1283 FwIndexType port = 0;
1284
1285 _status = msg.serialize(port);
1286 FW_ASSERT (
1287 _status == Fw::FW_SERIALIZE_OK,
1288 static_cast<FwAssertArgType>(_status)
1289 );
1290
1291 _status = msg.serialize(opCode);
1292 FW_ASSERT (
1293 _status == Fw::FW_SERIALIZE_OK,
1294 static_cast<FwAssertArgType>(_status)
1295 );
1296
1297 _status = msg.serialize(cmdSeq);
1298 FW_ASSERT (
1299 _status == Fw::FW_SERIALIZE_OK,
1300 static_cast<FwAssertArgType>(_status)
1301 );
1302
1303 _status = msg.serialize(args);
1304 FW_ASSERT (
1305 _status == Fw::FW_SERIALIZE_OK,
1306 static_cast<FwAssertArgType>(_status)
1307 );
1308
1309 // Send message
1311 Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1312
1313 FW_ASSERT(
1314 qStatus == Os::Queue::OP_OK,
1315 static_cast<FwAssertArgType>(qStatus)
1316 );
1317 }
1318
1319 void BufferLoggerComponentBase ::
1320 BL_CloseFile_cmdHandlerBase(
1321 FwOpcodeType opCode,
1322 U32 cmdSeq,
1323 Fw::CmdArgBuffer& args
1324 )
1325 {
1326 // Call pre-message hook
1327 this->BL_CloseFile_preMsgHook(opCode,cmdSeq);
1328
1329 // Defer deserializing arguments to the message dispatcher
1330 // to avoid deserializing and reserializing just for IPC
1331 ComponentIpcSerializableBuffer msg;
1333
1334 // Serialize for IPC
1335 _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_BL_CLOSEFILE));
1336 FW_ASSERT (
1337 _status == Fw::FW_SERIALIZE_OK,
1338 static_cast<FwAssertArgType>(_status)
1339 );
1340
1341 // Fake port number to make message dequeue work
1342 FwIndexType port = 0;
1343
1344 _status = msg.serialize(port);
1345 FW_ASSERT (
1346 _status == Fw::FW_SERIALIZE_OK,
1347 static_cast<FwAssertArgType>(_status)
1348 );
1349
1350 _status = msg.serialize(opCode);
1351 FW_ASSERT (
1352 _status == Fw::FW_SERIALIZE_OK,
1353 static_cast<FwAssertArgType>(_status)
1354 );
1355
1356 _status = msg.serialize(cmdSeq);
1357 FW_ASSERT (
1358 _status == Fw::FW_SERIALIZE_OK,
1359 static_cast<FwAssertArgType>(_status)
1360 );
1361
1362 _status = msg.serialize(args);
1363 FW_ASSERT (
1364 _status == Fw::FW_SERIALIZE_OK,
1365 static_cast<FwAssertArgType>(_status)
1366 );
1367
1368 // Send message
1370 Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1371
1372 FW_ASSERT(
1373 qStatus == Os::Queue::OP_OK,
1374 static_cast<FwAssertArgType>(qStatus)
1375 );
1376 }
1377
1378 void BufferLoggerComponentBase ::
1379 BL_SetLogging_cmdHandlerBase(
1380 FwOpcodeType opCode,
1381 U32 cmdSeq,
1382 Fw::CmdArgBuffer& args
1383 )
1384 {
1385 // Call pre-message hook
1386 this->BL_SetLogging_preMsgHook(opCode,cmdSeq);
1387
1388 // Defer deserializing arguments to the message dispatcher
1389 // to avoid deserializing and reserializing just for IPC
1390 ComponentIpcSerializableBuffer msg;
1392
1393 // Serialize for IPC
1394 _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_BL_SETLOGGING));
1395 FW_ASSERT (
1396 _status == Fw::FW_SERIALIZE_OK,
1397 static_cast<FwAssertArgType>(_status)
1398 );
1399
1400 // Fake port number to make message dequeue work
1401 FwIndexType port = 0;
1402
1403 _status = msg.serialize(port);
1404 FW_ASSERT (
1405 _status == Fw::FW_SERIALIZE_OK,
1406 static_cast<FwAssertArgType>(_status)
1407 );
1408
1409 _status = msg.serialize(opCode);
1410 FW_ASSERT (
1411 _status == Fw::FW_SERIALIZE_OK,
1412 static_cast<FwAssertArgType>(_status)
1413 );
1414
1415 _status = msg.serialize(cmdSeq);
1416 FW_ASSERT (
1417 _status == Fw::FW_SERIALIZE_OK,
1418 static_cast<FwAssertArgType>(_status)
1419 );
1420
1421 _status = msg.serialize(args);
1422 FW_ASSERT (
1423 _status == Fw::FW_SERIALIZE_OK,
1424 static_cast<FwAssertArgType>(_status)
1425 );
1426
1427 // Send message
1429 Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1430
1431 FW_ASSERT(
1432 qStatus == Os::Queue::OP_OK,
1433 static_cast<FwAssertArgType>(qStatus)
1434 );
1435 }
1436
1437 void BufferLoggerComponentBase ::
1438 BL_FlushFile_cmdHandlerBase(
1439 FwOpcodeType opCode,
1440 U32 cmdSeq,
1441 Fw::CmdArgBuffer& args
1442 )
1443 {
1444 // Call pre-message hook
1445 this->BL_FlushFile_preMsgHook(opCode,cmdSeq);
1446
1447 // Defer deserializing arguments to the message dispatcher
1448 // to avoid deserializing and reserializing just for IPC
1449 ComponentIpcSerializableBuffer msg;
1451
1452 // Serialize for IPC
1453 _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_BL_FLUSHFILE));
1454 FW_ASSERT (
1455 _status == Fw::FW_SERIALIZE_OK,
1456 static_cast<FwAssertArgType>(_status)
1457 );
1458
1459 // Fake port number to make message dequeue work
1460 FwIndexType port = 0;
1461
1462 _status = msg.serialize(port);
1463 FW_ASSERT (
1464 _status == Fw::FW_SERIALIZE_OK,
1465 static_cast<FwAssertArgType>(_status)
1466 );
1467
1468 _status = msg.serialize(opCode);
1469 FW_ASSERT (
1470 _status == Fw::FW_SERIALIZE_OK,
1471 static_cast<FwAssertArgType>(_status)
1472 );
1473
1474 _status = msg.serialize(cmdSeq);
1475 FW_ASSERT (
1476 _status == Fw::FW_SERIALIZE_OK,
1477 static_cast<FwAssertArgType>(_status)
1478 );
1479
1480 _status = msg.serialize(args);
1481 FW_ASSERT (
1482 _status == Fw::FW_SERIALIZE_OK,
1483 static_cast<FwAssertArgType>(_status)
1484 );
1485
1486 // Send message
1488 Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1489
1490 FW_ASSERT(
1491 qStatus == Os::Queue::OP_OK,
1492 static_cast<FwAssertArgType>(qStatus)
1493 );
1494 }
1495
1496 // ----------------------------------------------------------------------
1497 // Pre-message hooks for async commands
1498 //
1499 // Each of these functions is invoked just before processing the
1500 // corresponding command. By default they do nothing. You can
1501 // override them to provide specific pre-command behavior.
1502 // ----------------------------------------------------------------------
1503
1504 void BufferLoggerComponentBase ::
1505 BL_OpenFile_preMsgHook(
1506 FwOpcodeType opCode,
1507 U32 cmdSeq
1508 )
1509 {
1510 // Defaults to no-op; can be overridden
1511 (void) opCode;
1512 (void) cmdSeq;
1513 }
1514
1515 void BufferLoggerComponentBase ::
1516 BL_CloseFile_preMsgHook(
1517 FwOpcodeType opCode,
1518 U32 cmdSeq
1519 )
1520 {
1521 // Defaults to no-op; can be overridden
1522 (void) opCode;
1523 (void) cmdSeq;
1524 }
1525
1526 void BufferLoggerComponentBase ::
1527 BL_SetLogging_preMsgHook(
1528 FwOpcodeType opCode,
1529 U32 cmdSeq
1530 )
1531 {
1532 // Defaults to no-op; can be overridden
1533 (void) opCode;
1534 (void) cmdSeq;
1535 }
1536
1537 void BufferLoggerComponentBase ::
1538 BL_FlushFile_preMsgHook(
1539 FwOpcodeType opCode,
1540 U32 cmdSeq
1541 )
1542 {
1543 // Defaults to no-op; can be overridden
1544 (void) opCode;
1545 (void) cmdSeq;
1546 }
1547
1548 // ----------------------------------------------------------------------
1549 // Event logging functions
1550 // ----------------------------------------------------------------------
1551
1552 void BufferLoggerComponentBase ::
1553 log_DIAGNOSTIC_BL_LogFileClosed(const Fw::StringBase& file) const
1554 {
1555 // Get the time
1556 Fw::Time _logTime;
1557 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1558 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1559 }
1560
1561 FwEventIdType _id = static_cast<FwEventIdType>(0);
1562
1563 _id = this->getIdBase() + EVENTID_BL_LOGFILECLOSED;
1564
1565 // Emit the event on the log port
1566 if (this->m_eventOut_OutputPort[0].isConnected()) {
1567 Fw::LogBuffer _logBuff;
1569
1570#if FW_AMPCS_COMPATIBLE
1571 // Serialize the number of arguments
1572 _status = _logBuff.serialize(static_cast<U8>(1));
1573 FW_ASSERT(
1574 _status == Fw::FW_SERIALIZE_OK,
1575 static_cast<FwAssertArgType>(_status)
1576 );
1577#endif
1578
1579 _status = file.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 256));
1580 FW_ASSERT(
1581 _status == Fw::FW_SERIALIZE_OK,
1582 static_cast<FwAssertArgType>(_status)
1583 );
1584
1585 this->m_eventOut_OutputPort[0].invoke(
1586 _id,
1587 _logTime,
1589 _logBuff
1590 );
1591 }
1592
1593 // Emit the event on the text log port
1594#if FW_ENABLE_TEXT_LOGGING
1595 if (this->m_eventOutText_OutputPort[0].isConnected()) {
1596#if FW_OBJECT_NAMES == 1
1597 const char* _formatString =
1598 "(%s) %s: File %s closed";
1599#else
1600 const char* _formatString =
1601 "%s: File %s closed";
1602#endif
1603
1604 Fw::TextLogString _logString;
1605 _logString.format(
1606 _formatString,
1607#if FW_OBJECT_NAMES == 1
1608 this->m_objName.toChar(),
1609#endif
1610 "BL_LogFileClosed ",
1611 file.toChar()
1612 );
1613
1614 this->m_eventOutText_OutputPort[0].invoke(
1615 _id,
1616 _logTime,
1618 _logString
1619 );
1620 }
1621#endif
1622 }
1623
1624 void BufferLoggerComponentBase ::
1625 log_WARNING_HI_BL_LogFileOpenError(
1626 U32 errornum,
1627 const Fw::StringBase& file
1628 ) const
1629 {
1630 // Get the time
1631 Fw::Time _logTime;
1632 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1633 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1634 }
1635
1636 FwEventIdType _id = static_cast<FwEventIdType>(0);
1637
1638 _id = this->getIdBase() + EVENTID_BL_LOGFILEOPENERROR;
1639
1640 // Emit the event on the log port
1641 if (this->m_eventOut_OutputPort[0].isConnected()) {
1642 Fw::LogBuffer _logBuff;
1644
1645#if FW_AMPCS_COMPATIBLE
1646 // Serialize the number of arguments
1647 _status = _logBuff.serialize(static_cast<U8>(2));
1648 FW_ASSERT(
1649 _status == Fw::FW_SERIALIZE_OK,
1650 static_cast<FwAssertArgType>(_status)
1651 );
1652#endif
1653
1654#if FW_AMPCS_COMPATIBLE
1655 // Serialize the argument size
1656 _status = _logBuff.serialize(
1657 static_cast<U8>(sizeof(U32))
1658 );
1659 FW_ASSERT(
1660 _status == Fw::FW_SERIALIZE_OK,
1661 static_cast<FwAssertArgType>(_status)
1662 );
1663#endif
1664 _status = _logBuff.serialize(errornum);
1665 FW_ASSERT(
1666 _status == Fw::FW_SERIALIZE_OK,
1667 static_cast<FwAssertArgType>(_status)
1668 );
1669
1670 _status = file.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 256));
1671 FW_ASSERT(
1672 _status == Fw::FW_SERIALIZE_OK,
1673 static_cast<FwAssertArgType>(_status)
1674 );
1675
1676 this->m_eventOut_OutputPort[0].invoke(
1677 _id,
1678 _logTime,
1680 _logBuff
1681 );
1682 }
1683
1684 // Emit the event on the text log port
1685#if FW_ENABLE_TEXT_LOGGING
1686 if (this->m_eventOutText_OutputPort[0].isConnected()) {
1687#if FW_OBJECT_NAMES == 1
1688 const char* _formatString =
1689 "(%s) %s: Error %" PRIu32 " opening file %s";
1690#else
1691 const char* _formatString =
1692 "%s: Error %" PRIu32 " opening file %s";
1693#endif
1694
1695 Fw::TextLogString _logString;
1696 _logString.format(
1697 _formatString,
1698#if FW_OBJECT_NAMES == 1
1699 this->m_objName.toChar(),
1700#endif
1701 "BL_LogFileOpenError ",
1702 errornum,
1703 file.toChar()
1704 );
1705
1706 this->m_eventOutText_OutputPort[0].invoke(
1707 _id,
1708 _logTime,
1710 _logString
1711 );
1712 }
1713#endif
1714 }
1715
1716 void BufferLoggerComponentBase ::
1717 log_WARNING_HI_BL_LogFileValidationError(
1718 const Fw::StringBase& validationFile,
1719 U32 status
1720 ) const
1721 {
1722 // Get the time
1723 Fw::Time _logTime;
1724 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1725 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1726 }
1727
1728 FwEventIdType _id = static_cast<FwEventIdType>(0);
1729
1730 _id = this->getIdBase() + EVENTID_BL_LOGFILEVALIDATIONERROR;
1731
1732 // Emit the event on the log port
1733 if (this->m_eventOut_OutputPort[0].isConnected()) {
1734 Fw::LogBuffer _logBuff;
1736
1737#if FW_AMPCS_COMPATIBLE
1738 // Serialize the number of arguments
1739 _status = _logBuff.serialize(static_cast<U8>(2));
1740 FW_ASSERT(
1741 _status == Fw::FW_SERIALIZE_OK,
1742 static_cast<FwAssertArgType>(_status)
1743 );
1744#endif
1745
1746 _status = validationFile.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 256));
1747 FW_ASSERT(
1748 _status == Fw::FW_SERIALIZE_OK,
1749 static_cast<FwAssertArgType>(_status)
1750 );
1751
1752#if FW_AMPCS_COMPATIBLE
1753 // Serialize the argument size
1754 _status = _logBuff.serialize(
1755 static_cast<U8>(sizeof(U32))
1756 );
1757 FW_ASSERT(
1758 _status == Fw::FW_SERIALIZE_OK,
1759 static_cast<FwAssertArgType>(_status)
1760 );
1761#endif
1762 _status = _logBuff.serialize(status);
1763 FW_ASSERT(
1764 _status == Fw::FW_SERIALIZE_OK,
1765 static_cast<FwAssertArgType>(_status)
1766 );
1767
1768 this->m_eventOut_OutputPort[0].invoke(
1769 _id,
1770 _logTime,
1772 _logBuff
1773 );
1774 }
1775
1776 // Emit the event on the text log port
1777#if FW_ENABLE_TEXT_LOGGING
1778 if (this->m_eventOutText_OutputPort[0].isConnected()) {
1779#if FW_OBJECT_NAMES == 1
1780 const char* _formatString =
1781 "(%s) %s: Failed creating validation file %s with status %" PRIu32 "";
1782#else
1783 const char* _formatString =
1784 "%s: Failed creating validation file %s with status %" PRIu32 "";
1785#endif
1786
1787 Fw::TextLogString _logString;
1788 _logString.format(
1789 _formatString,
1790#if FW_OBJECT_NAMES == 1
1791 this->m_objName.toChar(),
1792#endif
1793 "BL_LogFileValidationError ",
1794 validationFile.toChar(),
1795 status
1796 );
1797
1798 this->m_eventOutText_OutputPort[0].invoke(
1799 _id,
1800 _logTime,
1802 _logString
1803 );
1804 }
1805#endif
1806 }
1807
1808 void BufferLoggerComponentBase ::
1809 log_WARNING_HI_BL_LogFileWriteError(
1810 U32 errornum,
1811 U32 bytesWritten,
1812 U32 bytesToWrite,
1813 const Fw::StringBase& file
1814 ) const
1815 {
1816 // Get the time
1817 Fw::Time _logTime;
1818 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1819 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1820 }
1821
1822 FwEventIdType _id = static_cast<FwEventIdType>(0);
1823
1824 _id = this->getIdBase() + EVENTID_BL_LOGFILEWRITEERROR;
1825
1826 // Emit the event on the log port
1827 if (this->m_eventOut_OutputPort[0].isConnected()) {
1828 Fw::LogBuffer _logBuff;
1830
1831#if FW_AMPCS_COMPATIBLE
1832 // Serialize the number of arguments
1833 _status = _logBuff.serialize(static_cast<U8>(4));
1834 FW_ASSERT(
1835 _status == Fw::FW_SERIALIZE_OK,
1836 static_cast<FwAssertArgType>(_status)
1837 );
1838#endif
1839
1840#if FW_AMPCS_COMPATIBLE
1841 // Serialize the argument size
1842 _status = _logBuff.serialize(
1843 static_cast<U8>(sizeof(U32))
1844 );
1845 FW_ASSERT(
1846 _status == Fw::FW_SERIALIZE_OK,
1847 static_cast<FwAssertArgType>(_status)
1848 );
1849#endif
1850 _status = _logBuff.serialize(errornum);
1851 FW_ASSERT(
1852 _status == Fw::FW_SERIALIZE_OK,
1853 static_cast<FwAssertArgType>(_status)
1854 );
1855
1856#if FW_AMPCS_COMPATIBLE
1857 // Serialize the argument size
1858 _status = _logBuff.serialize(
1859 static_cast<U8>(sizeof(U32))
1860 );
1861 FW_ASSERT(
1862 _status == Fw::FW_SERIALIZE_OK,
1863 static_cast<FwAssertArgType>(_status)
1864 );
1865#endif
1866 _status = _logBuff.serialize(bytesWritten);
1867 FW_ASSERT(
1868 _status == Fw::FW_SERIALIZE_OK,
1869 static_cast<FwAssertArgType>(_status)
1870 );
1871
1872#if FW_AMPCS_COMPATIBLE
1873 // Serialize the argument size
1874 _status = _logBuff.serialize(
1875 static_cast<U8>(sizeof(U32))
1876 );
1877 FW_ASSERT(
1878 _status == Fw::FW_SERIALIZE_OK,
1879 static_cast<FwAssertArgType>(_status)
1880 );
1881#endif
1882 _status = _logBuff.serialize(bytesToWrite);
1883 FW_ASSERT(
1884 _status == Fw::FW_SERIALIZE_OK,
1885 static_cast<FwAssertArgType>(_status)
1886 );
1887
1888 _status = file.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 256));
1889 FW_ASSERT(
1890 _status == Fw::FW_SERIALIZE_OK,
1891 static_cast<FwAssertArgType>(_status)
1892 );
1893
1894 this->m_eventOut_OutputPort[0].invoke(
1895 _id,
1896 _logTime,
1898 _logBuff
1899 );
1900 }
1901
1902 // Emit the event on the text log port
1903#if FW_ENABLE_TEXT_LOGGING
1904 if (this->m_eventOutText_OutputPort[0].isConnected()) {
1905#if FW_OBJECT_NAMES == 1
1906 const char* _formatString =
1907 "(%s) %s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1908#else
1909 const char* _formatString =
1910 "%s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1911#endif
1912
1913 Fw::TextLogString _logString;
1914 _logString.format(
1915 _formatString,
1916#if FW_OBJECT_NAMES == 1
1917 this->m_objName.toChar(),
1918#endif
1919 "BL_LogFileWriteError ",
1920 errornum,
1921 bytesWritten,
1922 bytesToWrite,
1923 file.toChar()
1924 );
1925
1926 this->m_eventOutText_OutputPort[0].invoke(
1927 _id,
1928 _logTime,
1930 _logString
1931 );
1932 }
1933#endif
1934 }
1935
1936 void BufferLoggerComponentBase ::
1937 log_ACTIVITY_LO_BL_Activated() const
1938 {
1939 // Get the time
1940 Fw::Time _logTime;
1941 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1942 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1943 }
1944
1945 FwEventIdType _id = static_cast<FwEventIdType>(0);
1946
1947 _id = this->getIdBase() + EVENTID_BL_ACTIVATED;
1948
1949 // Emit the event on the log port
1950 if (this->m_eventOut_OutputPort[0].isConnected()) {
1951 Fw::LogBuffer _logBuff;
1952
1953#if FW_AMPCS_COMPATIBLE
1955 // Serialize the number of arguments
1956 _status = _logBuff.serialize(static_cast<U8>(0));
1957 FW_ASSERT(
1958 _status == Fw::FW_SERIALIZE_OK,
1959 static_cast<FwAssertArgType>(_status)
1960 );
1961#endif
1962
1963 this->m_eventOut_OutputPort[0].invoke(
1964 _id,
1965 _logTime,
1967 _logBuff
1968 );
1969 }
1970
1971 // Emit the event on the text log port
1972#if FW_ENABLE_TEXT_LOGGING
1973 if (this->m_eventOutText_OutputPort[0].isConnected()) {
1974#if FW_OBJECT_NAMES == 1
1975 const char* _formatString =
1976 "(%s) %s: Buffer logger was activated";
1977#else
1978 const char* _formatString =
1979 "%s: Buffer logger was activated";
1980#endif
1981
1982 Fw::TextLogString _logString;
1983 _logString.format(
1984 _formatString,
1985#if FW_OBJECT_NAMES == 1
1986 this->m_objName.toChar(),
1987#endif
1988 "BL_Activated "
1989 );
1990
1991 this->m_eventOutText_OutputPort[0].invoke(
1992 _id,
1993 _logTime,
1995 _logString
1996 );
1997 }
1998#endif
1999 }
2000
2001 void BufferLoggerComponentBase ::
2002 log_ACTIVITY_LO_BL_Deactivated() const
2003 {
2004 // Get the time
2005 Fw::Time _logTime;
2006 if (this->m_timeCaller_OutputPort[0].isConnected()) {
2007 this->m_timeCaller_OutputPort[0].invoke(_logTime);
2008 }
2009
2010 FwEventIdType _id = static_cast<FwEventIdType>(0);
2011
2012 _id = this->getIdBase() + EVENTID_BL_DEACTIVATED;
2013
2014 // Emit the event on the log port
2015 if (this->m_eventOut_OutputPort[0].isConnected()) {
2016 Fw::LogBuffer _logBuff;
2017
2018#if FW_AMPCS_COMPATIBLE
2020 // Serialize the number of arguments
2021 _status = _logBuff.serialize(static_cast<U8>(0));
2022 FW_ASSERT(
2023 _status == Fw::FW_SERIALIZE_OK,
2024 static_cast<FwAssertArgType>(_status)
2025 );
2026#endif
2027
2028 this->m_eventOut_OutputPort[0].invoke(
2029 _id,
2030 _logTime,
2032 _logBuff
2033 );
2034 }
2035
2036 // Emit the event on the text log port
2037#if FW_ENABLE_TEXT_LOGGING
2038 if (this->m_eventOutText_OutputPort[0].isConnected()) {
2039#if FW_OBJECT_NAMES == 1
2040 const char* _formatString =
2041 "(%s) %s: Buffer logger was deactivated";
2042#else
2043 const char* _formatString =
2044 "%s: Buffer logger was deactivated";
2045#endif
2046
2047 Fw::TextLogString _logString;
2048 _logString.format(
2049 _formatString,
2050#if FW_OBJECT_NAMES == 1
2051 this->m_objName.toChar(),
2052#endif
2053 "BL_Deactivated "
2054 );
2055
2056 this->m_eventOutText_OutputPort[0].invoke(
2057 _id,
2058 _logTime,
2060 _logString
2061 );
2062 }
2063#endif
2064 }
2065
2066 void BufferLoggerComponentBase ::
2067 log_WARNING_HI_BL_NoLogFileOpenInitError() const
2068 {
2069 // Get the time
2070 Fw::Time _logTime;
2071 if (this->m_timeCaller_OutputPort[0].isConnected()) {
2072 this->m_timeCaller_OutputPort[0].invoke(_logTime);
2073 }
2074
2075 FwEventIdType _id = static_cast<FwEventIdType>(0);
2076
2077 _id = this->getIdBase() + EVENTID_BL_NOLOGFILEOPENINITERROR;
2078
2079 // Emit the event on the log port
2080 if (this->m_eventOut_OutputPort[0].isConnected()) {
2081 Fw::LogBuffer _logBuff;
2082
2083#if FW_AMPCS_COMPATIBLE
2085 // Serialize the number of arguments
2086 _status = _logBuff.serialize(static_cast<U8>(0));
2087 FW_ASSERT(
2088 _status == Fw::FW_SERIALIZE_OK,
2089 static_cast<FwAssertArgType>(_status)
2090 );
2091#endif
2092
2093 this->m_eventOut_OutputPort[0].invoke(
2094 _id,
2095 _logTime,
2097 _logBuff
2098 );
2099 }
2100
2101 // Emit the event on the text log port
2102#if FW_ENABLE_TEXT_LOGGING
2103 if (this->m_eventOutText_OutputPort[0].isConnected()) {
2104#if FW_OBJECT_NAMES == 1
2105 const char* _formatString =
2106 "(%s) %s: No log file open command";
2107#else
2108 const char* _formatString =
2109 "%s: No log file open command";
2110#endif
2111
2112 Fw::TextLogString _logString;
2113 _logString.format(
2114 _formatString,
2115#if FW_OBJECT_NAMES == 1
2116 this->m_objName.toChar(),
2117#endif
2118 "BL_NoLogFileOpenInitError "
2119 );
2120
2121 this->m_eventOutText_OutputPort[0].invoke(
2122 _id,
2123 _logTime,
2125 _logString
2126 );
2127 }
2128#endif
2129 }
2130
2131 // ----------------------------------------------------------------------
2132 // Telemetry write functions
2133 // ----------------------------------------------------------------------
2134
2135 void BufferLoggerComponentBase ::
2136 tlmWrite_BufferLogger_NumLoggedBuffers(
2137 U32 arg,
2138 Fw::Time _tlmTime
2139 ) const
2140 {
2141 if (this->m_tlmOut_OutputPort[0].isConnected()) {
2142 if (
2143 this->m_timeCaller_OutputPort[0].isConnected() &&
2144 (_tlmTime == Fw::ZERO_TIME)
2145 ) {
2146 this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2147 }
2148
2149 Fw::TlmBuffer _tlmBuff;
2150 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
2151 FW_ASSERT(
2152 _stat == Fw::FW_SERIALIZE_OK,
2153 static_cast<FwAssertArgType>(_stat)
2154 );
2155
2156 FwChanIdType _id;
2157
2158 _id = this->getIdBase() + CHANNELID_BUFFERLOGGER_NUMLOGGEDBUFFERS;
2159
2160 this->m_tlmOut_OutputPort[0].invoke(
2161 _id,
2162 _tlmTime,
2163 _tlmBuff
2164 );
2165 }
2166 }
2167
2168 // ----------------------------------------------------------------------
2169 // Time
2170 // ----------------------------------------------------------------------
2171
2172 Fw::Time BufferLoggerComponentBase ::
2173 getTime()
2174 {
2175 if (this->m_timeCaller_OutputPort[0].isConnected()) {
2176 Fw::Time _time;
2177 this->m_timeCaller_OutputPort[0].invoke(_time);
2178 return _time;
2179 }
2180 else {
2181 return Fw::Time(TB_NONE, 0, 0);
2182 }
2183 }
2184
2185 // ----------------------------------------------------------------------
2186 // Message dispatch functions
2187 // ----------------------------------------------------------------------
2188
2189 Fw::QueuedComponentBase::MsgDispatchStatus BufferLoggerComponentBase ::
2190 doDispatch()
2191 {
2192 ComponentIpcSerializableBuffer msg;
2193 FwQueuePriorityType priority = 0;
2194
2195 Os::Queue::Status msgStatus = this->m_queue.receive(
2196 msg,
2198 priority
2199 );
2200 FW_ASSERT(
2201 msgStatus == Os::Queue::OP_OK,
2202 static_cast<FwAssertArgType>(msgStatus)
2203 );
2204
2205 // Reset to beginning of buffer
2206 msg.resetDeser();
2207
2208 FwEnumStoreType desMsg = 0;
2209 Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
2210 FW_ASSERT(
2211 deserStatus == Fw::FW_SERIALIZE_OK,
2212 static_cast<FwAssertArgType>(deserStatus)
2213 );
2214
2215 MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
2216
2217 if (msgType == BUFFERLOGGER_COMPONENT_EXIT) {
2218 return MSG_DISPATCH_EXIT;
2219 }
2220
2221 FwIndexType portNum = 0;
2222 deserStatus = msg.deserialize(portNum);
2223 FW_ASSERT(
2224 deserStatus == Fw::FW_SERIALIZE_OK,
2225 static_cast<FwAssertArgType>(deserStatus)
2226 );
2227
2228 switch (msgType) {
2229 // Handle async input port bufferSendIn
2230 case BUFFERSENDIN_BUFFERSEND: {
2231 // Deserialize argument fwBuffer
2232 Fw::Buffer fwBuffer;
2233 deserStatus = msg.deserialize(fwBuffer);
2234 FW_ASSERT(
2235 deserStatus == Fw::FW_SERIALIZE_OK,
2236 static_cast<FwAssertArgType>(deserStatus)
2237 );
2238 // Call handler function
2239 this->bufferSendIn_handler(
2240 portNum,
2241 fwBuffer
2242 );
2243
2244 break;
2245 }
2246
2247 // Handle async input port comIn
2248 case COMIN_COM: {
2249 // Deserialize argument data
2250 Fw::ComBuffer data;
2251 deserStatus = msg.deserialize(data);
2252 FW_ASSERT(
2253 deserStatus == Fw::FW_SERIALIZE_OK,
2254 static_cast<FwAssertArgType>(deserStatus)
2255 );
2256
2257 // Deserialize argument context
2258 U32 context;
2259 deserStatus = msg.deserialize(context);
2260 FW_ASSERT(
2261 deserStatus == Fw::FW_SERIALIZE_OK,
2262 static_cast<FwAssertArgType>(deserStatus)
2263 );
2264 // Call handler function
2265 this->comIn_handler(
2266 portNum,
2267 data,
2268 context
2269 );
2270
2271 break;
2272 }
2273
2274 // Handle async input port pingIn
2275 case PINGIN_PING: {
2276 // Deserialize argument key
2277 U32 key;
2278 deserStatus = msg.deserialize(key);
2279 FW_ASSERT(
2280 deserStatus == Fw::FW_SERIALIZE_OK,
2281 static_cast<FwAssertArgType>(deserStatus)
2282 );
2283 // Call handler function
2284 this->pingIn_handler(
2285 portNum,
2286 key
2287 );
2288
2289 break;
2290 }
2291
2292 // Handle async input port schedIn
2293 case SCHEDIN_SCHED: {
2294 // Deserialize argument context
2295 U32 context;
2296 deserStatus = msg.deserialize(context);
2297 FW_ASSERT(
2298 deserStatus == Fw::FW_SERIALIZE_OK,
2299 static_cast<FwAssertArgType>(deserStatus)
2300 );
2301 // Call handler function
2302 this->schedIn_handler(
2303 portNum,
2304 context
2305 );
2306
2307 break;
2308 }
2309
2310 // Handle command BL_OpenFile
2311 case CMD_BL_OPENFILE: {
2312 // Deserialize opcode
2313 FwOpcodeType opCode = 0;
2314 deserStatus = msg.deserialize(opCode);
2315 FW_ASSERT (
2316 deserStatus == Fw::FW_SERIALIZE_OK,
2317 static_cast<FwAssertArgType>(deserStatus)
2318 );
2319
2320 // Deserialize command sequence
2321 U32 cmdSeq = 0;
2322 deserStatus = msg.deserialize(cmdSeq);
2323 FW_ASSERT (
2324 deserStatus == Fw::FW_SERIALIZE_OK,
2325 static_cast<FwAssertArgType>(deserStatus)
2326 );
2327
2328 // Deserialize command argument buffer
2329 Fw::CmdArgBuffer args;
2330 deserStatus = msg.deserialize(args);
2331 FW_ASSERT (
2332 deserStatus == Fw::FW_SERIALIZE_OK,
2333 static_cast<FwAssertArgType>(deserStatus)
2334 );
2335
2336 // Reset buffer
2337 args.resetDeser();
2338
2339 // Deserialize argument file
2340 Fw::CmdStringArg file;
2341 deserStatus = args.deserialize(file);
2342 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2343 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2344 this->cmdResponse_out(
2345 opCode,
2346 cmdSeq,
2348 );
2349 }
2350 // Don't crash the task if bad arguments were passed from the ground
2351 break;
2352 }
2353
2354 // Make sure there was no data left over.
2355 // That means the argument buffer size was incorrect.
2356#if FW_CMD_CHECK_RESIDUAL
2357 if (args.getBuffLeft() != 0) {
2358 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2359 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2360 }
2361 // Don't crash the task if bad arguments were passed from the ground
2362 break;
2363 }
2364#endif
2365
2366 // Call handler function
2367 this->BL_OpenFile_cmdHandler(
2368 opCode, cmdSeq,
2369 file
2370 );
2371
2372 break;
2373 }
2374
2375 // Handle command BL_CloseFile
2376 case CMD_BL_CLOSEFILE: {
2377 // Deserialize opcode
2378 FwOpcodeType opCode = 0;
2379 deserStatus = msg.deserialize(opCode);
2380 FW_ASSERT (
2381 deserStatus == Fw::FW_SERIALIZE_OK,
2382 static_cast<FwAssertArgType>(deserStatus)
2383 );
2384
2385 // Deserialize command sequence
2386 U32 cmdSeq = 0;
2387 deserStatus = msg.deserialize(cmdSeq);
2388 FW_ASSERT (
2389 deserStatus == Fw::FW_SERIALIZE_OK,
2390 static_cast<FwAssertArgType>(deserStatus)
2391 );
2392
2393 // Deserialize command argument buffer
2394 Fw::CmdArgBuffer args;
2395 deserStatus = msg.deserialize(args);
2396 FW_ASSERT (
2397 deserStatus == Fw::FW_SERIALIZE_OK,
2398 static_cast<FwAssertArgType>(deserStatus)
2399 );
2400
2401 // Reset buffer
2402 args.resetDeser();
2403
2404 // Make sure there was no data left over.
2405 // That means the argument buffer size was incorrect.
2406#if FW_CMD_CHECK_RESIDUAL
2407 if (args.getBuffLeft() != 0) {
2408 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2409 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2410 }
2411 // Don't crash the task if bad arguments were passed from the ground
2412 break;
2413 }
2414#endif
2415
2416 // Call handler function
2417 this->BL_CloseFile_cmdHandler(opCode, cmdSeq);
2418
2419 break;
2420 }
2421
2422 // Handle command BL_SetLogging
2423 case CMD_BL_SETLOGGING: {
2424 // Deserialize opcode
2425 FwOpcodeType opCode = 0;
2426 deserStatus = msg.deserialize(opCode);
2427 FW_ASSERT (
2428 deserStatus == Fw::FW_SERIALIZE_OK,
2429 static_cast<FwAssertArgType>(deserStatus)
2430 );
2431
2432 // Deserialize command sequence
2433 U32 cmdSeq = 0;
2434 deserStatus = msg.deserialize(cmdSeq);
2435 FW_ASSERT (
2436 deserStatus == Fw::FW_SERIALIZE_OK,
2437 static_cast<FwAssertArgType>(deserStatus)
2438 );
2439
2440 // Deserialize command argument buffer
2441 Fw::CmdArgBuffer args;
2442 deserStatus = msg.deserialize(args);
2443 FW_ASSERT (
2444 deserStatus == Fw::FW_SERIALIZE_OK,
2445 static_cast<FwAssertArgType>(deserStatus)
2446 );
2447
2448 // Reset buffer
2449 args.resetDeser();
2450
2451 // Deserialize argument state
2453 deserStatus = args.deserialize(state);
2454 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2455 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2456 this->cmdResponse_out(
2457 opCode,
2458 cmdSeq,
2460 );
2461 }
2462 // Don't crash the task if bad arguments were passed from the ground
2463 break;
2464 }
2465
2466 // Make sure there was no data left over.
2467 // That means the argument buffer size was incorrect.
2468#if FW_CMD_CHECK_RESIDUAL
2469 if (args.getBuffLeft() != 0) {
2470 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2471 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2472 }
2473 // Don't crash the task if bad arguments were passed from the ground
2474 break;
2475 }
2476#endif
2477
2478 // Call handler function
2479 this->BL_SetLogging_cmdHandler(
2480 opCode, cmdSeq,
2481 state
2482 );
2483
2484 break;
2485 }
2486
2487 // Handle command BL_FlushFile
2488 case CMD_BL_FLUSHFILE: {
2489 // Deserialize opcode
2490 FwOpcodeType opCode = 0;
2491 deserStatus = msg.deserialize(opCode);
2492 FW_ASSERT (
2493 deserStatus == Fw::FW_SERIALIZE_OK,
2494 static_cast<FwAssertArgType>(deserStatus)
2495 );
2496
2497 // Deserialize command sequence
2498 U32 cmdSeq = 0;
2499 deserStatus = msg.deserialize(cmdSeq);
2500 FW_ASSERT (
2501 deserStatus == Fw::FW_SERIALIZE_OK,
2502 static_cast<FwAssertArgType>(deserStatus)
2503 );
2504
2505 // Deserialize command argument buffer
2506 Fw::CmdArgBuffer args;
2507 deserStatus = msg.deserialize(args);
2508 FW_ASSERT (
2509 deserStatus == Fw::FW_SERIALIZE_OK,
2510 static_cast<FwAssertArgType>(deserStatus)
2511 );
2512
2513 // Reset buffer
2514 args.resetDeser();
2515
2516 // Make sure there was no data left over.
2517 // That means the argument buffer size was incorrect.
2518#if FW_CMD_CHECK_RESIDUAL
2519 if (args.getBuffLeft() != 0) {
2520 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2521 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2522 }
2523 // Don't crash the task if bad arguments were passed from the ground
2524 break;
2525 }
2526#endif
2527
2528 // Call handler function
2529 this->BL_FlushFile_cmdHandler(opCode, cmdSeq);
2530
2531 break;
2532 }
2533
2534 default:
2535 return MSG_DISPATCH_ERROR;
2536 }
2537
2538 return MSG_DISPATCH_OK;
2539 }
2540
2541 // ----------------------------------------------------------------------
2542 // Calls for messages received on special input ports
2543 // ----------------------------------------------------------------------
2544
2545 void BufferLoggerComponentBase ::
2546 m_p_cmdIn_in(
2547 Fw::PassiveComponentBase* callComp,
2548 FwIndexType portNum,
2549 FwOpcodeType opCode,
2550 U32 cmdSeq,
2551 Fw::CmdArgBuffer& args
2552 )
2553 {
2554 FW_ASSERT(callComp);
2555 BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2556
2557 const U32 idBase = callComp->getIdBase();
2558 FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
2559
2560 // Select base class function based on opcode
2561 switch (opCode - idBase) {
2562 case OPCODE_BL_OPENFILE: {
2563 compPtr->BL_OpenFile_cmdHandlerBase(
2564 opCode,
2565 cmdSeq,
2566 args
2567 );
2568 break;
2569 }
2570
2571 case OPCODE_BL_CLOSEFILE: {
2572 compPtr->BL_CloseFile_cmdHandlerBase(
2573 opCode,
2574 cmdSeq,
2575 args
2576 );
2577 break;
2578 }
2579
2580 case OPCODE_BL_SETLOGGING: {
2581 compPtr->BL_SetLogging_cmdHandlerBase(
2582 opCode,
2583 cmdSeq,
2584 args
2585 );
2586 break;
2587 }
2588
2589 case OPCODE_BL_FLUSHFILE: {
2590 compPtr->BL_FlushFile_cmdHandlerBase(
2591 opCode,
2592 cmdSeq,
2593 args
2594 );
2595 break;
2596 }
2597 }
2598 }
2599
2600 // ----------------------------------------------------------------------
2601 // Calls for messages received on typed input ports
2602 // ----------------------------------------------------------------------
2603
2604 void BufferLoggerComponentBase ::
2605 m_p_bufferSendIn_in(
2606 Fw::PassiveComponentBase* callComp,
2607 FwIndexType portNum,
2608 Fw::Buffer& fwBuffer
2609 )
2610 {
2611 FW_ASSERT(callComp);
2612 BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2613 compPtr->bufferSendIn_handlerBase(
2614 portNum,
2615 fwBuffer
2616 );
2617 }
2618
2619 void BufferLoggerComponentBase ::
2620 m_p_comIn_in(
2621 Fw::PassiveComponentBase* callComp,
2622 FwIndexType portNum,
2623 Fw::ComBuffer& data,
2624 U32 context
2625 )
2626 {
2627 FW_ASSERT(callComp);
2628 BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2629 compPtr->comIn_handlerBase(
2630 portNum,
2631 data,
2632 context
2633 );
2634 }
2635
2636 void BufferLoggerComponentBase ::
2637 m_p_pingIn_in(
2638 Fw::PassiveComponentBase* callComp,
2639 FwIndexType portNum,
2640 U32 key
2641 )
2642 {
2643 FW_ASSERT(callComp);
2644 BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2645 compPtr->pingIn_handlerBase(
2646 portNum,
2647 key
2648 );
2649 }
2650
2651 void BufferLoggerComponentBase ::
2652 m_p_schedIn_in(
2653 Fw::PassiveComponentBase* callComp,
2654 FwIndexType portNum,
2655 U32 context
2656 )
2657 {
2658 FW_ASSERT(callComp);
2659 BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2660 compPtr->schedIn_handlerBase(
2661 portNum,
2662 context
2663 );
2664 }
2665
2666}
#define FW_ASSERT(...)
Definition Assert.hpp:14
U8 BYTE
byte type
Definition BasicTypes.h:31
#define FW_MIN(a, b)
MIN macro.
Definition BasicTypes.h:72
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 FwChanIdType
Definition FpConfig.h:95
U32 FwEventIdType
Definition FpConfig.h:103
U32 FwOpcodeType
Definition FpConfig.h:91
PlatformSizeType FwSizeType
Definition FpConfig.h:35
#define FW_LOG_STRING_MAX_SIZE
Max size of log string parameter type.
Definition FpConfig.h:319
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.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition CmdPortAc.hpp:37
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition ComPortAc.hpp:37
@ WARNING_HI
A serious but recoverable event.
@ DIAGNOSTIC
Software diagnostic events.
@ ACTIVITY_LO
Less important informational events.
void init()
Object initializer.
Definition ObjBase.cpp:27
const char * toChar() const
NATIVE_UINT_TYPE SizeType
void resetDeser()
reset deserialization to beginning
Serializable::SizeType getBuffLeft() const
returns how much deserialization buffer is left
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
void format(const CHAR *formatString,...)
write formatted string to buffer
virtual SerializeStatus serialize(SerializeBufferBase &buffer) const
serialization function
virtual const CHAR * toChar() const =0
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 representations of the port arguments.
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
const Time ZERO_TIME
Definition Time.cpp:5