F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
ComLoggerComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ComLoggerComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for ComLogger component base class
5 // ======================================================================
6 
7 #include "Fw/Types/Assert.hpp"
9 #if FW_ENABLE_TEXT_LOGGING
10 #include "Fw/Types/String.hpp"
11 #endif
13 
14 namespace Svc {
15 
16  namespace {
17  enum MsgTypeEnum {
18  COMLOGGER_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19  COMIN_COM,
20  PINGIN_PING,
21  CMD_CLOSEFILE,
22  };
23 
24  // Get the max size by constructing a union of the async input, command, and
25  // internal port serialization sizes
26  union BuffUnion {
27  BYTE comInPortSize[Fw::ComPortBuffer::CAPACITY];
28  BYTE pingInPortSize[Svc::PingPortBuffer::CAPACITY];
29  BYTE cmdPortSize[Fw::CmdPortBuffer::CAPACITY];
30  };
31 
32  // Define a message buffer class large enough to handle all the
33  // asynchronous inputs to the component
34  class ComponentIpcSerializableBuffer :
36  {
37 
38  public:
39 
40  enum {
41  // Offset into data in buffer: Size of message ID and port number
42  DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
43  // Max data size
44  MAX_DATA_SIZE = sizeof(BuffUnion),
45  // Max message size: Size of message id + size of port + max data size
46  SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
47  };
48 
49  Fw::Serializable::SizeType getCapacity() const {
50  return sizeof(m_buff);
51  }
52 
53  U8* getBuffAddr() {
54  return m_buff;
55  }
56 
57  const U8* getBuffAddr() const {
58  return m_buff;
59  }
60 
61  private:
62  // Should be the max of all the input ports serialized sizes...
63  U8 m_buff[SERIALIZATION_SIZE];
64 
65  };
66  }
67 
68  // ----------------------------------------------------------------------
69  // Component initialization
70  // ----------------------------------------------------------------------
71 
74  FwSizeType queueDepth,
75  FwEnumStoreType instance
76  )
77  {
78  // Initialize base class
80 
81 #if !FW_DIRECT_PORT_CALLS
82  // Connect input port cmdIn
83  for (
84  FwIndexType port = 0;
85  port < static_cast<FwIndexType>(this->getNum_cmdIn_InputPorts());
86  port++
87  ) {
88  this->m_cmdIn_InputPort[port].init();
89  this->m_cmdIn_InputPort[port].addCallComp(
90  this,
91  m_p_cmdIn_in
92  );
93  this->m_cmdIn_InputPort[port].setPortNum(port);
94 
95 #if FW_OBJECT_NAMES == 1
96  Fw::ObjectName portName;
97  portName.format(
98  "%s_cmdIn_InputPort[%" PRI_FwIndexType "]",
99  this->m_objName.toChar(),
100  port
101  );
102  this->m_cmdIn_InputPort[port].setObjName(portName.toChar());
103 #endif
104  }
105 #endif
106 
107 #if !FW_DIRECT_PORT_CALLS
108  // Connect input port comIn
109  for (
110  FwIndexType port = 0;
111  port < static_cast<FwIndexType>(this->getNum_comIn_InputPorts());
112  port++
113  ) {
114  this->m_comIn_InputPort[port].init();
115  this->m_comIn_InputPort[port].addCallComp(
116  this,
117  m_p_comIn_in
118  );
119  this->m_comIn_InputPort[port].setPortNum(port);
120 
121 #if FW_OBJECT_NAMES == 1
122  Fw::ObjectName portName;
123  portName.format(
124  "%s_comIn_InputPort[%" PRI_FwIndexType "]",
125  this->m_objName.toChar(),
126  port
127  );
128  this->m_comIn_InputPort[port].setObjName(portName.toChar());
129 #endif
130  }
131 #endif
132 
133 #if !FW_DIRECT_PORT_CALLS
134  // Connect input port pingIn
135  for (
136  FwIndexType port = 0;
137  port < static_cast<FwIndexType>(this->getNum_pingIn_InputPorts());
138  port++
139  ) {
140  this->m_pingIn_InputPort[port].init();
141  this->m_pingIn_InputPort[port].addCallComp(
142  this,
143  m_p_pingIn_in
144  );
145  this->m_pingIn_InputPort[port].setPortNum(port);
146 
147 #if FW_OBJECT_NAMES == 1
148  Fw::ObjectName portName;
149  portName.format(
150  "%s_pingIn_InputPort[%" PRI_FwIndexType "]",
151  this->m_objName.toChar(),
152  port
153  );
154  this->m_pingIn_InputPort[port].setObjName(portName.toChar());
155 #endif
156  }
157 #endif
158 
159 #if !FW_DIRECT_PORT_CALLS && FW_ENABLE_TEXT_LOGGING
160  // Connect output port LogText
161  for (
162  FwIndexType port = 0;
163  port < static_cast<FwIndexType>(this->getNum_LogText_OutputPorts());
164  port++
165  ) {
166  this->m_LogText_OutputPort[port].init();
167 
168 #if FW_OBJECT_NAMES == 1
169  Fw::ObjectName portName;
170  portName.format(
171  "%s_LogText_OutputPort[%" PRI_FwIndexType "]",
172  this->m_objName.toChar(),
173  port
174  );
175  this->m_LogText_OutputPort[port].setObjName(portName.toChar());
176 #endif
177  }
178 #endif
179 
180 #if !FW_DIRECT_PORT_CALLS
181  // Connect output port cmdRegOut
182  for (
183  FwIndexType port = 0;
184  port < static_cast<FwIndexType>(this->getNum_cmdRegOut_OutputPorts());
185  port++
186  ) {
187  this->m_cmdRegOut_OutputPort[port].init();
188 
189 #if FW_OBJECT_NAMES == 1
190  Fw::ObjectName portName;
191  portName.format(
192  "%s_cmdRegOut_OutputPort[%" PRI_FwIndexType "]",
193  this->m_objName.toChar(),
194  port
195  );
196  this->m_cmdRegOut_OutputPort[port].setObjName(portName.toChar());
197 #endif
198  }
199 #endif
200 
201 #if !FW_DIRECT_PORT_CALLS
202  // Connect output port cmdResponseOut
203  for (
204  FwIndexType port = 0;
205  port < static_cast<FwIndexType>(this->getNum_cmdResponseOut_OutputPorts());
206  port++
207  ) {
208  this->m_cmdResponseOut_OutputPort[port].init();
209 
210 #if FW_OBJECT_NAMES == 1
211  Fw::ObjectName portName;
212  portName.format(
213  "%s_cmdResponseOut_OutputPort[%" PRI_FwIndexType "]",
214  this->m_objName.toChar(),
215  port
216  );
217  this->m_cmdResponseOut_OutputPort[port].setObjName(portName.toChar());
218 #endif
219  }
220 #endif
221 
222 #if !FW_DIRECT_PORT_CALLS
223  // Connect output port logOut
224  for (
225  FwIndexType port = 0;
226  port < static_cast<FwIndexType>(this->getNum_logOut_OutputPorts());
227  port++
228  ) {
229  this->m_logOut_OutputPort[port].init();
230 
231 #if FW_OBJECT_NAMES == 1
232  Fw::ObjectName portName;
233  portName.format(
234  "%s_logOut_OutputPort[%" PRI_FwIndexType "]",
235  this->m_objName.toChar(),
236  port
237  );
238  this->m_logOut_OutputPort[port].setObjName(portName.toChar());
239 #endif
240  }
241 #endif
242 
243 #if !FW_DIRECT_PORT_CALLS
244  // Connect output port timeCaller
245  for (
246  FwIndexType port = 0;
247  port < static_cast<FwIndexType>(this->getNum_timeCaller_OutputPorts());
248  port++
249  ) {
250  this->m_timeCaller_OutputPort[port].init();
251 
252 #if FW_OBJECT_NAMES == 1
253  Fw::ObjectName portName;
254  portName.format(
255  "%s_timeCaller_OutputPort[%" PRI_FwIndexType "]",
256  this->m_objName.toChar(),
257  port
258  );
259  this->m_timeCaller_OutputPort[port].setObjName(portName.toChar());
260 #endif
261  }
262 #endif
263 
264 #if !FW_DIRECT_PORT_CALLS
265  // Connect output port pingOut
266  for (
267  FwIndexType port = 0;
268  port < static_cast<FwIndexType>(this->getNum_pingOut_OutputPorts());
269  port++
270  ) {
271  this->m_pingOut_OutputPort[port].init();
272 
273 #if FW_OBJECT_NAMES == 1
274  Fw::ObjectName portName;
275  portName.format(
276  "%s_pingOut_OutputPort[%" PRI_FwIndexType "]",
277  this->m_objName.toChar(),
278  port
279  );
280  this->m_pingOut_OutputPort[port].setObjName(portName.toChar());
281 #endif
282  }
283 #endif
284 
285  // Create the queue
286  Os::Queue::Status qStat = this->createQueue(
287  queueDepth,
288  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
289  );
290  FW_ASSERT(
291  Os::Queue::Status::OP_OK == qStat,
292  static_cast<FwAssertArgType>(qStat)
293  );
294  }
295 
296 #if !FW_DIRECT_PORT_CALLS
297 
298  // ----------------------------------------------------------------------
299  // Getters for special input ports
300  // ----------------------------------------------------------------------
301 
304  {
305  FW_ASSERT(
306  (0 <= portNum) && (portNum < this->getNum_cmdIn_InputPorts()),
307  static_cast<FwAssertArgType>(portNum)
308  );
309 
310  return &this->m_cmdIn_InputPort[portNum];
311  }
312 
313 #endif
314 
315 #if !FW_DIRECT_PORT_CALLS
316 
317  // ----------------------------------------------------------------------
318  // Getters for typed input ports
319  // ----------------------------------------------------------------------
320 
323  {
324  FW_ASSERT(
325  (0 <= portNum) && (portNum < this->getNum_comIn_InputPorts()),
326  static_cast<FwAssertArgType>(portNum)
327  );
328 
329  return &this->m_comIn_InputPort[portNum];
330  }
331 
334  {
335  FW_ASSERT(
336  (0 <= portNum) && (portNum < this->getNum_pingIn_InputPorts()),
337  static_cast<FwAssertArgType>(portNum)
338  );
339 
340  return &this->m_pingIn_InputPort[portNum];
341  }
342 
343 #endif
344 
345 #if !FW_DIRECT_PORT_CALLS
346 
347  // ----------------------------------------------------------------------
348  // Connect input ports to special output ports
349  // ----------------------------------------------------------------------
350 
351 #if FW_ENABLE_TEXT_LOGGING == 1
352 
353  void ComLoggerComponentBase ::
354  set_LogText_OutputPort(
355  FwIndexType portNum,
357  )
358  {
359  FW_ASSERT(
360  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
361  static_cast<FwAssertArgType>(portNum)
362  );
363 
364  this->m_LogText_OutputPort[portNum].addCallPort(port);
365  }
366 
367 #endif
368 
371  FwIndexType portNum,
372  Fw::InputCmdRegPort* port
373  )
374  {
375  FW_ASSERT(
376  (0 <= portNum) && (portNum < this->getNum_cmdRegOut_OutputPorts()),
377  static_cast<FwAssertArgType>(portNum)
378  );
379 
380  this->m_cmdRegOut_OutputPort[portNum].addCallPort(port);
381  }
382 
385  FwIndexType portNum,
387  )
388  {
389  FW_ASSERT(
390  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
391  static_cast<FwAssertArgType>(portNum)
392  );
393 
394  this->m_cmdResponseOut_OutputPort[portNum].addCallPort(port);
395  }
396 
399  FwIndexType portNum,
400  Fw::InputLogPort* port
401  )
402  {
403  FW_ASSERT(
404  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
405  static_cast<FwAssertArgType>(portNum)
406  );
407 
408  this->m_logOut_OutputPort[portNum].addCallPort(port);
409  }
410 
413  FwIndexType portNum,
414  Fw::InputTimePort* port
415  )
416  {
417  FW_ASSERT(
418  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
419  static_cast<FwAssertArgType>(portNum)
420  );
421 
422  this->m_timeCaller_OutputPort[portNum].addCallPort(port);
423  }
424 
425 #endif
426 
427 #if !FW_DIRECT_PORT_CALLS
428 
429  // ----------------------------------------------------------------------
430  // Connect typed input ports to typed output ports
431  // ----------------------------------------------------------------------
432 
435  FwIndexType portNum,
436  Svc::InputPingPort* port
437  )
438  {
439  FW_ASSERT(
440  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
441  static_cast<FwAssertArgType>(portNum)
442  );
443 
444  this->m_pingOut_OutputPort[portNum].addCallPort(port);
445  }
446 
447 #endif
448 
449 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
450 
451  // ----------------------------------------------------------------------
452  // Connect serial input ports to special output ports
453  // ----------------------------------------------------------------------
454 
455 #if FW_ENABLE_TEXT_LOGGING == 1
456 
457  void ComLoggerComponentBase ::
458  set_LogText_OutputPort(
459  FwIndexType portNum,
460  Fw::InputSerializePort* port
461  )
462  {
463  FW_ASSERT(
464  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
465  static_cast<FwAssertArgType>(portNum)
466  );
467 
468  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
469  }
470 
471 #endif
472 
475  FwIndexType portNum,
476  Fw::InputSerializePort* port
477  )
478  {
479  FW_ASSERT(
480  (0 <= portNum) && (portNum < this->getNum_cmdRegOut_OutputPorts()),
481  static_cast<FwAssertArgType>(portNum)
482  );
483 
484  this->m_cmdRegOut_OutputPort[portNum].registerSerialPort(port);
485  }
486 
489  FwIndexType portNum,
490  Fw::InputSerializePort* port
491  )
492  {
493  FW_ASSERT(
494  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
495  static_cast<FwAssertArgType>(portNum)
496  );
497 
498  this->m_cmdResponseOut_OutputPort[portNum].registerSerialPort(port);
499  }
500 
503  FwIndexType portNum,
504  Fw::InputSerializePort* port
505  )
506  {
507  FW_ASSERT(
508  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
509  static_cast<FwAssertArgType>(portNum)
510  );
511 
512  this->m_logOut_OutputPort[portNum].registerSerialPort(port);
513  }
514 
517  FwIndexType portNum,
518  Fw::InputSerializePort* port
519  )
520  {
521  FW_ASSERT(
522  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
523  static_cast<FwAssertArgType>(portNum)
524  );
525 
526  this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
527  }
528 
529 #endif
530 
531 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
532 
533  // ----------------------------------------------------------------------
534  // Connect serial input ports to typed output ports
535  // ----------------------------------------------------------------------
536 
539  FwIndexType portNum,
540  Fw::InputSerializePort* port
541  )
542  {
543  FW_ASSERT(
544  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
545  static_cast<FwAssertArgType>(portNum)
546  );
547 
548  this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
549  }
550 
551 #endif
552 
553  // ----------------------------------------------------------------------
554  // Command registration
555  // ----------------------------------------------------------------------
556 
559  {
561 
562  this->cmdRegOut_out(
563  0,
564  this->getIdBase() + OPCODE_CLOSEFILE
565  );
566  }
567 
568  // ----------------------------------------------------------------------
569  // Component construction and destruction
570  // ----------------------------------------------------------------------
571 
573  ComLoggerComponentBase(const char* compName) :
574  Fw::ActiveComponentBase(compName)
575  {
576  this->m_FileNotInitializedThrottle = 0;
577  }
578 
581  {
582 
583  }
584 
585 #if !FW_DIRECT_PORT_CALLS
586 
587  // ----------------------------------------------------------------------
588  // Connection status queries for special output ports
589  // ----------------------------------------------------------------------
590 
591 #if FW_ENABLE_TEXT_LOGGING == 1
592 
593  bool ComLoggerComponentBase ::
594  isConnected_LogText_OutputPort(FwIndexType portNum) const
595  {
596  FW_ASSERT(
597  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
598  static_cast<FwAssertArgType>(portNum)
599  );
600 
601  return this->m_LogText_OutputPort[portNum].isConnected();
602  }
603 
604 #endif
605 
608  {
609  FW_ASSERT(
610  (0 <= portNum) && (portNum < this->getNum_cmdRegOut_OutputPorts()),
611  static_cast<FwAssertArgType>(portNum)
612  );
613 
614  return this->m_cmdRegOut_OutputPort[portNum].isConnected();
615  }
616 
619  {
620  FW_ASSERT(
621  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
622  static_cast<FwAssertArgType>(portNum)
623  );
624 
625  return this->m_cmdResponseOut_OutputPort[portNum].isConnected();
626  }
627 
630  {
631  FW_ASSERT(
632  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
633  static_cast<FwAssertArgType>(portNum)
634  );
635 
636  return this->m_logOut_OutputPort[portNum].isConnected();
637  }
638 
641  {
642  FW_ASSERT(
643  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
644  static_cast<FwAssertArgType>(portNum)
645  );
646 
647  return this->m_timeCaller_OutputPort[portNum].isConnected();
648  }
649 
650 #endif
651 
652 #if !FW_DIRECT_PORT_CALLS
653 
654  // ----------------------------------------------------------------------
655  // Connection status queries for typed output ports
656  // ----------------------------------------------------------------------
657 
660  {
661  FW_ASSERT(
662  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
663  static_cast<FwAssertArgType>(portNum)
664  );
665 
666  return this->m_pingOut_OutputPort[portNum].isConnected();
667  }
668 
669 #endif
670 
671  // ----------------------------------------------------------------------
672  // Port handler base-class functions for special input ports
673  //
674  // Call these functions directly to bypass the corresponding ports
675  // ----------------------------------------------------------------------
676 
679  FwIndexType portNum,
680  FwOpcodeType opCode,
681  U32 cmdSeq,
682  Fw::CmdArgBuffer& args
683  )
684  {
685 
686  const U32 idBase = this->getIdBase();
687  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
688 
689  // Select base class function based on opcode
690  switch (opCode - idBase) {
691  case OPCODE_CLOSEFILE: {
693  opCode,
694  cmdSeq,
695  args
696  );
697  break;
698  }
699  default:
700  // Unknown opcode: ignore it
701  break;
702  }
703  }
704 
705  // ----------------------------------------------------------------------
706  // Port handler base-class functions for typed input ports
707  //
708  // Call these functions directly to bypass the corresponding ports
709  // ----------------------------------------------------------------------
710 
713  FwIndexType portNum,
714  Fw::ComBuffer& data,
715  U32 context
716  )
717  {
718  // Make sure port number is valid
719  FW_ASSERT(
720  (0 <= portNum) && (portNum < this->getNum_comIn_InputPorts()),
721  static_cast<FwAssertArgType>(portNum)
722  );
723 
724  // Call pre-message hook
726  portNum,
727  data,
728  context
729  );
730  ComponentIpcSerializableBuffer msg;
732 
733  // Serialize message ID
734  _status = msg.serializeFrom(
735  static_cast<FwEnumStoreType>(COMIN_COM)
736  );
737  FW_ASSERT(
738  _status == Fw::FW_SERIALIZE_OK,
739  static_cast<FwAssertArgType>(_status)
740  );
741 
742  // Serialize port number
743  _status = msg.serializeFrom(portNum);
744  FW_ASSERT(
745  _status == Fw::FW_SERIALIZE_OK,
746  static_cast<FwAssertArgType>(_status)
747  );
748 
749  // Serialize argument data
750  _status = msg.serializeFrom(data);
751  FW_ASSERT(
752  _status == Fw::FW_SERIALIZE_OK,
753  static_cast<FwAssertArgType>(_status)
754  );
755 
756  // Serialize argument context
757  _status = msg.serializeFrom(context);
758  FW_ASSERT(
759  _status == Fw::FW_SERIALIZE_OK,
760  static_cast<FwAssertArgType>(_status)
761  );
762 
763  // Send message
765  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
766 
767  FW_ASSERT(
768  qStatus == Os::Queue::OP_OK,
769  static_cast<FwAssertArgType>(qStatus)
770  );
771  }
772 
775  FwIndexType portNum,
776  U32 key
777  )
778  {
779  // Make sure port number is valid
780  FW_ASSERT(
781  (0 <= portNum) && (portNum < this->getNum_pingIn_InputPorts()),
782  static_cast<FwAssertArgType>(portNum)
783  );
784 
785  // Call pre-message hook
787  portNum,
788  key
789  );
790  ComponentIpcSerializableBuffer msg;
792 
793  // Serialize message ID
794  _status = msg.serializeFrom(
795  static_cast<FwEnumStoreType>(PINGIN_PING)
796  );
797  FW_ASSERT(
798  _status == Fw::FW_SERIALIZE_OK,
799  static_cast<FwAssertArgType>(_status)
800  );
801 
802  // Serialize port number
803  _status = msg.serializeFrom(portNum);
804  FW_ASSERT(
805  _status == Fw::FW_SERIALIZE_OK,
806  static_cast<FwAssertArgType>(_status)
807  );
808 
809  // Serialize argument key
810  _status = msg.serializeFrom(key);
811  FW_ASSERT(
812  _status == Fw::FW_SERIALIZE_OK,
813  static_cast<FwAssertArgType>(_status)
814  );
815 
816  // Send message
818  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
819 
820  FW_ASSERT(
821  qStatus == Os::Queue::OP_OK,
822  static_cast<FwAssertArgType>(qStatus)
823  );
824  }
825 
826  // ----------------------------------------------------------------------
827  // Pre-message hooks for typed async input ports
828  //
829  // Each of these functions is invoked just before processing a message
830  // on the corresponding port. By default, they do nothing. You can
831  // override them to provide specific pre-message behavior.
832  // ----------------------------------------------------------------------
833 
836  FwIndexType portNum,
837  Fw::ComBuffer& data,
838  U32 context
839  )
840  {
841  // Default: no-op
842  }
843 
846  FwIndexType portNum,
847  U32 key
848  )
849  {
850  // Default: no-op
851  }
852 
853 #if !FW_DIRECT_PORT_CALLS
854 
855  // ----------------------------------------------------------------------
856  // Invocation functions for typed output ports
857  // ----------------------------------------------------------------------
858 
861  FwIndexType portNum,
862  U32 key
863  ) const
864  {
865  FW_ASSERT(
866  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
867  static_cast<FwAssertArgType>(portNum)
868  );
869 
870  FW_ASSERT(
871  this->m_pingOut_OutputPort[portNum].isConnected(),
872  static_cast<FwAssertArgType>(portNum)
873  );
874  this->m_pingOut_OutputPort[portNum].invoke(
875  key
876  );
877  }
878 
879 #endif
880 
881  // ----------------------------------------------------------------------
882  // Command response
883  // ----------------------------------------------------------------------
884 
887  FwOpcodeType opCode,
888  U32 cmdSeq,
889  Fw::CmdResponse response
890  )
891  {
893  this->cmdResponseOut_out(0, opCode, cmdSeq, response);
894  }
895 
896  // ----------------------------------------------------------------------
897  // Command handler base-class functions
898  //
899  // Call these functions directly to bypass the command input port
900  // ----------------------------------------------------------------------
901 
904  FwOpcodeType opCode,
905  U32 cmdSeq,
906  Fw::CmdArgBuffer& args
907  )
908  {
909  // Call pre-message hook
910  this->CloseFile_preMsgHook(opCode,cmdSeq);
911 
912  // Defer deserializing arguments to the message dispatcher
913  // to avoid deserializing and reserializing just for IPC
914  ComponentIpcSerializableBuffer msg;
916 
917  // Serialize for IPC
918  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_CLOSEFILE));
919  FW_ASSERT (
920  _status == Fw::FW_SERIALIZE_OK,
921  static_cast<FwAssertArgType>(_status)
922  );
923 
924  // Fake port number to make message dequeue work
925  FwIndexType port = 0;
926 
927  _status = msg.serializeFrom(port);
928  FW_ASSERT (
929  _status == Fw::FW_SERIALIZE_OK,
930  static_cast<FwAssertArgType>(_status)
931  );
932 
933  _status = msg.serializeFrom(opCode);
934  FW_ASSERT (
935  _status == Fw::FW_SERIALIZE_OK,
936  static_cast<FwAssertArgType>(_status)
937  );
938 
939  _status = msg.serializeFrom(cmdSeq);
940  FW_ASSERT (
941  _status == Fw::FW_SERIALIZE_OK,
942  static_cast<FwAssertArgType>(_status)
943  );
944 
945  _status = msg.serializeFrom(args);
946  FW_ASSERT (
947  _status == Fw::FW_SERIALIZE_OK,
948  static_cast<FwAssertArgType>(_status)
949  );
950 
951  // Send message
953  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
954 
955  FW_ASSERT(
956  qStatus == Os::Queue::OP_OK,
957  static_cast<FwAssertArgType>(qStatus)
958  );
959  }
960 
961  // ----------------------------------------------------------------------
962  // Pre-message hooks for async commands
963  //
964  // Each of these functions is invoked just before processing the
965  // corresponding command. By default they do nothing. You can
966  // override them to provide specific pre-command behavior.
967  // ----------------------------------------------------------------------
968 
971  FwOpcodeType opCode,
972  U32 cmdSeq
973  )
974  {
975  // Defaults to no-op; can be overridden
976  (void) opCode;
977  (void) cmdSeq;
978  }
979 
980  // ----------------------------------------------------------------------
981  // Event logging functions
982  // ----------------------------------------------------------------------
983 
986  U32 errornum,
987  const Fw::StringBase& file
988  ) const
989  {
990  // Get the time
991  Fw::Time _logTime;
992  if (this->isConnected_timeCaller_OutputPort(0)) {
993  this->timeCaller_out(0, _logTime);
994  }
995 
996  const FwEventIdType _id = this->getIdBase() + EVENTID_FILEOPENERROR;
997 
998  // Emit the event on the log port
999  if (this->isConnected_logOut_OutputPort(0)) {
1000  Fw::LogBuffer _logBuff;
1002 
1003 #if FW_AMPCS_COMPATIBLE
1004  // Serialize the number of arguments
1005  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1006  FW_ASSERT(
1007  _status == Fw::FW_SERIALIZE_OK,
1008  static_cast<FwAssertArgType>(_status)
1009  );
1010 #endif
1011 
1012 #if FW_AMPCS_COMPATIBLE
1013  // Serialize the argument size
1014  _status = _logBuff.serializeFrom(
1015  static_cast<U8>(sizeof(U32))
1016  );
1017  FW_ASSERT(
1018  _status == Fw::FW_SERIALIZE_OK,
1019  static_cast<FwAssertArgType>(_status)
1020  );
1021 #endif
1022  _status = _logBuff.serializeFrom(errornum);
1023  FW_ASSERT(
1024  _status == Fw::FW_SERIALIZE_OK,
1025  static_cast<FwAssertArgType>(_status)
1026  );
1027 
1028  _status = file.serializeTo(
1029  _logBuff,
1030  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
1031  );
1032  FW_ASSERT(
1033  _status == Fw::FW_SERIALIZE_OK,
1034  static_cast<FwAssertArgType>(_status)
1035  );
1036 
1037  this->logOut_out(
1038  0,
1039  _id,
1040  _logTime,
1042  _logBuff
1043  );
1044  }
1045 
1046  // Emit the event on the text log port
1047 #if FW_ENABLE_TEXT_LOGGING
1048  if (this->isConnected_LogText_OutputPort(0)) {
1049 #if FW_OBJECT_NAMES == 1
1050  const char* _formatString =
1051  "(%s) %s: Error %" PRIu32 " opening file %s";
1052 #else
1053  const char* _formatString =
1054  "%s: Error %" PRIu32 " opening file %s";
1055 #endif
1056 
1057  Fw::TextLogString _logString;
1058  _logString.format(
1059  _formatString,
1060 #if FW_OBJECT_NAMES == 1
1061  this->m_objName.toChar(),
1062 #endif
1063  "FileOpenError ",
1064  errornum,
1065  file.toChar()
1066  );
1067 
1068  this->LogText_out(
1069  0,
1070  _id,
1071  _logTime,
1073  _logString
1074  );
1075  }
1076 #endif
1077  }
1078 
1081  U32 errornum,
1082  U32 bytesWritten,
1083  U32 bytesToWrite,
1084  const Fw::StringBase& file
1085  ) const
1086  {
1087  // Get the time
1088  Fw::Time _logTime;
1089  if (this->isConnected_timeCaller_OutputPort(0)) {
1090  this->timeCaller_out(0, _logTime);
1091  }
1092 
1093  const FwEventIdType _id = this->getIdBase() + EVENTID_FILEWRITEERROR;
1094 
1095  // Emit the event on the log port
1096  if (this->isConnected_logOut_OutputPort(0)) {
1097  Fw::LogBuffer _logBuff;
1099 
1100 #if FW_AMPCS_COMPATIBLE
1101  // Serialize the number of arguments
1102  _status = _logBuff.serializeFrom(static_cast<U8>(4));
1103  FW_ASSERT(
1104  _status == Fw::FW_SERIALIZE_OK,
1105  static_cast<FwAssertArgType>(_status)
1106  );
1107 #endif
1108 
1109 #if FW_AMPCS_COMPATIBLE
1110  // Serialize the argument size
1111  _status = _logBuff.serializeFrom(
1112  static_cast<U8>(sizeof(U32))
1113  );
1114  FW_ASSERT(
1115  _status == Fw::FW_SERIALIZE_OK,
1116  static_cast<FwAssertArgType>(_status)
1117  );
1118 #endif
1119  _status = _logBuff.serializeFrom(errornum);
1120  FW_ASSERT(
1121  _status == Fw::FW_SERIALIZE_OK,
1122  static_cast<FwAssertArgType>(_status)
1123  );
1124 
1125 #if FW_AMPCS_COMPATIBLE
1126  // Serialize the argument size
1127  _status = _logBuff.serializeFrom(
1128  static_cast<U8>(sizeof(U32))
1129  );
1130  FW_ASSERT(
1131  _status == Fw::FW_SERIALIZE_OK,
1132  static_cast<FwAssertArgType>(_status)
1133  );
1134 #endif
1135  _status = _logBuff.serializeFrom(bytesWritten);
1136  FW_ASSERT(
1137  _status == Fw::FW_SERIALIZE_OK,
1138  static_cast<FwAssertArgType>(_status)
1139  );
1140 
1141 #if FW_AMPCS_COMPATIBLE
1142  // Serialize the argument size
1143  _status = _logBuff.serializeFrom(
1144  static_cast<U8>(sizeof(U32))
1145  );
1146  FW_ASSERT(
1147  _status == Fw::FW_SERIALIZE_OK,
1148  static_cast<FwAssertArgType>(_status)
1149  );
1150 #endif
1151  _status = _logBuff.serializeFrom(bytesToWrite);
1152  FW_ASSERT(
1153  _status == Fw::FW_SERIALIZE_OK,
1154  static_cast<FwAssertArgType>(_status)
1155  );
1156 
1157  _status = file.serializeTo(
1158  _logBuff,
1159  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
1160  );
1161  FW_ASSERT(
1162  _status == Fw::FW_SERIALIZE_OK,
1163  static_cast<FwAssertArgType>(_status)
1164  );
1165 
1166  this->logOut_out(
1167  0,
1168  _id,
1169  _logTime,
1171  _logBuff
1172  );
1173  }
1174 
1175  // Emit the event on the text log port
1176 #if FW_ENABLE_TEXT_LOGGING
1177  if (this->isConnected_LogText_OutputPort(0)) {
1178 #if FW_OBJECT_NAMES == 1
1179  const char* _formatString =
1180  "(%s) %s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1181 #else
1182  const char* _formatString =
1183  "%s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1184 #endif
1185 
1186  Fw::TextLogString _logString;
1187  _logString.format(
1188  _formatString,
1189 #if FW_OBJECT_NAMES == 1
1190  this->m_objName.toChar(),
1191 #endif
1192  "FileWriteError ",
1193  errornum,
1194  bytesWritten,
1195  bytesToWrite,
1196  file.toChar()
1197  );
1198 
1199  this->LogText_out(
1200  0,
1201  _id,
1202  _logTime,
1204  _logString
1205  );
1206  }
1207 #endif
1208  }
1209 
1212  const Fw::StringBase& validationFile,
1213  const Fw::StringBase& file,
1214  U32 status
1215  ) const
1216  {
1217  // Get the time
1218  Fw::Time _logTime;
1219  if (this->isConnected_timeCaller_OutputPort(0)) {
1220  this->timeCaller_out(0, _logTime);
1221  }
1222 
1223  const FwEventIdType _id = this->getIdBase() + EVENTID_FILEVALIDATIONERROR;
1224 
1225  // Emit the event on the log port
1226  if (this->isConnected_logOut_OutputPort(0)) {
1227  Fw::LogBuffer _logBuff;
1229 
1230 #if FW_AMPCS_COMPATIBLE
1231  // Serialize the number of arguments
1232  _status = _logBuff.serializeFrom(static_cast<U8>(3));
1233  FW_ASSERT(
1234  _status == Fw::FW_SERIALIZE_OK,
1235  static_cast<FwAssertArgType>(_status)
1236  );
1237 #endif
1238 
1239  _status = validationFile.serializeTo(
1240  _logBuff,
1241  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
1242  );
1243  FW_ASSERT(
1244  _status == Fw::FW_SERIALIZE_OK,
1245  static_cast<FwAssertArgType>(_status)
1246  );
1247 
1248  _status = file.serializeTo(
1249  _logBuff,
1250  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
1251  );
1252  FW_ASSERT(
1253  _status == Fw::FW_SERIALIZE_OK,
1254  static_cast<FwAssertArgType>(_status)
1255  );
1256 
1257 #if FW_AMPCS_COMPATIBLE
1258  // Serialize the argument size
1259  _status = _logBuff.serializeFrom(
1260  static_cast<U8>(sizeof(U32))
1261  );
1262  FW_ASSERT(
1263  _status == Fw::FW_SERIALIZE_OK,
1264  static_cast<FwAssertArgType>(_status)
1265  );
1266 #endif
1267  _status = _logBuff.serializeFrom(status);
1268  FW_ASSERT(
1269  _status == Fw::FW_SERIALIZE_OK,
1270  static_cast<FwAssertArgType>(_status)
1271  );
1272 
1273  this->logOut_out(
1274  0,
1275  _id,
1276  _logTime,
1278  _logBuff
1279  );
1280  }
1281 
1282  // Emit the event on the text log port
1283 #if FW_ENABLE_TEXT_LOGGING
1284  if (this->isConnected_LogText_OutputPort(0)) {
1285 #if FW_OBJECT_NAMES == 1
1286  const char* _formatString =
1287  "(%s) %s: The ComLogger failed to create a validation file %s for %s with error %" PRIu32 ".";
1288 #else
1289  const char* _formatString =
1290  "%s: The ComLogger failed to create a validation file %s for %s with error %" PRIu32 ".";
1291 #endif
1292 
1293  Fw::TextLogString _logString;
1294  _logString.format(
1295  _formatString,
1296 #if FW_OBJECT_NAMES == 1
1297  this->m_objName.toChar(),
1298 #endif
1299  "FileValidationError ",
1300  validationFile.toChar(),
1301  file.toChar(),
1302  status
1303  );
1304 
1305  this->LogText_out(
1306  0,
1307  _id,
1308  _logTime,
1310  _logString
1311  );
1312  }
1313 #endif
1314  }
1315 
1318  {
1319  // Get the time
1320  Fw::Time _logTime;
1321  if (this->isConnected_timeCaller_OutputPort(0)) {
1322  this->timeCaller_out(0, _logTime);
1323  }
1324 
1325  const FwEventIdType _id = this->getIdBase() + EVENTID_FILECLOSED;
1326 
1327  // Emit the event on the log port
1328  if (this->isConnected_logOut_OutputPort(0)) {
1329  Fw::LogBuffer _logBuff;
1331 
1332 #if FW_AMPCS_COMPATIBLE
1333  // Serialize the number of arguments
1334  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1335  FW_ASSERT(
1336  _status == Fw::FW_SERIALIZE_OK,
1337  static_cast<FwAssertArgType>(_status)
1338  );
1339 #endif
1340 
1341  _status = file.serializeTo(
1342  _logBuff,
1343  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
1344  );
1345  FW_ASSERT(
1346  _status == Fw::FW_SERIALIZE_OK,
1347  static_cast<FwAssertArgType>(_status)
1348  );
1349 
1350  this->logOut_out(
1351  0,
1352  _id,
1353  _logTime,
1355  _logBuff
1356  );
1357  }
1358 
1359  // Emit the event on the text log port
1360 #if FW_ENABLE_TEXT_LOGGING
1361  if (this->isConnected_LogText_OutputPort(0)) {
1362 #if FW_OBJECT_NAMES == 1
1363  const char* _formatString =
1364  "(%s) %s: File %s closed successfully.";
1365 #else
1366  const char* _formatString =
1367  "%s: File %s closed successfully.";
1368 #endif
1369 
1370  Fw::TextLogString _logString;
1371  _logString.format(
1372  _formatString,
1373 #if FW_OBJECT_NAMES == 1
1374  this->m_objName.toChar(),
1375 #endif
1376  "FileClosed ",
1377  file.toChar()
1378  );
1379 
1380  this->LogText_out(
1381  0,
1382  _id,
1383  _logTime,
1385  _logString
1386  );
1387  }
1388 #endif
1389  }
1390 
1393  {
1394  // Check throttle value
1395  if (this->m_FileNotInitializedThrottle >= EVENTID_FILENOTINITIALIZED_THROTTLE) {
1396  return;
1397  }
1398  else {
1399  this->m_FileNotInitializedThrottle++;
1400  }
1401 
1402  // Get the time
1403  Fw::Time _logTime;
1404  if (this->isConnected_timeCaller_OutputPort(0)) {
1405  this->timeCaller_out(0, _logTime);
1406  }
1407 
1408  const FwEventIdType _id = this->getIdBase() + EVENTID_FILENOTINITIALIZED;
1409 
1410  // Emit the event on the log port
1411  if (this->isConnected_logOut_OutputPort(0)) {
1412  Fw::LogBuffer _logBuff;
1413 
1414 #if FW_AMPCS_COMPATIBLE
1416  // Serialize the number of arguments
1417  _status = _logBuff.serializeFrom(static_cast<U8>(0));
1418  FW_ASSERT(
1419  _status == Fw::FW_SERIALIZE_OK,
1420  static_cast<FwAssertArgType>(_status)
1421  );
1422 #endif
1423 
1424  this->logOut_out(
1425  0,
1426  _id,
1427  _logTime,
1429  _logBuff
1430  );
1431  }
1432 
1433  // Emit the event on the text log port
1434 #if FW_ENABLE_TEXT_LOGGING
1435  if (this->isConnected_LogText_OutputPort(0)) {
1436 #if FW_OBJECT_NAMES == 1
1437  const char* _formatString =
1438  "(%s) %s: Could not open ComLogger file. File not initialized";
1439 #else
1440  const char* _formatString =
1441  "%s: Could not open ComLogger file. File not initialized";
1442 #endif
1443 
1444  Fw::TextLogString _logString;
1445  _logString.format(
1446  _formatString,
1447 #if FW_OBJECT_NAMES == 1
1448  this->m_objName.toChar(),
1449 #endif
1450  "FileNotInitialized "
1451  );
1452 
1453  this->LogText_out(
1454  0,
1455  _id,
1456  _logTime,
1458  _logString
1459  );
1460  }
1461 #endif
1462  }
1463 
1464  // ----------------------------------------------------------------------
1465  // Event throttle reset functions
1466  // ----------------------------------------------------------------------
1467 
1470  {
1471  // Reset throttle counter
1472  this->m_FileNotInitializedThrottle = 0;
1473  }
1474 
1475  // ----------------------------------------------------------------------
1476  // Time
1477  // ----------------------------------------------------------------------
1478 
1480  getTime() const
1481  {
1482  if (this->isConnected_timeCaller_OutputPort(0)) {
1483  Fw::Time _time;
1484  this->timeCaller_out(0, _time);
1485  return _time;
1486  }
1487  else {
1488  return Fw::Time(TimeBase::TB_NONE, 0, 0);
1489  }
1490  }
1491 
1492  // ----------------------------------------------------------------------
1493  // Message dispatch functions
1494  // ----------------------------------------------------------------------
1495 
1496  Fw::QueuedComponentBase::MsgDispatchStatus ComLoggerComponentBase ::
1497  doDispatch()
1498  {
1499  ComponentIpcSerializableBuffer _msg;
1500  FwQueuePriorityType _priority = 0;
1501 
1502  Os::Queue::Status _msgStatus = this->m_queue.receive(
1503  _msg,
1505  _priority
1506  );
1507  FW_ASSERT(
1508  _msgStatus == Os::Queue::OP_OK,
1509  static_cast<FwAssertArgType>(_msgStatus)
1510  );
1511 
1512  // Reset to beginning of buffer
1513  _msg.resetDeser();
1514 
1515  FwEnumStoreType _desMsg = 0;
1516  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
1517  FW_ASSERT(
1518  _deserStatus == Fw::FW_SERIALIZE_OK,
1519  static_cast<FwAssertArgType>(_deserStatus)
1520  );
1521 
1522  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
1523 
1524  if (_msgType == COMLOGGER_COMPONENT_EXIT) {
1525  return MSG_DISPATCH_EXIT;
1526  }
1527 
1528  FwIndexType portNum = 0;
1529  _deserStatus = _msg.deserializeTo(portNum);
1530  FW_ASSERT(
1531  _deserStatus == Fw::FW_SERIALIZE_OK,
1532  static_cast<FwAssertArgType>(_deserStatus)
1533  );
1534 
1535  switch (_msgType) {
1536  // Handle async input port comIn
1537  case COMIN_COM: {
1538  // Deserialize argument data
1539  Fw::ComBuffer data;
1540  _deserStatus = _msg.deserializeTo(data);
1541  FW_ASSERT(
1542  _deserStatus == Fw::FW_SERIALIZE_OK,
1543  static_cast<FwAssertArgType>(_deserStatus)
1544  );
1545 
1546  // Deserialize argument context
1547  U32 context;
1548  _deserStatus = _msg.deserializeTo(context);
1549  FW_ASSERT(
1550  _deserStatus == Fw::FW_SERIALIZE_OK,
1551  static_cast<FwAssertArgType>(_deserStatus)
1552  );
1553  // Call handler function
1554  this->comIn_handler(
1555  portNum,
1556  data,
1557  context
1558  );
1559 
1560  break;
1561  }
1562 
1563  // Handle async input port pingIn
1564  case PINGIN_PING: {
1565  // Deserialize argument key
1566  U32 key;
1567  _deserStatus = _msg.deserializeTo(key);
1568  FW_ASSERT(
1569  _deserStatus == Fw::FW_SERIALIZE_OK,
1570  static_cast<FwAssertArgType>(_deserStatus)
1571  );
1572  // Call handler function
1573  this->pingIn_handler(
1574  portNum,
1575  key
1576  );
1577 
1578  break;
1579  }
1580 
1581  // Handle command CloseFile
1582  case CMD_CLOSEFILE: {
1583  // Deserialize opcode
1584  FwOpcodeType _opCode = 0;
1585  _deserStatus = _msg.deserializeTo(_opCode);
1586  FW_ASSERT (
1587  _deserStatus == Fw::FW_SERIALIZE_OK,
1588  static_cast<FwAssertArgType>(_deserStatus)
1589  );
1590 
1591  // Deserialize command sequence
1592  U32 _cmdSeq = 0;
1593  _deserStatus = _msg.deserializeTo(_cmdSeq);
1594  FW_ASSERT (
1595  _deserStatus == Fw::FW_SERIALIZE_OK,
1596  static_cast<FwAssertArgType>(_deserStatus)
1597  );
1598 
1599  // Deserialize command argument buffer
1600  Fw::CmdArgBuffer args;
1601  _deserStatus = _msg.deserializeTo(args);
1602  FW_ASSERT (
1603  _deserStatus == Fw::FW_SERIALIZE_OK,
1604  static_cast<FwAssertArgType>(_deserStatus)
1605  );
1606 
1607  // Reset buffer
1608  args.resetDeser();
1609 
1610  // Make sure there was no data left over.
1611  // That means the argument buffer size was incorrect.
1612 #if FW_CMD_CHECK_RESIDUAL
1613  if (args.getDeserializeSizeLeft() != 0) {
1615  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
1616  }
1617  // Don't crash the task if bad arguments were passed from the ground
1618  break;
1619  }
1620 #endif
1621 
1622  // Call handler function
1623  this->CloseFile_cmdHandler(_opCode, _cmdSeq);
1624 
1625  break;
1626  }
1627 
1628  default:
1629  return MSG_DISPATCH_ERROR;
1630  }
1631 
1632  return MSG_DISPATCH_OK;
1633  }
1634 
1635  // ----------------------------------------------------------------------
1636  // Calls for messages received on special input ports
1637  // ----------------------------------------------------------------------
1638 
1639  void ComLoggerComponentBase ::
1640  m_p_cmdIn_in(
1641  Fw::PassiveComponentBase* callComp,
1642  FwIndexType portNum,
1643  FwOpcodeType opCode,
1644  U32 cmdSeq,
1645  Fw::CmdArgBuffer& args
1646  )
1647  {
1648  FW_ASSERT(callComp);
1649  ComLoggerComponentBase* compPtr = static_cast<ComLoggerComponentBase*>(callComp);
1650  compPtr->cmdIn_handlerBase(
1651  portNum,
1652  opCode,
1653  cmdSeq,
1654  args
1655  );
1656  }
1657 
1658  // ----------------------------------------------------------------------
1659  // Calls for messages received on typed input ports
1660  // ----------------------------------------------------------------------
1661 
1662  void ComLoggerComponentBase ::
1663  m_p_comIn_in(
1664  Fw::PassiveComponentBase* callComp,
1665  FwIndexType portNum,
1666  Fw::ComBuffer& data,
1667  U32 context
1668  )
1669  {
1670  FW_ASSERT(callComp);
1671  ComLoggerComponentBase* compPtr = static_cast<ComLoggerComponentBase*>(callComp);
1672  compPtr->comIn_handlerBase(
1673  portNum,
1674  data,
1675  context
1676  );
1677  }
1678 
1679  void ComLoggerComponentBase ::
1680  m_p_pingIn_in(
1681  Fw::PassiveComponentBase* callComp,
1682  FwIndexType portNum,
1683  U32 key
1684  )
1685  {
1686  FW_ASSERT(callComp);
1687  ComLoggerComponentBase* compPtr = static_cast<ComLoggerComponentBase*>(callComp);
1688  compPtr->pingIn_handlerBase(
1689  portNum,
1690  key
1691  );
1692  }
1693 
1694 #if !FW_DIRECT_PORT_CALLS
1695 
1696  // ----------------------------------------------------------------------
1697  // Invocation functions for special output ports
1698  // ----------------------------------------------------------------------
1699 
1700 #if FW_ENABLE_TEXT_LOGGING
1701 
1702  void ComLoggerComponentBase ::
1703  LogText_out(
1704  FwIndexType portNum,
1705  FwEventIdType id,
1706  Fw::Time& timeTag,
1707  const Fw::LogSeverity& severity,
1708  Fw::TextLogString& text
1709  ) const
1710  {
1711  FW_ASSERT(
1712  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
1713  static_cast<FwAssertArgType>(portNum)
1714  );
1715 
1716  FW_ASSERT(
1717  this->m_LogText_OutputPort[portNum].isConnected(),
1718  static_cast<FwAssertArgType>(portNum)
1719  );
1720  this->m_LogText_OutputPort[portNum].invoke(
1721  id,
1722  timeTag,
1723  severity,
1724  text
1725  );
1726  }
1727 
1728 #endif
1729 
1730  void ComLoggerComponentBase ::
1731  cmdRegOut_out(
1732  FwIndexType portNum,
1733  FwOpcodeType opCode
1734  ) const
1735  {
1736  FW_ASSERT(
1737  (0 <= portNum) && (portNum < this->getNum_cmdRegOut_OutputPorts()),
1738  static_cast<FwAssertArgType>(portNum)
1739  );
1740 
1741  FW_ASSERT(
1742  this->m_cmdRegOut_OutputPort[portNum].isConnected(),
1743  static_cast<FwAssertArgType>(portNum)
1744  );
1745  this->m_cmdRegOut_OutputPort[portNum].invoke(
1746  opCode
1747  );
1748  }
1749 
1750  void ComLoggerComponentBase ::
1751  cmdResponseOut_out(
1752  FwIndexType portNum,
1753  FwOpcodeType opCode,
1754  U32 cmdSeq,
1755  const Fw::CmdResponse& response
1756  ) const
1757  {
1758  FW_ASSERT(
1759  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
1760  static_cast<FwAssertArgType>(portNum)
1761  );
1762 
1763  FW_ASSERT(
1764  this->m_cmdResponseOut_OutputPort[portNum].isConnected(),
1765  static_cast<FwAssertArgType>(portNum)
1766  );
1767  this->m_cmdResponseOut_OutputPort[portNum].invoke(
1768  opCode,
1769  cmdSeq,
1770  response
1771  );
1772  }
1773 
1774  void ComLoggerComponentBase ::
1775  logOut_out(
1776  FwIndexType portNum,
1777  FwEventIdType id,
1778  Fw::Time& timeTag,
1779  const Fw::LogSeverity& severity,
1780  Fw::LogBuffer& args
1781  ) const
1782  {
1783  FW_ASSERT(
1784  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
1785  static_cast<FwAssertArgType>(portNum)
1786  );
1787 
1788  FW_ASSERT(
1789  this->m_logOut_OutputPort[portNum].isConnected(),
1790  static_cast<FwAssertArgType>(portNum)
1791  );
1792  this->m_logOut_OutputPort[portNum].invoke(
1793  id,
1794  timeTag,
1795  severity,
1796  args
1797  );
1798  }
1799 
1800  void ComLoggerComponentBase ::
1801  timeCaller_out(
1802  FwIndexType portNum,
1803  Fw::Time& time
1804  ) const
1805  {
1806  FW_ASSERT(
1807  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
1808  static_cast<FwAssertArgType>(portNum)
1809  );
1810 
1811  FW_ASSERT(
1812  this->m_timeCaller_OutputPort[portNum].isConnected(),
1813  static_cast<FwAssertArgType>(portNum)
1814  );
1815  this->m_timeCaller_OutputPort[portNum].invoke(
1816  time
1817  );
1818  }
1819 
1820 #endif
1821 
1822 }
Serialization/Deserialization operation was successful.
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:157
static constexpr FwSizeType CAPACITY
Definition: CmdPortAc.hpp:36
ComLoggerComponentBase(const char *compName="")
Construct ComLoggerComponentBase object.
bool isConnected_timeCaller_OutputPort(FwIndexType portNum) const
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
FwIdType FwOpcodeType
The type of a command opcode.
Fw::InputCmdPort * get_cmdIn_InputPort(FwIndexType portNum)
Operation succeeded.
Definition: Os.hpp:26
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
virtual void comIn_preMsgHook(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Pre-message hook for async input port comIn.
PlatformSizeType FwSizeType
void log_WARNING_LO_FileNotInitialized()
Log event FileNotInitialized.
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
Definition: Queue.cpp:71
I32 FwEnumStoreType
void log_DIAGNOSTIC_FileClosed(const Fw::StringBase &file) const
Status
status returned from the queue send function
Definition: Queue.hpp:30
virtual void pingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port pingIn.
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
void init()
Initialization function.
Definition: CmdPortAc.cpp:89
The ComLogger encountered an error writing the validation file.
void invoke(U32 key) const
Invoke a port connection.
Definition: PingPortAc.cpp:170
static constexpr FwIndexType getNum_cmdResponseOut_OutputPorts()
static constexpr FwIndexType getNum_pingIn_InputPorts()
virtual const CHAR * toChar() const =0
Convert to a C-style char*.
Enum representing a command response.
No time base has been established (Required)
void regCommands()
Register commands with the Command Dispatcher.
void addCallPort(InputCmdRegPort *callPort)
Register an input port.
Os::Queue m_queue
queue object for active component
Software diagnostic events.
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
void init()
Object initializer.
Definition: ObjBase.cpp:24
void init()
Initialization function.
Definition: ComPortAc.cpp:81
SerializeStatus
forward declaration for string
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CmdPortAc.cpp:95
Message will block until space is available.
Definition: Queue.hpp:47
void set_cmdRegOut_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to cmdRegOut[portNum].
FwIdType FwEventIdType
The type of an event identifier.
void invoke(FwOpcodeType opCode) const
Invoke a port connection.
static constexpr FwSizeType CAPACITY
Definition: PingPortAc.hpp:34
The ComLogger successfully closed a file on command.
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:40
void init()
Initialization function.
Definition: TimePortAc.cpp:151
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: ComPortAc.cpp:87
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
static constexpr FwSizeType CAPACITY
Definition: ComPortAc.hpp:35
virtual void CloseFile_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command CloseFile.
void log_WARNING_HI_FileOpenError(U32 errornum, const Fw::StringBase &file) const
#define FW_MIN(a, b)
MIN macro (deprecated in C++, use std::min)
Definition: BasicTypes.h:94
A less serious but recoverable event.
void init()
Initialization function.
Definition: PingPortAc.cpp:151
void log_WARNING_LO_FileNotInitialized_ThrottleClear()
Reset throttle value for FileNotInitialized.
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
bool isConnected_logOut_OutputPort(FwIndexType portNum) const
message to exit active component task
void CloseFile_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
Serializable::SizeType getDeserializeSizeLeft() const override
Get remaining deserialization buffer size.
const char * toChar() const
Convert to a C-style char*.
Definition: ObjectName.hpp:50
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) const
Invoke a port connection.
FwSizeType SizeType
void addCallPort(InputPingPort *callPort)
Register an input port.
Definition: PingPortAc.cpp:157
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
Definition: Queue.cpp:54
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
void resetDeser() override
Reset deserialization pointer to beginning of buffer.
Fw::InputComPort * get_comIn_InputPort(FwIndexType portNum)
void log_WARNING_HI_FileWriteError(U32 errornum, U32 bytesWritten, U32 bytesToWrite, const Fw::StringBase &file) const
virtual ~ComLoggerComponentBase()
Destroy ComLoggerComponentBase object.
A serious but recoverable event.
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
bool isConnected() const
Definition: PortBase.cpp:38
Enum representing event severity.
void set_cmdResponseOut_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
static constexpr FwIndexType getNum_logOut_OutputPorts()
#define PRI_FwIndexType
void pingOut_out(FwIndexType portNum, U32 key) const
Invoke output port pingOut.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
void init()
Initialization function.
Definition: LogPortAc.cpp:180
void cmdIn_handlerBase(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
Handler base-class function for input port cmdIn.
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
BlockingType
message type
Definition: Queue.hpp:46
Forces a close of the currently opened file.
Command failed to deserialize.
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
void log_WARNING_LO_FileValidationError(const Fw::StringBase &validationFile, const Fw::StringBase &file, U32 status) const
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port connection.
Definition: LogPortAc.cpp:199
void pingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port pingIn.
void set_logOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to logOut[portNum].
static constexpr FwIndexType getNum_comIn_InputPorts()
A message was sent requesting an exit of the loop.
PlatformIndexType FwIndexType
virtual void comIn_handler(FwIndexType portNum, Fw::ComBuffer &data, U32 context)=0
Handler for input port comIn.
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:186
void init()
Initialization function.
void comIn_handlerBase(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port comIn.
void init()
Initialization function.
Definition: PingPortAc.cpp:73
RateGroupDivider component implementation.
static constexpr FwIndexType getNum_pingOut_OutputPorts()
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:56
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum) const
static constexpr FwIndexType getNum_cmdRegOut_OutputPorts()
bool isConnected_pingOut_OutputPort(FwIndexType portNum) const
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:79
Message will return with status when space is unavailable.
Definition: Queue.hpp:48
static constexpr FwIndexType getNum_cmdIn_InputPorts()
Implementation of malloc based allocator.
void init()
Initialization function.
virtual void CloseFile_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
#define FW_ASSERT(...)
Definition: Assert.hpp:14
bool isConnected_cmdRegOut_OutputPort(FwIndexType portNum) const
The ComLogger encountered an error writing to a file.
The ComLogger encountered an error opening a file.
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
SerializeStatus serializeTo(SerialBufferBase &buffer, Endianness mode=Endianness::BIG) const override
Serialize the contents of this object to a buffer.