Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -rccfd15568f1e3d304320c2babb2fd4bcf0413304 -r8bd1ae47aa13a843aa8abd6321ddc050deacb4a6 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision ccfd15568f1e3d304320c2babb2fd4bcf0413304) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 8bd1ae47aa13a843aa8abd6321ddc050deacb4a6) @@ -79,7 +79,6 @@ static U32 resMgmtTimer = 0; ///< Used for keeping state time. // DG sensor data -static F32 dgPressures[ NUM_OF_DG_PRESSURE_SENSORS ]; ///< Latest pressures reported by the DG. static F32 dgDialysateTemp = 0.0; ///< Dialysate temperature reported by the DG. static F32 dgRedundantDialysateTemp = 0.0; ///< Redundant dialysate temperature reported by the DG. static F32 dgPrimaryTempSet = 0.0; ///< Primary heater target temperature commanded. @@ -98,11 +97,10 @@ static U32 lgLoadCellReadingsIdx = 0; ///< Index for next sample in large load cell rolling average sample array. static F32 lgLoadCellReadingsTotal[ NUM_OF_DG_RESERVOIRS ]; ///< Rolling total - used to calc large load cell moving average. -// DG pumps data -static F32 dgROPumpFlowRateMlMin = 0.0; ///< Latest RO water flow rate reported by the DG. -static U32 dgROPumpPressureSetPtPSI = 0; ///< Latest RO pump target pressure reported by the DG. -static U32 dgDrainPumpSpeedSetPtRPM = 0; ///< Latest Drain pump target speed reported by the DG. - +// DG Dialysate flow rate +static F32 dgDialysateFlowRateMlMin = 0.0; ///< Latest dialysate flow rate reported by the DG. +static BOOL dgDialysateFlowDataFreshFlag = FALSE; ///< Flag to signal the execDialInFlowMonitor() to process fresh flow rate data + // Reservoir data static DG_RESERVOIR_ID_T dgActiveReservoir = DG_RESERVOIR_2; ///< Latest active reservoir reported by the DG. static DG_RESERVOIR_ID_T dgActiveReservoirSet = DG_RESERVOIR_2; ///< Active reservoir commanded. @@ -138,7 +136,7 @@ dgTrimmerTempSet = 0.0; dgActiveReservoirSet = DG_RESERVOIR_2; dgReservoirFillVolumeTargetSet = 0; - dgReservoirDrainVolumeTargetSet = 0; + dgReservoirDrainVolumeTargetSet = 0; // initialize load cell weights for ( i = 0; i < NUM_OF_LOAD_CELLS; i++ ) @@ -267,7 +265,7 @@ { if ( DG_GEN_IDLE_MODE_STATE_FLUSH_WATER == dgSubMode ) { - cmdStartDGDrain( DRAIN_RESERVOIR_TO_VOLUME_ML, TRUE ); + cmdStartDGDrain( DRAIN_RESERVOIR_TO_VOLUME_ML, TRUE, FALSE, TRUE ); } } else if ( DG_MODE_DRAI == dgOpMode ) @@ -430,76 +428,38 @@ return ( dgActiveReservoir == dgActiveReservoirSet ); } -/*********************************************************************//** - * @brief - * The getDGPressure function gets the latest pressure reported by the DG - * for a given pressure sensor. - * @details Inputs: dgPressures[] - * @details Outputs: none - * @param sensorID pressure sensor we are getting reading for - * @return Latest pressure reading reported by DG for the given sensor. - *************************************************************************/ -F32 getDGPressure( DG_PRESSURE_SENSORS_T sensorID ) -{ - F32 result = 0.0; - - if ( sensorID < NUM_OF_DG_PRESSURE_SENSORS ) - { - result = dgPressures[ sensorID ]; - } - else - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_DG_PRESSURE_ID, sensorID ) - } - - return result; +/*********************************************************************//** + * @brief + * The getDGDialysateFlowRateLMin function gets the latest dialysate flow + * rate reported by the DG. + * @details Inputs: dgDialysateFlowRateMlMin + * @details Outputs: none + * @return Latest dialysate flow rate (in L/min) reported by DG. + *************************************************************************/ +F32 getDGDialysateFlowRateLMin( void ) +{ + F32 result = dgDialysateFlowRateMlMin; + + return result; } + +/*********************************************************************//** + * @brief + * The getDialysateFlowDataFreshFlag function returns a flag to indicate + * if the dialysate flow rate data reported by the DG is fresh or stale data. + * @details Inputs: dgDialysateFlowDataFreshFlag + * @details Outputs: dgDialysateFlowDataFreshFlag + * @return T/F flag to indicate fresh/stale status of dialysate flow data. + *************************************************************************/ +BOOL getDialysateFlowDataFreshFlag( void ) +{ + BOOL result = dgDialysateFlowDataFreshFlag; + + dgDialysateFlowDataFreshFlag = FALSE; + + return result; +} -/*********************************************************************//** - * @brief - * The getDGROPumpPressureSetPt function gets the latest RO pump - * pressure set point reported by the DG. - * @details Inputs: dgROPumpPressureSetPtPSI - * @details Outputs: none - * @return Latest RO pump pressure set point reported by DG. - *************************************************************************/ -U32 getDGROPumpPressureSetPt( void ) -{ - U32 result = dgROPumpPressureSetPtPSI; - - return result; -} - -/*********************************************************************//** - * @brief - * The getDGROPumpFlowRateMlMin function gets the latest RO pump flow - * rate reported by the DG. - * @details Inputs: dgROPumpFlowRateMlMin - * @details Outputs: none - * @return Latest RO pump flow rate reported by DG. - *************************************************************************/ -F32 getDGROPumpFlowRateMlMin( void ) -{ - F32 result = dgROPumpFlowRateMlMin; - - return result; -} - -/*********************************************************************//** - * @brief - * The getDGDrainPumpRPMSetPt function gets the latest drain pump RPM - * set point reported by the DG. - * @details Inputs: dgDrainPumpSpeedSetPtRPM - * @details Outputs: none - * @return Latest drain pump RPM set point reported by DG. - *************************************************************************/ -U32 getDGDrainPumpRPMSetPt( void ) -{ - U32 result = dgDrainPumpSpeedSetPtRPM; - - return result; -} - /*********************************************************************//** * @brief * The getLoadCellWeight function gets the current load cell weight. @@ -671,56 +631,24 @@ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_INVALID_RESERVOIR_ID, resID ); } } - -/*********************************************************************//** - * @brief - * The setDGPressures function sets the latest pressures reported by the DG. - * @details Inputs: none - * @details Outputs: dgPressures[] - * @param roIn latest RO pump inlet pressure reported by DG - * @param roOut latest RO pump outlet pressure reported by DG - * @param drainIn latest drain pump inlet pressure reported by DG - * @param drainOut latest drain pump outlet pressure reported by DG - * @return none - *************************************************************************/ -void setDGPressures( F32 roIn, F32 roOut, F32 drainIn, F32 drainOut ) -{ - dgPressures[ DG_PRESSURE_SENSOR_RO_PUMP_INLET ] = roIn; - dgPressures[ DG_PRESSURE_SENSOR_RO_PUMP_OUTLET ] = roOut; - dgPressures[ DG_PRESSURE_SENSOR_DRAIN_PUMP_INLET ] = drainIn; - dgPressures[ DG_PRESSURE_SENSOR_DRAIN_PUMP_OUTLET ] = drainOut; -} - -/*********************************************************************//** - * @brief - * The setDGROPumpData function sets the latest RO pump data reported by the DG. - * @details Inputs: none - * @details Outputs: dgROPumpPressureSetPtPSI, dgROPumpFlowRateMlMin - * @param presSetPt latest RO pump pressure set point reported by DG - * @param flowRate latest RO pump flow rate (LPM) reported by DG - * @return none - *************************************************************************/ -void setDGROPumpData( U32 presSetPt, F32 flowRate ) -{ - dgROPumpPressureSetPtPSI = presSetPt; - dgROPumpFlowRateMlMin = flowRate * ML_PER_LITER; -} - -/*********************************************************************//** - * @brief - * The setDGDrainPumpData function sets the latest drain pump data reported by the DG. - * @details Inputs: none - * @details Outputs: dgDrainPumpSpeedSetPtRPM - * @param rpmSetPt latest drain pump RPM set point reported by DG - * @return none - *************************************************************************/ -void setDGDrainPumpData( U32 rpmSetPt ) -{ - dgDrainPumpSpeedSetPtRPM = rpmSetPt; -} - + /*********************************************************************//** * @brief + * The setDialysateFlowData function sets the latest dialysate flow rate + * and its freshness status. The dialysate flow data is reported by the DG. + * @details Inputs: none + * @details Outputs: dgDialysateFlowRateMlMin + * @param flowRate latest dialysate flow rate (mL/min) reported by DG + * @return none + *************************************************************************/ +void setDialysateFlowData( F32 flowRate ) +{ + dgDialysateFlowRateMlMin = flowRate; + dgDialysateFlowDataFreshFlag = TRUE; +} + +/*********************************************************************//** + * @brief * The setNewLoadCellReadings function sets the latest DG reservoir load cell * readings sent by the DG (in g or mL). New readings are expected once * every 100 ms. @@ -802,7 +730,7 @@ { dgStartCommandSent = TRUE; - sendDGStartStopCommand( START_DG_CMD ); + sendDGStartStopCommand( (BOOL)START_DG_CMD ); } /*********************************************************************//** @@ -817,7 +745,7 @@ { dgStarted = FALSE; - sendDGStartStopCommand( STOP_DG_CMD ); + sendDGStartStopCommand( (BOOL)STOP_DG_CMD ); } /*********************************************************************//** @@ -936,16 +864,19 @@ * @details Inputs: none * @details Outputs: drain command sent to DG. * @param drainToVolMl volume (in mL) to drain inactive reservoir to - * @param tareLoadCell flag to tell DG tare load cell or not + * @param tareLoadCell flag to tell DG tare load cell or not + * @param start flag to tell DG to start or stop the drain mode * @return none *************************************************************************/ -void cmdStartDGDrain( U32 drainToVolMl, BOOL tareLoadCell ) +void cmdStartDGDrain( U32 drainToVolMl, BOOL tareLoadCell, BOOL rinse, BOOL start ) { DRAIN_RESERVOIR_CMD_PAYLOAD_T payload; dgCmdResp[ DG_CMD_START_DRAIN ].commandID = DG_CMD_NONE; payload.drainToVolumeML = drainToVolMl; - payload.tareLoadCells = tareLoadCell; + payload.tareLoadCells = tareLoadCell; + payload.rinseConcentrateLines = rinse; + payload.cmd = start; dgReservoirDrainVolumeTargetSet = drainToVolMl; sendDGDrainCommand( &payload );