F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
ComLoggerComponentAc.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ComLoggerComponentAc.hpp
3 // \author Generated by fpp-to-cpp
4 // \brief hpp file for ComLogger component base class
5 // ======================================================================
6 
7 #ifndef Svc_ComLoggerComponentAc_HPP
8 #define Svc_ComLoggerComponentAc_HPP
9 
10 #include <atomic>
11 
12 #include "Fw/Cmd/CmdPortAc.hpp"
13 #include "Fw/Cmd/CmdRegPortAc.hpp"
15 #include "Fw/Cmd/CmdString.hpp"
16 #include "Fw/Com/ComPortAc.hpp"
18 #include "Fw/FPrimeBasicTypes.hpp"
19 #include "Fw/Log/LogPortAc.hpp"
20 #include "Fw/Log/LogString.hpp"
21 #include "Fw/Log/LogTextPortAc.hpp"
22 #if !FW_DIRECT_PORT_CALLS
24 #endif
25 #if !FW_DIRECT_PORT_CALLS
27 #endif
28 #include "Fw/Time/TimePortAc.hpp"
29 #include "Svc/Ping/PingPortAc.hpp"
31 
32 namespace Svc {
33 
40  {
41 
42  // ----------------------------------------------------------------------
43  // Friend classes
44  // ----------------------------------------------------------------------
45 
47  friend class ComLoggerTesterBase;
49  friend class ComLoggerTester;
50 
51  protected:
52 
53  // ----------------------------------------------------------------------
54  // Constants
55  // ----------------------------------------------------------------------
56 
58  enum {
60  };
61 
63  enum {
66  };
67 
69  enum {
75  };
76 
78  enum {
80  };
81 
83  enum {
85  };
86 
88  enum {
94  };
95 
97  enum {
99  };
100 
101  public:
102 
103  // ----------------------------------------------------------------------
104  // Component initialization
105  // ----------------------------------------------------------------------
106 
108  void init(
109  FwSizeType queueDepth,
110  FwEnumStoreType instance = 0
111  );
112 
113 #if !FW_DIRECT_PORT_CALLS
114 
115  public:
116 
117  // ----------------------------------------------------------------------
118  // Getters for special input ports
119  // ----------------------------------------------------------------------
120 
125  FwIndexType portNum
126  );
127 
128 #endif
129 
130 #if !FW_DIRECT_PORT_CALLS
131 
132  public:
133 
134  // ----------------------------------------------------------------------
135  // Getters for typed input ports
136  // ----------------------------------------------------------------------
137 
142  FwIndexType portNum
143  );
144 
149  FwIndexType portNum
150  );
151 
152 #endif
153 
154 #if !FW_DIRECT_PORT_CALLS
155 
156  public:
157 
158  // ----------------------------------------------------------------------
159  // Connect input ports to special output ports
160  // ----------------------------------------------------------------------
161 
162 #if FW_ENABLE_TEXT_LOGGING == 1
163 
165  void set_LogText_OutputPort(
166  FwIndexType portNum,
167  Fw::InputLogTextPort* port
168  );
169 
170 #endif
171 
174  FwIndexType portNum,
175  Fw::InputCmdRegPort* port
176  );
177 
180  FwIndexType portNum,
182  );
183 
186  FwIndexType portNum,
187  Fw::InputLogPort* port
188  );
189 
192  FwIndexType portNum,
193  Fw::InputTimePort* port
194  );
195 
196 #endif
197 
198 #if !FW_DIRECT_PORT_CALLS
199 
200  public:
201 
202  // ----------------------------------------------------------------------
203  // Connect typed input ports to typed output ports
204  // ----------------------------------------------------------------------
205 
208  FwIndexType portNum,
209  Svc::InputPingPort* port
210  );
211 
212 #endif
213 
214 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
215 
216  public:
217 
218  // ----------------------------------------------------------------------
219  // Connect serial input ports to special output ports
220  // ----------------------------------------------------------------------
221 
222 #if FW_ENABLE_TEXT_LOGGING == 1
223 
225  void set_LogText_OutputPort(
226  FwIndexType portNum,
227  Fw::InputSerializePort* port
228  );
229 
230 #endif
231 
234  FwIndexType portNum,
235  Fw::InputSerializePort* port
236  );
237 
240  FwIndexType portNum,
241  Fw::InputSerializePort* port
242  );
243 
246  FwIndexType portNum,
247  Fw::InputSerializePort* port
248  );
249 
252  FwIndexType portNum,
253  Fw::InputSerializePort* port
254  );
255 
256 #endif
257 
258 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
259 
260  public:
261 
262  // ----------------------------------------------------------------------
263  // Connect serial input ports to typed output ports
264  // ----------------------------------------------------------------------
265 
268  FwIndexType portNum,
269  Fw::InputSerializePort* port
270  );
271 
272 #endif
273 
274  public:
275 
276  // ----------------------------------------------------------------------
277  // Command registration
278  // ----------------------------------------------------------------------
279 
283  void regCommands();
284 
285  protected:
286 
287  // ----------------------------------------------------------------------
288  // Component construction and destruction
289  // ----------------------------------------------------------------------
290 
293  const char* compName = ""
294  );
295 
297  virtual ~ComLoggerComponentBase();
298 
299  protected:
300 
301  // ----------------------------------------------------------------------
302  // Getters for numbers of special input ports
303  // ----------------------------------------------------------------------
304 
309  return NUM_CMDIN_INPUT_PORTS;
310  }
311 
312  protected:
313 
314  // ----------------------------------------------------------------------
315  // Getters for numbers of typed input ports
316  // ----------------------------------------------------------------------
317 
322  return NUM_COMIN_INPUT_PORTS;
323  }
324 
329  return NUM_PINGIN_INPUT_PORTS;
330  }
331 
332  protected:
333 
334  // ----------------------------------------------------------------------
335  // Getters for numbers of special output ports
336  // ----------------------------------------------------------------------
337 
338 #if FW_ENABLE_TEXT_LOGGING == 1
339 
343  static constexpr FwIndexType getNum_LogText_OutputPorts() {
345  }
346 
347 #endif
348 
354  }
355 
361  }
362 
368  }
369 
375  }
376 
377  protected:
378 
379  // ----------------------------------------------------------------------
380  // Getters for numbers of typed output ports
381  // ----------------------------------------------------------------------
382 
388  }
389 
390  protected:
391 
392  // ----------------------------------------------------------------------
393  // Connection status queries for special output ports
394  // ----------------------------------------------------------------------
395 
396 #if FW_ENABLE_TEXT_LOGGING == 1
397 
401  bool isConnected_LogText_OutputPort(
402  FwIndexType portNum
403  ) const;
404 
405 #endif
406 
411  FwIndexType portNum
412  ) const;
413 
418  FwIndexType portNum
419  ) const;
420 
425  FwIndexType portNum
426  ) const;
427 
432  FwIndexType portNum
433  ) const;
434 
435  protected:
436 
437  // ----------------------------------------------------------------------
438  // Connection status queries for typed output ports
439  // ----------------------------------------------------------------------
440 
445  FwIndexType portNum
446  ) const;
447 
448 #if FW_DIRECT_PORT_CALLS
449  public:
450 #else
451  protected:
452 #endif
453 
454  // ----------------------------------------------------------------------
455  // Port handler base-class functions for special input ports
456  //
457  // Call these functions directly to bypass the corresponding ports
458  // ----------------------------------------------------------------------
459 
461  void cmdIn_handlerBase(
462  FwIndexType portNum,
463  FwOpcodeType opCode,
464  U32 cmdSeq,
465  Fw::CmdArgBuffer& args
466  );
467 
468  protected:
469 
470  // ----------------------------------------------------------------------
471  // Handlers to implement for typed input ports
472  // ----------------------------------------------------------------------
473 
475  virtual void comIn_handler(
476  FwIndexType portNum,
477  Fw::ComBuffer& data,
478  U32 context
479  ) = 0;
480 
482  virtual void pingIn_handler(
483  FwIndexType portNum,
484  U32 key
485  ) = 0;
486 
487 #if FW_DIRECT_PORT_CALLS
488  public:
489 #else
490  protected:
491 #endif
492 
493  // ----------------------------------------------------------------------
494  // Port handler base-class functions for typed input ports
495  //
496  // Call these functions directly to bypass the corresponding ports
497  // ----------------------------------------------------------------------
498 
500  void comIn_handlerBase(
501  FwIndexType portNum,
502  Fw::ComBuffer& data,
503  U32 context
504  );
505 
507  void pingIn_handlerBase(
508  FwIndexType portNum,
509  U32 key
510  );
511 
512  protected:
513 
514  // ----------------------------------------------------------------------
515  // Pre-message hooks for typed async input ports
516  //
517  // Each of these functions is invoked just before processing a message
518  // on the corresponding port. By default, they do nothing. You can
519  // override them to provide specific pre-message behavior.
520  // ----------------------------------------------------------------------
521 
523  virtual void comIn_preMsgHook(
524  FwIndexType portNum,
525  Fw::ComBuffer& data,
526  U32 context
527  );
528 
530  virtual void pingIn_preMsgHook(
531  FwIndexType portNum,
532  U32 key
533  );
534 
535  protected:
536 
537  // ----------------------------------------------------------------------
538  // Invocation functions for typed output ports
539  // ----------------------------------------------------------------------
540 
542  void pingOut_out(
543  FwIndexType portNum,
544  U32 key
545  ) const;
546 
547  protected:
548 
549  // ----------------------------------------------------------------------
550  // Command response
551  // ----------------------------------------------------------------------
552 
554  void cmdResponse_out(
555  FwOpcodeType opCode,
556  U32 cmdSeq,
557  Fw::CmdResponse response
558  );
559 
560  protected:
561 
562  // ----------------------------------------------------------------------
563  // Command handlers to implement
564  // ----------------------------------------------------------------------
565 
569  virtual void CloseFile_cmdHandler(
570  FwOpcodeType opCode,
571  U32 cmdSeq
572  ) = 0;
573 
574  protected:
575 
576  // ----------------------------------------------------------------------
577  // Command handler base-class functions
578  //
579  // Call these functions directly to bypass the command input port
580  // ----------------------------------------------------------------------
581 
586  FwOpcodeType opCode,
587  U32 cmdSeq,
588  Fw::CmdArgBuffer& args
589  );
590 
591  protected:
592 
593  // ----------------------------------------------------------------------
594  // Pre-message hooks for async commands
595  //
596  // Each of these functions is invoked just before processing the
597  // corresponding command. By default they do nothing. You can
598  // override them to provide specific pre-command behavior.
599  // ----------------------------------------------------------------------
600 
602  virtual void CloseFile_preMsgHook(
603  FwOpcodeType opCode,
604  U32 cmdSeq
605  );
606 
607  protected:
608 
609  // ----------------------------------------------------------------------
610  // Event logging functions
611  // ----------------------------------------------------------------------
612 
617  U32 errornum,
618  const Fw::StringBase& file
619  ) const;
620 
625  U32 errornum,
626  U32 bytesWritten,
627  U32 bytesToWrite,
628  const Fw::StringBase& file
629  ) const;
630 
635  const Fw::StringBase& validationFile,
636  const Fw::StringBase& file,
637  U32 status
638  ) const;
639 
644  const Fw::StringBase& file
645  ) const;
646 
649 
650  protected:
651 
652  // ----------------------------------------------------------------------
653  // Event throttle reset functions
654  // ----------------------------------------------------------------------
655 
658 
659  protected:
660 
661  // ----------------------------------------------------------------------
662  // Time
663  // ----------------------------------------------------------------------
664 
668  Fw::Time getTime() const;
669 
670  private:
671 
672  // ----------------------------------------------------------------------
673  // Message dispatch functions
674  // ----------------------------------------------------------------------
675 
677  virtual MsgDispatchStatus doDispatch();
678 
679  private:
680 
681  // ----------------------------------------------------------------------
682  // Calls for messages received on special input ports
683  // ----------------------------------------------------------------------
684 
686  static void m_p_cmdIn_in(
687  Fw::PassiveComponentBase* callComp,
688  FwIndexType portNum,
689  FwOpcodeType opCode,
690  U32 cmdSeq,
691  Fw::CmdArgBuffer& args
692  );
693 
694  private:
695 
696  // ----------------------------------------------------------------------
697  // Calls for messages received on typed input ports
698  // ----------------------------------------------------------------------
699 
701  static void m_p_comIn_in(
702  Fw::PassiveComponentBase* callComp,
703  FwIndexType portNum,
704  Fw::ComBuffer& data,
705  U32 context
706  );
707 
709  static void m_p_pingIn_in(
710  Fw::PassiveComponentBase* callComp,
711  FwIndexType portNum,
712  U32 key
713  );
714 
715  private:
716 
717  // ----------------------------------------------------------------------
718  // Invocation functions for special output ports
719  // ----------------------------------------------------------------------
720 
721 #if FW_ENABLE_TEXT_LOGGING
722 
724  void LogText_out(
725  FwIndexType portNum,
726  FwEventIdType id,
727  Fw::Time& timeTag,
728  const Fw::LogSeverity& severity,
729  Fw::TextLogString& text
730  ) const;
731 
732 #endif
733 
735  void cmdRegOut_out(
736  FwIndexType portNum,
737  FwOpcodeType opCode
738  ) const;
739 
741  void cmdResponseOut_out(
742  FwIndexType portNum,
743  FwOpcodeType opCode,
744  U32 cmdSeq,
745  const Fw::CmdResponse& response
746  ) const;
747 
749  void logOut_out(
750  FwIndexType portNum,
751  FwEventIdType id,
752  Fw::Time& timeTag,
753  const Fw::LogSeverity& severity,
754  Fw::LogBuffer& args
755  ) const;
756 
758  void timeCaller_out(
759  FwIndexType portNum,
760  Fw::Time& time
761  ) const;
762 
763 #if !FW_DIRECT_PORT_CALLS
764 
765  private:
766 
767  // ----------------------------------------------------------------------
768  // Special input ports
769  // ----------------------------------------------------------------------
770 
772  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
773 
774 #endif
775 
776 #if !FW_DIRECT_PORT_CALLS
777 
778  private:
779 
780  // ----------------------------------------------------------------------
781  // Typed input ports
782  // ----------------------------------------------------------------------
783 
785  Fw::InputComPort m_comIn_InputPort[NUM_COMIN_INPUT_PORTS];
786 
788  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
789 
790 #endif
791 
792 #if !FW_DIRECT_PORT_CALLS
793 
794  private:
795 
796  // ----------------------------------------------------------------------
797  // Special output ports
798  // ----------------------------------------------------------------------
799 
800 #if FW_ENABLE_TEXT_LOGGING == 1
801 
803  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
804 
805 #endif
806 
808  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
809 
811  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
812 
814  Fw::OutputLogPort m_logOut_OutputPort[NUM_LOGOUT_OUTPUT_PORTS];
815 
817  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
818 
819 #endif
820 
821 #if !FW_DIRECT_PORT_CALLS
822 
823  private:
824 
825  // ----------------------------------------------------------------------
826  // Typed output ports
827  // ----------------------------------------------------------------------
828 
830  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
831 
832 #endif
833 
834  private:
835 
836  // ----------------------------------------------------------------------
837  // Counter values for event throttling
838  // ----------------------------------------------------------------------
839 
841  std::atomic<FwIndexType> m_FileNotInitializedThrottle;
842 
843  };
844 
845 }
846 
847 #endif
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
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)
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.
I32 FwEnumStoreType
void log_DIAGNOSTIC_FileClosed(const Fw::StringBase &file) const
virtual void pingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port pingIn.
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_cmdResponseOut_OutputPorts()
static constexpr FwIndexType getNum_pingIn_InputPorts()
Forces a close of the currently opened file.
The ComLogger encountered an error opening a file.
Enum representing a command response.
void regCommands()
Register commands with the Command Dispatcher.
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
void init()
Object initializer.
Definition: ObjBase.cpp:24
void set_cmdRegOut_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to cmdRegOut[portNum].
FwIdType FwEventIdType
The type of an event identifier.
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
void log_WARNING_LO_FileNotInitialized_ThrottleClear()
Reset throttle value for FileNotInitialized.
bool isConnected_logOut_OutputPort(FwIndexType portNum) const
void CloseFile_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
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.
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
Enum representing event severity.
The ComLogger encountered an error writing the validation file.
void set_cmdResponseOut_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
static constexpr FwIndexType getNum_logOut_OutputPorts()
void pingOut_out(FwIndexType portNum, U32 key) const
Invoke output port pingOut.
void cmdIn_handlerBase(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
Handler base-class function for input port cmdIn.
friend class ComLoggerTester
Friend class tester implementation to support white-box testing.
void log_WARNING_LO_FileValidationError(const Fw::StringBase &validationFile, const Fw::StringBase &file, U32 status) const
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()
PlatformIndexType FwIndexType
virtual void comIn_handler(FwIndexType portNum, Fw::ComBuffer &data, U32 context)=0
Handler for input port comIn.
friend class ComLoggerTesterBase
Friend class tester to support autocoded test harness.
void comIn_handlerBase(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port comIn.
RateGroupDivider component implementation.
static constexpr FwIndexType getNum_pingOut_OutputPorts()
The ComLogger successfully closed a file on command.
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum) const
The ComLogger encountered an error writing to a file.
static constexpr FwIndexType getNum_cmdRegOut_OutputPorts()
bool isConnected_pingOut_OutputPort(FwIndexType portNum) const
static constexpr FwIndexType getNum_cmdIn_InputPorts()
virtual void CloseFile_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
bool isConnected_cmdRegOut_OutputPort(FwIndexType portNum) const
Auto-generated base for ComLogger component.