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"
29 
30 namespace Svc {
31 
38  {
39 
40  // ----------------------------------------------------------------------
41  // Friend classes
42  // ----------------------------------------------------------------------
43 
45  friend class ComLoggerTesterBase;
47  friend class ComLoggerTester;
48 
49  protected:
50 
51  // ----------------------------------------------------------------------
52  // Constants
53  // ----------------------------------------------------------------------
54 
56  enum {
58  };
59 
61  enum {
64  };
65 
67  enum {
73  };
74 
76  enum {
78  };
79 
81  enum {
83  };
84 
86  enum {
92  };
93 
95  enum {
97  };
98 
99  public:
100 
101  // ----------------------------------------------------------------------
102  // Component initialization
103  // ----------------------------------------------------------------------
104 
106  void init(
107  FwSizeType queueDepth,
108  FwEnumStoreType instance = 0
109  );
110 
111  public:
112 
113  // ----------------------------------------------------------------------
114  // Getters for special input ports
115  // ----------------------------------------------------------------------
116 
121  FwIndexType portNum
122  );
123 
124  public:
125 
126  // ----------------------------------------------------------------------
127  // Getters for typed input ports
128  // ----------------------------------------------------------------------
129 
134  FwIndexType portNum
135  );
136 
141  FwIndexType portNum
142  );
143 
144  public:
145 
146  // ----------------------------------------------------------------------
147  // Connect input ports to special output ports
148  // ----------------------------------------------------------------------
149 
150 #if FW_ENABLE_TEXT_LOGGING == 1
151 
153  void set_LogText_OutputPort(
154  FwIndexType portNum,
155  Fw::InputLogTextPort* port
156  );
157 
158 #endif
159 
162  FwIndexType portNum,
163  Fw::InputCmdRegPort* port
164  );
165 
168  FwIndexType portNum,
170  );
171 
174  FwIndexType portNum,
175  Fw::InputLogPort* port
176  );
177 
180  FwIndexType portNum,
181  Fw::InputTimePort* port
182  );
183 
184  public:
185 
186  // ----------------------------------------------------------------------
187  // Connect typed input ports to typed output ports
188  // ----------------------------------------------------------------------
189 
192  FwIndexType portNum,
193  Svc::InputPingPort* port
194  );
195 
196 #if FW_PORT_SERIALIZATION
197 
198  public:
199 
200  // ----------------------------------------------------------------------
201  // Connect serial input ports to special output ports
202  // ----------------------------------------------------------------------
203 
204 #if FW_ENABLE_TEXT_LOGGING == 1
205 
207  void set_LogText_OutputPort(
208  FwIndexType portNum,
209  Fw::InputSerializePort* port
210  );
211 
212 #endif
213 
216  FwIndexType portNum,
217  Fw::InputSerializePort* port
218  );
219 
222  FwIndexType portNum,
223  Fw::InputSerializePort* port
224  );
225 
228  FwIndexType portNum,
229  Fw::InputSerializePort* port
230  );
231 
234  FwIndexType portNum,
235  Fw::InputSerializePort* port
236  );
237 
238 #endif
239 
240 #if FW_PORT_SERIALIZATION
241 
242  public:
243 
244  // ----------------------------------------------------------------------
245  // Connect serial input ports to typed output ports
246  // ----------------------------------------------------------------------
247 
250  FwIndexType portNum,
251  Fw::InputSerializePort* port
252  );
253 
254 #endif
255 
256  public:
257 
258  // ----------------------------------------------------------------------
259  // Command registration
260  // ----------------------------------------------------------------------
261 
265  void regCommands();
266 
267  protected:
268 
269  // ----------------------------------------------------------------------
270  // Component construction and destruction
271  // ----------------------------------------------------------------------
272 
275  const char* compName = ""
276  );
277 
279  virtual ~ComLoggerComponentBase();
280 
281  protected:
282 
283  // ----------------------------------------------------------------------
284  // Getters for numbers of special input ports
285  // ----------------------------------------------------------------------
286 
291  return NUM_CMDIN_INPUT_PORTS;
292  }
293 
294  protected:
295 
296  // ----------------------------------------------------------------------
297  // Getters for numbers of typed input ports
298  // ----------------------------------------------------------------------
299 
304  return NUM_COMIN_INPUT_PORTS;
305  }
306 
311  return NUM_PINGIN_INPUT_PORTS;
312  }
313 
314  protected:
315 
316  // ----------------------------------------------------------------------
317  // Getters for numbers of special output ports
318  // ----------------------------------------------------------------------
319 
320 #if FW_ENABLE_TEXT_LOGGING == 1
321 
325  static constexpr FwIndexType getNum_LogText_OutputPorts() {
327  }
328 
329 #endif
330 
336  }
337 
343  }
344 
350  }
351 
357  }
358 
359  protected:
360 
361  // ----------------------------------------------------------------------
362  // Getters for numbers of typed output ports
363  // ----------------------------------------------------------------------
364 
370  }
371 
372  protected:
373 
374  // ----------------------------------------------------------------------
375  // Connection status queries for special output ports
376  // ----------------------------------------------------------------------
377 
378 #if FW_ENABLE_TEXT_LOGGING == 1
379 
383  bool isConnected_LogText_OutputPort(
384  FwIndexType portNum
385  );
386 
387 #endif
388 
393  FwIndexType portNum
394  );
395 
400  FwIndexType portNum
401  );
402 
407  FwIndexType portNum
408  );
409 
414  FwIndexType portNum
415  );
416 
417  protected:
418 
419  // ----------------------------------------------------------------------
420  // Connection status queries for typed output ports
421  // ----------------------------------------------------------------------
422 
427  FwIndexType portNum
428  );
429 
430  protected:
431 
432  // ----------------------------------------------------------------------
433  // Handlers to implement for typed input ports
434  // ----------------------------------------------------------------------
435 
437  virtual void comIn_handler(
438  FwIndexType portNum,
439  Fw::ComBuffer& data,
440  U32 context
441  ) = 0;
442 
444  virtual void pingIn_handler(
445  FwIndexType portNum,
446  U32 key
447  ) = 0;
448 
449  protected:
450 
451  // ----------------------------------------------------------------------
452  // Port handler base-class functions for typed input ports
453  //
454  // Call these functions directly to bypass the corresponding ports
455  // ----------------------------------------------------------------------
456 
458  void comIn_handlerBase(
459  FwIndexType portNum,
460  Fw::ComBuffer& data,
461  U32 context
462  );
463 
465  void pingIn_handlerBase(
466  FwIndexType portNum,
467  U32 key
468  );
469 
470  protected:
471 
472  // ----------------------------------------------------------------------
473  // Pre-message hooks for typed async input ports
474  //
475  // Each of these functions is invoked just before processing a message
476  // on the corresponding port. By default, they do nothing. You can
477  // override them to provide specific pre-message behavior.
478  // ----------------------------------------------------------------------
479 
481  virtual void comIn_preMsgHook(
482  FwIndexType portNum,
483  Fw::ComBuffer& data,
484  U32 context
485  );
486 
488  virtual void pingIn_preMsgHook(
489  FwIndexType portNum,
490  U32 key
491  );
492 
493  protected:
494 
495  // ----------------------------------------------------------------------
496  // Invocation functions for typed output ports
497  // ----------------------------------------------------------------------
498 
500  void pingOut_out(
501  FwIndexType portNum,
502  U32 key
503  );
504 
505  protected:
506 
507  // ----------------------------------------------------------------------
508  // Command response
509  // ----------------------------------------------------------------------
510 
512  void cmdResponse_out(
513  FwOpcodeType opCode,
514  U32 cmdSeq,
515  Fw::CmdResponse response
516  );
517 
518  protected:
519 
520  // ----------------------------------------------------------------------
521  // Command handlers to implement
522  // ----------------------------------------------------------------------
523 
527  virtual void CloseFile_cmdHandler(
528  FwOpcodeType opCode,
529  U32 cmdSeq
530  ) = 0;
531 
532  protected:
533 
534  // ----------------------------------------------------------------------
535  // Command handler base-class functions
536  //
537  // Call these functions directly to bypass the command input port
538  // ----------------------------------------------------------------------
539 
544  FwOpcodeType opCode,
545  U32 cmdSeq,
546  Fw::CmdArgBuffer& args
547  );
548 
549  protected:
550 
551  // ----------------------------------------------------------------------
552  // Pre-message hooks for async commands
553  //
554  // Each of these functions is invoked just before processing the
555  // corresponding command. By default they do nothing. You can
556  // override them to provide specific pre-command behavior.
557  // ----------------------------------------------------------------------
558 
560  virtual void CloseFile_preMsgHook(
561  FwOpcodeType opCode,
562  U32 cmdSeq
563  );
564 
565  protected:
566 
567  // ----------------------------------------------------------------------
568  // Event logging functions
569  // ----------------------------------------------------------------------
570 
575  U32 errornum,
576  const Fw::StringBase& file
577  ) const;
578 
583  U32 errornum,
584  U32 bytesWritten,
585  U32 bytesToWrite,
586  const Fw::StringBase& file
587  ) const;
588 
593  const Fw::StringBase& validationFile,
594  const Fw::StringBase& file,
595  U32 status
596  ) const;
597 
602  const Fw::StringBase& file
603  ) const;
604 
607 
608  protected:
609 
610  // ----------------------------------------------------------------------
611  // Event throttle reset functions
612  // ----------------------------------------------------------------------
613 
616 
617  protected:
618 
619  // ----------------------------------------------------------------------
620  // Time
621  // ----------------------------------------------------------------------
622 
626  Fw::Time getTime() const;
627 
628  private:
629 
630  // ----------------------------------------------------------------------
631  // Message dispatch functions
632  // ----------------------------------------------------------------------
633 
635  virtual MsgDispatchStatus doDispatch();
636 
637  private:
638 
639  // ----------------------------------------------------------------------
640  // Calls for messages received on special input ports
641  // ----------------------------------------------------------------------
642 
644  static void m_p_cmdIn_in(
645  Fw::PassiveComponentBase* callComp,
646  FwIndexType portNum,
647  FwOpcodeType opCode,
648  U32 cmdSeq,
649  Fw::CmdArgBuffer& args
650  );
651 
652  private:
653 
654  // ----------------------------------------------------------------------
655  // Calls for messages received on typed input ports
656  // ----------------------------------------------------------------------
657 
659  static void m_p_comIn_in(
660  Fw::PassiveComponentBase* callComp,
661  FwIndexType portNum,
662  Fw::ComBuffer& data,
663  U32 context
664  );
665 
667  static void m_p_pingIn_in(
668  Fw::PassiveComponentBase* callComp,
669  FwIndexType portNum,
670  U32 key
671  );
672 
673  private:
674 
675  // ----------------------------------------------------------------------
676  // Special input ports
677  // ----------------------------------------------------------------------
678 
680  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
681 
682  private:
683 
684  // ----------------------------------------------------------------------
685  // Typed input ports
686  // ----------------------------------------------------------------------
687 
689  Fw::InputComPort m_comIn_InputPort[NUM_COMIN_INPUT_PORTS];
690 
692  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
693 
694  private:
695 
696  // ----------------------------------------------------------------------
697  // Special output ports
698  // ----------------------------------------------------------------------
699 
700 #if FW_ENABLE_TEXT_LOGGING == 1
701 
703  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
704 
705 #endif
706 
708  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
709 
711  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
712 
714  Fw::OutputLogPort m_logOut_OutputPort[NUM_LOGOUT_OUTPUT_PORTS];
715 
717  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
718 
719  private:
720 
721  // ----------------------------------------------------------------------
722  // Typed output ports
723  // ----------------------------------------------------------------------
724 
726  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
727 
728  private:
729 
730  // ----------------------------------------------------------------------
731  // Counter values for event throttling
732  // ----------------------------------------------------------------------
733 
735  std::atomic<FwIndexType> m_FileNotInitializedThrottle;
736 
737  };
738 
739 }
740 
741 #endif
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 to a 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()
The ComLogger successfully closed a file on command.
Enum representing a command response.
void regCommands()
Register commands with the Command Dispatcher.
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
Forces a close of the currently opened file.
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].
bool isConnected_logOut_OutputPort(FwIndexType portNum)
The ComLogger encountered an error writing the validation file.
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)
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()
The ComLogger encountered an error opening a file.
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()
virtual void CloseFile_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
Auto-generated base for ComLogger component.