F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
PrmDbImpl.hpp
Go to the documentation of this file.
1 
13 #ifndef PRMDBIMPL_HPP_
14 #define PRMDBIMPL_HPP_
15 
17 #include <Fw/Types/String.hpp>
18 #include <Os/Mutex.hpp>
22 #include <config/PrmDbImplCfg.hpp>
23 #include <cstring>
24 
25 namespace Svc {
26 
31 
38 
39 class PrmDbImpl final : public PrmDbComponentBase {
40  friend class PrmDbTester;
41 
43 
44  public:
51  PrmDbImpl(const char* name);
52 
58  void configure(const char* file);
59 
65  void readParamFile(); // NOTE: Assumed to run at initialization time. No guard of data structure.
66 
69  virtual ~PrmDbImpl();
70 
71  // Parameter update status for an individual parameter update or add
77  };
78 
79  // Enum to return status of parameter file load
83  };
84 
85  protected:
86  private:
87  Fw::String m_fileName;
88 
89  PrmDbFileLoadState m_state; // Current file load state of the parameter database
90 
91  // helper to compute CRC over a buffer
92  U32 computeCrc(U32 crc, const BYTE* buff, FwSizeType size);
93 
94  // Pointers to the active and staging databases
95  // These point to the actual storage arrays below
96  // The active database is the ONLY one used for getting parameters
97  // The staging database is used for loading parameters from a file
98  // when commanded. Upon reading the file, the parameters are "staged"
99  // into the staging database, and then committed to the active database
100  // when a commit command is received.
101  PrmDbStore* m_activeDb;
102  PrmDbStore* m_stagingDb;
103 
104  // Actual storage for the active and staging databases
105  PrmDbStore m_dbStore1;
106  PrmDbStore m_dbStore2;
107 
111 
121  PrmLoadStatus readParamFileImpl(const Fw::StringBase& fileName, PrmDbType dbType);
122 
132  Fw::ParamValid getPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val);
133 
142  void setPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val);
143 
151  PrmDbImpl::PrmUpdateType updateAddPrmImpl(FwPrmIdType id, Fw::ParamBuffer& val, PrmDbType prmDbType);
152 
161  void pingIn_handler(FwIndexType portNum, U32 key);
162 
171  void PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq);
172 
185  void PRM_LOAD_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdStringArg& fileName, PrmDb_Merge merge);
186 
196  void PRM_COMMIT_STAGED_cmdHandler(FwOpcodeType opCode, U32 cmdSeq);
197 
201 
207  void clearDb(PrmDbType prmDbType);
208 
213  PrmDbStore* getDbPtr(PrmDbType dbType);
214 
219  static Fw::String getDbString(PrmDbType dbType);
220 
226  void dbCopy(PrmDbType dest, PrmDbType src);
227 };
228 } // namespace Svc
229 
230 #endif /* PRMDBIMPL_HPP_ */
Parameter already in database, updated parameter.
Definition: PrmDbImpl.hpp:75
State of parameter DB file load operations.
FwIdType FwOpcodeType
The type of a command opcode.
PrmDb_PrmWriteError PrmWriteError
Definition: PrmDbImpl.hpp:27
PlatformSizeType FwSizeType
friend class PrmDbTester
Definition: PrmDbImpl.hpp:40
void readParamFile()
PrmDb file read function.
Definition: PrmDbImpl.cpp:58
FwIdType FwPrmIdType
The type of a parameter identifier.
PrmDbImpl(const char *name)
PrmDb constructor.
Definition: PrmDbImpl.cpp:43
PrmDb_PrmDbType PrmDbType
Definition: PrmDbImpl.hpp:29
Parameter added to database.
Definition: PrmDbImpl.hpp:74
Component class for managing parameters.
Definition: PrmDbImpl.hpp:39
File load error.
Definition: PrmDbImpl.hpp:82
void configure(const char *file)
PrmDb configure method.
Definition: PrmDbImpl.cpp:53
Auto-generated base for PrmDb component.
PrmDb_PrmReadError PrmReadError
Definition: PrmDbImpl.hpp:28
PrmDb_PrmDbFileLoadState PrmDbFileLoadState
Definition: PrmDbImpl.hpp:30
PlatformIndexType FwIndexType
File load successful.
Definition: PrmDbImpl.hpp:81
RateGroupDivider component implementation.
Enum representing parameter validity.
U8 BYTE
byte type
Definition: BasicTypes.h:56
No slots available to add new parameter.
Definition: PrmDbImpl.hpp:73
virtual ~PrmDbImpl()
PrmDb destructor.
Definition: PrmDbImpl.cpp:51