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"
37 
38 namespace Svc {
39 
46  {
47 
48  // ----------------------------------------------------------------------
49  // Friend classes
50  // ----------------------------------------------------------------------
51 
53  friend class PrmDbTesterBase;
55  friend class PrmDbTester;
56 
57  protected:
58 
59  // ----------------------------------------------------------------------
60  // Constants
61  // ----------------------------------------------------------------------
62 
64  enum {
66  };
67 
69  enum {
73  };
74 
76  enum {
82  };
83 
85  enum {
87  };
88 
90  enum {
94  };
95 
97  enum {
111  };
112 
114  enum {
116  };
117 
118  public:
119 
120  // ----------------------------------------------------------------------
121  // Component initialization
122  // ----------------------------------------------------------------------
123 
125  void init(
126  FwSizeType queueDepth,
127  FwEnumStoreType instance = 0
128  );
129 
130  public:
131 
132  // ----------------------------------------------------------------------
133  // Getters for special input ports
134  // ----------------------------------------------------------------------
135 
140  FwIndexType portNum
141  );
142 
143  public:
144 
145  // ----------------------------------------------------------------------
146  // Getters for typed input ports
147  // ----------------------------------------------------------------------
148 
153  FwIndexType portNum
154  );
155 
160  FwIndexType portNum
161  );
162 
167  FwIndexType portNum
168  );
169 
170  public:
171 
172  // ----------------------------------------------------------------------
173  // Connect input ports to special output ports
174  // ----------------------------------------------------------------------
175 
178  FwIndexType portNum,
179  Fw::InputCmdRegPort* port
180  );
181 
184  FwIndexType portNum,
186  );
187 
189  void set_Log_OutputPort(
190  FwIndexType portNum,
191  Fw::InputLogPort* port
192  );
193 
194 #if FW_ENABLE_TEXT_LOGGING == 1
195 
197  void set_LogText_OutputPort(
198  FwIndexType portNum,
199  Fw::InputLogTextPort* port
200  );
201 
202 #endif
203 
205  void set_Time_OutputPort(
206  FwIndexType portNum,
207  Fw::InputTimePort* port
208  );
209 
210  public:
211 
212  // ----------------------------------------------------------------------
213  // Connect typed input ports to typed output ports
214  // ----------------------------------------------------------------------
215 
218  FwIndexType portNum,
219  Svc::InputPingPort* port
220  );
221 
222 #if FW_PORT_SERIALIZATION
223 
224  public:
225 
226  // ----------------------------------------------------------------------
227  // Connect serial input ports to special output ports
228  // ----------------------------------------------------------------------
229 
232  FwIndexType portNum,
233  Fw::InputSerializePort* port
234  );
235 
238  FwIndexType portNum,
239  Fw::InputSerializePort* port
240  );
241 
243  void set_Log_OutputPort(
244  FwIndexType portNum,
245  Fw::InputSerializePort* port
246  );
247 
248 #if FW_ENABLE_TEXT_LOGGING == 1
249 
251  void set_LogText_OutputPort(
252  FwIndexType portNum,
253  Fw::InputSerializePort* port
254  );
255 
256 #endif
257 
259  void set_Time_OutputPort(
260  FwIndexType portNum,
261  Fw::InputSerializePort* port
262  );
263 
264 #endif
265 
266 #if FW_PORT_SERIALIZATION
267 
268  public:
269 
270  // ----------------------------------------------------------------------
271  // Connect serial input ports to typed output ports
272  // ----------------------------------------------------------------------
273 
276  FwIndexType portNum,
277  Fw::InputSerializePort* port
278  );
279 
280 #endif
281 
282  public:
283 
284  // ----------------------------------------------------------------------
285  // Command registration
286  // ----------------------------------------------------------------------
287 
291  void regCommands();
292 
293  protected:
294 
295  // ----------------------------------------------------------------------
296  // Component construction and destruction
297  // ----------------------------------------------------------------------
298 
301  const char* compName = ""
302  );
303 
305  virtual ~PrmDbComponentBase();
306 
307  protected:
308 
309  // ----------------------------------------------------------------------
310  // Getters for numbers of special input ports
311  // ----------------------------------------------------------------------
312 
318  }
319 
320  protected:
321 
322  // ----------------------------------------------------------------------
323  // Getters for numbers of typed input ports
324  // ----------------------------------------------------------------------
325 
330  return NUM_GETPRM_INPUT_PORTS;
331  }
332 
337  return NUM_PINGIN_INPUT_PORTS;
338  }
339 
344  return NUM_SETPRM_INPUT_PORTS;
345  }
346 
347  protected:
348 
349  // ----------------------------------------------------------------------
350  // Getters for numbers of special output ports
351  // ----------------------------------------------------------------------
352 
358  }
359 
365  }
366 
370  static constexpr FwIndexType getNum_Log_OutputPorts() {
371  return NUM_LOG_OUTPUT_PORTS;
372  }
373 
374 #if FW_ENABLE_TEXT_LOGGING == 1
375 
379  static constexpr FwIndexType getNum_LogText_OutputPorts() {
381  }
382 
383 #endif
384 
389  return NUM_TIME_OUTPUT_PORTS;
390  }
391 
392  protected:
393 
394  // ----------------------------------------------------------------------
395  // Getters for numbers of typed output ports
396  // ----------------------------------------------------------------------
397 
403  }
404 
405  protected:
406 
407  // ----------------------------------------------------------------------
408  // Connection status queries for special output ports
409  // ----------------------------------------------------------------------
410 
415  FwIndexType portNum
416  );
417 
422  FwIndexType portNum
423  );
424 
429  FwIndexType portNum
430  );
431 
432 #if FW_ENABLE_TEXT_LOGGING == 1
433 
437  bool isConnected_LogText_OutputPort(
438  FwIndexType portNum
439  );
440 
441 #endif
442 
447  FwIndexType portNum
448  );
449 
450  protected:
451 
452  // ----------------------------------------------------------------------
453  // Connection status queries for typed output ports
454  // ----------------------------------------------------------------------
455 
460  FwIndexType portNum
461  );
462 
463  protected:
464 
465  // ----------------------------------------------------------------------
466  // Handlers to implement for typed input ports
467  // ----------------------------------------------------------------------
468 
471  FwIndexType portNum,
472  FwPrmIdType id,
473  Fw::ParamBuffer& val
474  ) = 0;
476 
478  virtual void pingIn_handler(
479  FwIndexType portNum,
480  U32 key
481  ) = 0;
482 
484  virtual void setPrm_handler(
485  FwIndexType portNum,
486  FwPrmIdType id,
487  Fw::ParamBuffer& val
488  ) = 0;
489 
490  protected:
491 
492  // ----------------------------------------------------------------------
493  // Port handler base-class functions for typed input ports
494  //
495  // Call these functions directly to bypass the corresponding ports
496  // ----------------------------------------------------------------------
497 
500  FwIndexType portNum,
501  FwPrmIdType id,
502  Fw::ParamBuffer& val
503  );
505 
507  void pingIn_handlerBase(
508  FwIndexType portNum,
509  U32 key
510  );
511 
513  void setPrm_handlerBase(
514  FwIndexType portNum,
515  FwPrmIdType id,
516  Fw::ParamBuffer& val
517  );
518 
519  protected:
520 
521  // ----------------------------------------------------------------------
522  // Pre-message hooks for typed async input ports
523  //
524  // Each of these functions is invoked just before processing a message
525  // on the corresponding port. By default, they do nothing. You can
526  // override them to provide specific pre-message behavior.
527  // ----------------------------------------------------------------------
528 
530  virtual void pingIn_preMsgHook(
531  FwIndexType portNum,
532  U32 key
533  );
534 
536  virtual void setPrm_preMsgHook(
537  FwIndexType portNum,
538  FwPrmIdType id,
539  Fw::ParamBuffer& val
540  );
541 
542  protected:
543 
544  // ----------------------------------------------------------------------
545  // Invocation functions for typed output ports
546  // ----------------------------------------------------------------------
547 
549  void pingOut_out(
550  FwIndexType portNum,
551  U32 key
552  );
553 
554  protected:
555 
556  // ----------------------------------------------------------------------
557  // Command response
558  // ----------------------------------------------------------------------
559 
561  void cmdResponse_out(
562  FwOpcodeType opCode,
563  U32 cmdSeq,
564  Fw::CmdResponse response
565  );
566 
567  protected:
568 
569  // ----------------------------------------------------------------------
570  // Command handlers to implement
571  // ----------------------------------------------------------------------
572 
576  virtual void PRM_SAVE_FILE_cmdHandler(
577  FwOpcodeType opCode,
578  U32 cmdSeq
579  ) = 0;
580 
584  virtual void PRM_LOAD_FILE_cmdHandler(
585  FwOpcodeType opCode,
586  U32 cmdSeq,
587  const Fw::CmdStringArg& fileName,
588  Svc::PrmDb_Merge merge
589  ) = 0;
590 
594  virtual void PRM_COMMIT_STAGED_cmdHandler(
595  FwOpcodeType opCode,
596  U32 cmdSeq
597  ) = 0;
598 
599  protected:
600 
601  // ----------------------------------------------------------------------
602  // Command handler base-class functions
603  //
604  // Call these functions directly to bypass the command input port
605  // ----------------------------------------------------------------------
606 
611  FwOpcodeType opCode,
612  U32 cmdSeq,
613  Fw::CmdArgBuffer& args
614  );
615 
620  FwOpcodeType opCode,
621  U32 cmdSeq,
622  Fw::CmdArgBuffer& args
623  );
624 
629  FwOpcodeType opCode,
630  U32 cmdSeq,
631  Fw::CmdArgBuffer& args
632  );
633 
634  protected:
635 
636  // ----------------------------------------------------------------------
637  // Pre-message hooks for async commands
638  //
639  // Each of these functions is invoked just before processing the
640  // corresponding command. By default they do nothing. You can
641  // override them to provide specific pre-command behavior.
642  // ----------------------------------------------------------------------
643 
645  virtual void PRM_SAVE_FILE_preMsgHook(
646  FwOpcodeType opCode,
647  U32 cmdSeq
648  );
649 
651  virtual void PRM_LOAD_FILE_preMsgHook(
652  FwOpcodeType opCode,
653  U32 cmdSeq
654  );
655 
657  virtual void PRM_COMMIT_STAGED_preMsgHook(
658  FwOpcodeType opCode,
659  U32 cmdSeq
660  );
661 
662  protected:
663 
664  // ----------------------------------------------------------------------
665  // Event logging functions
666  // ----------------------------------------------------------------------
667 
672  FwPrmIdType Id
673  );
674 
679  FwPrmIdType Id
680  ) const;
681 
686  FwPrmIdType Id
687  ) const;
688 
693  FwPrmIdType Id
694  ) const;
695 
701  I32 record,
702  I32 error
703  ) const;
704 
709  U32 records
710  ) const;
711 
717  I32 record,
718  I32 error
719  ) const;
720 
725  const Fw::StringBase& databaseString,
726  U32 recordsTotal,
727  U32 recordsAdded,
728  U32 recordsUpdated
729  ) const;
730 
735 
740  const Fw::StringBase& databaseStringSrc,
741  const Fw::StringBase& databaseStringDest
742  ) const;
743 
748 
753  Svc::PrmDb_PrmDbFileLoadState currentState,
754  Svc::PrmDb_PrmLoadAction attemptedAction
755  ) const;
756 
761  U32 readCrc,
762  U32 compCrc
763  ) const;
764 
765  protected:
766 
767  // ----------------------------------------------------------------------
768  // Event throttle reset functions
769  // ----------------------------------------------------------------------
770 
773 
774  protected:
775 
776  // ----------------------------------------------------------------------
777  // Time
778  // ----------------------------------------------------------------------
779 
783  Fw::Time getTime() const;
784 
785  protected:
786 
787  // ----------------------------------------------------------------------
788  // Mutex operations for guarded ports
789  //
790  // You can override these operations to provide more sophisticated
791  // synchronization
792  // ----------------------------------------------------------------------
793 
795  virtual void lock();
796 
798  virtual void unLock();
799 
800  private:
801 
802  // ----------------------------------------------------------------------
803  // Message dispatch functions
804  // ----------------------------------------------------------------------
805 
807  virtual MsgDispatchStatus doDispatch();
808 
809  private:
810 
811  // ----------------------------------------------------------------------
812  // Calls for messages received on special input ports
813  // ----------------------------------------------------------------------
814 
816  static void m_p_CmdDisp_in(
817  Fw::PassiveComponentBase* callComp,
818  FwIndexType portNum,
819  FwOpcodeType opCode,
820  U32 cmdSeq,
821  Fw::CmdArgBuffer& args
822  );
823 
824  private:
825 
826  // ----------------------------------------------------------------------
827  // Calls for messages received on typed input ports
828  // ----------------------------------------------------------------------
829 
831  static Fw::ParamValid m_p_getPrm_in(
832  Fw::PassiveComponentBase* callComp,
833  FwIndexType portNum,
834  FwPrmIdType id,
835  Fw::ParamBuffer& val
836  );
838 
840  static void m_p_pingIn_in(
841  Fw::PassiveComponentBase* callComp,
842  FwIndexType portNum,
843  U32 key
844  );
845 
847  static void m_p_setPrm_in(
848  Fw::PassiveComponentBase* callComp,
849  FwIndexType portNum,
850  FwPrmIdType id,
851  Fw::ParamBuffer& val
852  );
853 
854  private:
855 
856  // ----------------------------------------------------------------------
857  // Special input ports
858  // ----------------------------------------------------------------------
859 
861  Fw::InputCmdPort m_CmdDisp_InputPort[NUM_CMDDISP_INPUT_PORTS];
862 
863  private:
864 
865  // ----------------------------------------------------------------------
866  // Typed input ports
867  // ----------------------------------------------------------------------
868 
870  Fw::InputPrmGetPort m_getPrm_InputPort[NUM_GETPRM_INPUT_PORTS];
871 
873  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
874 
876  Fw::InputPrmSetPort m_setPrm_InputPort[NUM_SETPRM_INPUT_PORTS];
877 
878  private:
879 
880  // ----------------------------------------------------------------------
881  // Special output ports
882  // ----------------------------------------------------------------------
883 
885  Fw::OutputCmdRegPort m_CmdReg_OutputPort[NUM_CMDREG_OUTPUT_PORTS];
886 
889 
891  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
892 
893 #if FW_ENABLE_TEXT_LOGGING == 1
894 
896  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
897 
898 #endif
899 
901  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
902 
903  private:
904 
905  // ----------------------------------------------------------------------
906  // Typed output ports
907  // ----------------------------------------------------------------------
908 
910  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
911 
912  private:
913 
914  // ----------------------------------------------------------------------
915  // Counter values for event throttling
916  // ----------------------------------------------------------------------
917 
919  std::atomic<FwIndexType> m_PrmIdNotFoundThrottle;
920 
921  private:
922 
923  // ----------------------------------------------------------------------
924  // Mutexes
925  // ----------------------------------------------------------------------
926 
928  Os::Mutex m_guardedPortMutex;
929 
930  };
931 
932 }
933 
934 #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.
Parameter ID not found in database.
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.
All parameters Copied from one DB to another.
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
Parameter file load failed, not staging any update.
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)
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.
Parameter ID updated in database.
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)
Loads a file from storage into the staging database. The file could have selective IDs and not the wh...
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.
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)
Command to save parameter image to file. Uses file name passed to constructor.
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
Commits the backup database to become the prime (active) database.
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.
void log_WARNING_HI_PrmFileBadCrc(U32 readCrc, U32 compCrc) const
void log_WARNING_HI_PrmDbFileLoadFailed() const