16 static_assert(std::numeric_limits<FwSizeType>::max() >= PRMDB_NUM_DB_ENTRIES,
"PRMDB_NUM_DB_ENTRIES must fit within range of FwSizeType");
29 return sizeof(m_buff);
36 const U8* getBuffAddr()
const {
52 this->m_fileName = file;
55 void PrmDbImpl::clearDb() {
56 for (
FwSizeType entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) {
57 this->m_db[entry].used =
false;
58 this->m_db[entry].id = 0;
69 for (
FwSizeType entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) {
70 if (this->m_db[entry].used) {
71 if (this->m_db[entry].
id ==
id) {
72 val = this->m_db[entry].val;
93 bool existingEntry =
false;
96 for (
FwSizeType entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) {
97 if ((this->m_db[entry].used) && (
id == this->m_db[entry].
id)) {
98 this->m_db[entry].val = val;
105 if (!existingEntry) {
106 for (
FwSizeType entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) {
107 if (!(this->m_db[entry].used)) {
108 this->m_db[entry].val = val;
109 this->m_db[entry].id = id;
110 this->m_db[entry].used =
true;
121 }
else if (noSlots) {
129 void PrmDbImpl::PRM_SAVE_FILE_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq) {
148 if (this->m_db[entry].used) {
150 static const U8 delim = PRMDB_ENTRY_DELIMITER;
152 stat = paramFile.write(&delim,writeSize,Os::File::WaitType::WAIT);
159 if (writeSize !=
sizeof(delim)) {
163 static_cast<I32>(numRecords),
164 static_cast<I32>(writeSize));
178 writeSize =
static_cast<FwSizeType>(buff.getBuffLength());
179 stat = paramFile.write(buff.getBuffAddr(),writeSize,Os::File::WaitType::WAIT);
186 if (writeSize !=
sizeof(recordSize)) {
190 static_cast<I32>(numRecords),
191 static_cast<I32>(writeSize));
201 serStat = buff.serialize(this->m_db[entry].
id);
206 writeSize =
static_cast<FwSizeType>(buff.getBuffLength());
207 stat = paramFile.write(buff.getBuffAddr(),writeSize,Os::File::WaitType::WAIT);
214 if (writeSize != static_cast<FwSizeType>(buff.getBuffLength())) {
218 static_cast<I32>(numRecords),
219 static_cast<I32>(writeSize));
226 writeSize =
static_cast<FwSizeType>(this->m_db[entry].val.getBuffLength());
227 stat = paramFile.write(this->m_db[entry].val.
getBuffAddr(),writeSize,Os::File::WaitType::WAIT);
234 if (writeSize != static_cast<FwSizeType>(this->m_db[entry].val.
getBuffLength())) {
238 static_cast<I32>(numRecords),
239 static_cast<I32>(writeSize));
273 for (
FwSizeType entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) {
279 Os::File::Status fStat = paramFile.read(&delimiter,readSize,Os::File::WaitType::WAIT);
291 if (
sizeof(delimiter) != readSize) {
296 if (PRMDB_ENTRY_DELIMITER != delimiter) {
303 readSize =
sizeof(recordSize);
305 fStat = paramFile.read(buff.getBuffAddr(),readSize,Os::File::WaitType::WAIT);
310 if (
sizeof(recordSize) != readSize) {
315 Fw::SerializeStatus desStat = buff.setBuffLen(static_cast<Fw::Serializable::SizeType>(readSize));
321 desStat = buff.deserialize(recordSize);
335 fStat = paramFile.read(buff.getBuffAddr(),readSize,Os::File::WaitType::WAIT);
340 if (
sizeof(parameterId) != static_cast<FwSizeType>(readSize)) {
346 desStat = buff.setBuffLen(static_cast<Fw::Serializable::SizeType>(readSize));
352 desStat = buff.deserialize(parameterId);
356 this->m_db[entry].used =
true;
357 this->m_db[entry].id = parameterId;
358 readSize = recordSize-
sizeof(parameterId);
360 fStat = paramFile.read(this->m_db[entry].val.
getBuffAddr(),readSize);
366 if (static_cast<U32>(readSize) != recordSize-
sizeof(parameterId)) {
372 desStat = this->m_db[entry].val.setBuffLen(static_cast<Fw::Serializable::SizeType>(readSize));
382 void PrmDbImpl::pingIn_handler(
FwIndexType portNum, U32 key) {
Serialization/Deserialization operation was successful.
U8 * getBuffAddr()
gets buffer address for data filling
PrmDb_PrmWriteError PrmWriteError
PlatformSizeType FwSizeType
void readParamFile()
PrmDb file read function.
const char * toChar() const
void log_WARNING_LO_PrmIdNotFound(U32 Id)
void log_ACTIVITY_HI_PrmFileSaveComplete(U32 records) const
PrmDbImpl(const char *name)
PrmDb constructor.
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
void log_WARNING_HI_PrmFileWriteError(Svc::PrmDb_PrmWriteError stage, I32 record, I32 error) const
SerializeStatus
forward declaration for string
void log_ACTIVITY_HI_PrmFileLoadComplete(U32 records) const
virtual void lock()
Lock the guarded mutex.
void log_WARNING_HI_PrmFileReadError(Svc::PrmDb_PrmReadError stage, I32 record, I32 error) const
Serializable::SizeType getBuffLength() const
returns current buffer size
U32 FwOpcodeType
The type of a command opcode.
void log_ACTIVITY_HI_PrmIdAdded(U32 Id) const
virtual void unLock()
Unlock the guarded mutex.
SizeType length() const
Get length of string.
void configure(const char *file)
PrmDb configure method.
U32 FwPrmIdType
The type of a parameter identifier.
Command successfully executed.
uint8_t U8
8-bit unsigned integer
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.
PrmDb_PrmReadError PrmReadError
Command had execution error.
Operation was successful.
PlatformIndexType FwIndexType
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
RateGroupDivider component implementation.
Enum representing parameter validity.
#define FW_PARAM_BUFFER_MAX_SIZE
virtual ~PrmDbImpl()
PrmDb destructor.
void log_FATAL_PrmDbFull(U32 Id) const
Component for managing parameters.