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>
19 #include <Os/SandboxedFile.hpp>
23 #include <config/PrmDbImplCfg.hpp>
24 #include <cstring>
25 
26 namespace Svc {
27 
32 
39 
40 class PrmDbImpl final : public PrmDbComponentBase {
41  friend class PrmDbTester;
42 
44 
45  public:
52  PrmDbImpl(const char* name);
53 
59  void configure(const char* file);
60 
67  void configureSandbox(const char* directory);
68 
74  void readParamFile(); // NOTE: Assumed to run at initialization time. No guard of data structure.
75 
78  virtual ~PrmDbImpl();
79 
80  // Parameter update status for an individual parameter update or add
86  };
87 
88  // Enum to return status of parameter file load
92  };
93 
94  protected:
95  private:
96  Fw::String m_fileName;
97  Fw::String m_sandboxDir;
98 
99  PrmDbFileLoadState m_state; // Current file load state of the parameter database
100 
101  // Pointers to the active and staging databases
102  // These point to the actual storage arrays below
103  // The active database is the ONLY one used for getting parameters
104  // The staging database is used for loading parameters from a file
105  // when commanded. Upon reading the file, the parameters are "staged"
106  // into the staging database, and then committed to the active database
107  // when a commit command is received.
108  PrmDbStore* m_activeDb;
109  PrmDbStore* m_stagingDb;
110 
111  // Actual storage for the active and staging databases
112  PrmDbStore m_dbStore1;
113  PrmDbStore m_dbStore2;
114 
118 
128  PrmLoadStatus readParamFileImpl(const Fw::StringBase& fileName, PrmDbType dbType);
129 
133  void applySandbox(Os::SandboxedFile& file) const;
134 
144  Fw::ParamValid getPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val);
145 
154  void setPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val);
155 
163  PrmDbImpl::PrmUpdateType updateAddPrmImpl(FwPrmIdType id, Fw::ParamBuffer& val, PrmDbType prmDbType);
164 
173  void pingIn_handler(FwIndexType portNum, U32 key);
174 
183  void PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq);
184 
197  void PRM_LOAD_FILE_cmdHandler(FwOpcodeType opCode,
198  U32 cmdSeq,
199  const Fw::CmdStringArg& fileName,
200  const PrmDb_Merge& merge);
201 
211  void PRM_COMMIT_STAGED_cmdHandler(FwOpcodeType opCode, U32 cmdSeq);
212 
216 
222  void clearDb(PrmDbType prmDbType);
223 
228  PrmDbStore* getDbPtr(PrmDbType dbType);
229 
234  static Fw::String getDbString(PrmDbType dbType);
235 
241  void dbCopy(PrmDbType dest, PrmDbType src);
242 };
243 } // namespace Svc
244 
245 #endif /* PRMDBIMPL_HPP_ */
Parameter already in database, updated parameter.
Definition: PrmDbImpl.hpp:84
State of parameter DB file load operations.
FwIdType FwOpcodeType
The type of a command opcode.
PrmDb_PrmWriteError PrmWriteError
Definition: PrmDbImpl.hpp:28
friend class PrmDbTester
Definition: PrmDbImpl.hpp:41
void configureSandbox(const char *directory)
PrmDb sandbox configure method.
Definition: PrmDbImpl.cpp:53
void readParamFile()
PrmDb file read function.
Definition: PrmDbImpl.cpp:65
FwIdType FwPrmIdType
The type of a parameter identifier.
A wrapper around Os::File that restricts file access to an allowed directory.
PrmDbImpl(const char *name)
PrmDb constructor.
Definition: PrmDbImpl.cpp:38
PrmDb_PrmDbType PrmDbType
Definition: PrmDbImpl.hpp:30
Parameter added to database.
Definition: PrmDbImpl.hpp:83
Component class for managing parameters.
Definition: PrmDbImpl.hpp:40
File load error.
Definition: PrmDbImpl.hpp:91
void configure(const char *file)
PrmDb configure method.
Definition: PrmDbImpl.cpp:48
Auto-generated base for PrmDb component.
PrmDb_PrmReadError PrmReadError
Definition: PrmDbImpl.hpp:29
PrmDb_PrmDbFileLoadState PrmDbFileLoadState
Definition: PrmDbImpl.hpp:31
PlatformIndexType FwIndexType
File load successful.
Definition: PrmDbImpl.hpp:90
RateGroupDivider component implementation.
Enum representing parameter validity.
No slots available to add new parameter.
Definition: PrmDbImpl.hpp:82
virtual ~PrmDbImpl()
PrmDb destructor.
Definition: PrmDbImpl.cpp:46