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 #if FW_ENABLE_TEXT_LOGGING == 1
22 #include "Fw/Log/LogTextPortAc.hpp"
23 #endif
24 #if !FW_DIRECT_PORT_CALLS
26 #endif
27 #if !FW_DIRECT_PORT_CALLS
29 #endif
30 #include "Fw/Time/TimePortAc.hpp"
31 #include "Svc/Ping/PingPortAc.hpp"
33 
34 namespace Svc {
35 
42  {
43 
44  // ----------------------------------------------------------------------
45  // Friend classes
46  // ----------------------------------------------------------------------
47 
49  friend class ComLoggerTesterBase;
51  friend class ComLoggerTester;
52 
53  protected:
54 
55  // ----------------------------------------------------------------------
56  // Constants
57  // ----------------------------------------------------------------------
58 
60  enum {
62  };
63 
65  enum {
68  };
69 
71  enum {
77  };
78 
80  enum {
82  };
83 
85  enum {
87  };
88 
90  enum {
96  };
97 
99  enum {
101  };
102 
103  public:
104 
105  // ----------------------------------------------------------------------
106  // Component initialization
107  // ----------------------------------------------------------------------
108 
110  void init(
111  FwSizeType queueDepth,
112  FwEnumStoreType instance = 0
113  );
114 
115 #if !FW_DIRECT_PORT_CALLS
116 
117  public:
118 
119  // ----------------------------------------------------------------------
120  // Getters for special input ports
121  // ----------------------------------------------------------------------
122 
127  FwIndexType portNum
128  );
129 
130 #endif
131 
132 #if !FW_DIRECT_PORT_CALLS
133 
134  public:
135 
136  // ----------------------------------------------------------------------
137  // Getters for typed input ports
138  // ----------------------------------------------------------------------
139 
144  FwIndexType portNum
145  );
146 
151  FwIndexType portNum
152  );
153 
154 #endif
155 
156 #if !FW_DIRECT_PORT_CALLS
157 
158  public:
159 
160  // ----------------------------------------------------------------------
161  // Connect input ports to special output ports
162  // ----------------------------------------------------------------------
163 
164 #if FW_ENABLE_TEXT_LOGGING == 1
165 
167  void set_LogText_OutputPort(
168  FwIndexType portNum,
169  Fw::InputLogTextPort* port
170  );
171 
172 #endif
173 
176  FwIndexType portNum,
177  Fw::InputCmdRegPort* port
178  );
179 
182  FwIndexType portNum,
184  );
185 
188  FwIndexType portNum,
189  Fw::InputLogPort* port
190  );
191 
194  FwIndexType portNum,
195  Fw::InputTimePort* port
196  );
197 
198 #endif
199 
200 #if !FW_DIRECT_PORT_CALLS
201 
202  public:
203 
204  // ----------------------------------------------------------------------
205  // Connect typed input ports to typed output ports
206  // ----------------------------------------------------------------------
207 
210  FwIndexType portNum,
211  Svc::InputPingPort* port
212  );
213 
214 #endif
215 
216 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
217 
218  public:
219 
220  // ----------------------------------------------------------------------
221  // Connect serial input ports to special output ports
222  // ----------------------------------------------------------------------
223 
224 #if FW_ENABLE_TEXT_LOGGING == 1
225 
227  void set_LogText_OutputPort(
228  FwIndexType portNum,
229  Fw::InputSerializePort* port
230  );
231 
232 #endif
233 
236  FwIndexType portNum,
237  Fw::InputSerializePort* port
238  );
239 
242  FwIndexType portNum,
243  Fw::InputSerializePort* port
244  );
245 
248  FwIndexType portNum,
249  Fw::InputSerializePort* port
250  );
251 
254  FwIndexType portNum,
255  Fw::InputSerializePort* port
256  );
257 
258 #endif
259 
260 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
261 
262  public:
263 
264  // ----------------------------------------------------------------------
265  // Connect serial input ports to typed output ports
266  // ----------------------------------------------------------------------
267 
270  FwIndexType portNum,
271  Fw::InputSerializePort* port
272  );
273 
274 #endif
275 
276  public:
277 
278  // ----------------------------------------------------------------------
279  // Command registration
280  // ----------------------------------------------------------------------
281 
285  void regCommands();
286 
287  protected:
288 
289  // ----------------------------------------------------------------------
290  // Component construction and destruction
291  // ----------------------------------------------------------------------
292 
295  const char* compName = ""
296  );
297 
299  virtual ~ComLoggerComponentBase();
300 
301  protected:
302 
303  // ----------------------------------------------------------------------
304  // Getters for numbers of special input ports
305  // ----------------------------------------------------------------------
306 
311  return NUM_CMDIN_INPUT_PORTS;
312  }
313 
314  protected:
315 
316  // ----------------------------------------------------------------------
317  // Getters for numbers of typed input ports
318  // ----------------------------------------------------------------------
319 
324  return NUM_COMIN_INPUT_PORTS;
325  }
326 
331  return NUM_PINGIN_INPUT_PORTS;
332  }
333 
334  protected:
335 
336  // ----------------------------------------------------------------------
337  // Getters for numbers of special output ports
338  // ----------------------------------------------------------------------
339 
340 #if FW_ENABLE_TEXT_LOGGING == 1
341 
345  static constexpr FwIndexType getNum_LogText_OutputPorts() {
347  }
348 
349 #endif
350 
356  }
357 
363  }
364 
370  }
371 
377  }
378 
379  protected:
380 
381  // ----------------------------------------------------------------------
382  // Getters for numbers of typed output ports
383  // ----------------------------------------------------------------------
384 
390  }
391 
392  protected:
393 
394  // ----------------------------------------------------------------------
395  // Connection status queries for special output ports
396  // ----------------------------------------------------------------------
397 
398 #if FW_ENABLE_TEXT_LOGGING == 1
399 
403  bool isConnected_LogText_OutputPort(
404  FwIndexType portNum
405  ) const;
406 
407 #endif
408 
413  FwIndexType portNum
414  ) const;
415 
420  FwIndexType portNum
421  ) const;
422 
427  FwIndexType portNum
428  ) const;
429 
434  FwIndexType portNum
435  ) const;
436 
437  protected:
438 
439  // ----------------------------------------------------------------------
440  // Connection status queries for typed output ports
441  // ----------------------------------------------------------------------
442 
447  FwIndexType portNum
448  ) const;
449 
450 #if FW_DIRECT_PORT_CALLS
451  public:
452 #else
453  protected:
454 #endif
455 
456  // ----------------------------------------------------------------------
457  // Port handler base-class functions for special input ports
458  //
459  // Call these functions directly to bypass the corresponding ports
460  // ----------------------------------------------------------------------
461 
463  void cmdIn_handlerBase(
464  FwIndexType portNum,
465  FwOpcodeType opCode,
466  U32 cmdSeq,
467  Fw::CmdArgBuffer& args
468  );
469 
470  protected:
471 
472  // ----------------------------------------------------------------------
473  // Handlers to implement for typed input ports
474  // ----------------------------------------------------------------------
475 
477  virtual void comIn_handler(
478  FwIndexType portNum,
479  Fw::ComBuffer& data,
480  U32 context
481  ) = 0;
482 
484  virtual void pingIn_handler(
485  FwIndexType portNum,
486  U32 key
487  ) = 0;
488 
489 #if FW_DIRECT_PORT_CALLS
490  public:
491 #else
492  protected:
493 #endif
494 
495  // ----------------------------------------------------------------------
496  // Port handler base-class functions for typed input ports
497  //
498  // Call these functions directly to bypass the corresponding ports
499  // ----------------------------------------------------------------------
500 
502  void comIn_handlerBase(
503  FwIndexType portNum,
504  Fw::ComBuffer& data,
505  U32 context
506  );
507 
509  void pingIn_handlerBase(
510  FwIndexType portNum,
511  U32 key
512  );
513 
514  protected:
515 
516  // ----------------------------------------------------------------------
517  // Pre-message hooks for typed async input ports
518  //
519  // Each of these functions is invoked just before processing a message
520  // on the corresponding port. By default, they do nothing. You can
521  // override them to provide specific pre-message behavior.
522  // ----------------------------------------------------------------------
523 
525  virtual void comIn_preMsgHook(
526  FwIndexType portNum,
527  Fw::ComBuffer& data,
528  U32 context
529  );
530 
532  virtual void pingIn_preMsgHook(
533  FwIndexType portNum,
534  U32 key
535  );
536 
537  protected:
538 
539  // ----------------------------------------------------------------------
540  // Invocation functions for typed output ports
541  // ----------------------------------------------------------------------
542 
544  void pingOut_out(
545  FwIndexType portNum,
546  U32 key
547  ) const;
548 
549  protected:
550 
551  // ----------------------------------------------------------------------
552  // Command response
553  // ----------------------------------------------------------------------
554 
556  void cmdResponse_out(
557  FwOpcodeType opCode,
558  U32 cmdSeq,
559  Fw::CmdResponse response
560  );
561 
562  protected:
563 
564  // ----------------------------------------------------------------------
565  // Command handlers to implement
566  // ----------------------------------------------------------------------
567 
571  virtual void CloseFile_cmdHandler(
572  FwOpcodeType opCode,
573  U32 cmdSeq
574  ) = 0;
575 
576  protected:
577 
578  // ----------------------------------------------------------------------
579  // Command handler base-class functions
580  //
581  // Call these functions directly to bypass the command input port
582  // ----------------------------------------------------------------------
583 
588  FwOpcodeType opCode,
589  U32 cmdSeq,
590  Fw::CmdArgBuffer& args
591  );
592 
593  protected:
594 
595  // ----------------------------------------------------------------------
596  // Pre-message hooks for async commands
597  //
598  // Each of these functions is invoked just before processing the
599  // corresponding command. By default they do nothing. You can
600  // override them to provide specific pre-command behavior.
601  // ----------------------------------------------------------------------
602 
604  virtual void CloseFile_preMsgHook(
605  FwOpcodeType opCode,
606  U32 cmdSeq
607  );
608 
609  protected:
610 
611  // ----------------------------------------------------------------------
612  // Event logging functions
613  // ----------------------------------------------------------------------
614 
619  U32 errornum,
620  const Fw::StringBase& file
621  ) const;
622 
627  U32 errornum,
628  U32 bytesWritten,
629  U32 bytesToWrite,
630  const Fw::StringBase& file
631  ) const;
632 
637  const Fw::StringBase& validationFile,
638  const Fw::StringBase& file,
639  U32 status
640  ) const;
641 
646  const Fw::StringBase& file
647  ) const;
648 
651 
652  protected:
653 
654  // ----------------------------------------------------------------------
655  // Event throttle reset functions
656  // ----------------------------------------------------------------------
657 
660 
661  protected:
662 
663  // ----------------------------------------------------------------------
664  // Time
665  // ----------------------------------------------------------------------
666 
670  Fw::Time getTime() const;
671 
672  private:
673 
674  // ----------------------------------------------------------------------
675  // Message dispatch functions
676  // ----------------------------------------------------------------------
677 
679  virtual MsgDispatchStatus doDispatch();
680 
681  private:
682 
683  // ----------------------------------------------------------------------
684  // Calls for messages received on special input ports
685  // ----------------------------------------------------------------------
686 
688  static void m_p_cmdIn_in(
689  Fw::PassiveComponentBase* callComp,
690  FwIndexType portNum,
691  FwOpcodeType opCode,
692  U32 cmdSeq,
693  Fw::CmdArgBuffer& args
694  );
695 
696  private:
697 
698  // ----------------------------------------------------------------------
699  // Calls for messages received on typed input ports
700  // ----------------------------------------------------------------------
701 
703  static void m_p_comIn_in(
704  Fw::PassiveComponentBase* callComp,
705  FwIndexType portNum,
706  Fw::ComBuffer& data,
707  U32 context
708  );
709 
711  static void m_p_pingIn_in(
712  Fw::PassiveComponentBase* callComp,
713  FwIndexType portNum,
714  U32 key
715  );
716 
717  private:
718 
719  // ----------------------------------------------------------------------
720  // Invocation functions for special output ports
721  // ----------------------------------------------------------------------
722 
723 #if FW_ENABLE_TEXT_LOGGING
724 
726  void LogText_out(
727  FwIndexType portNum,
728  FwEventIdType id,
729  Fw::Time& timeTag,
730  const Fw::LogSeverity& severity,
731  Fw::TextLogString& text
732  ) const;
733 
734 #endif
735 
737  void cmdRegOut_out(
738  FwIndexType portNum,
739  FwOpcodeType opCode
740  ) const;
741 
743  void cmdResponseOut_out(
744  FwIndexType portNum,
745  FwOpcodeType opCode,
746  U32 cmdSeq,
747  const Fw::CmdResponse& response
748  ) const;
749 
751  void logOut_out(
752  FwIndexType portNum,
753  FwEventIdType id,
754  Fw::Time& timeTag,
755  const Fw::LogSeverity& severity,
756  Fw::LogBuffer& args
757  ) const;
758 
760  void timeCaller_out(
761  FwIndexType portNum,
762  Fw::Time& time
763  ) const;
764 
765 #if !FW_DIRECT_PORT_CALLS
766 
767  private:
768 
769  // ----------------------------------------------------------------------
770  // Special input ports
771  // ----------------------------------------------------------------------
772 
774  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
775 
776 #endif
777 
778 #if !FW_DIRECT_PORT_CALLS
779 
780  private:
781 
782  // ----------------------------------------------------------------------
783  // Typed input ports
784  // ----------------------------------------------------------------------
785 
787  Fw::InputComPort m_comIn_InputPort[NUM_COMIN_INPUT_PORTS];
788 
790  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
791 
792 #endif
793 
794 #if !FW_DIRECT_PORT_CALLS
795 
796  private:
797 
798  // ----------------------------------------------------------------------
799  // Special output ports
800  // ----------------------------------------------------------------------
801 
802 #if FW_ENABLE_TEXT_LOGGING == 1
803 
805  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
806 
807 #endif
808 
810  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
811 
813  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
814 
816  Fw::OutputLogPort m_logOut_OutputPort[NUM_LOGOUT_OUTPUT_PORTS];
817 
819  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
820 
821 #endif
822 
823 #if !FW_DIRECT_PORT_CALLS
824 
825  private:
826 
827  // ----------------------------------------------------------------------
828  // Typed output ports
829  // ----------------------------------------------------------------------
830 
832  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
833 
834 #endif
835 
836  private:
837 
838  // ----------------------------------------------------------------------
839  // Counter values for event throttling
840  // ----------------------------------------------------------------------
841 
843  std::atomic<FwIndexType> m_FileNotInitializedThrottle;
844 
845  };
846 
847 }
848 
849 #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)
The ComLogger encountered an error writing the validation file.
static constexpr FwIndexType getNum_cmdResponseOut_OutputPorts()
static constexpr FwIndexType getNum_pingIn_InputPorts()
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.
The ComLogger successfully closed a file on command.
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.
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.
Forces a close of the currently opened file.
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()
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum) const
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
The ComLogger encountered an error writing to a file.
Auto-generated base for ComLogger component.
The ComLogger encountered an error opening a file.