F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
ActiveRateGroupComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title ActiveRateGroupComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for ActiveRateGroup 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 ACTIVERATEGROUP_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19 CYCLEIN_CYCLE,
20 PINGIN_PING,
21 };
22
23 // Get the max size by constructing a union of the async input, command, and
24 // internal port serialization sizes
25 union BuffUnion {
28 };
29
30 // Define a message buffer class large enough to handle all the
31 // asynchronous inputs to the component
32 class ComponentIpcSerializableBuffer :
34 {
35
36 public:
37
38 enum {
39 // Offset into data in buffer: Size of message ID and port number
40 DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
41 // Max data size
42 MAX_DATA_SIZE = sizeof(BuffUnion),
43 // Max message size: Size of message id + size of port + max data size
44 SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
45 };
46
47 Fw::Serializable::SizeType getBuffCapacity() const {
48 return sizeof(m_buff);
49 }
50
51 U8* getBuffAddr() {
52 return m_buff;
53 }
54
55 const U8* getBuffAddr() const {
56 return m_buff;
57 }
58
59 private:
60 // Should be the max of all the input ports serialized sizes...
61 U8 m_buff[SERIALIZATION_SIZE];
62
63 };
64 }
65
66 // ----------------------------------------------------------------------
67 // Component initialization
68 // ----------------------------------------------------------------------
69
70 void ActiveRateGroupComponentBase ::
71 init(
72 FwSizeType queueDepth,
73 FwEnumStoreType instance
74 )
75 {
76 // Initialize base class
78
79 // Connect input port CycleIn
80 for (
81 FwIndexType port = 0;
82 port < static_cast<FwIndexType>(this->getNum_CycleIn_InputPorts());
83 port++
84 ) {
85 this->m_CycleIn_InputPort[port].init();
86 this->m_CycleIn_InputPort[port].addCallComp(
87 this,
88 m_p_CycleIn_in
89 );
90 this->m_CycleIn_InputPort[port].setPortNum(port);
91
92#if FW_OBJECT_NAMES == 1
93 Fw::ObjectName portName;
94 portName.format(
95 "%s_CycleIn_InputPort[%" PRI_PlatformIntType "]",
96 this->m_objName.toChar(),
97 port
98 );
99 this->m_CycleIn_InputPort[port].setObjName(portName.toChar());
100#endif
101 }
102
103 // Connect input port PingIn
104 for (
105 FwIndexType port = 0;
106 port < static_cast<FwIndexType>(this->getNum_PingIn_InputPorts());
107 port++
108 ) {
109 this->m_PingIn_InputPort[port].init();
110 this->m_PingIn_InputPort[port].addCallComp(
111 this,
112 m_p_PingIn_in
113 );
114 this->m_PingIn_InputPort[port].setPortNum(port);
115
116#if FW_OBJECT_NAMES == 1
117 Fw::ObjectName portName;
118 portName.format(
119 "%s_PingIn_InputPort[%" PRI_PlatformIntType "]",
120 this->m_objName.toChar(),
121 port
122 );
123 this->m_PingIn_InputPort[port].setObjName(portName.toChar());
124#endif
125 }
126
127 // Connect output port Log
128 for (
129 FwIndexType port = 0;
130 port < static_cast<FwIndexType>(this->getNum_Log_OutputPorts());
131 port++
132 ) {
133 this->m_Log_OutputPort[port].init();
134
135#if FW_OBJECT_NAMES == 1
136 Fw::ObjectName portName;
137 portName.format(
138 "%s_Log_OutputPort[%" PRI_PlatformIntType "]",
139 this->m_objName.toChar(),
140 port
141 );
142 this->m_Log_OutputPort[port].setObjName(portName.toChar());
143#endif
144 }
145
146#if FW_ENABLE_TEXT_LOGGING == 1
147 // Connect output port LogText
148 for (
149 FwIndexType port = 0;
150 port < static_cast<FwIndexType>(this->getNum_LogText_OutputPorts());
151 port++
152 ) {
153 this->m_LogText_OutputPort[port].init();
154
155#if FW_OBJECT_NAMES == 1
156 Fw::ObjectName portName;
157 portName.format(
158 "%s_LogText_OutputPort[%" PRI_PlatformIntType "]",
159 this->m_objName.toChar(),
160 port
161 );
162 this->m_LogText_OutputPort[port].setObjName(portName.toChar());
163#endif
164 }
165#endif
166
167 // Connect output port Time
168 for (
169 FwIndexType port = 0;
170 port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
171 port++
172 ) {
173 this->m_Time_OutputPort[port].init();
174
175#if FW_OBJECT_NAMES == 1
176 Fw::ObjectName portName;
177 portName.format(
178 "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
179 this->m_objName.toChar(),
180 port
181 );
182 this->m_Time_OutputPort[port].setObjName(portName.toChar());
183#endif
184 }
185
186 // Connect output port Tlm
187 for (
188 FwIndexType port = 0;
189 port < static_cast<FwIndexType>(this->getNum_Tlm_OutputPorts());
190 port++
191 ) {
192 this->m_Tlm_OutputPort[port].init();
193
194#if FW_OBJECT_NAMES == 1
195 Fw::ObjectName portName;
196 portName.format(
197 "%s_Tlm_OutputPort[%" PRI_PlatformIntType "]",
198 this->m_objName.toChar(),
199 port
200 );
201 this->m_Tlm_OutputPort[port].setObjName(portName.toChar());
202#endif
203 }
204
205 // Connect output port PingOut
206 for (
207 FwIndexType port = 0;
208 port < static_cast<FwIndexType>(this->getNum_PingOut_OutputPorts());
209 port++
210 ) {
211 this->m_PingOut_OutputPort[port].init();
212
213#if FW_OBJECT_NAMES == 1
214 Fw::ObjectName portName;
215 portName.format(
216 "%s_PingOut_OutputPort[%" PRI_PlatformIntType "]",
217 this->m_objName.toChar(),
218 port
219 );
220 this->m_PingOut_OutputPort[port].setObjName(portName.toChar());
221#endif
222 }
223
224 // Connect output port RateGroupMemberOut
225 for (
226 FwIndexType port = 0;
227 port < static_cast<FwIndexType>(this->getNum_RateGroupMemberOut_OutputPorts());
228 port++
229 ) {
230 this->m_RateGroupMemberOut_OutputPort[port].init();
231
232#if FW_OBJECT_NAMES == 1
233 Fw::ObjectName portName;
234 portName.format(
235 "%s_RateGroupMemberOut_OutputPort[%" PRI_PlatformIntType "]",
236 this->m_objName.toChar(),
237 port
238 );
239 this->m_RateGroupMemberOut_OutputPort[port].setObjName(portName.toChar());
240#endif
241 }
242
243 // Create the queue
244 Os::Queue::Status qStat = this->createQueue(
245 queueDepth,
246 static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
247 );
248 FW_ASSERT(
250 static_cast<FwAssertArgType>(qStat)
251 );
252 }
253
254 // ----------------------------------------------------------------------
255 // Getters for typed input ports
256 // ----------------------------------------------------------------------
257
258 Svc::InputCyclePort* ActiveRateGroupComponentBase ::
259 get_CycleIn_InputPort(FwIndexType portNum)
260 {
261 FW_ASSERT(
262 portNum < this->getNum_CycleIn_InputPorts(),
263 static_cast<FwAssertArgType>(portNum)
264 );
265
266 return &this->m_CycleIn_InputPort[portNum];
267 }
268
269 Svc::InputPingPort* ActiveRateGroupComponentBase ::
270 get_PingIn_InputPort(FwIndexType portNum)
271 {
272 FW_ASSERT(
273 portNum < this->getNum_PingIn_InputPorts(),
274 static_cast<FwAssertArgType>(portNum)
275 );
276
277 return &this->m_PingIn_InputPort[portNum];
278 }
279
280 // ----------------------------------------------------------------------
281 // Connect input ports to special output ports
282 // ----------------------------------------------------------------------
283
284 void ActiveRateGroupComponentBase ::
285 set_Log_OutputPort(
286 FwIndexType portNum,
287 Fw::InputLogPort* port
288 )
289 {
290 FW_ASSERT(
291 portNum < this->getNum_Log_OutputPorts(),
292 static_cast<FwAssertArgType>(portNum)
293 );
294
295 this->m_Log_OutputPort[portNum].addCallPort(port);
296 }
297
298#if FW_ENABLE_TEXT_LOGGING == 1
299
300 void ActiveRateGroupComponentBase ::
301 set_LogText_OutputPort(
302 FwIndexType portNum,
304 )
305 {
306 FW_ASSERT(
307 portNum < this->getNum_LogText_OutputPorts(),
308 static_cast<FwAssertArgType>(portNum)
309 );
310
311 this->m_LogText_OutputPort[portNum].addCallPort(port);
312 }
313
314#endif
315
316 void ActiveRateGroupComponentBase ::
317 set_Time_OutputPort(
318 FwIndexType portNum,
320 )
321 {
322 FW_ASSERT(
323 portNum < this->getNum_Time_OutputPorts(),
324 static_cast<FwAssertArgType>(portNum)
325 );
326
327 this->m_Time_OutputPort[portNum].addCallPort(port);
328 }
329
330 void ActiveRateGroupComponentBase ::
331 set_Tlm_OutputPort(
332 FwIndexType portNum,
333 Fw::InputTlmPort* port
334 )
335 {
336 FW_ASSERT(
337 portNum < this->getNum_Tlm_OutputPorts(),
338 static_cast<FwAssertArgType>(portNum)
339 );
340
341 this->m_Tlm_OutputPort[portNum].addCallPort(port);
342 }
343
344 // ----------------------------------------------------------------------
345 // Connect typed input ports to typed output ports
346 // ----------------------------------------------------------------------
347
348 void ActiveRateGroupComponentBase ::
349 set_PingOut_OutputPort(
350 FwIndexType portNum,
352 )
353 {
354 FW_ASSERT(
355 portNum < this->getNum_PingOut_OutputPorts(),
356 static_cast<FwAssertArgType>(portNum)
357 );
358
359 this->m_PingOut_OutputPort[portNum].addCallPort(port);
360 }
361
362 void ActiveRateGroupComponentBase ::
363 set_RateGroupMemberOut_OutputPort(
364 FwIndexType portNum,
366 )
367 {
368 FW_ASSERT(
369 portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
370 static_cast<FwAssertArgType>(portNum)
371 );
372
373 this->m_RateGroupMemberOut_OutputPort[portNum].addCallPort(port);
374 }
375
376#if FW_PORT_SERIALIZATION
377
378 // ----------------------------------------------------------------------
379 // Connect serial input ports to special output ports
380 // ----------------------------------------------------------------------
381
382 void ActiveRateGroupComponentBase ::
383 set_Log_OutputPort(
384 FwIndexType portNum,
385 Fw::InputSerializePort* port
386 )
387 {
388 FW_ASSERT(
389 portNum < this->getNum_Log_OutputPorts(),
390 static_cast<FwAssertArgType>(portNum)
391 );
392
393 this->m_Log_OutputPort[portNum].registerSerialPort(port);
394 }
395
396#if FW_ENABLE_TEXT_LOGGING == 1
397
398 void ActiveRateGroupComponentBase ::
399 set_LogText_OutputPort(
400 FwIndexType portNum,
401 Fw::InputSerializePort* port
402 )
403 {
404 FW_ASSERT(
405 portNum < this->getNum_LogText_OutputPorts(),
406 static_cast<FwAssertArgType>(portNum)
407 );
408
409 this->m_LogText_OutputPort[portNum].registerSerialPort(port);
410 }
411
412#endif
413
414 void ActiveRateGroupComponentBase ::
415 set_Time_OutputPort(
416 FwIndexType portNum,
417 Fw::InputSerializePort* port
418 )
419 {
420 FW_ASSERT(
421 portNum < this->getNum_Time_OutputPorts(),
422 static_cast<FwAssertArgType>(portNum)
423 );
424
425 this->m_Time_OutputPort[portNum].registerSerialPort(port);
426 }
427
428 void ActiveRateGroupComponentBase ::
429 set_Tlm_OutputPort(
430 FwIndexType portNum,
431 Fw::InputSerializePort* port
432 )
433 {
434 FW_ASSERT(
435 portNum < this->getNum_Tlm_OutputPorts(),
436 static_cast<FwAssertArgType>(portNum)
437 );
438
439 this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
440 }
441
442#endif
443
444#if FW_PORT_SERIALIZATION
445
446 // ----------------------------------------------------------------------
447 // Connect serial input ports to typed output ports
448 // ----------------------------------------------------------------------
449
450 void ActiveRateGroupComponentBase ::
451 set_PingOut_OutputPort(
452 FwIndexType portNum,
453 Fw::InputSerializePort* port
454 )
455 {
456 FW_ASSERT(
457 portNum < this->getNum_PingOut_OutputPorts(),
458 static_cast<FwAssertArgType>(portNum)
459 );
460
461 this->m_PingOut_OutputPort[portNum].registerSerialPort(port);
462 }
463
464 void ActiveRateGroupComponentBase ::
465 set_RateGroupMemberOut_OutputPort(
466 FwIndexType portNum,
467 Fw::InputSerializePort* port
468 )
469 {
470 FW_ASSERT(
471 portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
472 static_cast<FwAssertArgType>(portNum)
473 );
474
475 this->m_RateGroupMemberOut_OutputPort[portNum].registerSerialPort(port);
476 }
477
478#endif
479
480 // ----------------------------------------------------------------------
481 // Component construction and destruction
482 // ----------------------------------------------------------------------
483
484 ActiveRateGroupComponentBase ::
485 ActiveRateGroupComponentBase(const char* compName) :
486 Fw::ActiveComponentBase(compName)
487 {
488 // Write telemetry channel RgMaxTime
489 this->m_first_update_RgMaxTime = true;
490 this->m_last_RgMaxTime = 0;
491
492 // Write telemetry channel RgCycleSlips
493 this->m_first_update_RgCycleSlips = true;
494 this->m_last_RgCycleSlips = 0;
495 }
496
497 ActiveRateGroupComponentBase ::
498 ~ActiveRateGroupComponentBase()
499 {
500
501 }
502
503 // ----------------------------------------------------------------------
504 // Getters for numbers of typed input ports
505 // ----------------------------------------------------------------------
506
507 FwIndexType ActiveRateGroupComponentBase ::
508 getNum_CycleIn_InputPorts() const
509 {
510 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_CycleIn_InputPort));
511 }
512
513 FwIndexType ActiveRateGroupComponentBase ::
514 getNum_PingIn_InputPorts() const
515 {
516 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_PingIn_InputPort));
517 }
518
519 // ----------------------------------------------------------------------
520 // Getters for numbers of special output ports
521 // ----------------------------------------------------------------------
522
523 FwIndexType ActiveRateGroupComponentBase ::
524 getNum_Log_OutputPorts() const
525 {
526 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Log_OutputPort));
527 }
528
529#if FW_ENABLE_TEXT_LOGGING == 1
530
531 FwIndexType ActiveRateGroupComponentBase ::
532 getNum_LogText_OutputPorts() const
533 {
534 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
535 }
536
537#endif
538
539 FwIndexType ActiveRateGroupComponentBase ::
540 getNum_Time_OutputPorts() const
541 {
542 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
543 }
544
545 FwIndexType ActiveRateGroupComponentBase ::
546 getNum_Tlm_OutputPorts() const
547 {
548 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Tlm_OutputPort));
549 }
550
551 // ----------------------------------------------------------------------
552 // Getters for numbers of typed output ports
553 // ----------------------------------------------------------------------
554
555 FwIndexType ActiveRateGroupComponentBase ::
556 getNum_PingOut_OutputPorts() const
557 {
558 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_PingOut_OutputPort));
559 }
560
561 FwIndexType ActiveRateGroupComponentBase ::
562 getNum_RateGroupMemberOut_OutputPorts() const
563 {
564 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_RateGroupMemberOut_OutputPort));
565 }
566
567 // ----------------------------------------------------------------------
568 // Connection status queries for special output ports
569 // ----------------------------------------------------------------------
570
571 bool ActiveRateGroupComponentBase ::
572 isConnected_Log_OutputPort(FwIndexType portNum)
573 {
574 FW_ASSERT(
575 portNum < this->getNum_Log_OutputPorts(),
576 static_cast<FwAssertArgType>(portNum)
577 );
578
579 return this->m_Log_OutputPort[portNum].isConnected();
580 }
581
582#if FW_ENABLE_TEXT_LOGGING == 1
583
584 bool ActiveRateGroupComponentBase ::
585 isConnected_LogText_OutputPort(FwIndexType portNum)
586 {
587 FW_ASSERT(
588 portNum < this->getNum_LogText_OutputPorts(),
589 static_cast<FwAssertArgType>(portNum)
590 );
591
592 return this->m_LogText_OutputPort[portNum].isConnected();
593 }
594
595#endif
596
597 bool ActiveRateGroupComponentBase ::
598 isConnected_Time_OutputPort(FwIndexType portNum)
599 {
600 FW_ASSERT(
601 portNum < this->getNum_Time_OutputPorts(),
602 static_cast<FwAssertArgType>(portNum)
603 );
604
605 return this->m_Time_OutputPort[portNum].isConnected();
606 }
607
608 bool ActiveRateGroupComponentBase ::
609 isConnected_Tlm_OutputPort(FwIndexType portNum)
610 {
611 FW_ASSERT(
612 portNum < this->getNum_Tlm_OutputPorts(),
613 static_cast<FwAssertArgType>(portNum)
614 );
615
616 return this->m_Tlm_OutputPort[portNum].isConnected();
617 }
618
619 // ----------------------------------------------------------------------
620 // Connection status queries for typed output ports
621 // ----------------------------------------------------------------------
622
623 bool ActiveRateGroupComponentBase ::
624 isConnected_PingOut_OutputPort(FwIndexType portNum)
625 {
626 FW_ASSERT(
627 portNum < this->getNum_PingOut_OutputPorts(),
628 static_cast<FwAssertArgType>(portNum)
629 );
630
631 return this->m_PingOut_OutputPort[portNum].isConnected();
632 }
633
634 bool ActiveRateGroupComponentBase ::
635 isConnected_RateGroupMemberOut_OutputPort(FwIndexType portNum)
636 {
637 FW_ASSERT(
638 portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
639 static_cast<FwAssertArgType>(portNum)
640 );
641
642 return this->m_RateGroupMemberOut_OutputPort[portNum].isConnected();
643 }
644
645 // ----------------------------------------------------------------------
646 // Port handler base-class functions for typed input ports
647 //
648 // Call these functions directly to bypass the corresponding ports
649 // ----------------------------------------------------------------------
650
651 void ActiveRateGroupComponentBase ::
652 CycleIn_handlerBase(
653 FwIndexType portNum,
654 Os::RawTime& cycleStart
655 )
656 {
657 // Make sure port number is valid
658 FW_ASSERT(
659 portNum < this->getNum_CycleIn_InputPorts(),
660 static_cast<FwAssertArgType>(portNum)
661 );
662
663 // Call pre-message hook
664 CycleIn_preMsgHook(
665 portNum,
666 cycleStart
667 );
668 ComponentIpcSerializableBuffer msg;
670
671 // Serialize message ID
672 _status = msg.serialize(
673 static_cast<FwEnumStoreType>(CYCLEIN_CYCLE)
674 );
675 FW_ASSERT(
676 _status == Fw::FW_SERIALIZE_OK,
677 static_cast<FwAssertArgType>(_status)
678 );
679
680 // Serialize port number
681 _status = msg.serialize(portNum);
682 FW_ASSERT(
683 _status == Fw::FW_SERIALIZE_OK,
684 static_cast<FwAssertArgType>(_status)
685 );
686
687 // Serialize argument cycleStart
688 _status = msg.serialize(cycleStart);
689 FW_ASSERT(
690 _status == Fw::FW_SERIALIZE_OK,
691 static_cast<FwAssertArgType>(_status)
692 );
693
694 // Send message
696 Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
697
698 if (qStatus == Os::Queue::Status::FULL) {
699 this->incNumMsgDropped();
700 return;
701 }
702
703 FW_ASSERT(
704 qStatus == Os::Queue::OP_OK,
705 static_cast<FwAssertArgType>(qStatus)
706 );
707 }
708
709 void ActiveRateGroupComponentBase ::
710 PingIn_handlerBase(
711 FwIndexType portNum,
712 U32 key
713 )
714 {
715 // Make sure port number is valid
716 FW_ASSERT(
717 portNum < this->getNum_PingIn_InputPorts(),
718 static_cast<FwAssertArgType>(portNum)
719 );
720
721 // Call pre-message hook
722 PingIn_preMsgHook(
723 portNum,
724 key
725 );
726 ComponentIpcSerializableBuffer msg;
728
729 // Serialize message ID
730 _status = msg.serialize(
731 static_cast<FwEnumStoreType>(PINGIN_PING)
732 );
733 FW_ASSERT(
734 _status == Fw::FW_SERIALIZE_OK,
735 static_cast<FwAssertArgType>(_status)
736 );
737
738 // Serialize port number
739 _status = msg.serialize(portNum);
740 FW_ASSERT(
741 _status == Fw::FW_SERIALIZE_OK,
742 static_cast<FwAssertArgType>(_status)
743 );
744
745 // Serialize argument key
746 _status = msg.serialize(key);
747 FW_ASSERT(
748 _status == Fw::FW_SERIALIZE_OK,
749 static_cast<FwAssertArgType>(_status)
750 );
751
752 // Send message
754 Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
755
756 FW_ASSERT(
757 qStatus == Os::Queue::OP_OK,
758 static_cast<FwAssertArgType>(qStatus)
759 );
760 }
761
762 // ----------------------------------------------------------------------
763 // Pre-message hooks for typed async input ports
764 //
765 // Each of these functions is invoked just before processing a message
766 // on the corresponding port. By default, they do nothing. You can
767 // override them to provide specific pre-message behavior.
768 // ----------------------------------------------------------------------
769
770 void ActiveRateGroupComponentBase ::
771 CycleIn_preMsgHook(
772 FwIndexType portNum,
773 Os::RawTime& cycleStart
774 )
775 {
776 // Default: no-op
777 }
778
779 void ActiveRateGroupComponentBase ::
780 PingIn_preMsgHook(
781 FwIndexType portNum,
782 U32 key
783 )
784 {
785 // Default: no-op
786 }
787
788 // ----------------------------------------------------------------------
789 // Invocation functions for typed output ports
790 // ----------------------------------------------------------------------
791
792 void ActiveRateGroupComponentBase ::
793 PingOut_out(
794 FwIndexType portNum,
795 U32 key
796 )
797 {
798 FW_ASSERT(
799 portNum < this->getNum_PingOut_OutputPorts(),
800 static_cast<FwAssertArgType>(portNum)
801 );
802 this->m_PingOut_OutputPort[portNum].invoke(
803 key
804 );
805 }
806
807 void ActiveRateGroupComponentBase ::
808 RateGroupMemberOut_out(
809 FwIndexType portNum,
810 U32 context
811 )
812 {
813 FW_ASSERT(
814 portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
815 static_cast<FwAssertArgType>(portNum)
816 );
817 this->m_RateGroupMemberOut_OutputPort[portNum].invoke(
818 context
819 );
820 }
821
822 // ----------------------------------------------------------------------
823 // Event logging functions
824 // ----------------------------------------------------------------------
825
826 void ActiveRateGroupComponentBase ::
827 log_DIAGNOSTIC_RateGroupStarted() const
828 {
829 // Get the time
830 Fw::Time _logTime;
831 if (this->m_Time_OutputPort[0].isConnected()) {
832 this->m_Time_OutputPort[0].invoke(_logTime);
833 }
834
835 FwEventIdType _id = static_cast<FwEventIdType>(0);
836
837 _id = this->getIdBase() + EVENTID_RATEGROUPSTARTED;
838
839 // Emit the event on the log port
840 if (this->m_Log_OutputPort[0].isConnected()) {
841 Fw::LogBuffer _logBuff;
842
843#if FW_AMPCS_COMPATIBLE
845 // Serialize the number of arguments
846 _status = _logBuff.serialize(static_cast<U8>(0));
847 FW_ASSERT(
848 _status == Fw::FW_SERIALIZE_OK,
849 static_cast<FwAssertArgType>(_status)
850 );
851#endif
852
853 this->m_Log_OutputPort[0].invoke(
854 _id,
855 _logTime,
857 _logBuff
858 );
859 }
860
861 // Emit the event on the text log port
862#if FW_ENABLE_TEXT_LOGGING
863 if (this->m_LogText_OutputPort[0].isConnected()) {
864#if FW_OBJECT_NAMES == 1
865 const char* _formatString =
866 "(%s) %s: Rate group started.";
867#else
868 const char* _formatString =
869 "%s: Rate group started.";
870#endif
871
872 Fw::TextLogString _logString;
873 _logString.format(
874 _formatString,
875#if FW_OBJECT_NAMES == 1
876 this->m_objName.toChar(),
877#endif
878 "RateGroupStarted "
879 );
880
881 this->m_LogText_OutputPort[0].invoke(
882 _id,
883 _logTime,
885 _logString
886 );
887 }
888#endif
889 }
890
891 void ActiveRateGroupComponentBase ::
892 log_WARNING_HI_RateGroupCycleSlip(U32 cycle) const
893 {
894 // Get the time
895 Fw::Time _logTime;
896 if (this->m_Time_OutputPort[0].isConnected()) {
897 this->m_Time_OutputPort[0].invoke(_logTime);
898 }
899
900 FwEventIdType _id = static_cast<FwEventIdType>(0);
901
902 _id = this->getIdBase() + EVENTID_RATEGROUPCYCLESLIP;
903
904 // Emit the event on the log port
905 if (this->m_Log_OutputPort[0].isConnected()) {
906 Fw::LogBuffer _logBuff;
908
909#if FW_AMPCS_COMPATIBLE
910 // Serialize the number of arguments
911 _status = _logBuff.serialize(static_cast<U8>(1));
912 FW_ASSERT(
913 _status == Fw::FW_SERIALIZE_OK,
914 static_cast<FwAssertArgType>(_status)
915 );
916#endif
917
918#if FW_AMPCS_COMPATIBLE
919 // Serialize the argument size
920 _status = _logBuff.serialize(
921 static_cast<U8>(sizeof(U32))
922 );
923 FW_ASSERT(
924 _status == Fw::FW_SERIALIZE_OK,
925 static_cast<FwAssertArgType>(_status)
926 );
927#endif
928 _status = _logBuff.serialize(cycle);
929 FW_ASSERT(
930 _status == Fw::FW_SERIALIZE_OK,
931 static_cast<FwAssertArgType>(_status)
932 );
933
934 this->m_Log_OutputPort[0].invoke(
935 _id,
936 _logTime,
938 _logBuff
939 );
940 }
941
942 // Emit the event on the text log port
943#if FW_ENABLE_TEXT_LOGGING
944 if (this->m_LogText_OutputPort[0].isConnected()) {
945#if FW_OBJECT_NAMES == 1
946 const char* _formatString =
947 "(%s) %s: Rate group cycle slipped on cycle %" PRIu32 "";
948#else
949 const char* _formatString =
950 "%s: Rate group cycle slipped on cycle %" PRIu32 "";
951#endif
952
953 Fw::TextLogString _logString;
954 _logString.format(
955 _formatString,
956#if FW_OBJECT_NAMES == 1
957 this->m_objName.toChar(),
958#endif
959 "RateGroupCycleSlip ",
960 cycle
961 );
962
963 this->m_LogText_OutputPort[0].invoke(
964 _id,
965 _logTime,
967 _logString
968 );
969 }
970#endif
971 }
972
973 // ----------------------------------------------------------------------
974 // Telemetry write functions
975 // ----------------------------------------------------------------------
976
977 void ActiveRateGroupComponentBase ::
978 tlmWrite_RgMaxTime(
979 U32 arg,
980 Fw::Time _tlmTime
981 )
982 {
983 // Check to see if it is the first time
984 if (not this->m_first_update_RgMaxTime) {
985 // Check to see if value has changed. If not, don't write it.
986 if (arg == this->m_last_RgMaxTime) {
987 return;
988 }
989 else {
990 this->m_last_RgMaxTime = arg;
991 }
992 }
993 else {
994 this->m_first_update_RgMaxTime = false;
995 this->m_last_RgMaxTime = arg;
996 }
997
998 if (this->m_Tlm_OutputPort[0].isConnected()) {
999 if (
1000 this->m_Time_OutputPort[0].isConnected() &&
1001 (_tlmTime == Fw::ZERO_TIME)
1002 ) {
1003 this->m_Time_OutputPort[0].invoke(_tlmTime);
1004 }
1005
1006 Fw::TlmBuffer _tlmBuff;
1007 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
1008 FW_ASSERT(
1009 _stat == Fw::FW_SERIALIZE_OK,
1010 static_cast<FwAssertArgType>(_stat)
1011 );
1012
1013 FwChanIdType _id;
1014
1015 _id = this->getIdBase() + CHANNELID_RGMAXTIME;
1016
1017 this->m_Tlm_OutputPort[0].invoke(
1018 _id,
1019 _tlmTime,
1020 _tlmBuff
1021 );
1022 }
1023 }
1024
1025 void ActiveRateGroupComponentBase ::
1026 tlmWrite_RgCycleSlips(
1027 U32 arg,
1028 Fw::Time _tlmTime
1029 )
1030 {
1031 // Check to see if it is the first time
1032 if (not this->m_first_update_RgCycleSlips) {
1033 // Check to see if value has changed. If not, don't write it.
1034 if (arg == this->m_last_RgCycleSlips) {
1035 return;
1036 }
1037 else {
1038 this->m_last_RgCycleSlips = arg;
1039 }
1040 }
1041 else {
1042 this->m_first_update_RgCycleSlips = false;
1043 this->m_last_RgCycleSlips = arg;
1044 }
1045
1046 if (this->m_Tlm_OutputPort[0].isConnected()) {
1047 if (
1048 this->m_Time_OutputPort[0].isConnected() &&
1049 (_tlmTime == Fw::ZERO_TIME)
1050 ) {
1051 this->m_Time_OutputPort[0].invoke(_tlmTime);
1052 }
1053
1054 Fw::TlmBuffer _tlmBuff;
1055 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
1056 FW_ASSERT(
1057 _stat == Fw::FW_SERIALIZE_OK,
1058 static_cast<FwAssertArgType>(_stat)
1059 );
1060
1061 FwChanIdType _id;
1062
1063 _id = this->getIdBase() + CHANNELID_RGCYCLESLIPS;
1064
1065 this->m_Tlm_OutputPort[0].invoke(
1066 _id,
1067 _tlmTime,
1068 _tlmBuff
1069 );
1070 }
1071 }
1072
1073 // ----------------------------------------------------------------------
1074 // Time
1075 // ----------------------------------------------------------------------
1076
1077 Fw::Time ActiveRateGroupComponentBase ::
1078 getTime()
1079 {
1080 if (this->m_Time_OutputPort[0].isConnected()) {
1081 Fw::Time _time;
1082 this->m_Time_OutputPort[0].invoke(_time);
1083 return _time;
1084 }
1085 else {
1086 return Fw::Time(TB_NONE, 0, 0);
1087 }
1088 }
1089
1090 // ----------------------------------------------------------------------
1091 // Message dispatch functions
1092 // ----------------------------------------------------------------------
1093
1094 Fw::QueuedComponentBase::MsgDispatchStatus ActiveRateGroupComponentBase ::
1095 doDispatch()
1096 {
1097 ComponentIpcSerializableBuffer msg;
1098 FwQueuePriorityType priority = 0;
1099
1100 Os::Queue::Status msgStatus = this->m_queue.receive(
1101 msg,
1103 priority
1104 );
1105 FW_ASSERT(
1106 msgStatus == Os::Queue::OP_OK,
1107 static_cast<FwAssertArgType>(msgStatus)
1108 );
1109
1110 // Reset to beginning of buffer
1111 msg.resetDeser();
1112
1113 FwEnumStoreType desMsg = 0;
1114 Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
1115 FW_ASSERT(
1116 deserStatus == Fw::FW_SERIALIZE_OK,
1117 static_cast<FwAssertArgType>(deserStatus)
1118 );
1119
1120 MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
1121
1122 if (msgType == ACTIVERATEGROUP_COMPONENT_EXIT) {
1123 return MSG_DISPATCH_EXIT;
1124 }
1125
1126 FwIndexType portNum = 0;
1127 deserStatus = msg.deserialize(portNum);
1128 FW_ASSERT(
1129 deserStatus == Fw::FW_SERIALIZE_OK,
1130 static_cast<FwAssertArgType>(deserStatus)
1131 );
1132
1133 switch (msgType) {
1134 // Handle async input port CycleIn
1135 case CYCLEIN_CYCLE: {
1136 // Deserialize argument cycleStart
1137 Os::RawTime cycleStart;
1138 deserStatus = msg.deserialize(cycleStart);
1139 FW_ASSERT(
1140 deserStatus == Fw::FW_SERIALIZE_OK,
1141 static_cast<FwAssertArgType>(deserStatus)
1142 );
1143 // Call handler function
1144 this->CycleIn_handler(
1145 portNum,
1146 cycleStart
1147 );
1148
1149 break;
1150 }
1151
1152 // Handle async input port PingIn
1153 case PINGIN_PING: {
1154 // Deserialize argument key
1155 U32 key;
1156 deserStatus = msg.deserialize(key);
1157 FW_ASSERT(
1158 deserStatus == Fw::FW_SERIALIZE_OK,
1159 static_cast<FwAssertArgType>(deserStatus)
1160 );
1161 // Call handler function
1162 this->PingIn_handler(
1163 portNum,
1164 key
1165 );
1166
1167 break;
1168 }
1169
1170 default:
1171 return MSG_DISPATCH_ERROR;
1172 }
1173
1174 return MSG_DISPATCH_OK;
1175 }
1176
1177 // ----------------------------------------------------------------------
1178 // Calls for messages received on typed input ports
1179 // ----------------------------------------------------------------------
1180
1181 void ActiveRateGroupComponentBase ::
1182 m_p_CycleIn_in(
1183 Fw::PassiveComponentBase* callComp,
1184 FwIndexType portNum,
1185 Os::RawTime& cycleStart
1186 )
1187 {
1188 FW_ASSERT(callComp);
1189 ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1190 compPtr->CycleIn_handlerBase(
1191 portNum,
1192 cycleStart
1193 );
1194 }
1195
1196 void ActiveRateGroupComponentBase ::
1197 m_p_PingIn_in(
1198 Fw::PassiveComponentBase* callComp,
1199 FwIndexType portNum,
1200 U32 key
1201 )
1202 {
1203 FW_ASSERT(callComp);
1204 ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1205 compPtr->PingIn_handlerBase(
1206 portNum,
1207 key
1208 );
1209 }
1210
1211}
#define FW_ASSERT(...)
Definition Assert.hpp:14
U8 BYTE
byte type
Definition BasicTypes.h:31
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:30
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition BasicTypes.h:70
BYTE PingInPortSize[Svc::InputPingPort::SERIALIZED_SIZE]
#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
PlatformSizeType FwSizeType
Definition FpConfig.h:35
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
@ WARNING_HI
A serious but recoverable event.
@ DIAGNOSTIC
Software diagnostic events.
void init()
Object initializer.
Definition ObjBase.cpp:27
const char * toChar() const
NATIVE_UINT_TYPE SizeType
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
void format(const CHAR *formatString,...)
write formatted string to buffer
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
@ FULL
queue was full when attempting to send a message
Definition Queue.hpp:39
@ 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