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
26 #include "Fw/Time/TimePortAc.hpp"
27 #include "Svc/Ping/PingPortAc.hpp"
28 
29 namespace Svc {
30 
37  {
38 
39  // ----------------------------------------------------------------------
40  // Friend classes
41  // ----------------------------------------------------------------------
42 
44  friend class ComLoggerTesterBase;
46  friend class ComLoggerTester;
47 
48  protected:
49 
50  // ----------------------------------------------------------------------
51  // Constants
52  // ----------------------------------------------------------------------
53 
55  enum {
57  };
58 
60  enum {
63  };
64 
66  enum {
72  };
73 
75  enum {
77  };
78 
80  enum {
82  };
83 
85  enum {
91  };
92 
94  enum {
96  };
97 
98  public:
99 
100  // ----------------------------------------------------------------------
101  // Component initialization
102  // ----------------------------------------------------------------------
103 
105  void init(
106  FwSizeType queueDepth,
107  FwEnumStoreType instance = 0
108  );
109 
110  public:
111 
112  // ----------------------------------------------------------------------
113  // Getters for special input ports
114  // ----------------------------------------------------------------------
115 
120  FwIndexType portNum
121  );
122 
123  public:
124 
125  // ----------------------------------------------------------------------
126  // Getters for typed input ports
127  // ----------------------------------------------------------------------
128 
133  FwIndexType portNum
134  );
135 
140  FwIndexType portNum
141  );
142 
143  public:
144 
145  // ----------------------------------------------------------------------
146  // Connect input ports to special output ports
147  // ----------------------------------------------------------------------
148 
149 #if FW_ENABLE_TEXT_LOGGING == 1
150 
152  void set_LogText_OutputPort(
153  FwIndexType portNum,
154  Fw::InputLogTextPort* port
155  );
156 
157 #endif
158 
161  FwIndexType portNum,
162  Fw::InputCmdRegPort* port
163  );
164 
167  FwIndexType portNum,
169  );
170 
173  FwIndexType portNum,
174  Fw::InputLogPort* port
175  );
176 
179  FwIndexType portNum,
180  Fw::InputTimePort* port
181  );
182 
183  public:
184 
185  // ----------------------------------------------------------------------
186  // Connect typed input ports to typed output ports
187  // ----------------------------------------------------------------------
188 
191  FwIndexType portNum,
192  Svc::InputPingPort* port
193  );
194 
195 #if FW_PORT_SERIALIZATION
196 
197  public:
198 
199  // ----------------------------------------------------------------------
200  // Connect serial input ports to special output ports
201  // ----------------------------------------------------------------------
202 
203 #if FW_ENABLE_TEXT_LOGGING == 1
204 
206  void set_LogText_OutputPort(
207  FwIndexType portNum,
208  Fw::InputSerializePort* port
209  );
210 
211 #endif
212 
215  FwIndexType portNum,
216  Fw::InputSerializePort* port
217  );
218 
221  FwIndexType portNum,
222  Fw::InputSerializePort* port
223  );
224 
227  FwIndexType portNum,
228  Fw::InputSerializePort* port
229  );
230 
233  FwIndexType portNum,
234  Fw::InputSerializePort* port
235  );
236 
237 #endif
238 
239 #if FW_PORT_SERIALIZATION
240 
241  public:
242 
243  // ----------------------------------------------------------------------
244  // Connect serial input ports to typed output ports
245  // ----------------------------------------------------------------------
246 
249  FwIndexType portNum,
250  Fw::InputSerializePort* port
251  );
252 
253 #endif
254 
255  public:
256 
257  // ----------------------------------------------------------------------
258  // Command registration
259  // ----------------------------------------------------------------------
260 
264  void regCommands();
265 
266  protected:
267 
268  // ----------------------------------------------------------------------
269  // Component construction and destruction
270  // ----------------------------------------------------------------------
271 
274  const char* compName = ""
275  );
276 
278  virtual ~ComLoggerComponentBase();
279 
280  protected:
281 
282  // ----------------------------------------------------------------------
283  // Getters for numbers of special input ports
284  // ----------------------------------------------------------------------
285 
290  return NUM_CMDIN_INPUT_PORTS;
291  }
292 
293  protected:
294 
295  // ----------------------------------------------------------------------
296  // Getters for numbers of typed input ports
297  // ----------------------------------------------------------------------
298 
303  return NUM_COMIN_INPUT_PORTS;
304  }
305 
310  return NUM_PINGIN_INPUT_PORTS;
311  }
312 
313  protected:
314 
315  // ----------------------------------------------------------------------
316  // Getters for numbers of special output ports
317  // ----------------------------------------------------------------------
318 
319 #if FW_ENABLE_TEXT_LOGGING == 1
320 
324  static constexpr FwIndexType getNum_LogText_OutputPorts() {
326  }
327 
328 #endif
329 
335  }
336 
342  }
343 
349  }
350 
356  }
357 
358  protected:
359 
360  // ----------------------------------------------------------------------
361  // Getters for numbers of typed output ports
362  // ----------------------------------------------------------------------
363 
369  }
370 
371  protected:
372 
373  // ----------------------------------------------------------------------
374  // Connection status queries for special output ports
375  // ----------------------------------------------------------------------
376 
377 #if FW_ENABLE_TEXT_LOGGING == 1
378 
382  bool isConnected_LogText_OutputPort(
383  FwIndexType portNum
384  );
385 
386 #endif
387 
392  FwIndexType portNum
393  );
394 
399  FwIndexType portNum
400  );
401 
406  FwIndexType portNum
407  );
408 
413  FwIndexType portNum
414  );
415 
416  protected:
417 
418  // ----------------------------------------------------------------------
419  // Connection status queries for typed output ports
420  // ----------------------------------------------------------------------
421 
426  FwIndexType portNum
427  );
428 
429  protected:
430 
431  // ----------------------------------------------------------------------
432  // Handlers to implement for typed input ports
433  // ----------------------------------------------------------------------
434 
436  virtual void comIn_handler(
437  FwIndexType portNum,
438  Fw::ComBuffer& data,
439  U32 context
440  ) = 0;
441 
443  virtual void pingIn_handler(
444  FwIndexType portNum,
445  U32 key
446  ) = 0;
447 
448  protected:
449 
450  // ----------------------------------------------------------------------
451  // Port handler base-class functions for typed input ports
452  //
453  // Call these functions directly to bypass the corresponding ports
454  // ----------------------------------------------------------------------
455 
457  void comIn_handlerBase(
458  FwIndexType portNum,
459  Fw::ComBuffer& data,
460  U32 context
461  );
462 
464  void pingIn_handlerBase(
465  FwIndexType portNum,
466  U32 key
467  );
468 
469  protected:
470 
471  // ----------------------------------------------------------------------
472  // Pre-message hooks for typed async input ports
473  //
474  // Each of these functions is invoked just before processing a message
475  // on the corresponding port. By default, they do nothing. You can
476  // override them to provide specific pre-message behavior.
477  // ----------------------------------------------------------------------
478 
480  virtual void comIn_preMsgHook(
481  FwIndexType portNum,
482  Fw::ComBuffer& data,
483  U32 context
484  );
485 
487  virtual void pingIn_preMsgHook(
488  FwIndexType portNum,
489  U32 key
490  );
491 
492  protected:
493 
494  // ----------------------------------------------------------------------
495  // Invocation functions for typed output ports
496  // ----------------------------------------------------------------------
497 
499  void pingOut_out(
500  FwIndexType portNum,
501  U32 key
502  );
503 
504  protected:
505 
506  // ----------------------------------------------------------------------
507  // Command response
508  // ----------------------------------------------------------------------
509 
511  void cmdResponse_out(
512  FwOpcodeType opCode,
513  U32 cmdSeq,
514  Fw::CmdResponse response
515  );
516 
517  protected:
518 
519  // ----------------------------------------------------------------------
520  // Command handlers to implement
521  // ----------------------------------------------------------------------
522 
526  virtual void CloseFile_cmdHandler(
527  FwOpcodeType opCode,
528  U32 cmdSeq
529  ) = 0;
530 
531  protected:
532 
533  // ----------------------------------------------------------------------
534  // Command handler base-class functions
535  //
536  // Call these functions directly to bypass the command input port
537  // ----------------------------------------------------------------------
538 
543  FwOpcodeType opCode,
544  U32 cmdSeq,
545  Fw::CmdArgBuffer& args
546  );
547 
548  protected:
549 
550  // ----------------------------------------------------------------------
551  // Pre-message hooks for async commands
552  //
553  // Each of these functions is invoked just before processing the
554  // corresponding command. By default they do nothing. You can
555  // override them to provide specific pre-command behavior.
556  // ----------------------------------------------------------------------
557 
559  virtual void CloseFile_preMsgHook(
560  FwOpcodeType opCode,
561  U32 cmdSeq
562  );
563 
564  protected:
565 
566  // ----------------------------------------------------------------------
567  // Event logging functions
568  // ----------------------------------------------------------------------
569 
574  U32 errornum,
575  const Fw::StringBase& file
576  ) const;
577 
582  U32 errornum,
583  U32 bytesWritten,
584  U32 bytesToWrite,
585  const Fw::StringBase& file
586  ) const;
587 
592  const Fw::StringBase& validationFile,
593  const Fw::StringBase& file,
594  U32 status
595  ) const;
596 
601  const Fw::StringBase& file
602  ) const;
603 
606 
607  protected:
608 
609  // ----------------------------------------------------------------------
610  // Event throttle reset functions
611  // ----------------------------------------------------------------------
612 
615 
616  protected:
617 
618  // ----------------------------------------------------------------------
619  // Time
620  // ----------------------------------------------------------------------
621 
625  Fw::Time getTime() const;
626 
627  private:
628 
629  // ----------------------------------------------------------------------
630  // Message dispatch functions
631  // ----------------------------------------------------------------------
632 
634  virtual MsgDispatchStatus doDispatch();
635 
636  private:
637 
638  // ----------------------------------------------------------------------
639  // Calls for messages received on special input ports
640  // ----------------------------------------------------------------------
641 
643  static void m_p_cmdIn_in(
644  Fw::PassiveComponentBase* callComp,
645  FwIndexType portNum,
646  FwOpcodeType opCode,
647  U32 cmdSeq,
648  Fw::CmdArgBuffer& args
649  );
650 
651  private:
652 
653  // ----------------------------------------------------------------------
654  // Calls for messages received on typed input ports
655  // ----------------------------------------------------------------------
656 
658  static void m_p_comIn_in(
659  Fw::PassiveComponentBase* callComp,
660  FwIndexType portNum,
661  Fw::ComBuffer& data,
662  U32 context
663  );
664 
666  static void m_p_pingIn_in(
667  Fw::PassiveComponentBase* callComp,
668  FwIndexType portNum,
669  U32 key
670  );
671 
672  private:
673 
674  // ----------------------------------------------------------------------
675  // Special input ports
676  // ----------------------------------------------------------------------
677 
679  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
680 
681  private:
682 
683  // ----------------------------------------------------------------------
684  // Typed input ports
685  // ----------------------------------------------------------------------
686 
688  Fw::InputComPort m_comIn_InputPort[NUM_COMIN_INPUT_PORTS];
689 
691  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
692 
693  private:
694 
695  // ----------------------------------------------------------------------
696  // Special output ports
697  // ----------------------------------------------------------------------
698 
699 #if FW_ENABLE_TEXT_LOGGING == 1
700 
702  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
703 
704 #endif
705 
707  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
708 
710  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
711 
713  Fw::OutputLogPort m_logOut_OutputPort[NUM_LOGOUT_OUTPUT_PORTS];
714 
716  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
717 
718  private:
719 
720  // ----------------------------------------------------------------------
721  // Typed output ports
722  // ----------------------------------------------------------------------
723 
725  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
726 
727  private:
728 
729  // ----------------------------------------------------------------------
730  // Counter values for event throttling
731  // ----------------------------------------------------------------------
732 
734  std::atomic<FwIndexType> m_FileNotInitializedThrottle;
735 
736  };
737 
738 }
739 
740 #endif
The ComLogger successfully closed a file on command.
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
ComLoggerComponentBase(const char *compName="")
Construct ComLoggerComponentBase object.
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
The ComLogger encountered an error writing the validation file.
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
bool isConnected_pingOut_OutputPort(FwIndexType portNum)
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()
Enum representing a command response.
void regCommands()
Register commands with the Command Dispatcher.
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
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].
The ComLogger encountered an error writing to a file.
bool isConnected_logOut_OutputPort(FwIndexType portNum)
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.
void CloseFile_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
Forces a close of the currently opened file.
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.
void set_cmdResponseOut_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
static constexpr FwIndexType getNum_logOut_OutputPorts()
bool isConnected_timeCaller_OutputPort(FwIndexType portNum)
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()
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum)
bool isConnected_cmdRegOut_OutputPort(FwIndexType portNum)
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()
static constexpr FwIndexType getNum_cmdRegOut_OutputPorts()
static constexpr FwIndexType getNum_cmdIn_InputPorts()
The ComLogger encountered an error opening a file.
virtual void CloseFile_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
Auto-generated base for ComLogger component.