Index: NVDataMgmt.c =================================================================== diff -u -r47db79f20ce114098f0383c54a554a0d7dc5102a -r7ef9ef29dad3efdbd58b63c4f6880bdc2a4135a6 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision 47db79f20ce114098f0383c54a554a0d7dc5102a) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 7ef9ef29dad3efdbd58b63c4f6880bdc2a4135a6) @@ -338,6 +338,7 @@ U16 crc; ///< CRC for the DG usage info structure. } DG_USAGE_INFO_GROUP_T; +/// DG heaters record typedef struct { DG_HEATERS_RECORD_T dgHeatersInfo; ///< DG heaters info record. @@ -477,6 +478,7 @@ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadHDTreatmentTime( void ); #endif #ifdef _DG_ +static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadDGHeatersInfo( void ); static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadDGWaterConsumption( void ); #endif static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadLogRecord( void ); @@ -711,6 +713,10 @@ case NVDATAMGMT_SELF_TEST_STATE_READ_WATER_CONSUMPTION: nvDataMgmtSelfTestState = handleSelfTestReadDGWaterConsumption(); break; + + case NVDATAMGMT_SELF_TEST_STATE_READ_DG_HEATERS_INFO: + nvDataMgmtSelfTestState = handleSelfTestReadDGHeatersInfo(); + break; #endif case NVDATAMGMT_SELF_TEST_STATE_CHECK_CRC: @@ -1754,11 +1760,11 @@ BOOL setHeatersInfoRecord( U08 *addressPtr ) { BOOL status = FALSE; - memcpy( &dgHeatersInfoGroup.dgHeatersInfo, addressPtr, sizeof(DG_HEATERS_RECORD_T) ); + memcpy( &dgHeatersInfoGroup.dgHeatersInfo, addressPtr, sizeof( DG_HEATERS_RECORD_T ) ); // The crc is the DG heaters info and padding - the CRC U16 variable - dgHeatersInfoGroup.crc = crc16 ( (U08*)&dgHeatersInfoGroup.dgHeatersInfo, sizeof(dgHeatersInfoGroup) - sizeof(U16) ); + dgHeatersInfoGroup.crc = crc16 ( (U08*)&dgHeatersInfoGroup.dgHeatersInfo, sizeof( dgHeatersInfoGroup ) - sizeof( U16 ) ); - if ( !isQueueFull() ) + if ( FALSE == isQueueFull() ) { // Queue is not full, schedule a write to RTC RAM the write the heaters information record enqueueRecordJob( NVDATAMGMT_WRITE, NVDATAMGMT_RTC, NVDATAMGMT_HEATERS_INFO_RECORD ); @@ -1908,15 +1914,15 @@ NVDATAMGMT_SELF_TEST_STATE_T state = NVDATAMGMT_SELF_TEST_STATE_READ_SCHEDULED_RUNS_RECORD; BOOL timeoutStatus = didCommandTimeout( ALARM_ID_RTC_RAM_OPS_ERROR, (U08*)&state ); - if ( getRTCRAMStatus() == RTC_RAM_STATUS_IDLE || timeoutStatus == TRUE ) + if ( ( RTC_RAM_STATUS_IDLE == getRTCRAMStatus() ) || ( TRUE == timeoutStatus ) ) { PROCESS_RECORD_SPECS_T specs = RECORDS_SPECS[ NVDATAMGMT_SCHEDULED_RUNS_RECORD ]; U08* bufferAddress = specs.structAddressPtr; U32 maxBufferLength = specs.maxReadBufferSize; getDataFromRAM( bufferAddress, maxBufferLength ); - state = NVDATAMGMT_SELF_TEST_STATE_CHECK_CRC; + state = NVDATAMGMT_SELF_TEST_STATE_READ_DG_HEATERS_INFO; } return state; @@ -1955,6 +1961,49 @@ #ifdef _DG_ /*********************************************************************//** * @brief + * The handleSelfTestReadDGHeatersInfo reads the DG heaters information + * from RTC RAM. + * @details Inputs: none + * @details Outputs: dgHeatersInfoGroup + * @return next state + *************************************************************************/ +static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadDGHeatersInfo( void ) +{ + NVDATAMGMT_SELF_TEST_STATE_T state = NVDATAMGMT_SELF_TEST_STATE_READ_DG_HEATERS_INFO; + BOOL timeoutStatus = didCommandTimeout( ALARM_ID_RTC_RAM_OPS_ERROR, (U08*)&state ); + + if ( ( RTC_RAM_STATUS_IDLE == getRTCRAMStatus() ) || ( TRUE == timeoutStatus ) ) + { + PROCESS_RECORD_SPECS_T specs = RECORDS_SPECS[ NVDATAMGMT_HEATERS_INFO_RECORD ]; + U08* bufferAddress = specs.structAddressPtr; + U32 maxBufferLength = specs.maxReadBufferSize; + + getDataFromRAM( bufferAddress, maxBufferLength ); + + // Calculate the CRC of the record + U16 calcCRC = crc16 ( specs.structAddressPtr, specs.sizeofJob - sizeof(U16) ); + U16 recordCRC = *(U16*)specs.structCRCPtr; + + // If the CRCs are not equal, set the average fill flow to 0.0 + // Otherwise, keep the data so it can be used + if ( calcCRC != recordCRC ) + { + dgHeatersInfoGroup.dgHeatersInfo.averageFillFlow = 0.0; + dgHeatersInfoGroup.crc = recordCRC; + } + else + { + memcpy( &dgHeatersInfoGroup, bufferAddress, sizeof( DG_HEATERS_INFO_GROUP_T ) ); + } + + state = NVDATAMGMT_SELF_TEST_STATE_CHECK_CRC; + } + + return state; +} + +/*********************************************************************//** + * @brief * The handleSelfTestReadDGWaterConsumption reads the DG water consumption * from RTC RAM. * @details Inputs: currentTime, waterConsumptionRecord Index: NVDataMgmtDGRecords.h =================================================================== diff -u -r47db79f20ce114098f0383c54a554a0d7dc5102a -r7ef9ef29dad3efdbd58b63c4f6880bdc2a4135a6 --- NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision 47db79f20ce114098f0383c54a554a0d7dc5102a) +++ NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision 7ef9ef29dad3efdbd58b63c4f6880bdc2a4135a6) @@ -396,8 +396,6 @@ typedef struct { F32 averageFillFlow; ///< Average fill flow rate. - F32 averageFillTemperature; ///< Average fill temperature. - F32 primaryHeaterEfficiency; ///< Primary heater efficiency. } DG_HEATERS_RECORD_T; #pragma pack(pop)