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 <Utils/Hash/Hash.hpp>
24 #include <config/PrmDbImplCfg.hpp>
25 #include <cstring>
26 
27 namespace Svc {
28 
33 
40 
41 class PrmDbImpl final : public PrmDbComponentBase {
42  friend class PrmDbTester;
43 
45 
46  public:
53  PrmDbImpl(const char* name);
54 
60  void configure(const char* file);
61 
68  void configureSandbox(const char* directory);
69 
75  void readParamFile(); // NOTE: Assumed to run at initialization time. No guard of data structure.
76 
79  virtual ~PrmDbImpl();
80 
81  // Parameter update status for an individual parameter update or add
87  };
88 
89  // Enum to return status of parameter file load
93  };
94 
95  protected:
96  private:
97  Fw::String m_fileName;
98  Fw::String m_sandboxDir;
99 
100  PrmDbFileLoadState m_state; // Current file load state of the parameter database
101 
102  // Pointers to the active and staging databases
103  // These point to the actual storage arrays below
104  // The active database is the ONLY one used for getting parameters
105  // The staging database is used for loading parameters from a file
106  // when commanded. Upon reading the file, the parameters are "staged"
107  // into the staging database, and then committed to the active database
108  // when a commit command is received.
109  PrmDbStore* m_activeDb;
110  PrmDbStore* m_stagingDb;
111 
112  // Actual storage for the active and staging databases
113  PrmDbStore m_dbStore1;
114  PrmDbStore m_dbStore2;
115 
119 
129  PrmLoadStatus readParamFileImpl(const Fw::StringBase& fileName, PrmDbType dbType);
130 
134  void applySandbox(Os::SandboxedFile& file) const;
135 
138  bool writeSaveFileChunk(Os::SandboxedFile& paramFile,
139  const U8* data,
140  FwSizeType size,
141  PrmWriteError::T statusStage,
142  PrmWriteError::T sizeStage,
143  U32 numRecords,
144  FwOpcodeType opCode,
145  U32 cmdSeq,
146  Utils::Hash& crc);
147 
157  Fw::ParamValid getPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val);
158 
167  void setPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val);
168 
176  PrmDbImpl::PrmUpdateType updateAddPrmImpl(FwPrmIdType id, Fw::ParamBuffer& val, PrmDbType prmDbType);
177 
186  void pingIn_handler(FwIndexType portNum, U32 key);
187 
196  void PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq);
197 
210  void PRM_LOAD_FILE_cmdHandler(FwOpcodeType opCode,
211  U32 cmdSeq,
212  const Fw::CmdStringArg& fileName,
213  const PrmDb_Merge& merge);
214 
224  void PRM_COMMIT_STAGED_cmdHandler(FwOpcodeType opCode, U32 cmdSeq);
225 
229 
235  void clearDb(PrmDbType prmDbType);
236 
241  PrmDbStore* getDbPtr(PrmDbType dbType);
242 
247  static Fw::String getDbString(PrmDbType dbType);
248 
254  void dbCopy(PrmDbType dest, PrmDbType src);
255 };
256 } // namespace Svc
257 
258 #endif /* PRMDBIMPL_HPP_ */
Parameter already in database, updated parameter.
Definition: PrmDbImpl.hpp:85
State of parameter DB file load operations.
FwIdType FwOpcodeType
The type of a command opcode.
PrmDb_PrmWriteError PrmWriteError
Definition: PrmDbImpl.hpp:29
PlatformSizeType FwSizeType
friend class PrmDbTester
Definition: PrmDbImpl.hpp:42
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:31
Parameter added to database.
Definition: PrmDbImpl.hpp:84
Component class for managing parameters.
Definition: PrmDbImpl.hpp:41
A generic interface for creating and comparing hash values.
Definition: Hash.hpp:24
File load error.
Definition: PrmDbImpl.hpp:92
void configure(const char *file)
PrmDb configure method.
Definition: PrmDbImpl.cpp:48
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
Auto-generated base for PrmDb component.
PrmDb_PrmReadError PrmReadError
Definition: PrmDbImpl.hpp:30
PrmDb_PrmDbFileLoadState PrmDbFileLoadState
Definition: PrmDbImpl.hpp:32
PlatformIndexType FwIndexType
File load successful.
Definition: PrmDbImpl.hpp:91
RateGroupDivider component implementation.
Enum representing parameter validity.
No slots available to add new parameter.
Definition: PrmDbImpl.hpp:83
virtual ~PrmDbImpl()
PrmDb destructor.
Definition: PrmDbImpl.cpp:46