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