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 
66  void configureLoadSandbox(const char* directory);
67 
73  void readParamFile(); // NOTE: Assumed to run at initialization time. No guard of data structure.
74 
77  virtual ~PrmDbImpl();
78 
79  // Parameter update status for an individual parameter update or add
85  };
86 
87  // Enum to return status of parameter file load
91  };
92 
93  protected:
94  private:
95  Fw::String m_fileName;
96  Fw::String m_sandboxDir;
97 
98  PrmDbFileLoadState m_state; // Current file load state of the parameter database
99 
100  // Pointers to the active and staging databases
101  // These point to the actual storage arrays below
102  // The active database is the ONLY one used for getting parameters
103  // The staging database is used for loading parameters from a file
104  // when commanded. Upon reading the file, the parameters are "staged"
105  // into the staging database, and then committed to the active database
106  // when a commit command is received.
107  PrmDbStore* m_activeDb;
108  PrmDbStore* m_stagingDb;
109 
110  // Actual storage for the active and staging databases
111  PrmDbStore m_dbStore1;
112  PrmDbStore m_dbStore2;
113 
117 
127  PrmLoadStatus readParamFileImpl(const Fw::StringBase& fileName, PrmDbType dbType);
128 
134  template <typename FileType>
135  PrmLoadStatus readParamFileWork(FileType& paramFile, const Fw::StringBase& fileName, PrmDbType dbType);
136 
146  Fw::ParamValid getPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val);
147 
156  void setPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val);
157 
165  PrmDbImpl::PrmUpdateType updateAddPrmImpl(FwPrmIdType id, Fw::ParamBuffer& val, PrmDbType prmDbType);
166 
175  void pingIn_handler(FwIndexType portNum, U32 key);
176 
185  void PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq);
186 
199  void PRM_LOAD_FILE_cmdHandler(FwOpcodeType opCode,
200  U32 cmdSeq,
201  const Fw::CmdStringArg& fileName,
202  const PrmDb_Merge& merge);
203 
213  void PRM_COMMIT_STAGED_cmdHandler(FwOpcodeType opCode, U32 cmdSeq);
214 
218 
224  void clearDb(PrmDbType prmDbType);
225 
230  PrmDbStore* getDbPtr(PrmDbType dbType);
231 
236  static Fw::String getDbString(PrmDbType dbType);
237 
243  void dbCopy(PrmDbType dest, PrmDbType src);
244 };
245 } // namespace Svc
246 
247 #endif /* PRMDBIMPL_HPP_ */
Parameter already in database, updated parameter.
Definition: PrmDbImpl.hpp:83
State of parameter DB file load operations.
FwIdType FwOpcodeType
The type of a command opcode.
PrmDb_PrmWriteError PrmWriteError
Definition: PrmDbImpl.hpp:27
friend class PrmDbTester
Definition: PrmDbImpl.hpp:40
void readParamFile()
PrmDb file read function.
Definition: PrmDbImpl.cpp:59
FwIdType FwPrmIdType
The type of a parameter identifier.
PrmDbImpl(const char *name)
PrmDb constructor.
Definition: PrmDbImpl.cpp:39
PrmDb_PrmDbType PrmDbType
Definition: PrmDbImpl.hpp:29
Parameter added to database.
Definition: PrmDbImpl.hpp:82
Component class for managing parameters.
Definition: PrmDbImpl.hpp:39
File load error.
Definition: PrmDbImpl.hpp:90
void configure(const char *file)
PrmDb configure method.
Definition: PrmDbImpl.cpp:49
Auto-generated base for PrmDb component.
PrmDb_PrmReadError PrmReadError
Definition: PrmDbImpl.hpp:28
void configureLoadSandbox(const char *directory)
PrmDb load sandbox configure method.
Definition: PrmDbImpl.cpp:54
PrmDb_PrmDbFileLoadState PrmDbFileLoadState
Definition: PrmDbImpl.hpp:30
PlatformIndexType FwIndexType
File load successful.
Definition: PrmDbImpl.hpp:89
RateGroupDivider component implementation.
Enum representing parameter validity.
No slots available to add new parameter.
Definition: PrmDbImpl.hpp:81
virtual ~PrmDbImpl()
PrmDb destructor.
Definition: PrmDbImpl.cpp:47