F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GroundInterfaceComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title GroundInterfaceComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for GroundInterface component base class
5// ======================================================================
6
7#include <cstdio>
8
10#include "Fw/Types/Assert.hpp"
11#if FW_ENABLE_TEXT_LOGGING
12#include "Fw/Types/String.hpp"
13#endif
14
15namespace Svc {
16
17 namespace {
18 // Get the max size by doing a union of the input and internal port serialization sizes
19 union BuffUnion {
20 BYTE downlinkPortPortSize[Fw::InputComPort::SERIALIZED_SIZE];
21 BYTE fileDownlinkBufferSendInPortSize[Fw::InputBufferSendPort::SERIALIZED_SIZE];
24 };
25
26 // Define a message buffer class large enough to handle all the
27 // asynchronous inputs to the component
28 class ComponentIpcSerializableBuffer :
30 {
31
32 public:
33
34 enum {
35 // Max. message size = size of data + message id + port
36 SERIALIZATION_SIZE =
37 sizeof(BuffUnion) +
38 sizeof(NATIVE_INT_TYPE) +
39 sizeof(NATIVE_INT_TYPE)
40 };
41
42 NATIVE_UINT_TYPE getBuffCapacity() const {
43 return sizeof(m_buff);
44 }
45
46 U8* getBuffAddr() {
47 return m_buff;
48 }
49
50 const U8* getBuffAddr() const {
51 return m_buff;
52 }
53
54 private:
55 // Should be the max of all the input ports serialized sizes...
56 U8 m_buff[SERIALIZATION_SIZE];
57
58 };
59 }
60
61 // ----------------------------------------------------------------------
62 // Component initialization
63 // ----------------------------------------------------------------------
64
65 void GroundInterfaceComponentBase ::
66 init(NATIVE_INT_TYPE instance)
67 {
68 // Initialize base class
70
71 // Connect input port downlinkPort
72 for (
73 PlatformIntType port = 0;
74 port < static_cast<PlatformIntType>(this->getNum_downlinkPort_InputPorts());
75 port++
76 ) {
77 this->m_downlinkPort_InputPort[port].init();
78 this->m_downlinkPort_InputPort[port].addCallComp(
79 this,
80 m_p_downlinkPort_in
81 );
82 this->m_downlinkPort_InputPort[port].setPortNum(port);
83
84#if FW_OBJECT_NAMES == 1
85 char portName[120];
86 (void) snprintf(
87 portName,
88 sizeof(portName),
89 "%s_downlinkPort_InputPort[%" PRI_PlatformIntType "]",
90 this->m_objName,
91 port
92 );
93 this->m_downlinkPort_InputPort[port].setObjName(portName);
94#endif
95 }
96
97 // Connect input port fileDownlinkBufferSendIn
98 for (
99 PlatformIntType port = 0;
100 port < static_cast<PlatformIntType>(this->getNum_fileDownlinkBufferSendIn_InputPorts());
101 port++
102 ) {
103 this->m_fileDownlinkBufferSendIn_InputPort[port].init();
104 this->m_fileDownlinkBufferSendIn_InputPort[port].addCallComp(
105 this,
106 m_p_fileDownlinkBufferSendIn_in
107 );
108 this->m_fileDownlinkBufferSendIn_InputPort[port].setPortNum(port);
109
110#if FW_OBJECT_NAMES == 1
111 char portName[120];
112 (void) snprintf(
113 portName,
114 sizeof(portName),
115 "%s_fileDownlinkBufferSendIn_InputPort[%" PRI_PlatformIntType "]",
116 this->m_objName,
117 port
118 );
119 this->m_fileDownlinkBufferSendIn_InputPort[port].setObjName(portName);
120#endif
121 }
122
123 // Connect input port readCallback
124 for (
125 PlatformIntType port = 0;
126 port < static_cast<PlatformIntType>(this->getNum_readCallback_InputPorts());
127 port++
128 ) {
129 this->m_readCallback_InputPort[port].init();
130 this->m_readCallback_InputPort[port].addCallComp(
131 this,
132 m_p_readCallback_in
133 );
134 this->m_readCallback_InputPort[port].setPortNum(port);
135
136#if FW_OBJECT_NAMES == 1
137 char portName[120];
138 (void) snprintf(
139 portName,
140 sizeof(portName),
141 "%s_readCallback_InputPort[%" PRI_PlatformIntType "]",
142 this->m_objName,
143 port
144 );
145 this->m_readCallback_InputPort[port].setObjName(portName);
146#endif
147 }
148
149 // Connect input port schedIn
150 for (
151 PlatformIntType port = 0;
152 port < static_cast<PlatformIntType>(this->getNum_schedIn_InputPorts());
153 port++
154 ) {
155 this->m_schedIn_InputPort[port].init();
156 this->m_schedIn_InputPort[port].addCallComp(
157 this,
158 m_p_schedIn_in
159 );
160 this->m_schedIn_InputPort[port].setPortNum(port);
161
162#if FW_OBJECT_NAMES == 1
163 char portName[120];
164 (void) snprintf(
165 portName,
166 sizeof(portName),
167 "%s_schedIn_InputPort[%" PRI_PlatformIntType "]",
168 this->m_objName,
169 port
170 );
171 this->m_schedIn_InputPort[port].setObjName(portName);
172#endif
173 }
174
175 // Connect output port Log
176 for (
177 PlatformIntType port = 0;
178 port < static_cast<PlatformIntType>(this->getNum_Log_OutputPorts());
179 port++
180 ) {
181 this->m_Log_OutputPort[port].init();
182
183#if FW_OBJECT_NAMES == 1
184 char portName[120];
185 (void) snprintf(
186 portName,
187 sizeof(portName),
188 "%s_Log_OutputPort[%" PRI_PlatformIntType "]",
189 this->m_objName,
190 port
191 );
192 this->m_Log_OutputPort[port].setObjName(portName);
193#endif
194 }
195
196#if FW_ENABLE_TEXT_LOGGING == 1
197 // Connect output port LogText
198 for (
199 PlatformIntType port = 0;
200 port < static_cast<PlatformIntType>(this->getNum_LogText_OutputPorts());
201 port++
202 ) {
203 this->m_LogText_OutputPort[port].init();
204
205#if FW_OBJECT_NAMES == 1
206 char portName[120];
207 (void) snprintf(
208 portName,
209 sizeof(portName),
210 "%s_LogText_OutputPort[%" PRI_PlatformIntType "]",
211 this->m_objName,
212 port
213 );
214 this->m_LogText_OutputPort[port].setObjName(portName);
215#endif
216 }
217#endif
218
219 // Connect output port Time
220 for (
221 PlatformIntType port = 0;
222 port < static_cast<PlatformIntType>(this->getNum_Time_OutputPorts());
223 port++
224 ) {
225 this->m_Time_OutputPort[port].init();
226
227#if FW_OBJECT_NAMES == 1
228 char portName[120];
229 (void) snprintf(
230 portName,
231 sizeof(portName),
232 "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
233 this->m_objName,
234 port
235 );
236 this->m_Time_OutputPort[port].setObjName(portName);
237#endif
238 }
239
240 // Connect output port fileDownlinkBufferSendOut
241 for (
242 PlatformIntType port = 0;
243 port < static_cast<PlatformIntType>(this->getNum_fileDownlinkBufferSendOut_OutputPorts());
244 port++
245 ) {
246 this->m_fileDownlinkBufferSendOut_OutputPort[port].init();
247
248#if FW_OBJECT_NAMES == 1
249 char portName[120];
250 (void) snprintf(
251 portName,
252 sizeof(portName),
253 "%s_fileDownlinkBufferSendOut_OutputPort[%" PRI_PlatformIntType "]",
254 this->m_objName,
255 port
256 );
257 this->m_fileDownlinkBufferSendOut_OutputPort[port].setObjName(portName);
258#endif
259 }
260
261 // Connect output port fileUplinkBufferGet
262 for (
263 PlatformIntType port = 0;
264 port < static_cast<PlatformIntType>(this->getNum_fileUplinkBufferGet_OutputPorts());
265 port++
266 ) {
267 this->m_fileUplinkBufferGet_OutputPort[port].init();
268
269#if FW_OBJECT_NAMES == 1
270 char portName[120];
271 (void) snprintf(
272 portName,
273 sizeof(portName),
274 "%s_fileUplinkBufferGet_OutputPort[%" PRI_PlatformIntType "]",
275 this->m_objName,
276 port
277 );
278 this->m_fileUplinkBufferGet_OutputPort[port].setObjName(portName);
279#endif
280 }
281
282 // Connect output port fileUplinkBufferSendOut
283 for (
284 PlatformIntType port = 0;
285 port < static_cast<PlatformIntType>(this->getNum_fileUplinkBufferSendOut_OutputPorts());
286 port++
287 ) {
288 this->m_fileUplinkBufferSendOut_OutputPort[port].init();
289
290#if FW_OBJECT_NAMES == 1
291 char portName[120];
292 (void) snprintf(
293 portName,
294 sizeof(portName),
295 "%s_fileUplinkBufferSendOut_OutputPort[%" PRI_PlatformIntType "]",
296 this->m_objName,
297 port
298 );
299 this->m_fileUplinkBufferSendOut_OutputPort[port].setObjName(portName);
300#endif
301 }
302
303 // Connect output port readPoll
304 for (
305 PlatformIntType port = 0;
306 port < static_cast<PlatformIntType>(this->getNum_readPoll_OutputPorts());
307 port++
308 ) {
309 this->m_readPoll_OutputPort[port].init();
310
311#if FW_OBJECT_NAMES == 1
312 char portName[120];
313 (void) snprintf(
314 portName,
315 sizeof(portName),
316 "%s_readPoll_OutputPort[%" PRI_PlatformIntType "]",
317 this->m_objName,
318 port
319 );
320 this->m_readPoll_OutputPort[port].setObjName(portName);
321#endif
322 }
323
324 // Connect output port uplinkPort
325 for (
326 PlatformIntType port = 0;
327 port < static_cast<PlatformIntType>(this->getNum_uplinkPort_OutputPorts());
328 port++
329 ) {
330 this->m_uplinkPort_OutputPort[port].init();
331
332#if FW_OBJECT_NAMES == 1
333 char portName[120];
334 (void) snprintf(
335 portName,
336 sizeof(portName),
337 "%s_uplinkPort_OutputPort[%" PRI_PlatformIntType "]",
338 this->m_objName,
339 port
340 );
341 this->m_uplinkPort_OutputPort[port].setObjName(portName);
342#endif
343 }
344
345 // Connect output port write
346 for (
347 PlatformIntType port = 0;
348 port < static_cast<PlatformIntType>(this->getNum_write_OutputPorts());
349 port++
350 ) {
351 this->m_write_OutputPort[port].init();
352
353#if FW_OBJECT_NAMES == 1
354 char portName[120];
355 (void) snprintf(
356 portName,
357 sizeof(portName),
358 "%s_write_OutputPort[%" PRI_PlatformIntType "]",
359 this->m_objName,
360 port
361 );
362 this->m_write_OutputPort[port].setObjName(portName);
363#endif
364 }
365 }
366
367 // ----------------------------------------------------------------------
368 // Getters for typed input ports
369 // ----------------------------------------------------------------------
370
371 Fw::InputComPort* GroundInterfaceComponentBase ::
372 get_downlinkPort_InputPort(NATIVE_INT_TYPE portNum)
373 {
374 FW_ASSERT(
375 portNum < this->getNum_downlinkPort_InputPorts(),
376 static_cast<FwAssertArgType>(portNum)
377 );
378
379 return &this->m_downlinkPort_InputPort[portNum];
380 }
381
382 Fw::InputBufferSendPort* GroundInterfaceComponentBase ::
383 get_fileDownlinkBufferSendIn_InputPort(NATIVE_INT_TYPE portNum)
384 {
385 FW_ASSERT(
386 portNum < this->getNum_fileDownlinkBufferSendIn_InputPorts(),
387 static_cast<FwAssertArgType>(portNum)
388 );
389
390 return &this->m_fileDownlinkBufferSendIn_InputPort[portNum];
391 }
392
393 Fw::InputBufferSendPort* GroundInterfaceComponentBase ::
394 get_readCallback_InputPort(NATIVE_INT_TYPE portNum)
395 {
396 FW_ASSERT(
397 portNum < this->getNum_readCallback_InputPorts(),
398 static_cast<FwAssertArgType>(portNum)
399 );
400
401 return &this->m_readCallback_InputPort[portNum];
402 }
403
404 Svc::InputSchedPort* GroundInterfaceComponentBase ::
405 get_schedIn_InputPort(NATIVE_INT_TYPE portNum)
406 {
407 FW_ASSERT(
408 portNum < this->getNum_schedIn_InputPorts(),
409 static_cast<FwAssertArgType>(portNum)
410 );
411
412 return &this->m_schedIn_InputPort[portNum];
413 }
414
415 // ----------------------------------------------------------------------
416 // Connect special input ports to special output ports
417 // ----------------------------------------------------------------------
418
419 void GroundInterfaceComponentBase ::
420 set_Log_OutputPort(
421 NATIVE_INT_TYPE portNum,
422 Fw::InputLogPort* port
423 )
424 {
425 FW_ASSERT(
426 portNum < this->getNum_Log_OutputPorts(),
427 static_cast<FwAssertArgType>(portNum)
428 );
429
430 this->m_Log_OutputPort[portNum].addCallPort(port);
431 }
432
433#if FW_ENABLE_TEXT_LOGGING == 1
434
435 void GroundInterfaceComponentBase ::
436 set_LogText_OutputPort(
437 NATIVE_INT_TYPE portNum,
439 )
440 {
441 FW_ASSERT(
442 portNum < this->getNum_LogText_OutputPorts(),
443 static_cast<FwAssertArgType>(portNum)
444 );
445
446 this->m_LogText_OutputPort[portNum].addCallPort(port);
447 }
448
449#endif
450
451 void GroundInterfaceComponentBase ::
452 set_Time_OutputPort(
453 NATIVE_INT_TYPE portNum,
455 )
456 {
457 FW_ASSERT(
458 portNum < this->getNum_Time_OutputPorts(),
459 static_cast<FwAssertArgType>(portNum)
460 );
461
462 this->m_Time_OutputPort[portNum].addCallPort(port);
463 }
464
465 // ----------------------------------------------------------------------
466 // Connect typed input ports to typed output ports
467 // ----------------------------------------------------------------------
468
469 void GroundInterfaceComponentBase ::
470 set_fileDownlinkBufferSendOut_OutputPort(
471 NATIVE_INT_TYPE portNum,
473 )
474 {
475 FW_ASSERT(
476 portNum < this->getNum_fileDownlinkBufferSendOut_OutputPorts(),
477 static_cast<FwAssertArgType>(portNum)
478 );
479
480 this->m_fileDownlinkBufferSendOut_OutputPort[portNum].addCallPort(port);
481 }
482
483 void GroundInterfaceComponentBase ::
484 set_fileUplinkBufferGet_OutputPort(
485 NATIVE_INT_TYPE portNum,
487 )
488 {
489 FW_ASSERT(
490 portNum < this->getNum_fileUplinkBufferGet_OutputPorts(),
491 static_cast<FwAssertArgType>(portNum)
492 );
493
494 this->m_fileUplinkBufferGet_OutputPort[portNum].addCallPort(port);
495 }
496
497 void GroundInterfaceComponentBase ::
498 set_fileUplinkBufferSendOut_OutputPort(
499 NATIVE_INT_TYPE portNum,
501 )
502 {
503 FW_ASSERT(
504 portNum < this->getNum_fileUplinkBufferSendOut_OutputPorts(),
505 static_cast<FwAssertArgType>(portNum)
506 );
507
508 this->m_fileUplinkBufferSendOut_OutputPort[portNum].addCallPort(port);
509 }
510
511 void GroundInterfaceComponentBase ::
512 set_readPoll_OutputPort(
513 NATIVE_INT_TYPE portNum,
515 )
516 {
517 FW_ASSERT(
518 portNum < this->getNum_readPoll_OutputPorts(),
519 static_cast<FwAssertArgType>(portNum)
520 );
521
522 this->m_readPoll_OutputPort[portNum].addCallPort(port);
523 }
524
525 void GroundInterfaceComponentBase ::
526 set_uplinkPort_OutputPort(
527 NATIVE_INT_TYPE portNum,
528 Fw::InputComPort* port
529 )
530 {
531 FW_ASSERT(
532 portNum < this->getNum_uplinkPort_OutputPorts(),
533 static_cast<FwAssertArgType>(portNum)
534 );
535
536 this->m_uplinkPort_OutputPort[portNum].addCallPort(port);
537 }
538
539 void GroundInterfaceComponentBase ::
540 set_write_OutputPort(
541 NATIVE_INT_TYPE portNum,
543 )
544 {
545 FW_ASSERT(
546 portNum < this->getNum_write_OutputPorts(),
547 static_cast<FwAssertArgType>(portNum)
548 );
549
550 this->m_write_OutputPort[portNum].addCallPort(port);
551 }
552
553#if FW_PORT_SERIALIZATION
554
555 // ----------------------------------------------------------------------
556 // Connect serial input ports to special output ports
557 // ----------------------------------------------------------------------
558
559 void GroundInterfaceComponentBase ::
560 set_Log_OutputPort(
561 NATIVE_INT_TYPE portNum,
562 Fw::InputSerializePort* port
563 )
564 {
565 FW_ASSERT(
566 portNum < this->getNum_Log_OutputPorts(),
567 static_cast<FwAssertArgType>(portNum)
568 );
569
570 this->m_Log_OutputPort[portNum].registerSerialPort(port);
571 }
572
573#if FW_ENABLE_TEXT_LOGGING == 1
574
575 void GroundInterfaceComponentBase ::
576 set_LogText_OutputPort(
577 NATIVE_INT_TYPE portNum,
578 Fw::InputSerializePort* port
579 )
580 {
581 FW_ASSERT(
582 portNum < this->getNum_LogText_OutputPorts(),
583 static_cast<FwAssertArgType>(portNum)
584 );
585
586 this->m_LogText_OutputPort[portNum].registerSerialPort(port);
587 }
588
589#endif
590
591 void GroundInterfaceComponentBase ::
592 set_Time_OutputPort(
593 NATIVE_INT_TYPE portNum,
594 Fw::InputSerializePort* port
595 )
596 {
597 FW_ASSERT(
598 portNum < this->getNum_Time_OutputPorts(),
599 static_cast<FwAssertArgType>(portNum)
600 );
601
602 this->m_Time_OutputPort[portNum].registerSerialPort(port);
603 }
604
605#endif
606
607#if FW_PORT_SERIALIZATION
608
609 // ----------------------------------------------------------------------
610 // Connect serial input ports to typed output ports
611 // ----------------------------------------------------------------------
612
613 void GroundInterfaceComponentBase ::
614 set_fileDownlinkBufferSendOut_OutputPort(
615 NATIVE_INT_TYPE portNum,
616 Fw::InputSerializePort* port
617 )
618 {
619 FW_ASSERT(
620 portNum < this->getNum_fileDownlinkBufferSendOut_OutputPorts(),
621 static_cast<FwAssertArgType>(portNum)
622 );
623
624 this->m_fileDownlinkBufferSendOut_OutputPort[portNum].registerSerialPort(port);
625 }
626
627 void GroundInterfaceComponentBase ::
628 set_fileUplinkBufferSendOut_OutputPort(
629 NATIVE_INT_TYPE portNum,
630 Fw::InputSerializePort* port
631 )
632 {
633 FW_ASSERT(
634 portNum < this->getNum_fileUplinkBufferSendOut_OutputPorts(),
635 static_cast<FwAssertArgType>(portNum)
636 );
637
638 this->m_fileUplinkBufferSendOut_OutputPort[portNum].registerSerialPort(port);
639 }
640
641 void GroundInterfaceComponentBase ::
642 set_readPoll_OutputPort(
643 NATIVE_INT_TYPE portNum,
644 Fw::InputSerializePort* port
645 )
646 {
647 FW_ASSERT(
648 portNum < this->getNum_readPoll_OutputPorts(),
649 static_cast<FwAssertArgType>(portNum)
650 );
651
652 this->m_readPoll_OutputPort[portNum].registerSerialPort(port);
653 }
654
655 void GroundInterfaceComponentBase ::
656 set_uplinkPort_OutputPort(
657 NATIVE_INT_TYPE portNum,
658 Fw::InputSerializePort* port
659 )
660 {
661 FW_ASSERT(
662 portNum < this->getNum_uplinkPort_OutputPorts(),
663 static_cast<FwAssertArgType>(portNum)
664 );
665
666 this->m_uplinkPort_OutputPort[portNum].registerSerialPort(port);
667 }
668
669 void GroundInterfaceComponentBase ::
670 set_write_OutputPort(
671 NATIVE_INT_TYPE portNum,
672 Fw::InputSerializePort* port
673 )
674 {
675 FW_ASSERT(
676 portNum < this->getNum_write_OutputPorts(),
677 static_cast<FwAssertArgType>(portNum)
678 );
679
680 this->m_write_OutputPort[portNum].registerSerialPort(port);
681 }
682
683#endif
684
685 // ----------------------------------------------------------------------
686 // Component construction and destruction
687 // ----------------------------------------------------------------------
688
689 GroundInterfaceComponentBase ::
690 GroundInterfaceComponentBase(const char* compName) :
691 Fw::PassiveComponentBase(compName)
692 {
693
694 }
695
696 GroundInterfaceComponentBase ::
697 ~GroundInterfaceComponentBase()
698 {
699
700 }
701
702 // ----------------------------------------------------------------------
703 // Getters for numbers of typed input ports
704 // ----------------------------------------------------------------------
705
706 NATIVE_INT_TYPE GroundInterfaceComponentBase ::
707 getNum_downlinkPort_InputPorts()
708 {
709 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_downlinkPort_InputPort));
710 }
711
712 NATIVE_INT_TYPE GroundInterfaceComponentBase ::
713 getNum_fileDownlinkBufferSendIn_InputPorts()
714 {
715 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_fileDownlinkBufferSendIn_InputPort));
716 }
717
718 NATIVE_INT_TYPE GroundInterfaceComponentBase ::
719 getNum_readCallback_InputPorts()
720 {
721 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_readCallback_InputPort));
722 }
723
724 NATIVE_INT_TYPE GroundInterfaceComponentBase ::
725 getNum_schedIn_InputPorts()
726 {
727 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_schedIn_InputPort));
728 }
729
730 // ----------------------------------------------------------------------
731 // Getters for numbers of special output ports
732 // ----------------------------------------------------------------------
733
734 NATIVE_INT_TYPE GroundInterfaceComponentBase ::
735 getNum_Log_OutputPorts()
736 {
737 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Log_OutputPort));
738 }
739
740#if FW_ENABLE_TEXT_LOGGING == 1
741
742 NATIVE_INT_TYPE GroundInterfaceComponentBase ::
743 getNum_LogText_OutputPorts()
744 {
745 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
746 }
747
748#endif
749
750 NATIVE_INT_TYPE GroundInterfaceComponentBase ::
751 getNum_Time_OutputPorts()
752 {
753 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
754 }
755
756 // ----------------------------------------------------------------------
757 // Getters for numbers of typed output ports
758 // ----------------------------------------------------------------------
759
760 NATIVE_INT_TYPE GroundInterfaceComponentBase ::
761 getNum_fileDownlinkBufferSendOut_OutputPorts()
762 {
763 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_fileDownlinkBufferSendOut_OutputPort));
764 }
765
766 NATIVE_INT_TYPE GroundInterfaceComponentBase ::
767 getNum_fileUplinkBufferGet_OutputPorts()
768 {
769 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_fileUplinkBufferGet_OutputPort));
770 }
771
772 NATIVE_INT_TYPE GroundInterfaceComponentBase ::
773 getNum_fileUplinkBufferSendOut_OutputPorts()
774 {
775 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_fileUplinkBufferSendOut_OutputPort));
776 }
777
778 NATIVE_INT_TYPE GroundInterfaceComponentBase ::
779 getNum_readPoll_OutputPorts()
780 {
781 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_readPoll_OutputPort));
782 }
783
784 NATIVE_INT_TYPE GroundInterfaceComponentBase ::
785 getNum_uplinkPort_OutputPorts()
786 {
787 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_uplinkPort_OutputPort));
788 }
789
790 NATIVE_INT_TYPE GroundInterfaceComponentBase ::
791 getNum_write_OutputPorts()
792 {
793 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_write_OutputPort));
794 }
795
796 // ----------------------------------------------------------------------
797 // Connection status queries for special output ports
798 // ----------------------------------------------------------------------
799
800 bool GroundInterfaceComponentBase ::
801 isConnected_Log_OutputPort(NATIVE_INT_TYPE portNum)
802 {
803 FW_ASSERT(
804 portNum < this->getNum_Log_OutputPorts(),
805 static_cast<FwAssertArgType>(portNum)
806 );
807
808 return this->m_Log_OutputPort[portNum].isConnected();
809 }
810
811#if FW_ENABLE_TEXT_LOGGING == 1
812
813 bool GroundInterfaceComponentBase ::
814 isConnected_LogText_OutputPort(NATIVE_INT_TYPE portNum)
815 {
816 FW_ASSERT(
817 portNum < this->getNum_LogText_OutputPorts(),
818 static_cast<FwAssertArgType>(portNum)
819 );
820
821 return this->m_LogText_OutputPort[portNum].isConnected();
822 }
823
824#endif
825
826 bool GroundInterfaceComponentBase ::
827 isConnected_Time_OutputPort(NATIVE_INT_TYPE portNum)
828 {
829 FW_ASSERT(
830 portNum < this->getNum_Time_OutputPorts(),
831 static_cast<FwAssertArgType>(portNum)
832 );
833
834 return this->m_Time_OutputPort[portNum].isConnected();
835 }
836
837 // ----------------------------------------------------------------------
838 // Connection status queries for typed output ports
839 // ----------------------------------------------------------------------
840
841 bool GroundInterfaceComponentBase ::
842 isConnected_fileDownlinkBufferSendOut_OutputPort(NATIVE_INT_TYPE portNum)
843 {
844 FW_ASSERT(
845 portNum < this->getNum_fileDownlinkBufferSendOut_OutputPorts(),
846 static_cast<FwAssertArgType>(portNum)
847 );
848
849 return this->m_fileDownlinkBufferSendOut_OutputPort[portNum].isConnected();
850 }
851
852 bool GroundInterfaceComponentBase ::
853 isConnected_fileUplinkBufferGet_OutputPort(NATIVE_INT_TYPE portNum)
854 {
855 FW_ASSERT(
856 portNum < this->getNum_fileUplinkBufferGet_OutputPorts(),
857 static_cast<FwAssertArgType>(portNum)
858 );
859
860 return this->m_fileUplinkBufferGet_OutputPort[portNum].isConnected();
861 }
862
863 bool GroundInterfaceComponentBase ::
864 isConnected_fileUplinkBufferSendOut_OutputPort(NATIVE_INT_TYPE portNum)
865 {
866 FW_ASSERT(
867 portNum < this->getNum_fileUplinkBufferSendOut_OutputPorts(),
868 static_cast<FwAssertArgType>(portNum)
869 );
870
871 return this->m_fileUplinkBufferSendOut_OutputPort[portNum].isConnected();
872 }
873
874 bool GroundInterfaceComponentBase ::
875 isConnected_readPoll_OutputPort(NATIVE_INT_TYPE portNum)
876 {
877 FW_ASSERT(
878 portNum < this->getNum_readPoll_OutputPorts(),
879 static_cast<FwAssertArgType>(portNum)
880 );
881
882 return this->m_readPoll_OutputPort[portNum].isConnected();
883 }
884
885 bool GroundInterfaceComponentBase ::
886 isConnected_uplinkPort_OutputPort(NATIVE_INT_TYPE portNum)
887 {
888 FW_ASSERT(
889 portNum < this->getNum_uplinkPort_OutputPorts(),
890 static_cast<FwAssertArgType>(portNum)
891 );
892
893 return this->m_uplinkPort_OutputPort[portNum].isConnected();
894 }
895
896 bool GroundInterfaceComponentBase ::
897 isConnected_write_OutputPort(NATIVE_INT_TYPE portNum)
898 {
899 FW_ASSERT(
900 portNum < this->getNum_write_OutputPorts(),
901 static_cast<FwAssertArgType>(portNum)
902 );
903
904 return this->m_write_OutputPort[portNum].isConnected();
905 }
906
907 // ----------------------------------------------------------------------
908 // Port handler base-class functions for typed input ports
909 //
910 // Call these functions directly to bypass the corresponding ports
911 // ----------------------------------------------------------------------
912
913 void GroundInterfaceComponentBase ::
914 downlinkPort_handlerBase(
915 NATIVE_INT_TYPE portNum,
916 Fw::ComBuffer& data,
917 U32 context
918 )
919 {
920 // Make sure port number is valid
921 FW_ASSERT(
922 portNum < this->getNum_downlinkPort_InputPorts(),
923 static_cast<FwAssertArgType>(portNum)
924 );
925
926 // Lock guard mutex before calling
927 this->lock();
928
929 // Down call to pure virtual handler method implemented in Impl class
930 this->downlinkPort_handler(
931 portNum,
932 data,
933 context
934 );
935
936 // Unlock guard mutex
937 this->unLock();
938 }
939
940 void GroundInterfaceComponentBase ::
941 fileDownlinkBufferSendIn_handlerBase(
942 NATIVE_INT_TYPE portNum,
943 Fw::Buffer& fwBuffer
944 )
945 {
946 // Make sure port number is valid
947 FW_ASSERT(
948 portNum < this->getNum_fileDownlinkBufferSendIn_InputPorts(),
949 static_cast<FwAssertArgType>(portNum)
950 );
951
952 // Lock guard mutex before calling
953 this->lock();
954
955 // Down call to pure virtual handler method implemented in Impl class
956 this->fileDownlinkBufferSendIn_handler(
957 portNum,
958 fwBuffer
959 );
960
961 // Unlock guard mutex
962 this->unLock();
963 }
964
965 void GroundInterfaceComponentBase ::
966 readCallback_handlerBase(
967 NATIVE_INT_TYPE portNum,
968 Fw::Buffer& fwBuffer
969 )
970 {
971 // Make sure port number is valid
972 FW_ASSERT(
973 portNum < this->getNum_readCallback_InputPorts(),
974 static_cast<FwAssertArgType>(portNum)
975 );
976
977 // Lock guard mutex before calling
978 this->lock();
979
980 // Down call to pure virtual handler method implemented in Impl class
981 this->readCallback_handler(
982 portNum,
983 fwBuffer
984 );
985
986 // Unlock guard mutex
987 this->unLock();
988 }
989
990 void GroundInterfaceComponentBase ::
991 schedIn_handlerBase(
992 NATIVE_INT_TYPE portNum,
993 NATIVE_UINT_TYPE context
994 )
995 {
996 // Make sure port number is valid
997 FW_ASSERT(
998 portNum < this->getNum_schedIn_InputPorts(),
999 static_cast<FwAssertArgType>(portNum)
1000 );
1001
1002 // Lock guard mutex before calling
1003 this->lock();
1004
1005 // Down call to pure virtual handler method implemented in Impl class
1006 this->schedIn_handler(
1007 portNum,
1008 context
1009 );
1010
1011 // Unlock guard mutex
1012 this->unLock();
1013 }
1014
1015 // ----------------------------------------------------------------------
1016 // Invocation functions for typed output ports
1017 // ----------------------------------------------------------------------
1018
1019 void GroundInterfaceComponentBase ::
1020 fileDownlinkBufferSendOut_out(
1021 NATIVE_INT_TYPE portNum,
1022 Fw::Buffer& fwBuffer
1023 )
1024 {
1025 FW_ASSERT(
1026 portNum < this->getNum_fileDownlinkBufferSendOut_OutputPorts(),
1027 static_cast<FwAssertArgType>(portNum)
1028 );
1029 this->m_fileDownlinkBufferSendOut_OutputPort[portNum].invoke(
1030 fwBuffer
1031 );
1032 }
1033
1034 Fw::Buffer GroundInterfaceComponentBase ::
1035 fileUplinkBufferGet_out(
1036 NATIVE_INT_TYPE portNum,
1037 U32 size
1038 )
1039 {
1040 FW_ASSERT(
1041 portNum < this->getNum_fileUplinkBufferGet_OutputPorts(),
1042 static_cast<FwAssertArgType>(portNum)
1043 );
1044 return this->m_fileUplinkBufferGet_OutputPort[portNum].invoke(
1045 size
1046 );
1047 }
1048
1049 void GroundInterfaceComponentBase ::
1050 fileUplinkBufferSendOut_out(
1051 NATIVE_INT_TYPE portNum,
1052 Fw::Buffer& fwBuffer
1053 )
1054 {
1055 FW_ASSERT(
1056 portNum < this->getNum_fileUplinkBufferSendOut_OutputPorts(),
1057 static_cast<FwAssertArgType>(portNum)
1058 );
1059 this->m_fileUplinkBufferSendOut_OutputPort[portNum].invoke(
1060 fwBuffer
1061 );
1062 }
1063
1064 void GroundInterfaceComponentBase ::
1065 readPoll_out(
1066 NATIVE_INT_TYPE portNum,
1067 Fw::Buffer& fwBuffer
1068 )
1069 {
1070 FW_ASSERT(
1071 portNum < this->getNum_readPoll_OutputPorts(),
1072 static_cast<FwAssertArgType>(portNum)
1073 );
1074 this->m_readPoll_OutputPort[portNum].invoke(
1075 fwBuffer
1076 );
1077 }
1078
1079 void GroundInterfaceComponentBase ::
1080 uplinkPort_out(
1081 NATIVE_INT_TYPE portNum,
1082 Fw::ComBuffer& data,
1083 U32 context
1084 )
1085 {
1086 FW_ASSERT(
1087 portNum < this->getNum_uplinkPort_OutputPorts(),
1088 static_cast<FwAssertArgType>(portNum)
1089 );
1090 this->m_uplinkPort_OutputPort[portNum].invoke(
1091 data,
1092 context
1093 );
1094 }
1095
1096 void GroundInterfaceComponentBase ::
1097 write_out(
1098 NATIVE_INT_TYPE portNum,
1099 Fw::Buffer& fwBuffer
1100 )
1101 {
1102 FW_ASSERT(
1103 portNum < this->getNum_write_OutputPorts(),
1104 static_cast<FwAssertArgType>(portNum)
1105 );
1106 this->m_write_OutputPort[portNum].invoke(
1107 fwBuffer
1108 );
1109 }
1110
1111 // ----------------------------------------------------------------------
1112 // Event logging functions
1113 // ----------------------------------------------------------------------
1114
1115 void GroundInterfaceComponentBase ::
1116 log_WARNING_HI_GroundInterfaceError()
1117 {
1118 // Get the time
1119 Fw::Time _logTime;
1120 if (this->m_Time_OutputPort[0].isConnected()) {
1121 this->m_Time_OutputPort[0].invoke(_logTime);
1122 }
1123
1124 FwEventIdType _id = static_cast<FwEventIdType>(0);
1125
1126 _id = this->getIdBase() + EVENTID_GROUNDINTERFACEERROR;
1127
1128 // Emit the event on the log port
1129 if (this->m_Log_OutputPort[0].isConnected()) {
1130 Fw::LogBuffer _logBuff;
1131
1132#if FW_AMPCS_COMPATIBLE
1134 // Serialize the number of arguments
1135 _status = _logBuff.serialize(static_cast<U8>(0));
1136 FW_ASSERT(
1137 _status == Fw::FW_SERIALIZE_OK,
1138 static_cast<FwAssertArgType>(_status)
1139 );
1140#endif
1141
1142 this->m_Log_OutputPort[0].invoke(
1143 _id,
1144 _logTime,
1146 _logBuff
1147 );
1148 }
1149
1150 // Emit the event on the text log port
1151#if FW_ENABLE_TEXT_LOGGING
1152 if (this->m_LogText_OutputPort[0].isConnected()) {
1153#if FW_OBJECT_NAMES == 1
1154 const char* _formatString =
1155 "(%s) %s: Ground interface encountered an error";
1156#else
1157 const char* _formatString =
1158 "%s: Ground interface encountered an error";
1159#endif
1160
1161 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1162
1163 (void) snprintf(
1164 _textBuffer,
1166 _formatString,
1167#if FW_OBJECT_NAMES == 1
1168 this->m_objName,
1169#endif
1170 "GroundInterfaceError "
1171 );
1172
1173 // Null terminate
1174 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1175 Fw::TextLogString _logString = _textBuffer;
1176 this->m_LogText_OutputPort[0].invoke(
1177 _id,
1178 _logTime,
1180 _logString
1181 );
1182 }
1183#endif
1184 }
1185
1186 // ----------------------------------------------------------------------
1187 // Time
1188 // ----------------------------------------------------------------------
1189
1190 Fw::Time GroundInterfaceComponentBase ::
1191 getTime()
1192 {
1193 if (this->m_Time_OutputPort[0].isConnected()) {
1194 Fw::Time _time;
1195 this->m_Time_OutputPort[0].invoke(_time);
1196 return _time;
1197 }
1198 else {
1199 return Fw::Time(TB_NONE, 0, 0);
1200 }
1201 }
1202
1203 // ----------------------------------------------------------------------
1204 // Mutex operations for guarded ports
1205 //
1206 // You can override these operations to provide more sophisticated
1207 // synchronization
1208 // ----------------------------------------------------------------------
1209
1210 void GroundInterfaceComponentBase ::
1211 lock()
1212 {
1213 this->m_guardedPortMutex.lock();
1214 }
1215
1216 void GroundInterfaceComponentBase ::
1217 unLock()
1218 {
1219 this->m_guardedPortMutex.unLock();
1220 }
1221
1222 // ----------------------------------------------------------------------
1223 // Calls for messages received on typed input ports
1224 // ----------------------------------------------------------------------
1225
1226 void GroundInterfaceComponentBase ::
1227 m_p_downlinkPort_in(
1228 Fw::PassiveComponentBase* callComp,
1229 NATIVE_INT_TYPE portNum,
1230 Fw::ComBuffer& data,
1231 U32 context
1232 )
1233 {
1234 FW_ASSERT(callComp);
1235 GroundInterfaceComponentBase* compPtr = static_cast<GroundInterfaceComponentBase*>(callComp);
1236 compPtr->downlinkPort_handlerBase(
1237 portNum,
1238 data,
1239 context
1240 );
1241 }
1242
1243 void GroundInterfaceComponentBase ::
1244 m_p_fileDownlinkBufferSendIn_in(
1245 Fw::PassiveComponentBase* callComp,
1246 NATIVE_INT_TYPE portNum,
1247 Fw::Buffer& fwBuffer
1248 )
1249 {
1250 FW_ASSERT(callComp);
1251 GroundInterfaceComponentBase* compPtr = static_cast<GroundInterfaceComponentBase*>(callComp);
1253 portNum,
1254 fwBuffer
1255 );
1256 }
1257
1258 void GroundInterfaceComponentBase ::
1259 m_p_readCallback_in(
1260 Fw::PassiveComponentBase* callComp,
1261 NATIVE_INT_TYPE portNum,
1262 Fw::Buffer& fwBuffer
1263 )
1264 {
1265 FW_ASSERT(callComp);
1266 GroundInterfaceComponentBase* compPtr = static_cast<GroundInterfaceComponentBase*>(callComp);
1267 compPtr->readCallback_handlerBase(
1268 portNum,
1269 fwBuffer
1270 );
1271 }
1272
1273 void GroundInterfaceComponentBase ::
1274 m_p_schedIn_in(
1275 Fw::PassiveComponentBase* callComp,
1276 NATIVE_INT_TYPE portNum,
1277 NATIVE_UINT_TYPE context
1278 )
1279 {
1280 FW_ASSERT(callComp);
1281 GroundInterfaceComponentBase* compPtr = static_cast<GroundInterfaceComponentBase*>(callComp);
1282 compPtr->schedIn_handlerBase(
1283 portNum,
1284 context
1285 );
1286 }
1287
1288}
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
U8 BYTE
byte type
Definition BasicTypes.h:27
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition BasicTypes.h:66
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
#define PRI_PlatformIntType
@ TB_NONE
No time base has been established.
Definition FpConfig.h:39
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:21
U32 FwEventIdType
Definition FpConfig.h:62
#define FW_LOG_TEXT_BUFFER_SIZE
Max size of string for text log message.
Definition FpConfig.h:291
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects)
Definition FpConfig.h:82
Input BufferGet port.
Input BufferSend port.
@ 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 ComPortAc.hpp:37
@ WARNING_HI
A serious but recoverable event.
void init()
Object initializer.
Definition ObjBase.cpp:27
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
Auto-generated base for GroundInterface component.
void downlinkPort_handlerBase(NATIVE_INT_TYPE portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port downlinkPort.
void fileDownlinkBufferSendIn_handlerBase(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port fileDownlinkBufferSendIn.
@ 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.