Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r9a45dcbdfae33fc06479d99b8d52bada8f682194 -rc7890e8beda1708d2dea0762dcc40ca5a12222e3 --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 9a45dcbdfae33fc06479d99b8d52bada8f682194) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision c7890e8beda1708d2dea0762dcc40ca5a12222e3) @@ -25,12 +25,10 @@ #define MAX_RESERVOIR_DEPLETION_TIME_MS ( 30 * SEC_PER_MIN * MS_PER_SECOND ) ///< Maximum allowed depletion time in milliseconds. #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. -#define DIALYSATE_FLOW_RATE_100_ML_PER_MIN 0.1 ///< Dialysate flow rate 100 mL/min. #define DIALYSATE_FLOW_RATE_350_ML_PER_MIN 0.35 ///< Dialysate flow rate 350 mL/min. #define DIALYSATE_FLOW_RATE_400_ML_PER_MIN 0.4 ///< Dialysate flow rate 400 mL/min. #define DIALYSATE_FLOW_RATE_500_ML_PER_MIN 0.5 ///< Dialysate flow rate 500 mL/min. #define DIALYSATE_FLOW_RATE_550_ML_PER_MIN 0.55 ///< Dialysate flow rate 550 mL/min. -#define DIALYSATE_FLOW_RATE_600_ML_PER_MIN 0.6 ///< Dialysate flow rate 600 mL/min. #define TGT_FILL_FLOW_FOR_DIA_FLOW_100_TO_350_ML_PER_MIN 0.5 ///< Target fill flow rate for dialysate flow rates in between 100 to 350 mL/min. #define TGT_FILL_FLOW_FOR_DIA_FLOW_550_TO_600_ML_PER_MIN 0.8 ///< Target fill flow rate for dialysate flow rates in between 500 to 600 mL/min. @@ -56,7 +54,6 @@ static TREATMENT_RESERVOIR_MGMT_STATE_T reservoirsState; ///< Treatment mode's reservoirs state. static U32 timeStartMS = 0; ///< Active reservoir start time in milliseconds. static U32 timeDepleteMS = 0; ///< Active reservoir depletion time in milliseconds. -static F32 volTotalML = 0.0; ///< Active reservoir total volume in milliliters. static F32 volSpentML = 0.0; ///< Active reservoir spent volume in milliliters. static U32 reservoirPublicationCounter = 0; ///< Reservoirs data publication timer counter. static F32 dilutionLevel = 0.0; @@ -103,7 +100,6 @@ reservoirsState = TREATMENT_RESERVOIR_MGMT_START_STATE; timeStartMS = 0; timeDepleteMS = 0; - volTotalML = 0.0; volSpentML = 0.0; reservoirPublicationCounter = 0; } @@ -224,23 +220,20 @@ F32 dialysateFlow = getDGDialysateFlowRateLMin(); - if ( ( dialysateFlow >= DIALYSATE_FLOW_RATE_100_ML_PER_MIN ) && ( dialysateFlow <= DIALYSATE_FLOW_RATE_350_ML_PER_MIN ) ) + if ( dialysateFlow <= DIALYSATE_FLOW_RATE_350_ML_PER_MIN ) { fillFlowRate = TGT_FILL_FLOW_FOR_DIA_FLOW_100_TO_350_ML_PER_MIN; } else if ( ( dialysateFlow >= DIALYSATE_FLOW_RATE_400_ML_PER_MIN ) && ( dialysateFlow <= DIALYSATE_FLOW_RATE_500_ML_PER_MIN ) ) { + // fill flow = 10 x dialysate_flow ^ 2 - 7.5 x dialysate_flow + 2.0 fillFlowRate = pow( dialysateFlow, 2 ) * DIA_FLOW_TO_FILL_FLOW_SECOND_ORDER_COEFF - dialysateFlow * DIA_FLOW_TO_FILL_FLOW_FIRST_ORDER_COEFF + DIA_FLOW_TO_FILL_FLOW_CONSTANT; } - else if ( ( dialysateFlow >= DIALYSATE_FLOW_RATE_550_ML_PER_MIN ) && ( dialysateFlow <= DIALYSATE_FLOW_RATE_600_ML_PER_MIN ) ) + else if ( dialysateFlow >= DIALYSATE_FLOW_RATE_550_ML_PER_MIN ) { fillFlowRate = TGT_FILL_FLOW_FOR_DIA_FLOW_550_TO_600_ML_PER_MIN; } - else - { - // TODO fault if the flow is not in range? - } return fillFlowRate; }