Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -re86af65442a36724461317980814f0868bd8c995 -r3d131237935eb36e56e0d057a713430e31dc6405 --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision e86af65442a36724461317980814f0868bd8c995) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 3d131237935eb36e56e0d057a713430e31dc6405) @@ -129,23 +129,31 @@ { case DG_RESERVOIR_1: activeReservoir.data = (U32)resID; - cmdResponse.rejected = FALSE; - setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); + cmdResponse.rejected = FALSE; + setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); +#ifndef V_2_SYSTEM + setValveState( VRD1, VALVE_STATE_OPEN ); +#else setValveState( VRD, VALVE_STATE_R2_C_TO_NO ); - setValveState( VRO, VALVE_STATE_R1_C_TO_NO ); - setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); - break; - - case DG_RESERVOIR_2: +#endif + setValveState( VRO, VALVE_STATE_R1_C_TO_NO ); + setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); + break; + + case DG_RESERVOIR_2: activeReservoir.data = (U32)resID; - cmdResponse.rejected = FALSE; - setValveState( VRF, VALVE_STATE_R1_C_TO_NC ); + cmdResponse.rejected = FALSE; + setValveState( VRF, VALVE_STATE_R1_C_TO_NC ); +#ifndef V_2_SYSTEM + setValveState( VRD2, VALVE_STATE_OPEN ); +#else setValveState( VRD, VALVE_STATE_R1_C_TO_NC ); - setValveState( VRO, VALVE_STATE_R2_C_TO_NC ); - setValveState( VRI, VALVE_STATE_R2_C_TO_NC ); - break; - - default: +#endif + setValveState( VRO, VALVE_STATE_R2_C_TO_NC ); + setValveState( VRI, VALVE_STATE_R2_C_TO_NC ); + break; + + default: // invalid reservoir given - cmd will be NAK'd w/ false result. cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_INVALID_PARAMETER; break; @@ -438,20 +446,7 @@ { BOOL result = FALSE; - F32 loadcellWeight = 0.0; - - // TODO remove this code once the load cell is repaired - if ( DG_RESERVOIR_1 == reservoirId ) - { - loadcellWeight = getLoadCellSmallFilteredWeight( LOAD_CELL_RESERVOIR_1_BACKUP ); - } - else - { - loadcellWeight = getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ); - } - // TODO remove the above code the load cell is repaired - - //F32 const loadcellWeight = getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ); + F32 const loadcellWeight = getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ); U32 const targetDrainVolume = getReservoirDrainVolumeTargetMl(); if ( loadcellWeight < reservoirLowestWeight[ reservoirId ] ) @@ -463,12 +458,15 @@ BOOL const hasTimeOut = didTimeout( reservoirWeightUnchangeStartTime[ reservoirId ], timeout ); BOOL const hasTargetReached = ( targetDrainVolume >= loadcellWeight ); - if ( hasTimeOut || hasTargetReached ) + // If the goal is to tare the load cell, then the target drain should be reached and timing out on the + // reservoir weight is not enough + if ( ( TRUE == hasTimeOut ) || ( ( TRUE == hasTargetReached ) && ( FALSE == tareLoadCellRequest ) ) ) { result = TRUE; + // Reset for next drain reservoirLowestWeight[ reservoirId ] = MAX_RESERVOIR_WEIGHT; - if ( tareLoadCellRequest ) + if ( TRUE == tareLoadCellRequest ) { tareLoadCellRequest = FALSE; tareLoadCell( associatedLoadCell[ reservoirId ] ); @@ -481,6 +479,38 @@ /*********************************************************************//** * @brief + * The tareLoadCellsAtEmpty function tares the load cells for the given + * reservoir when empty and tare request is pending. + * @details Inputs: tareLoadCellRequest + * @details Outputs: tareLoadCellRequest + * @param reservoirId ID of reservoir to tare + * @return none + *************************************************************************/ +void tareLoadCellsAtEmpty( DG_RESERVOIR_ID_T reservoirId ) +{ + if ( TRUE == tareLoadCellRequest ) + { + tareLoadCellRequest = FALSE; + tareLoadCell( associatedLoadCell[ reservoirId ] ); + tareLoadCell( redundantLoadCell[ reservoirId ] ); + } +} + +/*********************************************************************//** + * @brief + * The isReservoirTarePending function determines whether a reservoir tare + * request is currently pending. + * @details Inputs: tareLoadCellRequest + * @details Outputs: none + * @return tareLoadCellRequest + *************************************************************************/ +BOOL isReservoirTarePending( void ) +{ + return tareLoadCellRequest; +} + +/*********************************************************************//** + * @brief * The getActiveReservoir function gets the active reservoir. * @details Inputs: activeReservoir * @details Outputs: none