F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
PrmDbComponentAc.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title PrmDbComponentAc.hpp
3 // \author Generated by fpp-to-cpp
4 // \brief hpp file for PrmDb component base class
5 // ======================================================================
6 
7 #ifndef Svc_PrmDbComponentAc_HPP
8 #define Svc_PrmDbComponentAc_HPP
9 
10 #include <atomic>
11 
12 #include "Fw/Cmd/CmdPortAc.hpp"
13 #include "Fw/Cmd/CmdRegPortAc.hpp"
15 #include "Fw/Cmd/CmdString.hpp"
17 #include "Fw/FPrimeBasicTypes.hpp"
18 #include "Fw/Log/LogPortAc.hpp"
19 #include "Fw/Log/LogString.hpp"
20 #if FW_ENABLE_TEXT_LOGGING == 1
21 #include "Fw/Log/LogTextPortAc.hpp"
22 #endif
25 #include "Fw/Prm/PrmGetPortAc.hpp"
26 #include "Fw/Prm/PrmSetPortAc.hpp"
27 #include "Fw/Time/TimePortAc.hpp"
28 #include "Os/Mutex.hpp"
29 #include "Svc/Ping/PingPortAc.hpp"
36 
37 namespace Svc {
38 
45  {
46 
47  // ----------------------------------------------------------------------
48  // Friend classes
49  // ----------------------------------------------------------------------
50 
52  friend class PrmDbTesterBase;
54  friend class PrmDbTester;
55 
56  protected:
57 
58  // ----------------------------------------------------------------------
59  // Constants
60  // ----------------------------------------------------------------------
61 
63  enum {
65  };
66 
68  enum {
72  };
73 
75  enum {
81  };
82 
84  enum {
86  };
87 
89  enum {
93  };
94 
96  enum {
109  };
110 
112  enum {
114  };
115 
116  public:
117 
118  // ----------------------------------------------------------------------
119  // Component initialization
120  // ----------------------------------------------------------------------
121 
123  void init(
124  FwSizeType queueDepth,
125  FwEnumStoreType instance = 0
126  );
127 
128  public:
129 
130  // ----------------------------------------------------------------------
131  // Getters for special input ports
132  // ----------------------------------------------------------------------
133 
138  FwIndexType portNum
139  );
140 
141  public:
142 
143  // ----------------------------------------------------------------------
144  // Getters for typed input ports
145  // ----------------------------------------------------------------------
146 
151  FwIndexType portNum
152  );
153 
158  FwIndexType portNum
159  );
160 
165  FwIndexType portNum
166  );
167 
168  public:
169 
170  // ----------------------------------------------------------------------
171  // Connect input ports to special output ports
172  // ----------------------------------------------------------------------
173 
176  FwIndexType portNum,
177  Fw::InputCmdRegPort* port
178  );
179 
182  FwIndexType portNum,
184  );
185 
187  void set_Log_OutputPort(
188  FwIndexType portNum,
189  Fw::InputLogPort* port
190  );
191 
192 #if FW_ENABLE_TEXT_LOGGING == 1
193 
195  void set_LogText_OutputPort(
196  FwIndexType portNum,
197  Fw::InputLogTextPort* port
198  );
199 
200 #endif
201 
203  void set_Time_OutputPort(
204  FwIndexType portNum,
205  Fw::InputTimePort* port
206  );
207 
208  public:
209 
210  // ----------------------------------------------------------------------
211  // Connect typed input ports to typed output ports
212  // ----------------------------------------------------------------------
213 
216  FwIndexType portNum,
217  Svc::InputPingPort* port
218  );
219 
220 #if FW_PORT_SERIALIZATION
221 
222  public:
223 
224  // ----------------------------------------------------------------------
225  // Connect serial input ports to special output ports
226  // ----------------------------------------------------------------------
227 
230  FwIndexType portNum,
231  Fw::InputSerializePort* port
232  );
233 
236  FwIndexType portNum,
237  Fw::InputSerializePort* port
238  );
239 
241  void set_Log_OutputPort(
242  FwIndexType portNum,
243  Fw::InputSerializePort* port
244  );
245 
246 #if FW_ENABLE_TEXT_LOGGING == 1
247 
249  void set_LogText_OutputPort(
250  FwIndexType portNum,
251  Fw::InputSerializePort* port
252  );
253 
254 #endif
255 
257  void set_Time_OutputPort(
258  FwIndexType portNum,
259  Fw::InputSerializePort* port
260  );
261 
262 #endif
263 
264 #if FW_PORT_SERIALIZATION
265 
266  public:
267 
268  // ----------------------------------------------------------------------
269  // Connect serial input ports to typed output ports
270  // ----------------------------------------------------------------------
271 
274  FwIndexType portNum,
275  Fw::InputSerializePort* port
276  );
277 
278 #endif
279 
280  public:
281 
282  // ----------------------------------------------------------------------
283  // Command registration
284  // ----------------------------------------------------------------------
285 
289  void regCommands();
290 
291  protected:
292 
293  // ----------------------------------------------------------------------
294  // Component construction and destruction
295  // ----------------------------------------------------------------------
296 
299  const char* compName = ""
300  );
301 
303  virtual ~PrmDbComponentBase();
304 
305  protected:
306 
307  // ----------------------------------------------------------------------
308  // Getters for numbers of special input ports
309  // ----------------------------------------------------------------------
310 
316  }
317 
318  protected:
319 
320  // ----------------------------------------------------------------------
321  // Getters for numbers of typed input ports
322  // ----------------------------------------------------------------------
323 
328  return NUM_GETPRM_INPUT_PORTS;
329  }
330 
335  return NUM_PINGIN_INPUT_PORTS;
336  }
337 
342  return NUM_SETPRM_INPUT_PORTS;
343  }
344 
345  protected:
346 
347  // ----------------------------------------------------------------------
348  // Getters for numbers of special output ports
349  // ----------------------------------------------------------------------
350 
356  }
357 
363  }
364 
368  static constexpr FwIndexType getNum_Log_OutputPorts() {
369  return NUM_LOG_OUTPUT_PORTS;
370  }
371 
372 #if FW_ENABLE_TEXT_LOGGING == 1
373 
377  static constexpr FwIndexType getNum_LogText_OutputPorts() {
379  }
380 
381 #endif
382 
387  return NUM_TIME_OUTPUT_PORTS;
388  }
389 
390  protected:
391 
392  // ----------------------------------------------------------------------
393  // Getters for numbers of typed output ports
394  // ----------------------------------------------------------------------
395 
401  }
402 
403  protected:
404 
405  // ----------------------------------------------------------------------
406  // Connection status queries for special output ports
407  // ----------------------------------------------------------------------
408 
413  FwIndexType portNum
414  );
415 
420  FwIndexType portNum
421  );
422 
427  FwIndexType portNum
428  );
429 
430 #if FW_ENABLE_TEXT_LOGGING == 1
431 
435  bool isConnected_LogText_OutputPort(
436  FwIndexType portNum
437  );
438 
439 #endif
440 
445  FwIndexType portNum
446  );
447 
448  protected:
449 
450  // ----------------------------------------------------------------------
451  // Connection status queries for typed output ports
452  // ----------------------------------------------------------------------
453 
458  FwIndexType portNum
459  );
460 
461  protected:
462 
463  // ----------------------------------------------------------------------
464  // Handlers to implement for typed input ports
465  // ----------------------------------------------------------------------
466 
469  FwIndexType portNum,
470  FwPrmIdType id,
471  Fw::ParamBuffer& val
472  ) = 0;
474 
476  virtual void pingIn_handler(
477  FwIndexType portNum,
478  U32 key
479  ) = 0;
480 
482  virtual void setPrm_handler(
483  FwIndexType portNum,
484  FwPrmIdType id,
485  Fw::ParamBuffer& val
486  ) = 0;
487 
488  protected:
489 
490  // ----------------------------------------------------------------------
491  // Port handler base-class functions for typed input ports
492  //
493  // Call these functions directly to bypass the corresponding ports
494  // ----------------------------------------------------------------------
495 
498  FwIndexType portNum,
499  FwPrmIdType id,
500  Fw::ParamBuffer& val
501  );
503 
505  void pingIn_handlerBase(
506  FwIndexType portNum,
507  U32 key
508  );
509 
511  void setPrm_handlerBase(
512  FwIndexType portNum,
513  FwPrmIdType id,
514  Fw::ParamBuffer& val
515  );
516 
517  protected:
518 
519  // ----------------------------------------------------------------------
520  // Pre-message hooks for typed async input ports
521  //
522  // Each of these functions is invoked just before processing a message
523  // on the corresponding port. By default, they do nothing. You can
524  // override them to provide specific pre-message behavior.
525  // ----------------------------------------------------------------------
526 
528  virtual void pingIn_preMsgHook(
529  FwIndexType portNum,
530  U32 key
531  );
532 
534  virtual void setPrm_preMsgHook(
535  FwIndexType portNum,
536  FwPrmIdType id,
537  Fw::ParamBuffer& val
538  );
539 
540  protected:
541 
542  // ----------------------------------------------------------------------
543  // Invocation functions for typed output ports
544  // ----------------------------------------------------------------------
545 
547  void pingOut_out(
548  FwIndexType portNum,
549  U32 key
550  );
551 
552  protected:
553 
554  // ----------------------------------------------------------------------
555  // Command response
556  // ----------------------------------------------------------------------
557 
559  void cmdResponse_out(
560  FwOpcodeType opCode,
561  U32 cmdSeq,
562  Fw::CmdResponse response
563  );
564 
565  protected:
566 
567  // ----------------------------------------------------------------------
568  // Command handlers to implement
569  // ----------------------------------------------------------------------
570 
574  virtual void PRM_SAVE_FILE_cmdHandler(
575  FwOpcodeType opCode,
576  U32 cmdSeq
577  ) = 0;
578 
582  virtual void PRM_LOAD_FILE_cmdHandler(
583  FwOpcodeType opCode,
584  U32 cmdSeq,
585  const Fw::CmdStringArg& fileName,
586  Svc::PrmDb_Merge merge
587  ) = 0;
588 
592  virtual void PRM_COMMIT_STAGED_cmdHandler(
593  FwOpcodeType opCode,
594  U32 cmdSeq
595  ) = 0;
596 
597  protected:
598 
599  // ----------------------------------------------------------------------
600  // Command handler base-class functions
601  //
602  // Call these functions directly to bypass the command input port
603  // ----------------------------------------------------------------------
604 
609  FwOpcodeType opCode,
610  U32 cmdSeq,
611  Fw::CmdArgBuffer& args
612  );
613 
618  FwOpcodeType opCode,
619  U32 cmdSeq,
620  Fw::CmdArgBuffer& args
621  );
622 
627  FwOpcodeType opCode,
628  U32 cmdSeq,
629  Fw::CmdArgBuffer& args
630  );
631 
632  protected:
633 
634  // ----------------------------------------------------------------------
635  // Pre-message hooks for async commands
636  //
637  // Each of these functions is invoked just before processing the
638  // corresponding command. By default they do nothing. You can
639  // override them to provide specific pre-command behavior.
640  // ----------------------------------------------------------------------
641 
643  virtual void PRM_SAVE_FILE_preMsgHook(
644  FwOpcodeType opCode,
645  U32 cmdSeq
646  );
647 
649  virtual void PRM_LOAD_FILE_preMsgHook(
650  FwOpcodeType opCode,
651  U32 cmdSeq
652  );
653 
655  virtual void PRM_COMMIT_STAGED_preMsgHook(
656  FwOpcodeType opCode,
657  U32 cmdSeq
658  );
659 
660  protected:
661 
662  // ----------------------------------------------------------------------
663  // Event logging functions
664  // ----------------------------------------------------------------------
665 
670  FwPrmIdType Id
671  );
672 
677  FwPrmIdType Id
678  ) const;
679 
684  FwPrmIdType Id
685  ) const;
686 
691  FwPrmIdType Id
692  ) const;
693 
699  I32 record,
700  I32 error
701  ) const;
702 
707  U32 records
708  ) const;
709 
715  I32 record,
716  I32 error
717  ) const;
718 
723  const Fw::StringBase& databaseString,
724  U32 recordsTotal,
725  U32 recordsAdded,
726  U32 recordsUpdated
727  ) const;
728 
733 
738  const Fw::StringBase& databaseStringSrc,
739  const Fw::StringBase& databaseStringDest
740  ) const;
741 
746 
751  Svc::PrmDb_PrmDbFileLoadState currentState,
752  Svc::PrmDb_PrmLoadAction attemptedAction
753  ) const;
754 
755  protected:
756 
757  // ----------------------------------------------------------------------
758  // Event throttle reset functions
759  // ----------------------------------------------------------------------
760 
763 
764  protected:
765 
766  // ----------------------------------------------------------------------
767  // Time
768  // ----------------------------------------------------------------------
769 
773  Fw::Time getTime() const;
774 
775  protected:
776 
777  // ----------------------------------------------------------------------
778  // Mutex operations for guarded ports
779  //
780  // You can override these operations to provide more sophisticated
781  // synchronization
782  // ----------------------------------------------------------------------
783 
785  virtual void lock();
786 
788  virtual void unLock();
789 
790  private:
791 
792  // ----------------------------------------------------------------------
793  // Message dispatch functions
794  // ----------------------------------------------------------------------
795 
797  virtual MsgDispatchStatus doDispatch();
798 
799  private:
800 
801  // ----------------------------------------------------------------------
802  // Calls for messages received on special input ports
803  // ----------------------------------------------------------------------
804 
806  static void m_p_CmdDisp_in(
807  Fw::PassiveComponentBase* callComp,
808  FwIndexType portNum,
809  FwOpcodeType opCode,
810  U32 cmdSeq,
811  Fw::CmdArgBuffer& args
812  );
813 
814  private:
815 
816  // ----------------------------------------------------------------------
817  // Calls for messages received on typed input ports
818  // ----------------------------------------------------------------------
819 
821  static Fw::ParamValid m_p_getPrm_in(
822  Fw::PassiveComponentBase* callComp,
823  FwIndexType portNum,
824  FwPrmIdType id,
825  Fw::ParamBuffer& val
826  );
828 
830  static void m_p_pingIn_in(
831  Fw::PassiveComponentBase* callComp,
832  FwIndexType portNum,
833  U32 key
834  );
835 
837  static void m_p_setPrm_in(
838  Fw::PassiveComponentBase* callComp,
839  FwIndexType portNum,
840  FwPrmIdType id,
841  Fw::ParamBuffer& val
842  );
843 
844  private:
845 
846  // ----------------------------------------------------------------------
847  // Special input ports
848  // ----------------------------------------------------------------------
849 
851  Fw::InputCmdPort m_CmdDisp_InputPort[NUM_CMDDISP_INPUT_PORTS];
852 
853  private:
854 
855  // ----------------------------------------------------------------------
856  // Typed input ports
857  // ----------------------------------------------------------------------
858 
860  Fw::InputPrmGetPort m_getPrm_InputPort[NUM_GETPRM_INPUT_PORTS];
861 
863  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
864 
866  Fw::InputPrmSetPort m_setPrm_InputPort[NUM_SETPRM_INPUT_PORTS];
867 
868  private:
869 
870  // ----------------------------------------------------------------------
871  // Special output ports
872  // ----------------------------------------------------------------------
873 
875  Fw::OutputCmdRegPort m_CmdReg_OutputPort[NUM_CMDREG_OUTPUT_PORTS];
876 
879 
881  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
882 
883 #if FW_ENABLE_TEXT_LOGGING == 1
884 
886  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
887 
888 #endif
889 
891  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
892 
893  private:
894 
895  // ----------------------------------------------------------------------
896  // Typed output ports
897  // ----------------------------------------------------------------------
898 
900  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
901 
902  private:
903 
904  // ----------------------------------------------------------------------
905  // Counter values for event throttling
906  // ----------------------------------------------------------------------
907 
909  std::atomic<FwIndexType> m_PrmIdNotFoundThrottle;
910 
911  private:
912 
913  // ----------------------------------------------------------------------
914  // Mutexes
915  // ----------------------------------------------------------------------
916 
918  Os::Mutex m_guardedPortMutex;
919 
920  };
921 
922 }
923 
924 #endif
void set_CmdReg_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to CmdReg[portNum].
void regCommands()
Register commands with the Command Dispatcher.
State of parameter DB file load operations.
bool isConnected_CmdReg_OutputPort(FwIndexType portNum)
FwIdType FwOpcodeType
The type of a command opcode.
Fw::ParamValid getPrm_handlerBase(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)
Handler base-class function for input port getPrm.
All parameters Copied from one DB to another.
void log_WARNING_LO_PrmIdNotFound_ThrottleClear()
Reset throttle value for PrmIdNotFound.
PlatformSizeType FwSizeType
I32 FwEnumStoreType
void log_ACTIVITY_HI_PrmIdUpdated(FwPrmIdType Id) const
static constexpr FwIndexType getNum_pingOut_OutputPorts()
PrmDbComponentBase(const char *compName="")
Construct PrmDbComponentBase object.
FwIdType FwPrmIdType
The type of a parameter identifier.
void log_ACTIVITY_HI_PrmFileSaveComplete(U32 records) const
static constexpr FwIndexType getNum_Log_OutputPorts()
Fw::InputPrmSetPort * get_setPrm_InputPort(FwIndexType portNum)
Loads a file from storage into the staging database. The file could have selective IDs and not the wh...
friend class PrmDbTesterBase
Friend class tester to support autocoded test harness.
virtual void PRM_COMMIT_STAGED_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command PRM_COMMIT_STAGED.
Enum representing a command response.
friend class PrmDbTester
Friend class tester implementation to support white-box testing.
virtual void PRM_COMMIT_STAGED_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
static constexpr FwIndexType getNum_Time_OutputPorts()
Command to save parameter image to file. Uses file name passed to constructor.
void log_WARNING_HI_PrmFileWriteError(Svc::PrmDb_PrmWriteError stage, I32 record, I32 error) const
void set_Log_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
virtual void pingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port pingIn.
void log_ACTIVITY_HI_PrmFileLoadComplete(const Fw::StringBase &databaseString, U32 recordsTotal, U32 recordsAdded, U32 recordsUpdated) const
void init()
Object initializer.
Definition: ObjBase.cpp:24
virtual ~PrmDbComponentBase()
Destroy PrmDbComponentBase object.
virtual void lock()
Lock the guarded mutex.
void log_WARNING_HI_PrmFileReadError(Svc::PrmDb_PrmReadError stage, I32 record, I32 error) const
static constexpr FwIndexType getNum_getPrm_InputPorts()
void log_ACTIVITY_HI_PrmDbCommitComplete() const
Fw::InputCmdPort * get_CmdDisp_InputPort(FwIndexType portNum)
void log_WARNING_LO_PrmDbFileLoadInvalidAction(Svc::PrmDb_PrmDbFileLoadState currentState, Svc::PrmDb_PrmLoadAction attemptedAction) const
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
void PRM_COMMIT_STAGED_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
bool isConnected_CmdStatus_OutputPort(FwIndexType portNum)
bool isConnected_Log_OutputPort(FwIndexType portNum)
virtual void PRM_LOAD_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdStringArg &fileName, Svc::PrmDb_Merge merge)=0
void setPrm_handlerBase(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)
Handler base-class function for input port setPrm.
virtual void unLock()
Unlock the guarded mutex.
void log_ACTIVITY_HI_PrmIdAdded(FwPrmIdType Id) const
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
Parameter ID not found in database.
void log_ACTIVITY_HI_PrmDbCopyAllComplete(const Fw::StringBase &databaseStringSrc, const Fw::StringBase &databaseStringDest) const
virtual Fw::ParamValid getPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)=0
Handler for input port getPrm.
void PRM_LOAD_FILE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
virtual void PRM_SAVE_FILE_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command PRM_SAVE_FILE.
void log_WARNING_HI_PrmDbFull(FwPrmIdType Id) const
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
virtual void PRM_LOAD_FILE_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command PRM_LOAD_FILE.
Auto-generated base for PrmDb component.
void pingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port pingIn.
void PRM_SAVE_FILE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
void log_WARNING_LO_PrmIdNotFound(FwPrmIdType Id)
PlatformIndexType FwIndexType
static constexpr FwIndexType getNum_CmdStatus_OutputPorts()
void set_CmdStatus_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to CmdStatus[portNum].
virtual void setPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)=0
Handler for input port setPrm.
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
static constexpr FwIndexType getNum_pingIn_InputPorts()
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
Parameter file load failed, not staging any update.
RateGroupDivider component implementation.
Enum representing parameter validity.
static constexpr FwIndexType getNum_CmdDisp_InputPorts()
bool isConnected_Time_OutputPort(FwIndexType portNum)
Fw::InputPrmGetPort * get_getPrm_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_CmdReg_OutputPorts()
bool isConnected_pingOut_OutputPort(FwIndexType portNum)
Parameter ID updated in database.
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
virtual void PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
static constexpr FwIndexType getNum_setPrm_InputPorts()
virtual void setPrm_preMsgHook(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)
Pre-message hook for async input port setPrm.
Commits the backup database to become the prime (active) database.
void log_WARNING_HI_PrmDbFileLoadFailed() const