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 {
110  };
111 
113  enum {
115  };
116 
117  public:
118 
119  // ----------------------------------------------------------------------
120  // Component initialization
121  // ----------------------------------------------------------------------
122 
124  void init(
125  FwSizeType queueDepth,
126  FwEnumStoreType instance = 0
127  );
128 
129  public:
130 
131  // ----------------------------------------------------------------------
132  // Getters for special input ports
133  // ----------------------------------------------------------------------
134 
139  FwIndexType portNum
140  );
141 
142  public:
143 
144  // ----------------------------------------------------------------------
145  // Getters for typed input ports
146  // ----------------------------------------------------------------------
147 
152  FwIndexType portNum
153  );
154 
159  FwIndexType portNum
160  );
161 
166  FwIndexType portNum
167  );
168 
169  public:
170 
171  // ----------------------------------------------------------------------
172  // Connect input ports to special output ports
173  // ----------------------------------------------------------------------
174 
177  FwIndexType portNum,
178  Fw::InputCmdRegPort* port
179  );
180 
183  FwIndexType portNum,
185  );
186 
188  void set_Log_OutputPort(
189  FwIndexType portNum,
190  Fw::InputLogPort* port
191  );
192 
193 #if FW_ENABLE_TEXT_LOGGING == 1
194 
196  void set_LogText_OutputPort(
197  FwIndexType portNum,
198  Fw::InputLogTextPort* port
199  );
200 
201 #endif
202 
204  void set_Time_OutputPort(
205  FwIndexType portNum,
206  Fw::InputTimePort* port
207  );
208 
209  public:
210 
211  // ----------------------------------------------------------------------
212  // Connect typed input ports to typed output ports
213  // ----------------------------------------------------------------------
214 
217  FwIndexType portNum,
218  Svc::InputPingPort* port
219  );
220 
221 #if FW_PORT_SERIALIZATION
222 
223  public:
224 
225  // ----------------------------------------------------------------------
226  // Connect serial input ports to special output ports
227  // ----------------------------------------------------------------------
228 
231  FwIndexType portNum,
232  Fw::InputSerializePort* port
233  );
234 
237  FwIndexType portNum,
238  Fw::InputSerializePort* port
239  );
240 
242  void set_Log_OutputPort(
243  FwIndexType portNum,
244  Fw::InputSerializePort* port
245  );
246 
247 #if FW_ENABLE_TEXT_LOGGING == 1
248 
250  void set_LogText_OutputPort(
251  FwIndexType portNum,
252  Fw::InputSerializePort* port
253  );
254 
255 #endif
256 
258  void set_Time_OutputPort(
259  FwIndexType portNum,
260  Fw::InputSerializePort* port
261  );
262 
263 #endif
264 
265 #if FW_PORT_SERIALIZATION
266 
267  public:
268 
269  // ----------------------------------------------------------------------
270  // Connect serial input ports to typed output ports
271  // ----------------------------------------------------------------------
272 
275  FwIndexType portNum,
276  Fw::InputSerializePort* port
277  );
278 
279 #endif
280 
281  public:
282 
283  // ----------------------------------------------------------------------
284  // Command registration
285  // ----------------------------------------------------------------------
286 
290  void regCommands();
291 
292  protected:
293 
294  // ----------------------------------------------------------------------
295  // Component construction and destruction
296  // ----------------------------------------------------------------------
297 
300  const char* compName = ""
301  );
302 
304  virtual ~PrmDbComponentBase();
305 
306  protected:
307 
308  // ----------------------------------------------------------------------
309  // Getters for numbers of special input ports
310  // ----------------------------------------------------------------------
311 
317  }
318 
319  protected:
320 
321  // ----------------------------------------------------------------------
322  // Getters for numbers of typed input ports
323  // ----------------------------------------------------------------------
324 
329  return NUM_GETPRM_INPUT_PORTS;
330  }
331 
336  return NUM_PINGIN_INPUT_PORTS;
337  }
338 
343  return NUM_SETPRM_INPUT_PORTS;
344  }
345 
346  protected:
347 
348  // ----------------------------------------------------------------------
349  // Getters for numbers of special output ports
350  // ----------------------------------------------------------------------
351 
357  }
358 
364  }
365 
369  static constexpr FwIndexType getNum_Log_OutputPorts() {
370  return NUM_LOG_OUTPUT_PORTS;
371  }
372 
373 #if FW_ENABLE_TEXT_LOGGING == 1
374 
378  static constexpr FwIndexType getNum_LogText_OutputPorts() {
380  }
381 
382 #endif
383 
388  return NUM_TIME_OUTPUT_PORTS;
389  }
390 
391  protected:
392 
393  // ----------------------------------------------------------------------
394  // Getters for numbers of typed output ports
395  // ----------------------------------------------------------------------
396 
402  }
403 
404  protected:
405 
406  // ----------------------------------------------------------------------
407  // Connection status queries for special output ports
408  // ----------------------------------------------------------------------
409 
414  FwIndexType portNum
415  );
416 
421  FwIndexType portNum
422  );
423 
428  FwIndexType portNum
429  );
430 
431 #if FW_ENABLE_TEXT_LOGGING == 1
432 
436  bool isConnected_LogText_OutputPort(
437  FwIndexType portNum
438  );
439 
440 #endif
441 
446  FwIndexType portNum
447  );
448 
449  protected:
450 
451  // ----------------------------------------------------------------------
452  // Connection status queries for typed output ports
453  // ----------------------------------------------------------------------
454 
459  FwIndexType portNum
460  );
461 
462  protected:
463 
464  // ----------------------------------------------------------------------
465  // Handlers to implement for typed input ports
466  // ----------------------------------------------------------------------
467 
470  FwIndexType portNum,
471  FwPrmIdType id,
472  Fw::ParamBuffer& val
473  ) = 0;
475 
477  virtual void pingIn_handler(
478  FwIndexType portNum,
479  U32 key
480  ) = 0;
481 
483  virtual void setPrm_handler(
484  FwIndexType portNum,
485  FwPrmIdType id,
486  Fw::ParamBuffer& val
487  ) = 0;
488 
489  protected:
490 
491  // ----------------------------------------------------------------------
492  // Port handler base-class functions for typed input ports
493  //
494  // Call these functions directly to bypass the corresponding ports
495  // ----------------------------------------------------------------------
496 
499  FwIndexType portNum,
500  FwPrmIdType id,
501  Fw::ParamBuffer& val
502  );
504 
506  void pingIn_handlerBase(
507  FwIndexType portNum,
508  U32 key
509  );
510 
512  void setPrm_handlerBase(
513  FwIndexType portNum,
514  FwPrmIdType id,
515  Fw::ParamBuffer& val
516  );
517 
518  protected:
519 
520  // ----------------------------------------------------------------------
521  // Pre-message hooks for typed async input ports
522  //
523  // Each of these functions is invoked just before processing a message
524  // on the corresponding port. By default, they do nothing. You can
525  // override them to provide specific pre-message behavior.
526  // ----------------------------------------------------------------------
527 
529  virtual void pingIn_preMsgHook(
530  FwIndexType portNum,
531  U32 key
532  );
533 
535  virtual void setPrm_preMsgHook(
536  FwIndexType portNum,
537  FwPrmIdType id,
538  Fw::ParamBuffer& val
539  );
540 
541  protected:
542 
543  // ----------------------------------------------------------------------
544  // Invocation functions for typed output ports
545  // ----------------------------------------------------------------------
546 
548  void pingOut_out(
549  FwIndexType portNum,
550  U32 key
551  );
552 
553  protected:
554 
555  // ----------------------------------------------------------------------
556  // Command response
557  // ----------------------------------------------------------------------
558 
560  void cmdResponse_out(
561  FwOpcodeType opCode,
562  U32 cmdSeq,
563  Fw::CmdResponse response
564  );
565 
566  protected:
567 
568  // ----------------------------------------------------------------------
569  // Command handlers to implement
570  // ----------------------------------------------------------------------
571 
575  virtual void PRM_SAVE_FILE_cmdHandler(
576  FwOpcodeType opCode,
577  U32 cmdSeq
578  ) = 0;
579 
583  virtual void PRM_LOAD_FILE_cmdHandler(
584  FwOpcodeType opCode,
585  U32 cmdSeq,
586  const Fw::CmdStringArg& fileName,
587  Svc::PrmDb_Merge merge
588  ) = 0;
589 
593  virtual void PRM_COMMIT_STAGED_cmdHandler(
594  FwOpcodeType opCode,
595  U32 cmdSeq
596  ) = 0;
597 
598  protected:
599 
600  // ----------------------------------------------------------------------
601  // Command handler base-class functions
602  //
603  // Call these functions directly to bypass the command input port
604  // ----------------------------------------------------------------------
605 
610  FwOpcodeType opCode,
611  U32 cmdSeq,
612  Fw::CmdArgBuffer& args
613  );
614 
619  FwOpcodeType opCode,
620  U32 cmdSeq,
621  Fw::CmdArgBuffer& args
622  );
623 
628  FwOpcodeType opCode,
629  U32 cmdSeq,
630  Fw::CmdArgBuffer& args
631  );
632 
633  protected:
634 
635  // ----------------------------------------------------------------------
636  // Pre-message hooks for async commands
637  //
638  // Each of these functions is invoked just before processing the
639  // corresponding command. By default they do nothing. You can
640  // override them to provide specific pre-command behavior.
641  // ----------------------------------------------------------------------
642 
644  virtual void PRM_SAVE_FILE_preMsgHook(
645  FwOpcodeType opCode,
646  U32 cmdSeq
647  );
648 
650  virtual void PRM_LOAD_FILE_preMsgHook(
651  FwOpcodeType opCode,
652  U32 cmdSeq
653  );
654 
656  virtual void PRM_COMMIT_STAGED_preMsgHook(
657  FwOpcodeType opCode,
658  U32 cmdSeq
659  );
660 
661  protected:
662 
663  // ----------------------------------------------------------------------
664  // Event logging functions
665  // ----------------------------------------------------------------------
666 
671  FwPrmIdType Id
672  );
673 
678  FwPrmIdType Id
679  ) const;
680 
685  FwPrmIdType Id
686  ) const;
687 
692  FwPrmIdType Id
693  ) const;
694 
700  I32 record,
701  I32 error
702  ) const;
703 
708  U32 records
709  ) const;
710 
716  I32 record,
717  I32 error
718  ) const;
719 
724  const Fw::StringBase& databaseString,
725  U32 recordsTotal,
726  U32 recordsAdded,
727  U32 recordsUpdated
728  ) const;
729 
734 
739  const Fw::StringBase& databaseStringSrc,
740  const Fw::StringBase& databaseStringDest
741  ) const;
742 
747 
752  Svc::PrmDb_PrmDbFileLoadState currentState,
753  Svc::PrmDb_PrmLoadAction attemptedAction
754  ) const;
755 
760  U32 readCrc,
761  U32 compCrc
762  ) const;
763 
764  protected:
765 
766  // ----------------------------------------------------------------------
767  // Event throttle reset functions
768  // ----------------------------------------------------------------------
769 
772 
773  protected:
774 
775  // ----------------------------------------------------------------------
776  // Time
777  // ----------------------------------------------------------------------
778 
782  Fw::Time getTime() const;
783 
784  protected:
785 
786  // ----------------------------------------------------------------------
787  // Mutex operations for guarded ports
788  //
789  // You can override these operations to provide more sophisticated
790  // synchronization
791  // ----------------------------------------------------------------------
792 
794  virtual void lock();
795 
797  virtual void unLock();
798 
799  private:
800 
801  // ----------------------------------------------------------------------
802  // Message dispatch functions
803  // ----------------------------------------------------------------------
804 
806  virtual MsgDispatchStatus doDispatch();
807 
808  private:
809 
810  // ----------------------------------------------------------------------
811  // Calls for messages received on special input ports
812  // ----------------------------------------------------------------------
813 
815  static void m_p_CmdDisp_in(
816  Fw::PassiveComponentBase* callComp,
817  FwIndexType portNum,
818  FwOpcodeType opCode,
819  U32 cmdSeq,
820  Fw::CmdArgBuffer& args
821  );
822 
823  private:
824 
825  // ----------------------------------------------------------------------
826  // Calls for messages received on typed input ports
827  // ----------------------------------------------------------------------
828 
830  static Fw::ParamValid m_p_getPrm_in(
831  Fw::PassiveComponentBase* callComp,
832  FwIndexType portNum,
833  FwPrmIdType id,
834  Fw::ParamBuffer& val
835  );
837 
839  static void m_p_pingIn_in(
840  Fw::PassiveComponentBase* callComp,
841  FwIndexType portNum,
842  U32 key
843  );
844 
846  static void m_p_setPrm_in(
847  Fw::PassiveComponentBase* callComp,
848  FwIndexType portNum,
849  FwPrmIdType id,
850  Fw::ParamBuffer& val
851  );
852 
853  private:
854 
855  // ----------------------------------------------------------------------
856  // Special input ports
857  // ----------------------------------------------------------------------
858 
860  Fw::InputCmdPort m_CmdDisp_InputPort[NUM_CMDDISP_INPUT_PORTS];
861 
862  private:
863 
864  // ----------------------------------------------------------------------
865  // Typed input ports
866  // ----------------------------------------------------------------------
867 
869  Fw::InputPrmGetPort m_getPrm_InputPort[NUM_GETPRM_INPUT_PORTS];
870 
872  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
873 
875  Fw::InputPrmSetPort m_setPrm_InputPort[NUM_SETPRM_INPUT_PORTS];
876 
877  private:
878 
879  // ----------------------------------------------------------------------
880  // Special output ports
881  // ----------------------------------------------------------------------
882 
884  Fw::OutputCmdRegPort m_CmdReg_OutputPort[NUM_CMDREG_OUTPUT_PORTS];
885 
888 
890  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
891 
892 #if FW_ENABLE_TEXT_LOGGING == 1
893 
895  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
896 
897 #endif
898 
900  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
901 
902  private:
903 
904  // ----------------------------------------------------------------------
905  // Typed output ports
906  // ----------------------------------------------------------------------
907 
909  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
910 
911  private:
912 
913  // ----------------------------------------------------------------------
914  // Counter values for event throttling
915  // ----------------------------------------------------------------------
916 
918  std::atomic<FwIndexType> m_PrmIdNotFoundThrottle;
919 
920  private:
921 
922  // ----------------------------------------------------------------------
923  // Mutexes
924  // ----------------------------------------------------------------------
925 
927  Os::Mutex m_guardedPortMutex;
928 
929  };
930 
931 }
932 
933 #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.
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)
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()
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)
Command to save parameter image to file. Uses file name passed to constructor.
void log_ACTIVITY_HI_PrmDbCopyAllComplete(const Fw::StringBase &databaseStringSrc, const Fw::StringBase &databaseStringDest) const
Parameter file load failed, not staging any update.
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
Parameter ID not found in database.
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)
Loads a file from storage into the staging database. The file could have selective IDs and not the wh...
void log_WARNING_LO_PrmIdNotFound(FwPrmIdType Id)
PlatformIndexType FwIndexType
All parameters Copied from one DB to another.
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.
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)
Commits the backup database to become the prime (active) 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.
Parameter ID updated in database.
void log_WARNING_HI_PrmFileBadCrc(U32 readCrc, U32 compCrc) const
void log_WARNING_HI_PrmDbFileLoadFailed() const