Index: Accel.c =================================================================== diff -u -r1797ae184a55396ff3464cead47f16bac9dda84c -rf853004049bc4701d911701e48768cd17189faea --- Accel.c (.../Accel.c) (revision 1797ae184a55396ff3464cead47f16bac9dda84c) +++ Accel.c (.../Accel.c) (revision f853004049bc4701d911701e48768cd17189faea) @@ -92,9 +92,11 @@ static BOOL shockErrorDetected; ///< Flag indicates a shock error has been detected and g-force must now come below alarm clear threshold to clear alarm. #ifdef _HD_ static HD_ACCELEROMETER_SENSOR_CAL_RECORD_T accelSensorCalRecord; ///< HD accelerometer calibration record. +static const ALARM_ID_T CAL_ALARM = ALARM_ID_HD_ACCELEROMETERS_INVALID_CAL_RECORD; ///< HD accelerometer calibration alarm. #endif #ifdef _DG_ static DG_ACCEL_SENSOR_CAL_RECORD_T accelSensorCalRecord; ///< DG accelerometer calibration record. +static const ALARM_ID_T CAL_ALARM = ALARM_ID_DG_ACCELEROMETERS_INVALID_CAL_RECORD; ///< DG accelerometer calibration alarm. #endif // ********** private function prototypes ********** @@ -105,7 +107,6 @@ static void filterAccelReadings( void ); static void checkForTiltError( void ); static void checkForShockError( void ); -static BOOL processCalibrationData( void ); static F32 calcVectorLength( F32 x, F32 y, F32 z ); /*********************************************************************//** @@ -151,7 +152,7 @@ // Check if a new calibration is available if ( TRUE == isNewCalibrationRecordAvailable() ) { - processCalibrationData(); + getNVRecord2Driver( GET_CAL_ACCEL_SENSORS, (U08*)&accelSensorCalRecord, sizeof( accelSensorCalRecord ), 0, CAL_ALARM ); } switch ( accelState ) @@ -582,51 +583,6 @@ /*********************************************************************//** * @brief - * The processCalibrationData function gets the calibration data and makes - * sure it is valid by checking the calibration date. The calibration date - * should not be 0. - * @details Inputs: none - * @details Outputs: accelSensorCalRecord - * @return TRUE if the calibration record is valid, otherwise FALSE - *************************************************************************/ -static BOOL processCalibrationData( void ) -{ - BOOL status = TRUE; - -#ifdef _HD_ - HD_ACCELEROMETER_SENSOR_CAL_RECORD_T calData = getHDAccelerometerSensorCalibrationRecord(); -#endif - -#ifdef _DG_ - DG_ACCEL_SENSOR_CAL_RECORD_T calData = getDGAccelerometerSensorCalibrationRecord(); -#endif - - // Check if the calibration data that was received from NVDataMgmt is legitimate - // The calibration date item should not be zero. If the calibration date is 0, - // then the accelerometer data is not stored in the NV memory or it was corrupted. - if ( 0 == calData.calibrationTime ) - { -#ifndef SKIP_CAL_CHECK -#ifdef _HD_ - activateAlarmNoData( ALARM_ID_HD_ACCELEROMETERS_INVALID_CAL_RECORD ); -#endif -#ifdef _DG_ - activateAlarmNoData( ALARM_ID_DG_ACCELEROMETERS_INVALID_CAL_RECORD ); -#endif - status = FALSE; -#endif - } - - // The calibration data was valid, update the local copy - accelSensorCalRecord.accelXOffset = calData.accelXOffset; - accelSensorCalRecord.accelYOffset = calData.accelYOffset; - accelSensorCalRecord.accelZOffset = calData.accelZOffset; - - return status; -} - -/*********************************************************************//** - * @brief * The calcVectorLength function calculates the length of a vector with * given vector axis magnitudes. * @details Inputs: none @@ -660,13 +616,7 @@ { case ACCELEROMETER_SELF_TEST_STATE_START: { -#ifdef _HD_ - HD_ACCELEROMETER_SENSOR_CAL_RECORD_T cal = getHDAccelerometerSensorCalibrationRecord(); -#endif -#ifdef _DG_ - DG_ACCEL_SENSOR_CAL_RECORD_T cal = getDGAccelerometerSensorCalibrationRecord(); -#endif - BOOL calStatus = processCalibrationData(); + BOOL calStatus = getNVRecord2Driver( GET_CAL_ACCEL_SENSORS, (U08*)&accelSensorCalRecord, sizeof( accelSensorCalRecord ), 0, CAL_ALARM ); if ( FALSE == calStatus ) { Index: NVDataMgmt.c =================================================================== diff -u -r1797ae184a55396ff3464cead47f16bac9dda84c -rf853004049bc4701d911701e48768cd17189faea --- NVDataMgmt.c (.../NVDataMgmt.c) (revision 1797ae184a55396ff3464cead47f16bac9dda84c) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision f853004049bc4701d911701e48768cd17189faea) @@ -20,8 +20,8 @@ #include // For memcpy #include // For ceilf function -#include "system.h" -#include "F021.h" +#include "system.h" // For fapi operations +#include "F021.h" // For fapi operations #include "MsgQueues.h" #include "NVDataMgmt.h" @@ -1283,6 +1283,11 @@ for ( i = 0; i < NUM_OF_CAL_DATA_HD_TEMP_SENSORS; i++ ) isNVDataValid |= ( 0 == hdCalibrationRecord.hdCalibrationGroups.tempSensorsCalRecord.hdTemperatureSensors[ i ].calibrationTime ? FALSE : TRUE ); break; + + case GET_CAL_ACCEL_SENSORS: + nvDataStartPtr = (U08*)&hdCalibrationRecord.hdCalibrationGroups.accelerometerSensorCalRecord; + isNVDataValid = ( 0 == hdCalibrationRecord.hdCalibrationGroups.accelerometerSensorCalRecord.calibrationTime ? FALSE : TRUE ); + break; #endif #ifdef _DG_ @@ -1321,10 +1326,46 @@ isNVDataValid |= ( 0 == dgCalibrationRecord.dgCalibrationGroups.bicarbConcentratesRecord.bicarbConcentrate[ i ].calibrationTime ? FALSE : TRUE ); break; + case GET_CAL_ACCEL_SENSORS: + nvDataStartPtr = (U08*)&dgCalibrationRecord.dgCalibrationGroups.accelerometerSensorCalRecord; + isNVDataValid = ( 0 == dgCalibrationRecord.dgCalibrationGroups.accelerometerSensorCalRecord.calibrationTime ? FALSE : TRUE ); + break; + + case GET_CAL_CONDUCTIVITY_SENSORS: + nvDataStartPtr = (U08*)&dgCalibrationRecord.dgCalibrationGroups.condSensorsCalRecord; + nvDataLength = sizeof( dgCalibrationRecord.dgCalibrationGroups.condSensorsCalRecord ); + for ( i = 0; i < numOfSnsrs2Check; i++ ) + isNVDataValid |= ( 0 == dgCalibrationRecord.dgCalibrationGroups.condSensorsCalRecord.condSensors[ i ].calibrationTime ? FALSE : TRUE ); + break; + + case GET_CAL_TEMP_SENSORS: + nvDataStartPtr = (U08*)&dgCalibrationRecord.dgCalibrationGroups.tempSensorsCalRecord; + nvDataLength = sizeof( dgCalibrationRecord.dgCalibrationGroups.tempSensorsCalRecord ); + for ( i = 0; i < numOfSnsrs2Check; i++ ) + isNVDataValid |= ( 0 == dgCalibrationRecord.dgCalibrationGroups.tempSensorsCalRecord.tempSensors[ i ].calibrationTime ? FALSE : TRUE ); + break; + + case GET_CAL_RSRVRS_VOL_RECORD: + nvDataStartPtr = (U08*)&dgCalibrationRecord.dgCalibrationGroups.reservoirVolumesRecord; + nvDataLength = sizeof( dgCalibrationRecord.dgCalibrationGroups.reservoirVolumesRecord ); + for ( i = 0; i < numOfSnsrs2Check; i++ ) + isNVDataValid |= ( 0 == dgCalibrationRecord.dgCalibrationGroups.reservoirVolumesRecord.reservoir[ i ].calibrationTime ? FALSE : TRUE ); + break; + case GET_INF_HEATERS_RECORD: nvDataStartPtr = (U08*)&dgHeatersInfoGroup.dgHeatersInfo; nvDataLength = sizeof( dgHeatersInfoGroup.dgHeatersInfo ); break; + + case GET_SYS_RECORD: + nvDataStartPtr = (U08*)&dgSystemGroup.dgSystemRecord; + nvDataLength = sizeof( dgSystemGroup.dgSystemRecord ); + break; + + case GET_SRV_RECORD: + nvDataStartPtr = (U08*)&dgServiceGroup.dgServiceRecord; + nvDataLength = sizeof( dgServiceGroup.dgServiceRecord ); + break; #endif } @@ -1360,32 +1401,6 @@ #ifdef _DG_ /*********************************************************************//** * @brief - * The getDGPressureSensorsCalibrationRecord function returns the DG pressure - * sensors record. - * @details Inputs: none - * @details Outputs: none - * @return DG pressure sensors calibration record - *************************************************************************/ -DG_PRES_SENSORS_CAL_RECORD_T getDGPressureSensorsCalibrationRecord( void ) -{ - return dgCalibrationRecord.dgCalibrationGroups.presSensorsCalRecord; -} - -/*********************************************************************//** - * @brief - * The getDGConducitivitySensorsCalibrationRecord function returns the DG - * conductivity sensors calibration record. - * @details Inputs: none - * @details Outputs: none - * @return DG conductivity sensors calibration record - *************************************************************************/ -DG_COND_SENSORS_CAL_RECORD_T getDGConducitivitySensorsCalibrationRecord( void ) -{ - return dgCalibrationRecord.dgCalibrationGroups.condSensorsCalRecord; -} - -/*********************************************************************//** - * @brief * The getDGROPumpRecord function returns the DG RO pump calibration record. * @details Inputs: none * @details Outputs: none @@ -1437,19 +1452,6 @@ /*********************************************************************//** * @brief - * The getDGPreROPurgeVolumeRecord function returns the DG pre RO purge - * volume record. - * @details Inputs: none - * @details Outputs: none - * @return DG pre RO purge volume record - *************************************************************************/ -DG_PRE_RO_PURGE_VOLUME_T getDGPreROPurgeVolumeRecord( void ) -{ - return dgCalibrationRecord.dgCalibrationGroups.preROPurgeVolumeRecord; -} - -/*********************************************************************//** - * @brief * The getDGReservoirsVolumeRecord function returns the DG reservoirs * volume record. * @details Inputs: none @@ -1487,43 +1489,6 @@ /*********************************************************************//** * @brief - * The getDGAccelerometerSensorCalibrationRecord function returns the DG - * accelerometer sensor calibration record. - * @details Inputs: none - * @details Outputs: none - * @return DG accelerometer sensor calibration record - *************************************************************************/ -DG_ACCEL_SENSOR_CAL_RECORD_T getDGAccelerometerSensorCalibrationRecord( void ) -{ - return dgCalibrationRecord.dgCalibrationGroups.accelerometerSensorCalRecord; -} - -/*********************************************************************//** - * @brief - * The getDGSystemRecord function returns the DG systems record. - * @details Inputs: none - * @details Outputs: none - * @return DG systems record - *************************************************************************/ -DG_SYSTEM_RECORD_T getDGSystemRecord( void ) -{ - return dgSystemGroup.dgSystemRecord; -} - -/*********************************************************************//** - * @brief - * The getDGServiceRecord function returns the DG service record. - * @details Inputs: none - * @details Outputs: none - * @return DG service record - *************************************************************************/ -DG_SERVICE_RECORD_T getDGServiceRecord( void ) -{ - return dgServiceGroup.dgServiceRecord; -} - -/*********************************************************************//** - * @brief * The getDGScheduledRunsRecord function returns the DG scheduled runs record. * @details Inputs: none * @details Outputs: none @@ -1629,19 +1594,6 @@ /*********************************************************************//** * @brief - * The getHDAccelerometerSensorCalibrationRecord function returns the HD - * accelerometer sensor calibration record. - * @details Inputs: none - * @details Outputs: none - * @return HD heparin force sensor calibration record - *************************************************************************/ -HD_ACCELEROMETER_SENSOR_CAL_RECORD_T getHDAccelerometerSensorCalibrationRecord( void ) -{ - return hdCalibrationRecord.hdCalibrationGroups.accelerometerSensorCalRecord; -} - -/*********************************************************************//** - * @brief * The getHDSystemRecord function returns the HD system record. * @details Inputs: none * @details Outputs: none Index: NVDataMgmt.h =================================================================== diff -u -r1797ae184a55396ff3464cead47f16bac9dda84c -rf853004049bc4701d911701e48768cd17189faea --- NVDataMgmt.h (.../NVDataMgmt.h) (revision 1797ae184a55396ff3464cead47f16bac9dda84c) +++ NVDataMgmt.h (.../NVDataMgmt.h) (revision f853004049bc4701d911701e48768cd17189faea) @@ -96,18 +96,13 @@ #ifdef _DG_ DG_TEMP_SENSORS_CAL_RECORD_T getDGTemperatureSensorsCalibrationRecord( void ); -DG_COND_SENSORS_CAL_RECORD_T getDGConducitivitySensorsCalibrationRecord( void ); DG_RO_PUMP_CAL_RECORD_T getDGROPumpRecord( void ); DG_CONC_PUMPS_CAL_RECORD_T getDGConcetnratePumpsRecord( void ); DG_DRAIN_PUMP_CAL_RECORD_T getDGDrainPumpRecord( void ); DG_DRAIN_LINE_VOLUME_T getDGDrainLineVolumeRecord( void ); DG_PRE_RO_PURGE_VOLUME_T getDGPreROPurgeVolumeRecord( void ); -DG_RESERVOIR_VOLUME_RECORD_T getDGReservoirsVolumeRecord( void ); DG_FILTERS_CAL_RECORD_T getDGFiltersRecord( void ); DG_FANS_CAL_RECORD_T getDGFansRecord( void ); -DG_ACCEL_SENSOR_CAL_RECORD_T getDGAccelerometerSensorCalibrationRecord( void ); -DG_SYSTEM_RECORD_T getDGSystemRecord( void ); -DG_SERVICE_RECORD_T getDGServiceRecord( void ); DG_SCHEDULED_RUN_RECORD_T getDGScheduledRunsRecord( void ); BOOL setWaterConsumption ( U32 liters ); U32 getWaterConsumption ( void ); @@ -121,7 +116,6 @@ HD_PRESSURE_SENSORS_CAL_RECORD_T getHDPressureSensorsCalibrationRecord( void ); HD_TEMP_SENSORS_CAL_RECORD_T getHDTemperatureSensorsCalibrationRecord( void ); HD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T getHDHeparinForceSensorCalibrationRecord( void ); -HD_ACCELEROMETER_SENSOR_CAL_RECORD_T getHDAccelerometerSensorCalibrationRecord( void ); HD_SYSTEM_RECORD_T getHDSystemRecord( void ); HD_SERVICE_RECORD_T getHDServiceRecord( void ); BOOL setTreatmentTime ( U32 hours ); Index: NVDataMgmtDGRecords.h =================================================================== diff -u -r1797ae184a55396ff3464cead47f16bac9dda84c -rf853004049bc4701d911701e48768cd17189faea --- NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision 1797ae184a55396ff3464cead47f16bac9dda84c) +++ NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision f853004049bc4701d911701e48768cd17189faea) @@ -34,6 +34,26 @@ #define MAX_TOP_LEVEL_PN_CHARS 10U ///< Max number of characters for top level part number. #define MAX_TOP_LEVEL_SN_CHARS 15U ///< Max number of characters for top level serial number. +// TODO this might need to be removed +typedef enum build_switches +{ + // Anything else other than build switches name? + BUILD_SWITCH_IGNORE_HEATERS_MONITOR = 0, + BUILD_SWITCH_THD_USING_TRO_CONNECTOR, + BUILD_SWITCH_DISABLE_ALL_SWITHCES, + NUM_OF_BUILD_SWITCHES +} BUILD_SWITHCES_T; + +// This function only returns a 1 or a 0. +//U08 getSwitchStatus( BUILD_SWITHCES_T switchName ); + +typedef struct +{ + U08 switchesList[ NUM_OF_BUILD_SWITCHES ]; + U16 crc; +} STUFF_STUFF_T; +// TODO this might need to be removed + /// DG available NV data to get typedef enum dg_nv_commands { @@ -42,8 +62,11 @@ GET_CAL_FLOW_SENSORS, ///< Get flow sensors calibration data. GET_CAL_ACID_CONCENTREATES, ///< Get acid concentrates calibration data. GET_CAL_BICARB_CONCENTRATES, ///< Get bicarb concentrates calibration data. + GET_CAL_ACCEL_SENSORS, ///< Get accelerometers calibration data. + GET_CAL_CONDUCTIVITY_SENSORS, ///< Get conductivity sensors calibration data. + GET_CAL_TEMP_SENSORS, ///< Get temperature sensors calibration data. + GET_CAL_RSRVRS_VOL_RECORD, ///< Get reservoirs volume record. GET_INF_HEATERS_RECORD, ///< Get heaters information form the the last run. - GET_MFG_RECORD, ///< Get manufacturing record. GET_SYS_RECORD, ///< Get system record. GET_SRV_RECORD, ///< Get service record. GET_SRR_RECORD, ///< Get scheduled runs record. @@ -414,6 +437,17 @@ { F32 averageFillFlow; ///< Average fill flow rate. } DG_HEATERS_RECORD_T; + +/// DG reservoir and ultrafilter Tau and ultrafilter volume +typedef struct +{ + F32 reservoirTempTauCPerMin; ///< Reservoir temperature Tau C/min. + F32 ultrafilterTempTauCPerMin; ///< Ultrafilter temperature Tau C/min. + U32 ultrafilterVolmL; ///< Ultrafilter volume in mL. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the reservoirs and UF record. +} DG_RSRVRS_AND_UF_CAL_RECORD_T; + #pragma pack(pop) /**@}*/ Index: NVDataMgmtHDRecords.h =================================================================== diff -u -r1797ae184a55396ff3464cead47f16bac9dda84c -rf853004049bc4701d911701e48768cd17189faea --- NVDataMgmtHDRecords.h (.../NVDataMgmtHDRecords.h) (revision 1797ae184a55396ff3464cead47f16bac9dda84c) +++ NVDataMgmtHDRecords.h (.../NVDataMgmtHDRecords.h) (revision f853004049bc4701d911701e48768cd17189faea) @@ -40,6 +40,7 @@ { GET_CAL_BLOOD_LEAK_SENSOR = 0, ///< Get blood leak sensor calibration data. GET_CAL_TEMPERATURE_SESNORS, ///< Get temperature sensors calibration data. + GET_CAL_ACCEL_SENSORS, ///< Get accelerometers calibration data. NUM_OF_NV_HD_DATA ///< Number of non-volatile data. } NV_DATA_T;