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  FW_ASSERT(
813  qStatus == Os::Queue::OP_OK,
814  static_cast<FwAssertArgType>(qStatus)
815  );
816  }
817 
818  // ----------------------------------------------------------------------
819  // Pre-message hooks for typed async input ports
820  //
821  // Each of these functions is invoked just before processing a message
822  // on the corresponding port. By default, they do nothing. You can
823  // override them to provide specific pre-message behavior.
824  // ----------------------------------------------------------------------
825 
828  FwIndexType portNum,
829  Fw::ComBuffer& data,
830  U32 context
831  )
832  {
833  // Default: no-op
834  }
835 
838  FwIndexType portNum,
839  U32 key
840  )
841  {
842  // Default: no-op
843  }
844 
845 #if !FW_DIRECT_PORT_CALLS
846 
847  // ----------------------------------------------------------------------
848  // Invocation functions for typed output ports
849  // ----------------------------------------------------------------------
850 
853  FwIndexType portNum,
854  U32 key
855  ) const
856  {
857  FW_ASSERT(
858  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
859  static_cast<FwAssertArgType>(portNum)
860  );
861 
862  FW_ASSERT(
863  this->m_pingOut_OutputPort[portNum].isConnected(),
864  static_cast<FwAssertArgType>(portNum)
865  );
866  this->m_pingOut_OutputPort[portNum].invoke(
867  key
868  );
869  }
870 
871 #endif
872 
873  // ----------------------------------------------------------------------
874  // Command response
875  // ----------------------------------------------------------------------
876 
879  FwOpcodeType opCode,
880  U32 cmdSeq,
881  Fw::CmdResponse response
882  )
883  {
885  this->cmdResponseOut_out(0, opCode, cmdSeq, response);
886  }
887 
888  // ----------------------------------------------------------------------
889  // Command handler base-class functions
890  //
891  // Call these functions directly to bypass the command input port
892  // ----------------------------------------------------------------------
893 
896  FwOpcodeType opCode,
897  U32 cmdSeq,
898  Fw::CmdArgBuffer& args
899  )
900  {
901  // Call pre-message hook
902  this->CloseFile_preMsgHook(opCode,cmdSeq);
903 
904  // Defer deserializing arguments to the message dispatcher
905  // to avoid deserializing and reserializing just for IPC
906  ComponentIpcSerializableBuffer msg;
908 
909  // Serialize for IPC
910  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_CLOSEFILE));
911  FW_ASSERT (
912  _status == Fw::FW_SERIALIZE_OK,
913  static_cast<FwAssertArgType>(_status)
914  );
915 
916  // Fake port number to make message dequeue work
917  FwIndexType port = 0;
918 
919  _status = msg.serializeFrom(port);
920  FW_ASSERT (
921  _status == Fw::FW_SERIALIZE_OK,
922  static_cast<FwAssertArgType>(_status)
923  );
924 
925  _status = msg.serializeFrom(opCode);
926  FW_ASSERT (
927  _status == Fw::FW_SERIALIZE_OK,
928  static_cast<FwAssertArgType>(_status)
929  );
930 
931  _status = msg.serializeFrom(cmdSeq);
932  FW_ASSERT (
933  _status == Fw::FW_SERIALIZE_OK,
934  static_cast<FwAssertArgType>(_status)
935  );
936 
937  _status = msg.serializeFrom(args);
938  FW_ASSERT (
939  _status == Fw::FW_SERIALIZE_OK,
940  static_cast<FwAssertArgType>(_status)
941  );
942 
943  // Send message
945  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
946 
947  FW_ASSERT(
948  qStatus == Os::Queue::OP_OK,
949  static_cast<FwAssertArgType>(qStatus)
950  );
951  }
952 
953  // ----------------------------------------------------------------------
954  // Pre-message hooks for async commands
955  //
956  // Each of these functions is invoked just before processing the
957  // corresponding command. By default they do nothing. You can
958  // override them to provide specific pre-command behavior.
959  // ----------------------------------------------------------------------
960 
963  FwOpcodeType opCode,
964  U32 cmdSeq
965  )
966  {
967  // Defaults to no-op; can be overridden
968  (void) opCode;
969  (void) cmdSeq;
970  }
971 
972  // ----------------------------------------------------------------------
973  // Event logging functions
974  // ----------------------------------------------------------------------
975 
978  U32 errornum,
979  const Fw::StringBase& file
980  ) const
981  {
982  // Get the time
983  Fw::Time _logTime;
984  if (this->isConnected_timeCaller_OutputPort(0)) {
985  this->timeCaller_out(0, _logTime);
986  }
987 
988  const FwEventIdType _id = this->getIdBase() + EVENTID_FILEOPENERROR;
989 
990  // Emit the event on the log port
991  if (this->isConnected_logOut_OutputPort(0)) {
992  Fw::LogBuffer _logBuff;
994 
995 #if FW_AMPCS_COMPATIBLE
996  // Serialize the number of arguments
997  _status = _logBuff.serializeFrom(static_cast<U8>(2));
998  FW_ASSERT(
999  _status == Fw::FW_SERIALIZE_OK,
1000  static_cast<FwAssertArgType>(_status)
1001  );
1002 #endif
1003 
1004 #if FW_AMPCS_COMPATIBLE
1005  // Serialize the argument size
1006  _status = _logBuff.serializeFrom(
1007  static_cast<U8>(sizeof(U32))
1008  );
1009  FW_ASSERT(
1010  _status == Fw::FW_SERIALIZE_OK,
1011  static_cast<FwAssertArgType>(_status)
1012  );
1013 #endif
1014  _status = _logBuff.serializeFrom(errornum);
1015  FW_ASSERT(
1016  _status == Fw::FW_SERIALIZE_OK,
1017  static_cast<FwAssertArgType>(_status)
1018  );
1019 
1020  _status = file.serializeTo(
1021  _logBuff,
1022  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
1023  );
1024  FW_ASSERT(
1025  _status == Fw::FW_SERIALIZE_OK,
1026  static_cast<FwAssertArgType>(_status)
1027  );
1028 
1029  this->logOut_out(
1030  0,
1031  _id,
1032  _logTime,
1034  _logBuff
1035  );
1036  }
1037 
1038  // Emit the event on the text log port
1039 #if FW_ENABLE_TEXT_LOGGING
1040  if (this->isConnected_LogText_OutputPort(0)) {
1041 #if FW_OBJECT_NAMES == 1
1042  const char* _formatString =
1043  "(%s) %s: Error %" PRIu32 " opening file %s";
1044 #else
1045  const char* _formatString =
1046  "%s: Error %" PRIu32 " opening file %s";
1047 #endif
1048 
1049  Fw::TextLogString _logString;
1050  (void) _logString.format(
1051  _formatString,
1052 #if FW_OBJECT_NAMES == 1
1053  this->m_objName.toChar(),
1054 #endif
1055  "FileOpenError ",
1056  errornum,
1057  file.toChar()
1058  );
1059 
1060  this->LogText_out(
1061  0,
1062  _id,
1063  _logTime,
1065  _logString
1066  );
1067  }
1068 #endif
1069  }
1070 
1073  U32 errornum,
1074  U32 bytesWritten,
1075  U32 bytesToWrite,
1076  const Fw::StringBase& file
1077  ) const
1078  {
1079  // Get the time
1080  Fw::Time _logTime;
1081  if (this->isConnected_timeCaller_OutputPort(0)) {
1082  this->timeCaller_out(0, _logTime);
1083  }
1084 
1085  const FwEventIdType _id = this->getIdBase() + EVENTID_FILEWRITEERROR;
1086 
1087  // Emit the event on the log port
1088  if (this->isConnected_logOut_OutputPort(0)) {
1089  Fw::LogBuffer _logBuff;
1091 
1092 #if FW_AMPCS_COMPATIBLE
1093  // Serialize the number of arguments
1094  _status = _logBuff.serializeFrom(static_cast<U8>(4));
1095  FW_ASSERT(
1096  _status == Fw::FW_SERIALIZE_OK,
1097  static_cast<FwAssertArgType>(_status)
1098  );
1099 #endif
1100 
1101 #if FW_AMPCS_COMPATIBLE
1102  // Serialize the argument size
1103  _status = _logBuff.serializeFrom(
1104  static_cast<U8>(sizeof(U32))
1105  );
1106  FW_ASSERT(
1107  _status == Fw::FW_SERIALIZE_OK,
1108  static_cast<FwAssertArgType>(_status)
1109  );
1110 #endif
1111  _status = _logBuff.serializeFrom(errornum);
1112  FW_ASSERT(
1113  _status == Fw::FW_SERIALIZE_OK,
1114  static_cast<FwAssertArgType>(_status)
1115  );
1116 
1117 #if FW_AMPCS_COMPATIBLE
1118  // Serialize the argument size
1119  _status = _logBuff.serializeFrom(
1120  static_cast<U8>(sizeof(U32))
1121  );
1122  FW_ASSERT(
1123  _status == Fw::FW_SERIALIZE_OK,
1124  static_cast<FwAssertArgType>(_status)
1125  );
1126 #endif
1127  _status = _logBuff.serializeFrom(bytesWritten);
1128  FW_ASSERT(
1129  _status == Fw::FW_SERIALIZE_OK,
1130  static_cast<FwAssertArgType>(_status)
1131  );
1132 
1133 #if FW_AMPCS_COMPATIBLE
1134  // Serialize the argument size
1135  _status = _logBuff.serializeFrom(
1136  static_cast<U8>(sizeof(U32))
1137  );
1138  FW_ASSERT(
1139  _status == Fw::FW_SERIALIZE_OK,
1140  static_cast<FwAssertArgType>(_status)
1141  );
1142 #endif
1143  _status = _logBuff.serializeFrom(bytesToWrite);
1144  FW_ASSERT(
1145  _status == Fw::FW_SERIALIZE_OK,
1146  static_cast<FwAssertArgType>(_status)
1147  );
1148 
1149  _status = file.serializeTo(
1150  _logBuff,
1151  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
1152  );
1153  FW_ASSERT(
1154  _status == Fw::FW_SERIALIZE_OK,
1155  static_cast<FwAssertArgType>(_status)
1156  );
1157 
1158  this->logOut_out(
1159  0,
1160  _id,
1161  _logTime,
1163  _logBuff
1164  );
1165  }
1166 
1167  // Emit the event on the text log port
1168 #if FW_ENABLE_TEXT_LOGGING
1169  if (this->isConnected_LogText_OutputPort(0)) {
1170 #if FW_OBJECT_NAMES == 1
1171  const char* _formatString =
1172  "(%s) %s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1173 #else
1174  const char* _formatString =
1175  "%s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1176 #endif
1177 
1178  Fw::TextLogString _logString;
1179  (void) _logString.format(
1180  _formatString,
1181 #if FW_OBJECT_NAMES == 1
1182  this->m_objName.toChar(),
1183 #endif
1184  "FileWriteError ",
1185  errornum,
1186  bytesWritten,
1187  bytesToWrite,
1188  file.toChar()
1189  );
1190 
1191  this->LogText_out(
1192  0,
1193  _id,
1194  _logTime,
1196  _logString
1197  );
1198  }
1199 #endif
1200  }
1201 
1204  const Fw::StringBase& validationFile,
1205  const Fw::StringBase& file,
1206  U32 status
1207  ) const
1208  {
1209  // Get the time
1210  Fw::Time _logTime;
1211  if (this->isConnected_timeCaller_OutputPort(0)) {
1212  this->timeCaller_out(0, _logTime);
1213  }
1214 
1215  const FwEventIdType _id = this->getIdBase() + EVENTID_FILEVALIDATIONERROR;
1216 
1217  // Emit the event on the log port
1218  if (this->isConnected_logOut_OutputPort(0)) {
1219  Fw::LogBuffer _logBuff;
1221 
1222 #if FW_AMPCS_COMPATIBLE
1223  // Serialize the number of arguments
1224  _status = _logBuff.serializeFrom(static_cast<U8>(3));
1225  FW_ASSERT(
1226  _status == Fw::FW_SERIALIZE_OK,
1227  static_cast<FwAssertArgType>(_status)
1228  );
1229 #endif
1230 
1231  _status = validationFile.serializeTo(
1232  _logBuff,
1233  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
1234  );
1235  FW_ASSERT(
1236  _status == Fw::FW_SERIALIZE_OK,
1237  static_cast<FwAssertArgType>(_status)
1238  );
1239 
1240  _status = file.serializeTo(
1241  _logBuff,
1242  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
1243  );
1244  FW_ASSERT(
1245  _status == Fw::FW_SERIALIZE_OK,
1246  static_cast<FwAssertArgType>(_status)
1247  );
1248 
1249 #if FW_AMPCS_COMPATIBLE
1250  // Serialize the argument size
1251  _status = _logBuff.serializeFrom(
1252  static_cast<U8>(sizeof(U32))
1253  );
1254  FW_ASSERT(
1255  _status == Fw::FW_SERIALIZE_OK,
1256  static_cast<FwAssertArgType>(_status)
1257  );
1258 #endif
1259  _status = _logBuff.serializeFrom(status);
1260  FW_ASSERT(
1261  _status == Fw::FW_SERIALIZE_OK,
1262  static_cast<FwAssertArgType>(_status)
1263  );
1264 
1265  this->logOut_out(
1266  0,
1267  _id,
1268  _logTime,
1270  _logBuff
1271  );
1272  }
1273 
1274  // Emit the event on the text log port
1275 #if FW_ENABLE_TEXT_LOGGING
1276  if (this->isConnected_LogText_OutputPort(0)) {
1277 #if FW_OBJECT_NAMES == 1
1278  const char* _formatString =
1279  "(%s) %s: The ComLogger failed to create a validation file %s for %s with error %" PRIu32 ".";
1280 #else
1281  const char* _formatString =
1282  "%s: The ComLogger failed to create a validation file %s for %s with error %" PRIu32 ".";
1283 #endif
1284 
1285  Fw::TextLogString _logString;
1286  (void) _logString.format(
1287  _formatString,
1288 #if FW_OBJECT_NAMES == 1
1289  this->m_objName.toChar(),
1290 #endif
1291  "FileValidationError ",
1292  validationFile.toChar(),
1293  file.toChar(),
1294  status
1295  );
1296 
1297  this->LogText_out(
1298  0,
1299  _id,
1300  _logTime,
1302  _logString
1303  );
1304  }
1305 #endif
1306  }
1307 
1310  {
1311  // Get the time
1312  Fw::Time _logTime;
1313  if (this->isConnected_timeCaller_OutputPort(0)) {
1314  this->timeCaller_out(0, _logTime);
1315  }
1316 
1317  const FwEventIdType _id = this->getIdBase() + EVENTID_FILECLOSED;
1318 
1319  // Emit the event on the log port
1320  if (this->isConnected_logOut_OutputPort(0)) {
1321  Fw::LogBuffer _logBuff;
1323 
1324 #if FW_AMPCS_COMPATIBLE
1325  // Serialize the number of arguments
1326  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1327  FW_ASSERT(
1328  _status == Fw::FW_SERIALIZE_OK,
1329  static_cast<FwAssertArgType>(_status)
1330  );
1331 #endif
1332 
1333  _status = file.serializeTo(
1334  _logBuff,
1335  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
1336  );
1337  FW_ASSERT(
1338  _status == Fw::FW_SERIALIZE_OK,
1339  static_cast<FwAssertArgType>(_status)
1340  );
1341 
1342  this->logOut_out(
1343  0,
1344  _id,
1345  _logTime,
1347  _logBuff
1348  );
1349  }
1350 
1351  // Emit the event on the text log port
1352 #if FW_ENABLE_TEXT_LOGGING
1353  if (this->isConnected_LogText_OutputPort(0)) {
1354 #if FW_OBJECT_NAMES == 1
1355  const char* _formatString =
1356  "(%s) %s: File %s closed successfully.";
1357 #else
1358  const char* _formatString =
1359  "%s: File %s closed successfully.";
1360 #endif
1361 
1362  Fw::TextLogString _logString;
1363  (void) _logString.format(
1364  _formatString,
1365 #if FW_OBJECT_NAMES == 1
1366  this->m_objName.toChar(),
1367 #endif
1368  "FileClosed ",
1369  file.toChar()
1370  );
1371 
1372  this->LogText_out(
1373  0,
1374  _id,
1375  _logTime,
1377  _logString
1378  );
1379  }
1380 #endif
1381  }
1382 
1385  {
1386  // Check throttle value
1387  if (this->m_FileNotInitializedThrottle >= EVENTID_FILENOTINITIALIZED_THROTTLE) {
1388  return;
1389  }
1390  else {
1391  this->m_FileNotInitializedThrottle++;
1392  }
1393 
1394  // Get the time
1395  Fw::Time _logTime;
1396  if (this->isConnected_timeCaller_OutputPort(0)) {
1397  this->timeCaller_out(0, _logTime);
1398  }
1399 
1400  const FwEventIdType _id = this->getIdBase() + EVENTID_FILENOTINITIALIZED;
1401 
1402  // Emit the event on the log port
1403  if (this->isConnected_logOut_OutputPort(0)) {
1404  Fw::LogBuffer _logBuff;
1405 
1406 #if FW_AMPCS_COMPATIBLE
1408  // Serialize the number of arguments
1409  _status = _logBuff.serializeFrom(static_cast<U8>(0));
1410  FW_ASSERT(
1411  _status == Fw::FW_SERIALIZE_OK,
1412  static_cast<FwAssertArgType>(_status)
1413  );
1414 #endif
1415 
1416  this->logOut_out(
1417  0,
1418  _id,
1419  _logTime,
1421  _logBuff
1422  );
1423  }
1424 
1425  // Emit the event on the text log port
1426 #if FW_ENABLE_TEXT_LOGGING
1427  if (this->isConnected_LogText_OutputPort(0)) {
1428 #if FW_OBJECT_NAMES == 1
1429  const char* _formatString =
1430  "(%s) %s: Could not open ComLogger file. File not initialized";
1431 #else
1432  const char* _formatString =
1433  "%s: Could not open ComLogger file. File not initialized";
1434 #endif
1435 
1436  Fw::TextLogString _logString;
1437  (void) _logString.format(
1438  _formatString,
1439 #if FW_OBJECT_NAMES == 1
1440  this->m_objName.toChar(),
1441 #endif
1442  "FileNotInitialized "
1443  );
1444 
1445  this->LogText_out(
1446  0,
1447  _id,
1448  _logTime,
1450  _logString
1451  );
1452  }
1453 #endif
1454  }
1455 
1456  // ----------------------------------------------------------------------
1457  // Event throttle reset functions
1458  // ----------------------------------------------------------------------
1459 
1462  {
1463  // Reset throttle counter
1464  this->m_FileNotInitializedThrottle = 0;
1465  }
1466 
1467  // ----------------------------------------------------------------------
1468  // Time
1469  // ----------------------------------------------------------------------
1470 
1472  getTime() const
1473  {
1474  if (this->isConnected_timeCaller_OutputPort(0)) {
1475  Fw::Time _time;
1476  this->timeCaller_out(0, _time);
1477  return _time;
1478  }
1479  else {
1480  return Fw::Time(TimeBase::TB_NONE, 0, 0);
1481  }
1482  }
1483 
1484  // ----------------------------------------------------------------------
1485  // Message dispatch functions
1486  // ----------------------------------------------------------------------
1487 
1488  Fw::QueuedComponentBase::MsgDispatchStatus ComLoggerComponentBase ::
1489  doDispatch()
1490  {
1491  ComponentIpcSerializableBuffer _msg;
1492  FwQueuePriorityType _priority = 0;
1493 
1494  Os::Queue::Status _msgStatus = this->m_queue.receive(
1495  _msg,
1497  _priority
1498  );
1499  FW_ASSERT(
1500  _msgStatus == Os::Queue::OP_OK,
1501  static_cast<FwAssertArgType>(_msgStatus)
1502  );
1503 
1504  // Reset to beginning of buffer
1505  _msg.resetDeser();
1506 
1507  FwEnumStoreType _desMsg = 0;
1508  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
1509  FW_ASSERT(
1510  _deserStatus == Fw::FW_SERIALIZE_OK,
1511  static_cast<FwAssertArgType>(_deserStatus)
1512  );
1513 
1514  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
1515 
1516  if (_msgType == COMLOGGER_COMPONENT_EXIT) {
1517  return MSG_DISPATCH_EXIT;
1518  }
1519 
1520  FwIndexType portNum = 0;
1521  _deserStatus = _msg.deserializeTo(portNum);
1522  FW_ASSERT(
1523  _deserStatus == Fw::FW_SERIALIZE_OK,
1524  static_cast<FwAssertArgType>(_deserStatus)
1525  );
1526 
1527  switch (_msgType) {
1528  // Handle async input port comIn
1529  case COMIN_COM: {
1530  // Deserialize argument data
1531  Fw::ComBuffer data;
1532  _deserStatus = _msg.deserializeTo(data);
1533  FW_ASSERT(
1534  _deserStatus == Fw::FW_SERIALIZE_OK,
1535  static_cast<FwAssertArgType>(_deserStatus)
1536  );
1537 
1538  // Deserialize argument context
1539  U32 context;
1540  _deserStatus = _msg.deserializeTo(context);
1541  FW_ASSERT(
1542  _deserStatus == Fw::FW_SERIALIZE_OK,
1543  static_cast<FwAssertArgType>(_deserStatus)
1544  );
1545  // Call handler function
1546  this->comIn_handler(
1547  portNum,
1548  data,
1549  context
1550  );
1551 
1552  break;
1553  }
1554 
1555  // Handle async input port pingIn
1556  case PINGIN_PING: {
1557  // Deserialize argument key
1558  U32 key;
1559  _deserStatus = _msg.deserializeTo(key);
1560  FW_ASSERT(
1561  _deserStatus == Fw::FW_SERIALIZE_OK,
1562  static_cast<FwAssertArgType>(_deserStatus)
1563  );
1564  // Call handler function
1565  this->pingIn_handler(
1566  portNum,
1567  key
1568  );
1569 
1570  break;
1571  }
1572 
1573  // Handle command CloseFile
1574  case CMD_CLOSEFILE: {
1575  // Deserialize opcode
1576  FwOpcodeType _opCode = 0;
1577  _deserStatus = _msg.deserializeTo(_opCode);
1578  FW_ASSERT (
1579  _deserStatus == Fw::FW_SERIALIZE_OK,
1580  static_cast<FwAssertArgType>(_deserStatus)
1581  );
1582 
1583  // Deserialize command sequence
1584  U32 _cmdSeq = 0;
1585  _deserStatus = _msg.deserializeTo(_cmdSeq);
1586  FW_ASSERT (
1587  _deserStatus == Fw::FW_SERIALIZE_OK,
1588  static_cast<FwAssertArgType>(_deserStatus)
1589  );
1590 
1591  // Deserialize command argument buffer
1592  Fw::CmdArgBuffer args;
1593  _deserStatus = _msg.deserializeTo(args);
1594  FW_ASSERT (
1595  _deserStatus == Fw::FW_SERIALIZE_OK,
1596  static_cast<FwAssertArgType>(_deserStatus)
1597  );
1598 
1599  // Reset buffer
1600  args.resetDeser();
1601 
1602  // Make sure there was no data left over.
1603  // That means the argument buffer size was incorrect.
1604 #if FW_CMD_CHECK_RESIDUAL
1605  if (args.getDeserializeSizeLeft() != 0) {
1607  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
1608  }
1609  // Don't crash the task if bad arguments were passed from the ground
1610  break;
1611  }
1612 #endif
1613 
1614  // Call handler function
1615  this->CloseFile_cmdHandler(_opCode, _cmdSeq);
1616 
1617  break;
1618  }
1619 
1620  default:
1621  return MSG_DISPATCH_ERROR;
1622  }
1623 
1624  return MSG_DISPATCH_OK;
1625  }
1626 
1627  // ----------------------------------------------------------------------
1628  // Calls for messages received on special input ports
1629  // ----------------------------------------------------------------------
1630 
1631  void ComLoggerComponentBase ::
1632  m_p_cmdIn_in(
1633  Fw::PassiveComponentBase* callComp,
1634  FwIndexType portNum,
1635  FwOpcodeType opCode,
1636  U32 cmdSeq,
1637  Fw::CmdArgBuffer& args
1638  )
1639  {
1640  FW_ASSERT(callComp != nullptr);
1641  ComLoggerComponentBase* compPtr = static_cast<ComLoggerComponentBase*>(callComp);
1642  compPtr->cmdIn_handlerBase(
1643  portNum,
1644  opCode,
1645  cmdSeq,
1646  args
1647  );
1648  }
1649 
1650  // ----------------------------------------------------------------------
1651  // Calls for messages received on typed input ports
1652  // ----------------------------------------------------------------------
1653 
1654  void ComLoggerComponentBase ::
1655  m_p_comIn_in(
1656  Fw::PassiveComponentBase* callComp,
1657  FwIndexType portNum,
1658  Fw::ComBuffer& data,
1659  U32 context
1660  )
1661  {
1662  FW_ASSERT(callComp != nullptr);
1663  ComLoggerComponentBase* compPtr = static_cast<ComLoggerComponentBase*>(callComp);
1664  compPtr->comIn_handlerBase(
1665  portNum,
1666  data,
1667  context
1668  );
1669  }
1670 
1671  void ComLoggerComponentBase ::
1672  m_p_pingIn_in(
1673  Fw::PassiveComponentBase* callComp,
1674  FwIndexType portNum,
1675  U32 key
1676  )
1677  {
1678  FW_ASSERT(callComp != nullptr);
1679  ComLoggerComponentBase* compPtr = static_cast<ComLoggerComponentBase*>(callComp);
1680  compPtr->pingIn_handlerBase(
1681  portNum,
1682  key
1683  );
1684  }
1685 
1686 #if !FW_DIRECT_PORT_CALLS
1687 
1688  // ----------------------------------------------------------------------
1689  // Invocation functions for special output ports
1690  // ----------------------------------------------------------------------
1691 
1692 #if FW_ENABLE_TEXT_LOGGING
1693 
1694  void ComLoggerComponentBase ::
1695  LogText_out(
1696  FwIndexType portNum,
1697  FwEventIdType id,
1698  Fw::Time& timeTag,
1699  const Fw::LogSeverity& severity,
1700  Fw::TextLogString& text
1701  ) const
1702  {
1703  FW_ASSERT(
1704  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
1705  static_cast<FwAssertArgType>(portNum)
1706  );
1707 
1708  FW_ASSERT(
1709  this->m_LogText_OutputPort[portNum].isConnected(),
1710  static_cast<FwAssertArgType>(portNum)
1711  );
1712  this->m_LogText_OutputPort[portNum].invoke(
1713  id,
1714  timeTag,
1715  severity,
1716  text
1717  );
1718  }
1719 
1720 #endif
1721 
1722  void ComLoggerComponentBase ::
1723  cmdRegOut_out(
1724  FwIndexType portNum,
1725  FwOpcodeType opCode
1726  ) const
1727  {
1728  FW_ASSERT(
1729  (0 <= portNum) && (portNum < this->getNum_cmdRegOut_OutputPorts()),
1730  static_cast<FwAssertArgType>(portNum)
1731  );
1732 
1733  FW_ASSERT(
1734  this->m_cmdRegOut_OutputPort[portNum].isConnected(),
1735  static_cast<FwAssertArgType>(portNum)
1736  );
1737  this->m_cmdRegOut_OutputPort[portNum].invoke(
1738  opCode
1739  );
1740  }
1741 
1742  void ComLoggerComponentBase ::
1743  cmdResponseOut_out(
1744  FwIndexType portNum,
1745  FwOpcodeType opCode,
1746  U32 cmdSeq,
1747  const Fw::CmdResponse& response
1748  ) const
1749  {
1750  FW_ASSERT(
1751  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
1752  static_cast<FwAssertArgType>(portNum)
1753  );
1754 
1755  FW_ASSERT(
1756  this->m_cmdResponseOut_OutputPort[portNum].isConnected(),
1757  static_cast<FwAssertArgType>(portNum)
1758  );
1759  this->m_cmdResponseOut_OutputPort[portNum].invoke(
1760  opCode,
1761  cmdSeq,
1762  response
1763  );
1764  }
1765 
1766  void ComLoggerComponentBase ::
1767  logOut_out(
1768  FwIndexType portNum,
1769  FwEventIdType id,
1770  Fw::Time& timeTag,
1771  const Fw::LogSeverity& severity,
1772  Fw::LogBuffer& args
1773  ) const
1774  {
1775  FW_ASSERT(
1776  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
1777  static_cast<FwAssertArgType>(portNum)
1778  );
1779 
1780  FW_ASSERT(
1781  this->m_logOut_OutputPort[portNum].isConnected(),
1782  static_cast<FwAssertArgType>(portNum)
1783  );
1784  this->m_logOut_OutputPort[portNum].invoke(
1785  id,
1786  timeTag,
1787  severity,
1788  args
1789  );
1790  }
1791 
1792  void ComLoggerComponentBase ::
1793  timeCaller_out(
1794  FwIndexType portNum,
1795  Fw::Time& time
1796  ) const
1797  {
1798  FW_ASSERT(
1799  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
1800  static_cast<FwAssertArgType>(portNum)
1801  );
1802 
1803  FW_ASSERT(
1804  this->m_timeCaller_OutputPort[portNum].isConnected(),
1805  static_cast<FwAssertArgType>(portNum)
1806  );
1807  this->m_timeCaller_OutputPort[portNum].invoke(
1808  time
1809  );
1810  }
1811 
1812 #endif
1813 
1814 }
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: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
message to exit active component task
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
The ComLogger encountered an error opening a file.
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)
The ComLogger successfully closed a file on command.
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
The ComLogger encountered an error writing to a file.
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: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
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
Forces a close of the currently opened file.
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
static constexpr FwIndexType getNum_cmdRegOut_OutputPorts()
bool isConnected_pingOut_OutputPort(FwIndexType portNum) const
The ComLogger encountered an error writing the validation file.
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]