Index: NVDataMgmt.c =================================================================== diff -u -r425252f82959bdd382d3a63a978f002e7bfe3011 -r5d12a10f75c6655992acb911af4bf339b2eb955b --- NVDataMgmt.c (.../NVDataMgmt.c) (revision 425252f82959bdd382d3a63a978f002e7bfe3011) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 5d12a10f75c6655992acb911af4bf339b2eb955b) @@ -240,24 +240,10 @@ /// Log record structure. typedef struct { - LOG_HEADER_T logHeader; ///< Log header struct - U16 crc; ///< Log header CRC + LOG_HEADER_T logHeader; ///< Log header struct. + U16 crc; ///< Log header CRC. } LOG_RECORD_T; -/// Treatment time structure. -typedef struct -{ - U32 treatmentTime; ///< Treatment time - U16 crc; ///< Treatment time CRC -} TREATMENT_TIME_RECORD_T; - -/// Water consumption structure. -typedef struct -{ - U32 waterConsumption; ///< Water consumption - U16 crc; ///< Water consumption CRC -} WATER_CONSUMPTION_RECORD_T; - // ********** HD/DG record structures ********** #ifdef _DG_ @@ -316,8 +302,16 @@ DG_SCHEDULED_RUN_RECORD_T dgScheduledRun; ///< DG scheduled runs. U08 padding[ RECORD_PADDING_LENGTH(DG_SCHEDULED_RUN_RECORD_T, MAX_RTC_RAM_OPS_BUFFER_BYTES) - RECORD_BYTE_SIZE(DG_SCHEDULED_RUN_RECORD_T) ]; ///< DG scheduled run group padding. - U16 crc; ///< CRC for the DG automated test time structure. + U16 crc; ///< CRC for the DG scheduled runs structure. } DG_SCHEDULED_RUNS_GROUP_T; + +typedef struct +{ + DG_USAGE_INFO_RECORD_T dgUsageInfo; ///< DG usage info record. + U08 padding[ RECORD_PADDING_LENGTH(DG_USAGE_INFO_RECORD_T, MAX_RTC_RAM_OPS_BUFFER_BYTES) - + RECORD_BYTE_SIZE(DG_USAGE_INFO_RECORD_T) ]; ///< DG scheduled run group padding. + U16 crc; ///< CRC for the DG usage info structure. +} DG_USAGE_INFO_GROUP_T; #endif #ifdef _HD_ @@ -360,8 +354,16 @@ RECORD_BYTE_SIZE(HD_SERVICE_RECORD_T) ]; ///< HD service group padding. U16 crc; ///< CRC for the HD service structure. } HD_SERVICE_GROUP_T; -#endif +/// HD usage info record structure +typedef struct +{ + HD_USAGE_INFO_RECORD_T hdUsageInfo; ///< HD usage info record. + U08 padding[ RECORD_PADDING_LENGTH(HD_USAGE_INFO_RECORD_T, MAX_RTC_RAM_OPS_BUFFER_BYTES) - + RECORD_BYTE_SIZE(HD_USAGE_INFO_RECORD_T) ]; ///< HD scheduled run group padding. + U16 crc; ///< CRC for the HD usage info structure. +} HD_USAGE_INFO_GROUP_T; +#endif #pragma pack(pop) // Calibration variables @@ -370,6 +372,7 @@ static DG_SYSTEM_GROUP_T dgSystemGroup; ///< DG system group structure (including padding and final CRC). static DG_SERVICE_GROUP_T dgServiceGroup; ///< DG service group structure (including padding and final CRC). static DG_SCHEDULED_RUNS_GROUP_T dgScheduledRunsGroup; ///< DG scheduled run structure (including padding and final CRC). +static DG_USAGE_INFO_GROUP_T dgUsageInfoGroup; ///< DG usage info structure (including padding and final CRC). // Process records specifications const PROCESS_RECORD_SPECS_T RECORDS_SPECS [ NUM_OF_NVDATMGMT_RECORDS_JOBS ] = { {BANK7_SECTOR0_START_ADDRESS, sizeof(DG_CALIBRATION_RECORD_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(DG_CALIBRATION_RECORD_T), (U08*)&dgCalibrationRecord, (U08*)&(dgCalibrationRecord.crc)}, // NVDATAMGMT_CALIBRATION_RECORD @@ -382,6 +385,7 @@ static HD_CALIBRATION_RECORD_T hdCalibrationRecord; ///< HD calibration record structure. static HD_SYSTEM_GROUP_T hdSystemGroup; ///< HD system group structure (including padding and final CRC). static HD_SERVICE_GROUP_T hdServiceGroup; ///< HD service group structure (including padding and final CRC). +static HD_USAGE_INFO_GROUP_T hdUsageInfoGroup; ///< HD usage info group structure (including padding and final CRC). // Process records specifications const PROCESS_RECORD_SPECS_T RECORDS_SPECS [ NUM_OF_NVDATMGMT_RECORDS_JOBS ] = { {BANK7_SECTOR0_START_ADDRESS, sizeof(HD_CALIBRATION_RECORD_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(HD_CALIBRATION_RECORD_T), (U08*)&hdCalibrationRecord, (U08*)&hdCalibrationRecord.crc}, // NVDATAMGMT_CALIBRATION_RECORD @@ -413,8 +417,6 @@ static MEMORY_LOG_OPS_T jobQueue [ QUEUE_MAX_SIZE ]; ///< Job queue buffer. static MEMORY_LOG_OPS_T currentJob; ///< Current job. static LOG_RECORD_T logRecord; ///< Log record variable. -static TREATMENT_TIME_RECORD_T treatmentTimeRecord; ///< Treatment time record. -static WATER_CONSUMPTION_RECORD_T waterConsumptionRecord; ///< Water consumption record. static U08 queueRearIndex = QUEUE_START_INDEX; ///< Queue rear index. static U08 queueFrontIndex = QUEUE_START_INDEX; ///< Queue front index. static U08 queueCount = 0; ///< Queue count. @@ -432,8 +434,12 @@ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadSystemRecord ( void ); static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadServiceRecord ( void ); static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadScheduledRunsRecord( void ); +#ifdef _HD_ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadHDTreatmentTime ( void ); +#endif +#ifdef _DG_ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadDGWaterConsumption ( void ); +#endif static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadLogRecord ( void ); static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestCheckCRC ( void ); @@ -639,15 +645,16 @@ case NVDATAMGMT_SELF_TEST_STATE_READ_LOG_RECORD: nvDataMgmtSelfTestState = handleSelfTestReadLogRecord(); break; - +#ifdef _HD_ case NVDATAMGMT_SELF_TEST_STATE_READ_TREATMENT_TIME: nvDataMgmtSelfTestState = handleSelfTestReadHDTreatmentTime(); break; - +#endif +#ifdef _DG_ case NVDATAMGMT_SELF_TEST_STATE_READ_WATER_CONSUMPTION: nvDataMgmtSelfTestState = handleSelfTestReadDGWaterConsumption(); break; - +#endif case NVDATAMGMT_SELF_TEST_STATE_CHECK_CRC: nvDataMgmtSelfTestState = handleSelfTestCheckCRC(); break; @@ -1008,10 +1015,6 @@ // CRC passed write the last service record to the RTC RAM enqueueRecordJob( NVDATAMGMT_WRITE, NVDATAMGMT_RTC, NVDATAMGMT_SERVICE_RECORD ); - // TODO FOR TESTING ONLY REMOVE - enqueueRecordJob( NVDATAMGMT_READ, NVDATAMGMT_RTC, NVDATAMGMT_SERVICE_RECORD ); - // TODO FOR TESTING ONLY REMOVE - // Done with receiving data, go back to idle nvDataMgmtExecReceiveRecordState = NVDATAMGMT_RECEIVE_RECORD_IDLE; } @@ -1116,10 +1119,6 @@ // CRC passed write the last service record to the RTC RAM enqueueRecordJob( NVDATAMGMT_WRITE, NVDATAMGMT_RTC, NVDATAMGMT_SCHEDULED_RUNS_RECORD ); - // TODO FOR TESTING ONLY REMOVE - enqueueRecordJob( NVDATAMGMT_READ, NVDATAMGMT_RTC, NVDATAMGMT_SCHEDULED_RUNS_RECORD ); - // TODO FOR TESTING ONLY REMOVE - // Done with receiving data, go back to idle nvDataMgmtExecReceiveRecordState = NVDATAMGMT_RECEIVE_RECORD_IDLE; } @@ -1558,7 +1557,7 @@ return status; } - +#ifdef _HD_ /*********************************************************************//** * @brief * The setTreatmentTime sets a queue job to write the treatment time in @@ -1571,13 +1570,13 @@ BOOL setTreatmentTime ( U32 hours ) { BOOL status = FALSE; - treatmentTimeRecord.treatmentTime = hours; - treatmentTimeRecord.crc = crc16 ( (U08*)&treatmentTimeRecord.treatmentTime, sizeof(U32) ); + hdUsageInfoGroup.treatmentTime = hours; + hdUsageInfoGroup.crc = crc16 ( (U08*)&hdUsageInfoGroup.treatmentTime, sizeof(U32) ); if ( !isQueueFull() ) { enqueue( NVDATAMGMT_WRITE, NVDATAMGMT_RTC, HD_TREATMENT_TIME_ADDRESS, - (U08*)&treatmentTimeRecord, 0, sizeof(TREATMENT_TIME_RECORD_T) ); + (U08*)&hdUsageInfoGroup, 0, sizeof(HD_USAGE_INFO_RECORD_T) ); status = TRUE; } @@ -1594,9 +1593,10 @@ *************************************************************************/ U32 getTreatmentTime ( void ) { - return treatmentTimeRecord.treatmentTime; + return hdUsageInfoGroup.treatmentTime; } - +#endif +#ifdef _DG_ /*********************************************************************//** * @brief * The setWaterConsumption sets a queue job to write the amount of water @@ -1609,13 +1609,13 @@ BOOL setWaterConsumption ( U32 liters ) { BOOL status = FALSE; - waterConsumptionRecord.waterConsumption = liters; - waterConsumptionRecord.crc = crc16 ( (U08*)&waterConsumptionRecord.waterConsumption, sizeof(U32) ); + dgUsageInfoGroup.dgUsageInfo.waterConsumption = liters; + dgUsageInfoGroup.crc = crc16 ( (U08*)&dgUsageInfoGroup.dgUsageInfo.waterConsumption, sizeof(U32) ); if ( !isQueueFull() ) { enqueue( NVDATAMGMT_WRITE, NVDATAMGMT_RTC, DG_CONSUMED_WATER_ADDRESS, - (U08*)&waterConsumptionRecord, 0, sizeof(WATER_CONSUMPTION_RECORD_T) ); + (U08*)&dgUsageInfoGroup, 0, sizeof(DG_USAGE_INFO_RECORD_T) ); status = TRUE; } @@ -1631,9 +1631,9 @@ *************************************************************************/ U32 getWaterConsumption ( void ) { - return waterConsumptionRecord.waterConsumption; + return dgUsageInfoGroup.dgUsageInfo.waterConsumption; } - +#endif /*********************************************************************//** * @brief * The handleSelfTestStart enables the EEPROM bank sectors. @@ -1788,7 +1788,7 @@ return state; } - +#ifdef _HD_ /*********************************************************************//** * @brief * The handleSelfTestReadHDTreatmentTime reads the HD treatment time @@ -1805,7 +1805,7 @@ // If the RTC RAM is ready, read the results if ( getRTCRAMStatus() == RTC_RAM_STATUS_IDLE || timeoutStatus == TRUE ) { - getDataFromRAM ( (U08*)&treatmentTimeRecord, sizeof(TREATMENT_TIME_RECORD_T) ); + getDataFromRAM ( (U08*)&hdUsageInfoGroup, sizeof(HD_USAGE_INFO_RECORD_T) ); // If the RAM is ready, request a read for the log records (RAM) if ( getRTCRAMState() == RTC_RAM_STATE_READY ) { @@ -1817,7 +1817,8 @@ return state; } - +#endif +#ifdef _DG_ /*********************************************************************//** * @brief * The handleSelfTestReadDGWaterConsumption reads the DG water consumption @@ -1834,7 +1835,7 @@ // If the RAM is ready, request a read for water consumption if ( getRTCRAMStatus() == RTC_RAM_STATUS_IDLE || timeoutStatus == TRUE ) { - getDataFromRAM ( (U08*)&waterConsumptionRecord, sizeof(WATER_CONSUMPTION_RECORD_T) ); + getDataFromRAM ( (U08*)&dgUsageInfoGroup, sizeof(DG_USAGE_INFO_RECORD_T) ); if ( getRTCRAMState() == RTC_RAM_STATE_READY ) { readFromRAM ( LOG_RECORD_START_ADDRESS, sizeof(LOG_RECORD_T) ); @@ -1845,7 +1846,7 @@ return state; } - +#endif /*********************************************************************//** * @brief * The handleSelfTestReadLogRecord reads the log record from RTC RAM. Index: NVDataMgmt.h =================================================================== diff -u -r76016122c2646fe718a67782f9a818163bf6923f -r5d12a10f75c6655992acb911af4bf339b2eb955b --- NVDataMgmt.h (.../NVDataMgmt.h) (revision 76016122c2646fe718a67782f9a818163bf6923f) +++ NVDataMgmt.h (.../NVDataMgmt.h) (revision 5d12a10f75c6655992acb911af4bf339b2eb955b) @@ -136,12 +136,14 @@ HD_SYSTEM_RECORD_T getHDSystemRecord( void ); HD_SERVICE_RECORD_T getHDServiceRecord( void ); #endif - +#ifdef _HD_ BOOL setTreatmentTime ( U32 hours ); U32 getTreatmentTime ( void ); - +#endif +#ifdef _DG_ BOOL setWaterConsumption ( U32 liters ); U32 getWaterConsumption ( void ); +#endif BOOL writeLogData ( LOG_DATA_T* data ); BOOL readLogData ( READ_DATA_T* buffer, U32 length ); Index: NVDataMgmtDGRecords.h =================================================================== diff -u -rba2efce4509d89ecc27a5f179774e32ac358b9ce -r5d12a10f75c6655992acb911af4bf339b2eb955b --- NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision ba2efce4509d89ecc27a5f179774e32ac358b9ce) +++ NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision 5d12a10f75c6655992acb911af4bf339b2eb955b) @@ -382,6 +382,13 @@ { DG_SCHEDULED_RUN_T dgScheduledRun[ NUM_OF_DG_SCHEDULED_RUNS ]; ///< DG scheduled run. } DG_SCHEDULED_RUN_RECORD_T; + +/// DG usage info structure. +typedef struct +{ + U32 waterConsumption; ///< Water consumption. + U16 crc; ///< CRC for the DG usage info structure. +} DG_USAGE_INFO_RECORD_T; #pragma pack(pop) /**@}*/ Index: NVDataMgmtHDRecords.h =================================================================== diff -u -r425252f82959bdd382d3a63a978f002e7bfe3011 -r5d12a10f75c6655992acb911af4bf339b2eb955b --- NVDataMgmtHDRecords.h (.../NVDataMgmtHDRecords.h) (revision 425252f82959bdd382d3a63a978f002e7bfe3011) +++ NVDataMgmtHDRecords.h (.../NVDataMgmtHDRecords.h) (revision 5d12a10f75c6655992acb911af4bf339b2eb955b) @@ -190,6 +190,12 @@ U16 crc; ///< CRC for the HD service record structure. } HD_SERVICE_RECORD_T; +/// HD usage info structure. +typedef struct +{ + U32 treatmentTime; ///< Treatment time. + U16 crc; ///< CRC for the HD usage info structure. +} HD_USAGE_INFO_RECORD_T; #pragma pack(pop) /**@}*/