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