Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r945dcc1391faefe5f4ddb4f505361501d008e293 -r62ee40b55ed96eb0de1c0f05455eb986f76c1842 --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 945dcc1391faefe5f4ddb4f505361501d008e293) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 62ee40b55ed96eb0de1c0f05455eb986f76c1842) @@ -41,7 +41,9 @@ #define MAX_FILL_VOLUME_ML MAX_RESERVOIR_VOLUME_ML ///> Maximum fill volume in mL. #define DEFAULT_DRAIN_VOLUME_ML 100 ///> Default drain volume in mL. #define MAX_DRAIN_VOLUME_ML MAX_RESERVOIR_VOLUME_ML ///> Maximum drain volume in mL. -#define MIN_DRAIN_VOLUME_ML 100 ///> Minimum drain volume in mL. +#define MIN_DRAIN_VOLUME_ML 100 ///> Minimum drain volume in mL. + +#define MAX_RESERVOIR_WEIGHT 10000 ///> Maximum reservoir weight in grams. #define RESERVOIR_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the reservoir data is published on the CAN bus. @@ -53,13 +55,13 @@ static OVERRIDE_U32_T fillVolumeTargetMl = { 0, 0, 0, 0 }; ///< The target reservoir fill volume (in mL). static OVERRIDE_U32_T drainVolumeTargetMl = { 0, 0, 0, 0 }; ///< The target reservoir drain volume (in mL). -static LOAD_CELL_ID_T associateLoadCell[ NUM_OF_RESERVOIRS ] = { LOAD_CELL_A1, - LOAD_CELL_B1 }; ///< The reservoirs' associate load cell. +static LOAD_CELL_ID_T associatedLoadCell[ NUM_OF_RESERVOIRS ] = { LOAD_CELL_A1, + LOAD_CELL_B1 }; ///< The reservoirs' associate load cell. static LOAD_CELL_ID_T redundantLoadCell[ NUM_OF_RESERVOIRS ] = { LOAD_CELL_A2, LOAD_CELL_B2 }; ///< The reservoirs' associate redundant load cell. -static F32 reservoirLowestWeight[ NUM_OF_RESERVOIRS ] = { MAX_RESERVOIR_VOLUME_ML, - MAX_RESERVOIR_VOLUME_ML }; ///< The reservoirs' lowest weight during draining. +static F32 reservoirLowestWeight[ NUM_OF_RESERVOIRS ] = { MAX_RESERVOIR_WEIGHT, + MAX_RESERVOIR_WEIGHT }; ///< The reservoirs' lowest weight during draining. static U32 reservoirWeightUnchangeStartTime[ NUM_OF_RESERVOIRS ] = { 0, 0 }; ///< The reservoirs' weight start time when weight stop decreasing. static BOOL tareLoadCellRequest; ///< Flag indicates if load cell tare has been requested by HD. @@ -314,12 +316,11 @@ * @param reservoirId reservoir id * @return TRUE if target fill volume has been reached, FALSE if not. *************************************************************************/ -BOOL hasTargetFillVolumeReached( RESERVOIR_ID_T reservoirId ) +BOOL hasTargetFillVolumeBeenReached( RESERVOIR_ID_T reservoirId ) { - F32 const loadcellWeight = getLoadCellFilteredWeight( associateLoadCell[ reservoirId ] ); - F32 const redundantLoadcellWeight = getLoadCellFilteredWeight( redundantLoadCell[ reservoirId ] ); + F32 const loadcellWeight = getLoadCellFilteredWeight( associatedLoadCell[ reservoirId ] ); U32 const targetFillVolume = getReservoirFillVolumeTargetMl(); - BOOL const hasTargetReached = ( loadcellWeight >= targetFillVolume ) || ( redundantLoadcellWeight >= targetFillVolume ); + BOOL const hasTargetReached = ( loadcellWeight >= targetFillVolume ); return hasTargetReached; } @@ -334,31 +335,30 @@ * @param timeout timeout period when weight remains the same * @return TRUE if target drain volume has been reached or exceeds time limit, FALSE if not. *************************************************************************/ -BOOL hasTargetDrainVolumeReached( RESERVOIR_ID_T reservoirId, U32 timeout ) +BOOL hasTargetDrainVolumeBeenReached( RESERVOIR_ID_T reservoirId, U32 timeout ) { BOOL result = FALSE; - F32 const loadcellWeight = getLoadCellFilteredWeight( associateLoadCell[ reservoirId ] ); - F32 const redundantLoadcellWeight = getLoadCellFilteredWeight( redundantLoadCell[ reservoirId ] ); + F32 const loadcellWeight = getLoadCellFilteredWeight( associatedLoadCell[ reservoirId ] ); U32 const targetDrainVolume = getReservoirDrainVolumeTargetMl(); - if ( ( loadcellWeight < reservoirLowestWeight[ reservoirId ] ) || ( redundantLoadcellWeight < reservoirLowestWeight[ reservoirId ] ) ) + if ( loadcellWeight < reservoirLowestWeight[ reservoirId ] ) { - reservoirLowestWeight[ reservoirId ] = loadcellWeight < redundantLoadcellWeight ? loadcellWeight : redundantLoadcellWeight; + reservoirLowestWeight[ reservoirId ] = loadcellWeight; reservoirWeightUnchangeStartTime[ reservoirId ] = getMSTimerCount(); } BOOL const hasTimeOut = didTimeout( reservoirWeightUnchangeStartTime[ reservoirId ], timeout ); - BOOL const hasTargetReached = ( targetDrainVolume >= loadcellWeight ) || ( targetDrainVolume >= redundantLoadcellWeight ); + BOOL const hasTargetReached = ( targetDrainVolume >= loadcellWeight ); if ( hasTimeOut || hasTargetReached ) { result = TRUE; - reservoirLowestWeight[ reservoirId ] = MAX_RESERVOIR_VOLUME_ML; + reservoirLowestWeight[ reservoirId ] = MAX_RESERVOIR_WEIGHT; if ( tareLoadCellRequest ) { tareLoadCellRequest = FALSE; - tareLoadCell( associateLoadCell[ reservoirId ] ); + tareLoadCell( associatedLoadCell[ reservoirId ] ); tareLoadCell( redundantLoadCell[ reservoirId ] ); } } @@ -377,7 +377,7 @@ *************************************************************************/ void resetReservoirLoadCellsOffset( RESERVOIR_ID_T reservoirId ) { - resetLoadCellOffset( associateLoadCell[ reservoirId ] ); + resetLoadCellOffset( associatedLoadCell[ reservoirId ] ); resetLoadCellOffset( redundantLoadCell[ reservoirId ] ); }