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"
32 
33 namespace Svc {
34 
41  {
42 
43  // ----------------------------------------------------------------------
44  // Friend classes
45  // ----------------------------------------------------------------------
46 
48  friend class PrmDbTesterBase;
50  friend class PrmDbTester;
51 
52  PROTECTED:
53 
54  // ----------------------------------------------------------------------
55  // Constants
56  // ----------------------------------------------------------------------
57 
59  enum {
61  };
62 
64  enum {
68  };
69 
71  enum {
77  };
78 
80  enum {
82  };
83 
85  enum {
87  };
88 
90  enum {
99  };
100 
102  enum {
104  };
105 
106  public:
107 
108  // ----------------------------------------------------------------------
109  // Component initialization
110  // ----------------------------------------------------------------------
111 
113  void init(
114  FwSizeType queueDepth,
115  FwEnumStoreType instance = 0
116  );
117 
118  public:
119 
120  // ----------------------------------------------------------------------
121  // Getters for special input ports
122  // ----------------------------------------------------------------------
123 
128  FwIndexType portNum
129  );
130 
131  public:
132 
133  // ----------------------------------------------------------------------
134  // Getters for typed input ports
135  // ----------------------------------------------------------------------
136 
141  FwIndexType portNum
142  );
143 
148  FwIndexType portNum
149  );
150 
155  FwIndexType portNum
156  );
157 
158  public:
159 
160  // ----------------------------------------------------------------------
161  // Connect input ports to special output ports
162  // ----------------------------------------------------------------------
163 
166  FwIndexType portNum,
167  Fw::InputCmdRegPort* port
168  );
169 
172  FwIndexType portNum,
174  );
175 
177  void set_Log_OutputPort(
178  FwIndexType portNum,
179  Fw::InputLogPort* port
180  );
181 
182 #if FW_ENABLE_TEXT_LOGGING == 1
183 
185  void set_LogText_OutputPort(
186  FwIndexType portNum,
187  Fw::InputLogTextPort* port
188  );
189 
190 #endif
191 
193  void set_Time_OutputPort(
194  FwIndexType portNum,
195  Fw::InputTimePort* port
196  );
197 
198  public:
199 
200  // ----------------------------------------------------------------------
201  // Connect typed input ports to typed output ports
202  // ----------------------------------------------------------------------
203 
206  FwIndexType portNum,
207  Svc::InputPingPort* port
208  );
209 
210 #if FW_PORT_SERIALIZATION
211 
212  public:
213 
214  // ----------------------------------------------------------------------
215  // Connect serial input ports to special output ports
216  // ----------------------------------------------------------------------
217 
220  FwIndexType portNum,
221  Fw::InputSerializePort* port
222  );
223 
226  FwIndexType portNum,
227  Fw::InputSerializePort* port
228  );
229 
231  void set_Log_OutputPort(
232  FwIndexType portNum,
233  Fw::InputSerializePort* port
234  );
235 
236 #if FW_ENABLE_TEXT_LOGGING == 1
237 
239  void set_LogText_OutputPort(
240  FwIndexType portNum,
241  Fw::InputSerializePort* port
242  );
243 
244 #endif
245 
247  void set_Time_OutputPort(
248  FwIndexType portNum,
249  Fw::InputSerializePort* port
250  );
251 
252 #endif
253 
254 #if FW_PORT_SERIALIZATION
255 
256  public:
257 
258  // ----------------------------------------------------------------------
259  // Connect serial input ports to typed output ports
260  // ----------------------------------------------------------------------
261 
264  FwIndexType portNum,
265  Fw::InputSerializePort* port
266  );
267 
268 #endif
269 
270  public:
271 
272  // ----------------------------------------------------------------------
273  // Command registration
274  // ----------------------------------------------------------------------
275 
279  void regCommands();
280 
281  PROTECTED:
282 
283  // ----------------------------------------------------------------------
284  // Component construction and destruction
285  // ----------------------------------------------------------------------
286 
289  const char* compName = ""
290  );
291 
293  virtual ~PrmDbComponentBase();
294 
295  PROTECTED:
296 
297  // ----------------------------------------------------------------------
298  // Getters for numbers of special input ports
299  // ----------------------------------------------------------------------
300 
305 
306  PROTECTED:
307 
308  // ----------------------------------------------------------------------
309  // Getters for numbers of typed input ports
310  // ----------------------------------------------------------------------
311 
316 
321 
326 
327  PROTECTED:
328 
329  // ----------------------------------------------------------------------
330  // Getters for numbers of special output ports
331  // ----------------------------------------------------------------------
332 
337 
342 
347 
348 #if FW_ENABLE_TEXT_LOGGING == 1
349 
353  FwIndexType getNum_LogText_OutputPorts() const;
354 
355 #endif
356 
361 
362  PROTECTED:
363 
364  // ----------------------------------------------------------------------
365  // Getters for numbers of typed output ports
366  // ----------------------------------------------------------------------
367 
372 
373  PROTECTED:
374 
375  // ----------------------------------------------------------------------
376  // Connection status queries for special output ports
377  // ----------------------------------------------------------------------
378 
383  FwIndexType portNum
384  );
385 
390  FwIndexType portNum
391  );
392 
397  FwIndexType portNum
398  );
399 
400 #if FW_ENABLE_TEXT_LOGGING == 1
401 
405  bool isConnected_LogText_OutputPort(
406  FwIndexType portNum
407  );
408 
409 #endif
410 
415  FwIndexType portNum
416  );
417 
418  PROTECTED:
419 
420  // ----------------------------------------------------------------------
421  // Connection status queries for typed output ports
422  // ----------------------------------------------------------------------
423 
428  FwIndexType portNum
429  );
430 
431  PROTECTED:
432 
433  // ----------------------------------------------------------------------
434  // Handlers to implement for typed input ports
435  // ----------------------------------------------------------------------
436 
439  FwIndexType portNum,
440  FwPrmIdType id,
441  Fw::ParamBuffer& val
442  ) = 0;
444 
446  virtual void pingIn_handler(
447  FwIndexType portNum,
448  U32 key
449  ) = 0;
450 
452  virtual void setPrm_handler(
453  FwIndexType portNum,
454  FwPrmIdType id,
455  Fw::ParamBuffer& val
456  ) = 0;
457 
458  PROTECTED:
459 
460  // ----------------------------------------------------------------------
461  // Port handler base-class functions for typed input ports
462  //
463  // Call these functions directly to bypass the corresponding ports
464  // ----------------------------------------------------------------------
465 
468  FwIndexType portNum,
469  FwPrmIdType id,
470  Fw::ParamBuffer& val
471  );
473 
475  void pingIn_handlerBase(
476  FwIndexType portNum,
477  U32 key
478  );
479 
481  void setPrm_handlerBase(
482  FwIndexType portNum,
483  FwPrmIdType id,
484  Fw::ParamBuffer& val
485  );
486 
487  PROTECTED:
488 
489  // ----------------------------------------------------------------------
490  // Pre-message hooks for typed async input ports
491  //
492  // Each of these functions is invoked just before processing a message
493  // on the corresponding port. By default, they do nothing. You can
494  // override them to provide specific pre-message behavior.
495  // ----------------------------------------------------------------------
496 
498  virtual void pingIn_preMsgHook(
499  FwIndexType portNum,
500  U32 key
501  );
502 
504  virtual void setPrm_preMsgHook(
505  FwIndexType portNum,
506  FwPrmIdType id,
507  Fw::ParamBuffer& val
508  );
509 
510  PROTECTED:
511 
512  // ----------------------------------------------------------------------
513  // Invocation functions for typed output ports
514  // ----------------------------------------------------------------------
515 
517  void pingOut_out(
518  FwIndexType portNum,
519  U32 key
520  );
521 
522  PROTECTED:
523 
524  // ----------------------------------------------------------------------
525  // Command response
526  // ----------------------------------------------------------------------
527 
529  void cmdResponse_out(
530  FwOpcodeType opCode,
531  U32 cmdSeq,
532  Fw::CmdResponse response
533  );
534 
535  PROTECTED:
536 
537  // ----------------------------------------------------------------------
538  // Command handlers to implement
539  // ----------------------------------------------------------------------
540 
544  virtual void PRM_SAVE_FILE_cmdHandler(
545  FwOpcodeType opCode,
546  U32 cmdSeq
547  ) = 0;
548 
549  PROTECTED:
550 
551  // ----------------------------------------------------------------------
552  // Command handler base-class functions
553  //
554  // Call these functions directly to bypass the command input port
555  // ----------------------------------------------------------------------
556 
561  FwOpcodeType opCode,
562  U32 cmdSeq,
563  Fw::CmdArgBuffer& args
564  );
565 
566  PROTECTED:
567 
568  // ----------------------------------------------------------------------
569  // Pre-message hooks for async commands
570  //
571  // Each of these functions is invoked just before processing the
572  // corresponding command. By default they do nothing. You can
573  // override them to provide specific pre-command behavior.
574  // ----------------------------------------------------------------------
575 
577  virtual void PRM_SAVE_FILE_preMsgHook(
578  FwOpcodeType opCode,
579  U32 cmdSeq
580  );
581 
582  PROTECTED:
583 
584  // ----------------------------------------------------------------------
585  // Event logging functions
586  // ----------------------------------------------------------------------
587 
592  U32 Id
593  );
594 
599  U32 Id
600  ) const;
601 
605  void log_FATAL_PrmDbFull(
606  U32 Id
607  ) const;
608 
613  U32 Id
614  ) const;
615 
621  I32 record,
622  I32 error
623  ) const;
624 
629  U32 records
630  ) const;
631 
637  I32 record,
638  I32 error
639  ) const;
640 
645  U32 records
646  ) const;
647 
648  PROTECTED:
649 
650  // ----------------------------------------------------------------------
651  // Event throttle reset functions
652  // ----------------------------------------------------------------------
653 
656 
657  PROTECTED:
658 
659  // ----------------------------------------------------------------------
660  // Time
661  // ----------------------------------------------------------------------
662 
666  Fw::Time getTime() const;
667 
668  PROTECTED:
669 
670  // ----------------------------------------------------------------------
671  // Mutex operations for guarded ports
672  //
673  // You can override these operations to provide more sophisticated
674  // synchronization
675  // ----------------------------------------------------------------------
676 
678  virtual void lock();
679 
681  virtual void unLock();
682 
683  PRIVATE:
684 
685  // ----------------------------------------------------------------------
686  // Message dispatch functions
687  // ----------------------------------------------------------------------
688 
690  virtual MsgDispatchStatus doDispatch();
691 
692  PRIVATE:
693 
694  // ----------------------------------------------------------------------
695  // Calls for messages received on special input ports
696  // ----------------------------------------------------------------------
697 
699  static void m_p_CmdDisp_in(
700  Fw::PassiveComponentBase* callComp,
701  FwIndexType portNum,
702  FwOpcodeType opCode,
703  U32 cmdSeq,
704  Fw::CmdArgBuffer& args
705  );
706 
707  PRIVATE:
708 
709  // ----------------------------------------------------------------------
710  // Calls for messages received on typed input ports
711  // ----------------------------------------------------------------------
712 
714  static Fw::ParamValid m_p_getPrm_in(
715  Fw::PassiveComponentBase* callComp,
716  FwIndexType portNum,
717  FwPrmIdType id,
718  Fw::ParamBuffer& val
719  );
721 
723  static void m_p_pingIn_in(
724  Fw::PassiveComponentBase* callComp,
725  FwIndexType portNum,
726  U32 key
727  );
728 
730  static void m_p_setPrm_in(
731  Fw::PassiveComponentBase* callComp,
732  FwIndexType portNum,
733  FwPrmIdType id,
734  Fw::ParamBuffer& val
735  );
736 
737  PRIVATE:
738 
739  // ----------------------------------------------------------------------
740  // Special input ports
741  // ----------------------------------------------------------------------
742 
744  Fw::InputCmdPort m_CmdDisp_InputPort[NUM_CMDDISP_INPUT_PORTS];
745 
746  PRIVATE:
747 
748  // ----------------------------------------------------------------------
749  // Typed input ports
750  // ----------------------------------------------------------------------
751 
753  Fw::InputPrmGetPort m_getPrm_InputPort[NUM_GETPRM_INPUT_PORTS];
754 
756  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
757 
759  Fw::InputPrmSetPort m_setPrm_InputPort[NUM_SETPRM_INPUT_PORTS];
760 
761  PRIVATE:
762 
763  // ----------------------------------------------------------------------
764  // Special output ports
765  // ----------------------------------------------------------------------
766 
768  Fw::OutputCmdRegPort m_CmdReg_OutputPort[NUM_CMDREG_OUTPUT_PORTS];
769 
772 
774  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
775 
776 #if FW_ENABLE_TEXT_LOGGING == 1
777 
779  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
780 
781 #endif
782 
784  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
785 
786  PRIVATE:
787 
788  // ----------------------------------------------------------------------
789  // Typed output ports
790  // ----------------------------------------------------------------------
791 
793  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
794 
795  PRIVATE:
796 
797  // ----------------------------------------------------------------------
798  // Counter values for event throttling
799  // ----------------------------------------------------------------------
800 
802  std::atomic<FwIndexType> m_PrmIdNotFoundThrottle;
803 
804  PRIVATE:
805 
806  // ----------------------------------------------------------------------
807  // Mutexes
808  // ----------------------------------------------------------------------
809 
811  Os::Mutex m_guardedPortMutex;
812 
813  };
814 
815 }
816 
817 #endif
void set_CmdReg_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to CmdReg[portNum].
void regCommands()
Register commands with the Command Dispatcher.
Definition: Time.hpp:9
bool isConnected_CmdReg_OutputPort(FwIndexType portNum)
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
Parameter ID updated in database.
I32 FwEnumStoreType
void log_WARNING_LO_PrmIdNotFound(U32 Id)
PrmDbComponentBase(const char *compName="")
Construct PrmDbComponentBase object.
void log_ACTIVITY_HI_PrmFileSaveComplete(U32 records) const
Fw::InputPrmSetPort * get_setPrm_InputPort(FwIndexType portNum)
friend class PrmDbTesterBase
Friend class tester to support autocoded test harness.
Enum representing a command response.
friend class PrmDbTester
Friend class tester implementation to support white-box testing.
Parameter ID not found in database.
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 init()
Object initializer.
Definition: ObjBase.cpp:26
virtual ~PrmDbComponentBase()
Destroy PrmDbComponentBase object.
void log_ACTIVITY_HI_PrmFileLoadComplete(U32 records) const
virtual void lock()
Lock the guarded mutex.
FwIndexType getNum_setPrm_InputPorts() const
void log_WARNING_HI_PrmFileReadError(Svc::PrmDb_PrmReadError stage, I32 record, I32 error) const
FwIndexType getNum_getPrm_InputPorts() const
U32 FwOpcodeType
The type of a command opcode.
Fw::InputCmdPort * get_CmdDisp_InputPort(FwIndexType portNum)
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
bool isConnected_CmdStatus_OutputPort(FwIndexType portNum)
bool isConnected_Log_OutputPort(FwIndexType portNum)
void log_ACTIVITY_HI_PrmIdAdded(U32 Id) const
void setPrm_handlerBase(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)
Handler base-class function for input port setPrm.
FwIndexType getNum_Log_OutputPorts() const
virtual void unLock()
Unlock the guarded mutex.
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
U32 FwPrmIdType
The type of a parameter identifier.
virtual Fw::ParamValid getPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)=0
Handler for input port getPrm.
virtual void PRM_SAVE_FILE_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command PRM_SAVE_FILE.
void log_ACTIVITY_HI_PrmIdUpdated(U32 Id) const
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
Auto-generated base for PrmDb component.
void pingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port pingIn.
FwIndexType getNum_pingOut_OutputPorts() const
void PRM_SAVE_FILE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
FwIndexType getNum_CmdDisp_InputPorts() const
FwIndexType getNum_Time_OutputPorts() const
FwIndexType getNum_CmdStatus_OutputPorts() const
PlatformIndexType FwIndexType
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.
Parameter ID added to database.
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
RateGroupDivider component implementation.
Enum representing parameter validity.
bool isConnected_Time_OutputPort(FwIndexType portNum)
Fw::InputPrmGetPort * get_getPrm_InputPort(FwIndexType portNum)
bool isConnected_pingOut_OutputPort(FwIndexType portNum)
FwIndexType getNum_pingIn_InputPorts() const
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
Command to save parameter image to file. Uses file name passed to constructor.
virtual void PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
FwIndexType getNum_CmdReg_OutputPorts() const
void log_FATAL_PrmDbFull(U32 Id) const
virtual void setPrm_preMsgHook(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)
Pre-message hook for async input port setPrm.