27 return sizeof(m_buff);
34 const U8* getBuffAddr()
const {
50 this->m_fileName = file;
53 void PrmDbImpl::clearDb() {
54 for (I32 entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) {
55 this->m_db[entry].used =
false;
56 this->m_db[entry].id = 0;
67 for (I32 entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) {
68 if (this->m_db[entry].used) {
69 if (this->m_db[entry].
id ==
id) {
70 val = this->m_db[entry].val;
91 bool existingEntry =
false;
94 for (
NATIVE_INT_TYPE entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) {
95 if ((this->m_db[entry].used) && (
id == this->m_db[entry].
id)) {
96 this->m_db[entry].val = val;
103 if (!existingEntry) {
104 for (I32 entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) {
105 if (!(this->m_db[entry].used)) {
106 this->m_db[entry].val = val;
107 this->m_db[entry].id = id;
108 this->m_db[entry].used =
true;
119 }
else if (noSlots) {
127 void PrmDbImpl::PRM_SAVE_FILE_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq) {
146 if (this->m_db[entry].used) {
148 static const U8 delim = PRMDB_ENTRY_DELIMITER;
150 stat = paramFile.
write(&delim,writeSize,Os::File::WaitType::WAIT);
157 if (writeSize !=
sizeof(delim)) {
161 static_cast<I32
>(numRecords),
162 static_cast<I32
>(writeSize));
176 writeSize = buff.getBuffLength();
177 stat = paramFile.
write(buff.getBuffAddr(),writeSize,Os::File::WaitType::WAIT);
184 if (writeSize !=
sizeof(recordSize)) {
188 static_cast<I32
>(numRecords),
189 static_cast<I32
>(writeSize));
199 serStat = buff.serialize(this->m_db[entry].
id);
204 writeSize = buff.getBuffLength();
205 stat = paramFile.
write(buff.getBuffAddr(),writeSize,Os::File::WaitType::WAIT);
216 static_cast<I32
>(numRecords),
217 static_cast<I32
>(writeSize));
224 writeSize = this->m_db[entry].val.getBuffLength();
225 stat = paramFile.
write(this->m_db[entry].val.
getBuffAddr(),writeSize,Os::File::WaitType::WAIT);
236 static_cast<I32
>(numRecords),
237 static_cast<I32
>(writeSize));
271 for (
NATIVE_INT_TYPE entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) {
289 if (
sizeof(delimiter) != readSize) {
294 if (PRMDB_ENTRY_DELIMITER != delimiter) {
301 readSize =
sizeof(recordSize);
303 fStat = paramFile.
read(buff.getBuffAddr(),readSize,Os::File::WaitType::WAIT);
308 if (
sizeof(recordSize) != readSize) {
319 desStat = buff.deserialize(recordSize);
333 fStat = paramFile.
read(buff.getBuffAddr(),readSize,Os::File::WaitType::WAIT);
338 if (
sizeof(parameterId) !=
static_cast<FwSizeType>(readSize)) {
350 desStat = buff.deserialize(parameterId);
354 this->m_db[entry].used =
true;
355 this->m_db[entry].id = parameterId;
356 readSize = recordSize-
sizeof(parameterId);
364 if (
static_cast<U32
>(readSize) != recordSize-
sizeof(parameterId)) {
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
PlatformUIntType NATIVE_UINT_TYPE
PlatformSignedSizeType FwSignedSizeType
#define FW_PARAM_BUFFER_MAX_SIZE
PlatformSizeType FwSizeType
Component for managing parameters.
@ EXECUTION_ERROR
Command had execution error.
@ OK
Command successfully executed.
U8 * getBuffAddr()
gets buffer address for data filling
Enum representing parameter validity.
NATIVE_UINT_TYPE SizeType
Serializable::SizeType getBuffLength() const
returns current buffer size
SizeType length() const
Get length of string.
const char * toChar() const
Status read(U8 *buffer, FwSignedSizeType &size)
read data from this file into supplied buffer bounded by size
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
Status write(const U8 *buffer, FwSignedSizeType &size)
write data to this file from the supplied buffer bounded by size
@ OP_OK
Operation was successful.
@ OPEN_WRITE
Open file for writing.
@ OPEN_READ
Open file for reading.
Auto-generated base for PrmDb component.
virtual void unLock()
Unlock the guarded mutex.
void log_WARNING_HI_PrmFileReadError(Svc::PrmDb_PrmReadError stage, I32 record, I32 error)
void log_WARNING_HI_PrmFileWriteError(Svc::PrmDb_PrmWriteError stage, I32 record, I32 error)
void log_ACTIVITY_HI_PrmIdUpdated(U32 Id)
virtual void lock()
Lock the guarded mutex.
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
void log_FATAL_PrmDbFull(U32 Id)
void log_ACTIVITY_HI_PrmFileLoadComplete(U32 records)
void log_WARNING_LO_PrmIdNotFound(U32 Id)
void log_ACTIVITY_HI_PrmFileSaveComplete(U32 records)
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
void log_ACTIVITY_HI_PrmIdAdded(U32 Id)
void readParamFile()
PrmDb file read function.
virtual ~PrmDbImpl()
PrmDb destructor.
PrmDbImpl(const char *name)
PrmDb constructor.
void configure(const char *file)
PrmDb configure method.
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
PrmDb_PrmReadError PrmReadError
PrmDb_PrmWriteError PrmWriteError