F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
BlockDriverComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title BlockDriverComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for BlockDriver component base class
5// ======================================================================
6
7#include <cstdio>
8
10#include "Fw/Types/Assert.hpp"
11#if FW_ENABLE_TEXT_LOGGING
12#include "Fw/Types/String.hpp"
13#endif
14
15namespace Drv {
16
17 namespace {
18 enum MsgTypeEnum {
19 BLOCKDRIVER_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
20 BUFFERIN_DATABUFFER,
21 PINGIN_PING,
22 SCHED_SCHED,
23 INT_IF_INTERRUPTREPORT,
24 };
25
26 // Get the max size by doing a union of the input and internal port serialization sizes
27 union BuffUnion {
31 // Size of InterruptReport argument list
33 sizeof(U32)
34 ];
35 };
36
37 // Define a message buffer class large enough to handle all the
38 // asynchronous inputs to the component
39 class ComponentIpcSerializableBuffer :
41 {
42
43 public:
44
45 enum {
46 // Max. message size = size of data + message id + port
47 SERIALIZATION_SIZE =
48 sizeof(BuffUnion) +
49 sizeof(NATIVE_INT_TYPE) +
50 sizeof(NATIVE_INT_TYPE)
51 };
52
53 NATIVE_UINT_TYPE getBuffCapacity() const {
54 return sizeof(m_buff);
55 }
56
57 U8* getBuffAddr() {
58 return m_buff;
59 }
60
61 const U8* getBuffAddr() const {
62 return m_buff;
63 }
64
65 private:
66 // Should be the max of all the input ports serialized sizes...
67 U8 m_buff[SERIALIZATION_SIZE];
68
69 };
70 }
71
72 // ----------------------------------------------------------------------
73 // Component initialization
74 // ----------------------------------------------------------------------
75
76 void BlockDriverComponentBase ::
77 init(
78 NATIVE_INT_TYPE queueDepth,
79 NATIVE_INT_TYPE instance
80 )
81 {
82 // Initialize base class
84
85 // Connect input port BufferIn
86 for (
87 PlatformIntType port = 0;
88 port < static_cast<PlatformIntType>(this->getNum_BufferIn_InputPorts());
89 port++
90 ) {
91 this->m_BufferIn_InputPort[port].init();
92 this->m_BufferIn_InputPort[port].addCallComp(
93 this,
94 m_p_BufferIn_in
95 );
96 this->m_BufferIn_InputPort[port].setPortNum(port);
97
98#if FW_OBJECT_NAMES == 1
99 char portName[120];
100 (void) snprintf(
101 portName,
102 sizeof(portName),
103 "%s_BufferIn_InputPort[%" PRI_PlatformIntType "]",
104 this->m_objName,
105 port
106 );
107 this->m_BufferIn_InputPort[port].setObjName(portName);
108#endif
109 }
110
111 // Connect input port PingIn
112 for (
113 PlatformIntType port = 0;
114 port < static_cast<PlatformIntType>(this->getNum_PingIn_InputPorts());
115 port++
116 ) {
117 this->m_PingIn_InputPort[port].init();
118 this->m_PingIn_InputPort[port].addCallComp(
119 this,
120 m_p_PingIn_in
121 );
122 this->m_PingIn_InputPort[port].setPortNum(port);
123
124#if FW_OBJECT_NAMES == 1
125 char portName[120];
126 (void) snprintf(
127 portName,
128 sizeof(portName),
129 "%s_PingIn_InputPort[%" PRI_PlatformIntType "]",
130 this->m_objName,
131 port
132 );
133 this->m_PingIn_InputPort[port].setObjName(portName);
134#endif
135 }
136
137 // Connect input port Sched
138 for (
139 PlatformIntType port = 0;
140 port < static_cast<PlatformIntType>(this->getNum_Sched_InputPorts());
141 port++
142 ) {
143 this->m_Sched_InputPort[port].init();
144 this->m_Sched_InputPort[port].addCallComp(
145 this,
146 m_p_Sched_in
147 );
148 this->m_Sched_InputPort[port].setPortNum(port);
149
150#if FW_OBJECT_NAMES == 1
151 char portName[120];
152 (void) snprintf(
153 portName,
154 sizeof(portName),
155 "%s_Sched_InputPort[%" PRI_PlatformIntType "]",
156 this->m_objName,
157 port
158 );
159 this->m_Sched_InputPort[port].setObjName(portName);
160#endif
161 }
162
163 // Connect output port Time
164 for (
165 PlatformIntType port = 0;
166 port < static_cast<PlatformIntType>(this->getNum_Time_OutputPorts());
167 port++
168 ) {
169 this->m_Time_OutputPort[port].init();
170
171#if FW_OBJECT_NAMES == 1
172 char portName[120];
173 (void) snprintf(
174 portName,
175 sizeof(portName),
176 "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
177 this->m_objName,
178 port
179 );
180 this->m_Time_OutputPort[port].setObjName(portName);
181#endif
182 }
183
184 // Connect output port Tlm
185 for (
186 PlatformIntType port = 0;
187 port < static_cast<PlatformIntType>(this->getNum_Tlm_OutputPorts());
188 port++
189 ) {
190 this->m_Tlm_OutputPort[port].init();
191
192#if FW_OBJECT_NAMES == 1
193 char portName[120];
194 (void) snprintf(
195 portName,
196 sizeof(portName),
197 "%s_Tlm_OutputPort[%" PRI_PlatformIntType "]",
198 this->m_objName,
199 port
200 );
201 this->m_Tlm_OutputPort[port].setObjName(portName);
202#endif
203 }
204
205 // Connect output port BufferOut
206 for (
207 PlatformIntType port = 0;
208 port < static_cast<PlatformIntType>(this->getNum_BufferOut_OutputPorts());
209 port++
210 ) {
211 this->m_BufferOut_OutputPort[port].init();
212
213#if FW_OBJECT_NAMES == 1
214 char portName[120];
215 (void) snprintf(
216 portName,
217 sizeof(portName),
218 "%s_BufferOut_OutputPort[%" PRI_PlatformIntType "]",
219 this->m_objName,
220 port
221 );
222 this->m_BufferOut_OutputPort[port].setObjName(portName);
223#endif
224 }
225
226 // Connect output port CycleOut
227 for (
228 PlatformIntType port = 0;
229 port < static_cast<PlatformIntType>(this->getNum_CycleOut_OutputPorts());
230 port++
231 ) {
232 this->m_CycleOut_OutputPort[port].init();
233
234#if FW_OBJECT_NAMES == 1
235 char portName[120];
236 (void) snprintf(
237 portName,
238 sizeof(portName),
239 "%s_CycleOut_OutputPort[%" PRI_PlatformIntType "]",
240 this->m_objName,
241 port
242 );
243 this->m_CycleOut_OutputPort[port].setObjName(portName);
244#endif
245 }
246
247 // Connect output port PingOut
248 for (
249 PlatformIntType port = 0;
250 port < static_cast<PlatformIntType>(this->getNum_PingOut_OutputPorts());
251 port++
252 ) {
253 this->m_PingOut_OutputPort[port].init();
254
255#if FW_OBJECT_NAMES == 1
256 char portName[120];
257 (void) snprintf(
258 portName,
259 sizeof(portName),
260 "%s_PingOut_OutputPort[%" PRI_PlatformIntType "]",
261 this->m_objName,
262 port
263 );
264 this->m_PingOut_OutputPort[port].setObjName(portName);
265#endif
266 }
267
268 Os::Queue::QueueStatus qStat = this->createQueue(
269 queueDepth,
270 ComponentIpcSerializableBuffer::SERIALIZATION_SIZE
271 );
272 FW_ASSERT(
273 Os::Queue::QUEUE_OK == qStat,
274 static_cast<FwAssertArgType>(qStat)
275 );
276 }
277
278 // ----------------------------------------------------------------------
279 // Getters for typed input ports
280 // ----------------------------------------------------------------------
281
282 Drv::InputDataBufferPort* BlockDriverComponentBase ::
283 get_BufferIn_InputPort(NATIVE_INT_TYPE portNum)
284 {
285 FW_ASSERT(
286 portNum < this->getNum_BufferIn_InputPorts(),
287 static_cast<FwAssertArgType>(portNum)
288 );
289
290 return &this->m_BufferIn_InputPort[portNum];
291 }
292
293 Svc::InputPingPort* BlockDriverComponentBase ::
294 get_PingIn_InputPort(NATIVE_INT_TYPE portNum)
295 {
296 FW_ASSERT(
297 portNum < this->getNum_PingIn_InputPorts(),
298 static_cast<FwAssertArgType>(portNum)
299 );
300
301 return &this->m_PingIn_InputPort[portNum];
302 }
303
304 Svc::InputSchedPort* BlockDriverComponentBase ::
305 get_Sched_InputPort(NATIVE_INT_TYPE portNum)
306 {
307 FW_ASSERT(
308 portNum < this->getNum_Sched_InputPorts(),
309 static_cast<FwAssertArgType>(portNum)
310 );
311
312 return &this->m_Sched_InputPort[portNum];
313 }
314
315 // ----------------------------------------------------------------------
316 // Connect special input ports to special output ports
317 // ----------------------------------------------------------------------
318
319 void BlockDriverComponentBase ::
320 set_Time_OutputPort(
321 NATIVE_INT_TYPE portNum,
323 )
324 {
325 FW_ASSERT(
326 portNum < this->getNum_Time_OutputPorts(),
327 static_cast<FwAssertArgType>(portNum)
328 );
329
330 this->m_Time_OutputPort[portNum].addCallPort(port);
331 }
332
333 void BlockDriverComponentBase ::
334 set_Tlm_OutputPort(
335 NATIVE_INT_TYPE portNum,
336 Fw::InputTlmPort* port
337 )
338 {
339 FW_ASSERT(
340 portNum < this->getNum_Tlm_OutputPorts(),
341 static_cast<FwAssertArgType>(portNum)
342 );
343
344 this->m_Tlm_OutputPort[portNum].addCallPort(port);
345 }
346
347 // ----------------------------------------------------------------------
348 // Connect typed input ports to typed output ports
349 // ----------------------------------------------------------------------
350
351 void BlockDriverComponentBase ::
352 set_BufferOut_OutputPort(
353 NATIVE_INT_TYPE portNum,
355 )
356 {
357 FW_ASSERT(
358 portNum < this->getNum_BufferOut_OutputPorts(),
359 static_cast<FwAssertArgType>(portNum)
360 );
361
362 this->m_BufferOut_OutputPort[portNum].addCallPort(port);
363 }
364
365 void BlockDriverComponentBase ::
366 set_CycleOut_OutputPort(
367 NATIVE_INT_TYPE portNum,
369 )
370 {
371 FW_ASSERT(
372 portNum < this->getNum_CycleOut_OutputPorts(),
373 static_cast<FwAssertArgType>(portNum)
374 );
375
376 this->m_CycleOut_OutputPort[portNum].addCallPort(port);
377 }
378
379 void BlockDriverComponentBase ::
380 set_PingOut_OutputPort(
381 NATIVE_INT_TYPE portNum,
383 )
384 {
385 FW_ASSERT(
386 portNum < this->getNum_PingOut_OutputPorts(),
387 static_cast<FwAssertArgType>(portNum)
388 );
389
390 this->m_PingOut_OutputPort[portNum].addCallPort(port);
391 }
392
393#if FW_PORT_SERIALIZATION
394
395 // ----------------------------------------------------------------------
396 // Connect serial input ports to special output ports
397 // ----------------------------------------------------------------------
398
399 void BlockDriverComponentBase ::
400 set_Time_OutputPort(
401 NATIVE_INT_TYPE portNum,
402 Fw::InputSerializePort* port
403 )
404 {
405 FW_ASSERT(
406 portNum < this->getNum_Time_OutputPorts(),
407 static_cast<FwAssertArgType>(portNum)
408 );
409
410 this->m_Time_OutputPort[portNum].registerSerialPort(port);
411 }
412
413 void BlockDriverComponentBase ::
414 set_Tlm_OutputPort(
415 NATIVE_INT_TYPE portNum,
416 Fw::InputSerializePort* port
417 )
418 {
419 FW_ASSERT(
420 portNum < this->getNum_Tlm_OutputPorts(),
421 static_cast<FwAssertArgType>(portNum)
422 );
423
424 this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
425 }
426
427#endif
428
429#if FW_PORT_SERIALIZATION
430
431 // ----------------------------------------------------------------------
432 // Connect serial input ports to typed output ports
433 // ----------------------------------------------------------------------
434
435 void BlockDriverComponentBase ::
436 set_BufferOut_OutputPort(
437 NATIVE_INT_TYPE portNum,
438 Fw::InputSerializePort* port
439 )
440 {
441 FW_ASSERT(
442 portNum < this->getNum_BufferOut_OutputPorts(),
443 static_cast<FwAssertArgType>(portNum)
444 );
445
446 this->m_BufferOut_OutputPort[portNum].registerSerialPort(port);
447 }
448
449 void BlockDriverComponentBase ::
450 set_CycleOut_OutputPort(
451 NATIVE_INT_TYPE portNum,
452 Fw::InputSerializePort* port
453 )
454 {
455 FW_ASSERT(
456 portNum < this->getNum_CycleOut_OutputPorts(),
457 static_cast<FwAssertArgType>(portNum)
458 );
459
460 this->m_CycleOut_OutputPort[portNum].registerSerialPort(port);
461 }
462
463 void BlockDriverComponentBase ::
464 set_PingOut_OutputPort(
465 NATIVE_INT_TYPE portNum,
466 Fw::InputSerializePort* port
467 )
468 {
469 FW_ASSERT(
470 portNum < this->getNum_PingOut_OutputPorts(),
471 static_cast<FwAssertArgType>(portNum)
472 );
473
474 this->m_PingOut_OutputPort[portNum].registerSerialPort(port);
475 }
476
477#endif
478
479 // ----------------------------------------------------------------------
480 // Component construction and destruction
481 // ----------------------------------------------------------------------
482
483 BlockDriverComponentBase ::
484 BlockDriverComponentBase(const char* compName) :
485 Fw::ActiveComponentBase(compName)
486 {
487
488 }
489
490 BlockDriverComponentBase ::
491 ~BlockDriverComponentBase()
492 {
493
494 }
495
496 // ----------------------------------------------------------------------
497 // Getters for numbers of typed input ports
498 // ----------------------------------------------------------------------
499
500 NATIVE_INT_TYPE BlockDriverComponentBase ::
501 getNum_BufferIn_InputPorts()
502 {
503 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_BufferIn_InputPort));
504 }
505
506 NATIVE_INT_TYPE BlockDriverComponentBase ::
507 getNum_PingIn_InputPorts()
508 {
509 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_PingIn_InputPort));
510 }
511
512 NATIVE_INT_TYPE BlockDriverComponentBase ::
513 getNum_Sched_InputPorts()
514 {
515 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Sched_InputPort));
516 }
517
518 // ----------------------------------------------------------------------
519 // Getters for numbers of special output ports
520 // ----------------------------------------------------------------------
521
522 NATIVE_INT_TYPE BlockDriverComponentBase ::
523 getNum_Time_OutputPorts()
524 {
525 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
526 }
527
528 NATIVE_INT_TYPE BlockDriverComponentBase ::
529 getNum_Tlm_OutputPorts()
530 {
531 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Tlm_OutputPort));
532 }
533
534 // ----------------------------------------------------------------------
535 // Getters for numbers of typed output ports
536 // ----------------------------------------------------------------------
537
538 NATIVE_INT_TYPE BlockDriverComponentBase ::
539 getNum_BufferOut_OutputPorts()
540 {
541 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_BufferOut_OutputPort));
542 }
543
544 NATIVE_INT_TYPE BlockDriverComponentBase ::
545 getNum_CycleOut_OutputPorts()
546 {
547 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CycleOut_OutputPort));
548 }
549
550 NATIVE_INT_TYPE BlockDriverComponentBase ::
551 getNum_PingOut_OutputPorts()
552 {
553 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_PingOut_OutputPort));
554 }
555
556 // ----------------------------------------------------------------------
557 // Connection status queries for special output ports
558 // ----------------------------------------------------------------------
559
560 bool BlockDriverComponentBase ::
561 isConnected_Time_OutputPort(NATIVE_INT_TYPE portNum)
562 {
563 FW_ASSERT(
564 portNum < this->getNum_Time_OutputPorts(),
565 static_cast<FwAssertArgType>(portNum)
566 );
567
568 return this->m_Time_OutputPort[portNum].isConnected();
569 }
570
571 bool BlockDriverComponentBase ::
572 isConnected_Tlm_OutputPort(NATIVE_INT_TYPE portNum)
573 {
574 FW_ASSERT(
575 portNum < this->getNum_Tlm_OutputPorts(),
576 static_cast<FwAssertArgType>(portNum)
577 );
578
579 return this->m_Tlm_OutputPort[portNum].isConnected();
580 }
581
582 // ----------------------------------------------------------------------
583 // Connection status queries for typed output ports
584 // ----------------------------------------------------------------------
585
586 bool BlockDriverComponentBase ::
587 isConnected_BufferOut_OutputPort(NATIVE_INT_TYPE portNum)
588 {
589 FW_ASSERT(
590 portNum < this->getNum_BufferOut_OutputPorts(),
591 static_cast<FwAssertArgType>(portNum)
592 );
593
594 return this->m_BufferOut_OutputPort[portNum].isConnected();
595 }
596
597 bool BlockDriverComponentBase ::
598 isConnected_CycleOut_OutputPort(NATIVE_INT_TYPE portNum)
599 {
600 FW_ASSERT(
601 portNum < this->getNum_CycleOut_OutputPorts(),
602 static_cast<FwAssertArgType>(portNum)
603 );
604
605 return this->m_CycleOut_OutputPort[portNum].isConnected();
606 }
607
608 bool BlockDriverComponentBase ::
609 isConnected_PingOut_OutputPort(NATIVE_INT_TYPE portNum)
610 {
611 FW_ASSERT(
612 portNum < this->getNum_PingOut_OutputPorts(),
613 static_cast<FwAssertArgType>(portNum)
614 );
615
616 return this->m_PingOut_OutputPort[portNum].isConnected();
617 }
618
619 // ----------------------------------------------------------------------
620 // Port handler base-class functions for typed input ports
621 //
622 // Call these functions directly to bypass the corresponding ports
623 // ----------------------------------------------------------------------
624
625 void BlockDriverComponentBase ::
626 BufferIn_handlerBase(
627 NATIVE_INT_TYPE portNum,
628 Drv::DataBuffer& buff
629 )
630 {
631 // Make sure port number is valid
632 FW_ASSERT(
633 portNum < this->getNum_BufferIn_InputPorts(),
634 static_cast<FwAssertArgType>(portNum)
635 );
636
637 // Call pre-message hook
638 BufferIn_preMsgHook(
639 portNum,
640 buff
641 );
642 ComponentIpcSerializableBuffer msg;
644
645 // Serialize message ID
646 _status = msg.serialize(
647 static_cast<NATIVE_INT_TYPE>(BUFFERIN_DATABUFFER)
648 );
649 FW_ASSERT(
650 _status == Fw::FW_SERIALIZE_OK,
651 static_cast<FwAssertArgType>(_status)
652 );
653
654 // Serialize port number
655 _status = msg.serialize(portNum);
656 FW_ASSERT(
657 _status == Fw::FW_SERIALIZE_OK,
658 static_cast<FwAssertArgType>(_status)
659 );
660
661 // Serialize argument buff
662 _status = msg.serialize(buff);
663 FW_ASSERT(
664 _status == Fw::FW_SERIALIZE_OK,
665 static_cast<FwAssertArgType>(_status)
666 );
667
668 // Send message
670 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
671
672 FW_ASSERT(
673 qStatus == Os::Queue::QUEUE_OK,
674 static_cast<FwAssertArgType>(qStatus)
675 );
676 }
677
678 void BlockDriverComponentBase ::
679 PingIn_handlerBase(
680 NATIVE_INT_TYPE portNum,
681 U32 key
682 )
683 {
684 // Make sure port number is valid
685 FW_ASSERT(
686 portNum < this->getNum_PingIn_InputPorts(),
687 static_cast<FwAssertArgType>(portNum)
688 );
689
690 // Call pre-message hook
691 PingIn_preMsgHook(
692 portNum,
693 key
694 );
695 ComponentIpcSerializableBuffer msg;
697
698 // Serialize message ID
699 _status = msg.serialize(
700 static_cast<NATIVE_INT_TYPE>(PINGIN_PING)
701 );
702 FW_ASSERT(
703 _status == Fw::FW_SERIALIZE_OK,
704 static_cast<FwAssertArgType>(_status)
705 );
706
707 // Serialize port number
708 _status = msg.serialize(portNum);
709 FW_ASSERT(
710 _status == Fw::FW_SERIALIZE_OK,
711 static_cast<FwAssertArgType>(_status)
712 );
713
714 // Serialize argument key
715 _status = msg.serialize(key);
716 FW_ASSERT(
717 _status == Fw::FW_SERIALIZE_OK,
718 static_cast<FwAssertArgType>(_status)
719 );
720
721 // Send message
723 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
724
725 FW_ASSERT(
726 qStatus == Os::Queue::QUEUE_OK,
727 static_cast<FwAssertArgType>(qStatus)
728 );
729 }
730
731 void BlockDriverComponentBase ::
732 Sched_handlerBase(
733 NATIVE_INT_TYPE portNum,
734 NATIVE_UINT_TYPE context
735 )
736 {
737 // Make sure port number is valid
738 FW_ASSERT(
739 portNum < this->getNum_Sched_InputPorts(),
740 static_cast<FwAssertArgType>(portNum)
741 );
742
743 // Call pre-message hook
744 Sched_preMsgHook(
745 portNum,
746 context
747 );
748 ComponentIpcSerializableBuffer msg;
750
751 // Serialize message ID
752 _status = msg.serialize(
753 static_cast<NATIVE_INT_TYPE>(SCHED_SCHED)
754 );
755 FW_ASSERT(
756 _status == Fw::FW_SERIALIZE_OK,
757 static_cast<FwAssertArgType>(_status)
758 );
759
760 // Serialize port number
761 _status = msg.serialize(portNum);
762 FW_ASSERT(
763 _status == Fw::FW_SERIALIZE_OK,
764 static_cast<FwAssertArgType>(_status)
765 );
766
767 // Serialize argument context
768 _status = msg.serialize(context);
769 FW_ASSERT(
770 _status == Fw::FW_SERIALIZE_OK,
771 static_cast<FwAssertArgType>(_status)
772 );
773
774 // Send message
776 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
777
778 FW_ASSERT(
779 qStatus == Os::Queue::QUEUE_OK,
780 static_cast<FwAssertArgType>(qStatus)
781 );
782 }
783
784 // ----------------------------------------------------------------------
785 // Pre-message hooks for typed async input ports
786 //
787 // Each of these functions is invoked just before processing a message
788 // on the corresponding port. By default, they do nothing. You can
789 // override them to provide specific pre-message behavior.
790 // ----------------------------------------------------------------------
791
792 void BlockDriverComponentBase ::
793 BufferIn_preMsgHook(
794 NATIVE_INT_TYPE portNum,
795 Drv::DataBuffer& buff
796 )
797 {
798 // Default: no-op
799 }
800
801 void BlockDriverComponentBase ::
802 PingIn_preMsgHook(
803 NATIVE_INT_TYPE portNum,
804 U32 key
805 )
806 {
807 // Default: no-op
808 }
809
810 void BlockDriverComponentBase ::
811 Sched_preMsgHook(
812 NATIVE_INT_TYPE portNum,
813 NATIVE_UINT_TYPE context
814 )
815 {
816 // Default: no-op
817 }
818
819 // ----------------------------------------------------------------------
820 // Invocation functions for typed output ports
821 // ----------------------------------------------------------------------
822
823 void BlockDriverComponentBase ::
824 BufferOut_out(
825 NATIVE_INT_TYPE portNum,
826 Drv::DataBuffer& buff
827 )
828 {
829 FW_ASSERT(
830 portNum < this->getNum_BufferOut_OutputPorts(),
831 static_cast<FwAssertArgType>(portNum)
832 );
833 this->m_BufferOut_OutputPort[portNum].invoke(
834 buff
835 );
836 }
837
838 void BlockDriverComponentBase ::
839 CycleOut_out(
840 NATIVE_INT_TYPE portNum,
841 Svc::TimerVal& cycleStart
842 )
843 {
844 FW_ASSERT(
845 portNum < this->getNum_CycleOut_OutputPorts(),
846 static_cast<FwAssertArgType>(portNum)
847 );
848 this->m_CycleOut_OutputPort[portNum].invoke(
849 cycleStart
850 );
851 }
852
853 void BlockDriverComponentBase ::
854 PingOut_out(
855 NATIVE_INT_TYPE portNum,
856 U32 key
857 )
858 {
859 FW_ASSERT(
860 portNum < this->getNum_PingOut_OutputPorts(),
861 static_cast<FwAssertArgType>(portNum)
862 );
863 this->m_PingOut_OutputPort[portNum].invoke(
864 key
865 );
866 }
867
868 // ----------------------------------------------------------------------
869 // Internal interface base-class functions
870 // ----------------------------------------------------------------------
871
872 void BlockDriverComponentBase ::
873 InterruptReport_internalInterfaceInvoke(U32 interrupt)
874 {
875 ComponentIpcSerializableBuffer msg;
877
878 // Serialize the message ID
879 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(INT_IF_INTERRUPTREPORT));
880 FW_ASSERT (
881 _status == Fw::FW_SERIALIZE_OK,
882 static_cast<FwAssertArgType>(_status)
883 );
884
885 // Fake port number to make message dequeue work
886 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(0));
887 FW_ASSERT (
888 _status == Fw::FW_SERIALIZE_OK,
889 static_cast<FwAssertArgType>(_status)
890 );
891
892 _status = msg.serialize(interrupt);
893 FW_ASSERT(
894 _status == Fw::FW_SERIALIZE_OK,
895 static_cast<FwAssertArgType>(_status)
896 );
897
898 // Send message
900 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 1, _block);
901
902 FW_ASSERT(
903 qStatus == Os::Queue::QUEUE_OK,
904 static_cast<FwAssertArgType>(qStatus)
905 );
906 }
907
908 // ----------------------------------------------------------------------
909 // Telemetry write functions
910 // ----------------------------------------------------------------------
911
912 void BlockDriverComponentBase ::
913 tlmWrite_BD_Cycles(
914 U32 arg,
915 Fw::Time _tlmTime
916 )
917 {
918 if (this->m_Tlm_OutputPort[0].isConnected()) {
919 if (
920 this->m_Time_OutputPort[0].isConnected() &&
921 (_tlmTime == Fw::ZERO_TIME)
922 ) {
923 this->m_Time_OutputPort[0].invoke(_tlmTime);
924 }
925
926 Fw::TlmBuffer _tlmBuff;
927 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
928 FW_ASSERT(
929 _stat == Fw::FW_SERIALIZE_OK,
930 static_cast<FwAssertArgType>(_stat)
931 );
932
933 FwChanIdType _id;
934
935 _id = this->getIdBase() + CHANNELID_BD_CYCLES;
936
937 this->m_Tlm_OutputPort[0].invoke(
938 _id,
939 _tlmTime,
940 _tlmBuff
941 );
942 }
943 }
944
945 // ----------------------------------------------------------------------
946 // Time
947 // ----------------------------------------------------------------------
948
949 Fw::Time BlockDriverComponentBase ::
950 getTime()
951 {
952 if (this->m_Time_OutputPort[0].isConnected()) {
953 Fw::Time _time;
954 this->m_Time_OutputPort[0].invoke(_time);
955 return _time;
956 }
957 else {
958 return Fw::Time(TB_NONE, 0, 0);
959 }
960 }
961
962 // ----------------------------------------------------------------------
963 // Message dispatch functions
964 // ----------------------------------------------------------------------
965
966 Fw::QueuedComponentBase::MsgDispatchStatus BlockDriverComponentBase ::
967 doDispatch()
968 {
969 ComponentIpcSerializableBuffer msg;
970 NATIVE_INT_TYPE priority = 0;
971
972 Os::Queue::QueueStatus msgStatus = this->m_queue.receive(
973 msg,
974 priority,
976 );
977 FW_ASSERT(
978 msgStatus == Os::Queue::QUEUE_OK,
979 static_cast<FwAssertArgType>(msgStatus)
980 );
981
982 // Reset to beginning of buffer
983 msg.resetDeser();
984
985 NATIVE_INT_TYPE desMsg = 0;
986 Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
987 FW_ASSERT(
988 deserStatus == Fw::FW_SERIALIZE_OK,
989 static_cast<FwAssertArgType>(deserStatus)
990 );
991
992 MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
993
994 if (msgType == BLOCKDRIVER_COMPONENT_EXIT) {
995 return MSG_DISPATCH_EXIT;
996 }
997
998 NATIVE_INT_TYPE portNum = 0;
999 deserStatus = msg.deserialize(portNum);
1000 FW_ASSERT(
1001 deserStatus == Fw::FW_SERIALIZE_OK,
1002 static_cast<FwAssertArgType>(deserStatus)
1003 );
1004
1005 switch (msgType) {
1006 // Handle async input port BufferIn
1007 case BUFFERIN_DATABUFFER: {
1008 // Deserialize argument buff
1009 Drv::DataBuffer buff;
1010 deserStatus = msg.deserialize(buff);
1011 FW_ASSERT(
1012 deserStatus == Fw::FW_SERIALIZE_OK,
1013 static_cast<FwAssertArgType>(deserStatus)
1014 );
1015 // Call handler function
1016 this->BufferIn_handler(
1017 portNum,
1018 buff
1019 );
1020
1021 break;
1022 }
1023
1024 // Handle async input port PingIn
1025 case PINGIN_PING: {
1026 // Deserialize argument key
1027 U32 key;
1028 deserStatus = msg.deserialize(key);
1029 FW_ASSERT(
1030 deserStatus == Fw::FW_SERIALIZE_OK,
1031 static_cast<FwAssertArgType>(deserStatus)
1032 );
1033 // Call handler function
1034 this->PingIn_handler(
1035 portNum,
1036 key
1037 );
1038
1039 break;
1040 }
1041
1042 // Handle async input port Sched
1043 case SCHED_SCHED: {
1044 // Deserialize argument context
1045 NATIVE_UINT_TYPE context;
1046 deserStatus = msg.deserialize(context);
1047 FW_ASSERT(
1048 deserStatus == Fw::FW_SERIALIZE_OK,
1049 static_cast<FwAssertArgType>(deserStatus)
1050 );
1051 // Call handler function
1052 this->Sched_handler(
1053 portNum,
1054 context
1055 );
1056
1057 break;
1058 }
1059
1060 // Handle internal interface InterruptReport
1061 case INT_IF_INTERRUPTREPORT: {
1062 U32 interrupt;
1063 deserStatus = msg.deserialize(interrupt);
1064
1065 // Internal interface should always deserialize
1066 FW_ASSERT(
1067 Fw::FW_SERIALIZE_OK == deserStatus,
1068 static_cast<FwAssertArgType>(deserStatus)
1069 );
1070
1071 // Make sure there was no data left over.
1072 // That means the buffer size was incorrect.
1073 FW_ASSERT(
1074 msg.getBuffLeft() == 0,
1075 static_cast<FwAssertArgType>(msg.getBuffLeft())
1076 );
1077
1078 // Call handler function
1079 this->InterruptReport_internalInterfaceHandler(
1080 interrupt
1081 );
1082
1083 break;
1084 }
1085
1086 default:
1087 return MSG_DISPATCH_ERROR;
1088 }
1089
1090 return MSG_DISPATCH_OK;
1091 }
1092
1093 // ----------------------------------------------------------------------
1094 // Calls for messages received on typed input ports
1095 // ----------------------------------------------------------------------
1096
1097 void BlockDriverComponentBase ::
1098 m_p_BufferIn_in(
1099 Fw::PassiveComponentBase* callComp,
1100 NATIVE_INT_TYPE portNum,
1101 Drv::DataBuffer& buff
1102 )
1103 {
1104 FW_ASSERT(callComp);
1105 BlockDriverComponentBase* compPtr = static_cast<BlockDriverComponentBase*>(callComp);
1106 compPtr->BufferIn_handlerBase(
1107 portNum,
1108 buff
1109 );
1110 }
1111
1112 void BlockDriverComponentBase ::
1113 m_p_PingIn_in(
1114 Fw::PassiveComponentBase* callComp,
1115 NATIVE_INT_TYPE portNum,
1116 U32 key
1117 )
1118 {
1119 FW_ASSERT(callComp);
1120 BlockDriverComponentBase* compPtr = static_cast<BlockDriverComponentBase*>(callComp);
1121 compPtr->PingIn_handlerBase(
1122 portNum,
1123 key
1124 );
1125 }
1126
1127 void BlockDriverComponentBase ::
1128 m_p_Sched_in(
1129 Fw::PassiveComponentBase* callComp,
1130 NATIVE_INT_TYPE portNum,
1131 NATIVE_UINT_TYPE context
1132 )
1133 {
1134 FW_ASSERT(callComp);
1135 BlockDriverComponentBase* compPtr = static_cast<BlockDriverComponentBase*>(callComp);
1136 compPtr->Sched_handlerBase(
1137 portNum,
1138 context
1139 );
1140 }
1141
1142}
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
U8 BYTE
byte type
Definition BasicTypes.h:27
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition BasicTypes.h:66
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
BYTE PingInPortSize[Svc::InputPingPort::SERIALIZED_SIZE]
BYTE InterruptReportIntIfSize[sizeof(U32)]
BYTE BufferInPortSize[Drv::InputDataBufferPort::SERIALIZED_SIZE]
BYTE SchedPortSize[Svc::InputSchedPort::SERIALIZED_SIZE]
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
#define PRI_PlatformIntType
@ TB_NONE
No time base has been established.
Definition FpConfig.h:39
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:21
U32 FwChanIdType
Definition FpConfig.h:59
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
@ ACTIVE_COMPONENT_EXIT
message to exit active component task
void init()
Object initializer.
Definition ObjBase.cpp:27
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
@ QUEUE_OK
message sent/received okay
Definition Queue.hpp:28
QueueBlocking
Definition Queue.hpp:40
@ QUEUE_BLOCKING
Queue receive blocks until a message arrives.
Definition Queue.hpp:41
@ QUEUE_NONBLOCKING
Queue receive always returns even if there is no message.
Definition Queue.hpp:42
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Serializable class for carrying timer values.
Definition TimerVal.hpp:22
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
const Time ZERO_TIME
Definition Time.cpp:5