Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r7c8ec681f8c5dc44674893b5c3924a6203f2c8d0 -r8e7158d8231435496fcf1d5649e51babf859ccc7 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 7c8ec681f8c5dc44674893b5c3924a6203f2c8d0) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 8e7158d8231435496fcf1d5649e51babf859ccc7) @@ -1,18 +1,19 @@ -/**********************************************************************//** - * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN - * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * @file DGInterface.c - * - * @date 08-Apr-2020 - * @author S. Nash - * - * @brief Interfaces with and monitors the DG sub-system. - * - **************************************************************************/ +/************************************************************************** +* +* Copyright (c) 2019-2021 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file DGInterface.c +* +* @author (last) Sean Nash +* @date (last) 13-Nov-2020 +* +* @author (original) Sean +* @date (original) 08-Apr-2020 +* +***************************************************************************/ #include "DialInFlow.h" #include "ModeTreatment.h" @@ -90,9 +91,8 @@ /*********************************************************************//** * @brief * The initDGInterface function initializes the DGInterface module. - * @details - * Inputs : none - * Outputs : DGInterface module initialized. + * @details Inputs: none + * @details Outputs: DGInterface module initialized. * @return none *************************************************************************/ void initDGInterface( void ) @@ -109,11 +109,10 @@ /*********************************************************************//** * @brief - * The initTreatmentReservoirMgmt function initializes the treatment reservoir \n + * The initTreatmentReservoirMgmt function initializes the treatment reservoir * management state machine. - * @details - * Inputs : none - * Outputs : treatment reservoir management state machine initialized. + * @details Inputs: none + * @details Outputs: treatment reservoir management state machine initialized. * @return none *************************************************************************/ void initTreatmentReservoirMgmt( void ) @@ -126,11 +125,10 @@ /*********************************************************************//** * @brief - * The execTreatmentReservoirMgmt function executes the state machine for the \n + * The execTreatmentReservoirMgmt function executes the state machine for the * reservoir management during treatment mode. - * @details - * Inputs : none - * Outputs : DG reservoirs (drains & fills) managed. + * @details Inputs: none + * @details Outputs: DG reservoirs (drains & fills) managed. * @return none *************************************************************************/ void execTreatmentReservoirMgmt( void ) @@ -140,8 +138,11 @@ U32 msSinceLastVolumeCalc = calcTimeSince( resUseTimer ); F32 flowRateMlPerMs = (F32)getTargetDialInFlowRate() / (F32)( MS_PER_SECOND * SEC_PER_MIN ); - // calculate volume used from active reservoir - resUseVolumeMl += ( flowRateMlPerMs * msSinceLastVolumeCalc ); // TODO - should this calc be done and kept by Dialysis sub-mode? + // calculate volume used from active reservoir - do not accumulate if saline bolus in progress + if ( SALINE_BOLUS_STATE_IN_PROGRESS != getSalineBolusState() ) + { + resUseVolumeMl += ( flowRateMlPerMs * msSinceLastVolumeCalc ); // TODO - should this calc be done and kept by Dialysis sub-mode? + } resUseTimer = getMSTimerCount(); // treatment reservoir mgmt. state machine @@ -255,9 +256,8 @@ /*********************************************************************//** * @brief * The getDGOpMode function gets the current DG operating mode. - * @details - * Inputs : dgCurrentOpMode - * Outputs : none + * @details Inputs: dgCurrentOpMode + * @details Outputs: none * @return Current DG operating mode. *************************************************************************/ DG_OP_MODE_T getDGOpMode( void ) @@ -268,9 +268,8 @@ /*********************************************************************//** * @brief * The getDGSubMode function gets the current DG operating sub-mode. - * @details - * Inputs : dgSubMode - * Outputs : none + * @details Inputs: dgSubMode + * @details Outputs: none * @return Current DG operating sub-mode. *************************************************************************/ U32 getDGSubMode( void ) @@ -281,9 +280,8 @@ /*********************************************************************//** * @brief * The getDGActiveReservoir function gets the current active reservoir. - * @details - * Inputs : dgActiveReservoirSet - * Outputs : none + * @details Inputs: dgActiveReservoirSet + * @details Outputs: none * @return Currently commanded active reservoir. *************************************************************************/ DG_RESERVOIR_ID_T getDGActiveReservoir( void ) @@ -293,12 +291,11 @@ /*********************************************************************//** * @brief - * The getDGPressure function gets the latest pressure reported by the DG \n + * The getDGPressure function gets the latest pressure reported by the DG * for a given pressure sensor. - * @details - * Inputs : dgPressures[] - * Outputs : none - * @param sensorID : pressure sensor we are getting reading for. + * @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 ) @@ -311,19 +308,18 @@ } else { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_DG_PRESSURE_ID, sensorID ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_DG_PRESSURE_ID, sensorID ) } return result; } /*********************************************************************//** * @brief - * The getDGROPumpPressureSetPt function gets the latest RO pump \n + * The getDGROPumpPressureSetPt function gets the latest RO pump * pressure set point reported by the DG. - * @details - * Inputs : dgROPumpPressureSetPtPSI - * Outputs : none + * @details Inputs: dgROPumpPressureSetPtPSI + * @details Outputs: none * @return Latest RO pump pressure set point reported by DG. *************************************************************************/ U32 getDGROPumpPressureSetPt( void ) @@ -335,11 +331,10 @@ /*********************************************************************//** * @brief - * The getDGROPumpFlowRateMlMin function gets the latest RO pump flow \n + * The getDGROPumpFlowRateMlMin function gets the latest RO pump flow * rate reported by the DG. - * @details - * Inputs : dgROPumpFlowRateMlMin - * Outputs : none + * @details Inputs: dgROPumpFlowRateMlMin + * @details Outputs: none * @return Latest RO pump flow rate reported by DG. *************************************************************************/ F32 getDGROPumpFlowRateMlMin( void ) @@ -351,11 +346,10 @@ /*********************************************************************//** * @brief - * The getDGDrainPumpRPMSetPt function gets the latest drain pump RPM \n + * The getDGDrainPumpRPMSetPt function gets the latest drain pump RPM * set point reported by the DG. - * @details - * Inputs : dgDrainPumpSpeedSetPtRPM - * Outputs : none + * @details Inputs: dgDrainPumpSpeedSetPtRPM + * @details Outputs: none * @return Latest drain pump RPM set point reported by DG. *************************************************************************/ U32 getDGDrainPumpRPMSetPt( void ) @@ -367,13 +361,12 @@ /*********************************************************************//** * @brief - * The setDGOpMode function sets the latest DG operating mode reported by \n + * The setDGOpMode function sets the latest DG operating mode reported by * the DG. - * @details - * Inputs : none - * Outputs : dgCurrentOpMode - * @param opMode : operating mode reported by DG. - * @param subMode : sub-mode (current state) of operating mode reported by DG. + * @details Inputs: none + * @details Outputs: dgCurrentOpMode + * @param opMode operating mode reported by DG + * @param subMode sub-mode (current state) of operating mode reported by DG * @return none *************************************************************************/ void setDGOpMode( U32 opMode, U32 subMode ) @@ -391,13 +384,12 @@ /*********************************************************************//** * @brief - * The setDialysateTemperatureReadings function sets the latest dialysate \n + * The setDialysateTemperatureReadings function sets the latest dialysate * temperatures reported by the DG. - * @details - * Inputs : none - * Outputs : dgDialysateTemp, dgRedundantDialysateTemp - * @param temp1 : dialysate temperature reported by DG. - * @param temp2 : redundant dialysate temperature reported by DG. + * @details Inputs: none + * @details Outputs: dgDialysateTemp, dgRedundantDialysateTemp + * @param temp1 dialysate temperature reported by DG + * @param temp2 redundant dialysate temperature reported by DG * @return none *************************************************************************/ void setDialysateTemperatureReadings( F32 temp1, F32 temp2 ) @@ -408,13 +400,12 @@ /*********************************************************************//** * @brief - * The setDGDialysateTemperatures function sets the latest temperature data \n + * The setDGDialysateTemperatures function sets the latest temperature data * reported by the DG. - * @details - * Inputs : none - * Outputs : dgPrimaryTemp, dgTrimmerTemp - * @param primaryHtrTemp : Primary heater temperature reported by DG. - * @param trimmerHtrTemp : Trimmer heater temperature reported by DG. + * @details Inputs: none + * @details Outputs: dgPrimaryTemp, dgTrimmerTemp + * @param primaryHtrTemp Primary heater temperature reported by DG + * @param trimmerHtrTemp Trimmer heater temperature reported by DG * @return none *************************************************************************/ void setDGDialysateTemperatures( F32 primaryHtrTemp, F32 trimmerHtrTemp ) @@ -425,14 +416,13 @@ /*********************************************************************//** * @brief - * The setDGReservoirsData function sets the latest reservoir data \n + * The setDGReservoirsData function sets the latest reservoir data * reported by the DG. - * @details - * Inputs : none - * Outputs : dgActiveReservoir, dgReservoirFillVolumeTarget, dgReservoirDrainVolumeTarget - * @param resID : ID of active reservoir. - * @param fillVol : Reservoir fill to volume reported by DG. - * @param drainVol : Reservoir drain to volume reported by DG. + * @details Inputs: none + * @details Outputs: dgActiveReservoir, dgReservoirFillVolumeTarget, dgReservoirDrainVolumeTarget + * @param resID ID of active reservoir + * @param fillVol Reservoir fill to volume reported by DG + * @param drainVol Reservoir drain to volume reported by DG * @return none *************************************************************************/ void setDGReservoirsData( DG_RESERVOIR_ID_T resID, U32 fillVol, U32 drainVol ) @@ -452,13 +442,12 @@ /*********************************************************************//** * @brief * The setDGPressures function sets the latest pressures reported by the DG. - * @details - * Inputs : none - * 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. + * @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 ) @@ -472,11 +461,10 @@ /*********************************************************************//** * @brief * The setDGROPumpData function sets the latest RO pump data reported by the DG. - * @details - * Inputs : none - * 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. + * @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 ) @@ -488,10 +476,9 @@ /*********************************************************************//** * @brief * The setDGDrainPumpData function sets the latest drain pump data reported by the DG. - * @details - * Inputs : none - * Outputs : dgDrainPumpSpeedSetPtRPM - * @param rpmSetPt : latest drain pump RPM set point reported by DG. + * @details Inputs: none + * @details Outputs: dgDrainPumpSpeedSetPtRPM + * @param rpmSetPt latest drain pump RPM set point reported by DG * @return none *************************************************************************/ void setDGDrainPumpData( U32 rpmSetPt ) @@ -501,13 +488,12 @@ /*********************************************************************//** * @brief - * The cmdSetDGDialysateTargetTemps function sends a target dialysate \n + * The cmdSetDGDialysateTargetTemps function sends a target dialysate * temperature command message to the DG. - * @details - * Inputs : none - * Outputs : dgPrimaryTempSet, dgTrimmerTempSet - * @param primaryHtrTemp : commanded target dialysate temperature for the primary heater. - * @param trimmerHtrTemp : commanded target dialysate temperature for the trimmer heater. + * @details Inputs: none + * @details Outputs: dgPrimaryTempSet, dgTrimmerTempSet + * @param primaryHtrTemp commanded target dialysate temperature for the primary heater + * @param trimmerHtrTemp commanded target dialysate temperature for the trimmer heater * @return none *************************************************************************/ void cmdSetDGDialysateTargetTemps( F32 primaryHtrTemp, F32 trimmerHtrTemp ) @@ -519,11 +505,10 @@ /*********************************************************************//** * @brief - * The cmdStartDG function sends a start command to the DG. DG will transition \n - * from standby to re-circulate mode and start producing warm, pure water. - * @details - * Inputs : none - * Outputs : start DG command sent + * The cmdStartDG function sends a start command to the DG. DG will transition + * from standby to recirculate mode and start producing warm, pure water. + * @details Inputs: none + * @details Outputs: start DG command sent * @return none *************************************************************************/ void cmdStartDG( void ) @@ -534,11 +519,10 @@ /*********************************************************************//** * @brief - * The cmdStopDG function sends a stop command to the DG. DG will transition \n - * from re-circulate mode to standby mode. Pumps and heater go off. - * @details - * Inputs : none - * Outputs : stop DG command sent + * The cmdStopDG function sends a stop command to the DG. DG will transition + * from recirculate mode to standby mode. Pumps and heater go off. + * @details Inputs: none + * @details Outputs: stop DG command sent * @return none *************************************************************************/ void cmdStopDG( void ) @@ -549,11 +533,10 @@ /*********************************************************************//** * @brief - * The cmdStartDGTrimmerHeater function sends a start trimmer heater command \n + * The cmdStartDGTrimmerHeater function sends a start trimmer heater command * to the DG. - * @details - * Inputs : none - * Outputs : start DG trimmer heater command sent + * @details Inputs: none + * @details Outputs: start DG trimmer heater command sent * @return none *************************************************************************/ void cmdStartDGTrimmerHeater( void ) @@ -564,11 +547,10 @@ /*********************************************************************//** * @brief - * The cmdStopDGTrimmerHeater function sends a stop trimmer heater command \n + * The cmdStopDGTrimmerHeater function sends a stop trimmer heater command * to the DG. - * @details - * Inputs : none - * Outputs : stop DG trimmer heater command sent + * @details Inputs: none + * @details Outputs: stop DG trimmer heater command sent * @return none *************************************************************************/ void cmdStopDGTrimmerHeater( void ) @@ -579,12 +561,11 @@ /*********************************************************************//** * @brief - * The cmdSetDGActiveReservoir function sends a set active reservoir command \n + * The cmdSetDGActiveReservoir function sends a set active reservoir command * message to the DG. - * @details - * Inputs : none - * Outputs : set active reservoir command sent to DG. - * @param resID : ID of reservoir to set as active (reservoir for HD to draw from). + * @details Inputs: none + * @details Outputs: set active reservoir command sent to DG. + * @param resID ID of reservoir to set as active (reservoir for HD to draw from) * @return none *************************************************************************/ void cmdSetDGActiveReservoir( DG_RESERVOIR_ID_T resID ) @@ -603,10 +584,9 @@ /*********************************************************************//** * @brief * The cmdStartDGFill function sends a fill command message to the DG. - * @details - * Inputs : none - * Outputs : fill command sent to DG. - * @param fillToVolMl : volume (in mL) to fill inactive reservoir to. + * @details Inputs: none + * @details Outputs: fill command sent to DG. + * @param fillToVolMl volume (in mL) to fill inactive reservoir to * @return none *************************************************************************/ void cmdStartDGFill( U32 fillToVolMl ) @@ -618,10 +598,9 @@ /*********************************************************************//** * @brief * The cmdStartDGDrain function sends a drain command message to the DG. - * @details - * Inputs : none - * Outputs : drain command sent to DG. - * @param drainToVolMl : volume (in mL) to drain inactive reservoir to. + * @details Inputs: none + * @details Outputs: drain command sent to DG. + * @param drainToVolMl volume (in mL) to drain inactive reservoir to * @return none *************************************************************************/ void cmdStartDGDrain( U32 drainToVolMl ) @@ -633,9 +612,8 @@ /*********************************************************************//** * @brief * The cmdDGSampleWater function sends a sample water command message to the DG. - * @details - * Inputs : none - * Outputs : sample water command sent to DG. + * @details Inputs: none + * @details Outputs: sample water command sent to DG. * @return none *************************************************************************/ void cmdDGSampleWater( void )