Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -rf760ffc4b10556e5186e9ceb90294262063440ca -r77392c1537f02650413087b86b946370a6289dcd --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision f760ffc4b10556e5186e9ceb90294262063440ca) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 77392c1537f02650413087b86b946370a6289dcd) @@ -8,7 +8,7 @@ * @file DGInterface.c * * @author (last) Sean Nash -* @date (last) 13-Jan-2023 +* @date (last) 10-Feb-2023 * * @author (original) Sean * @date (original) 08-Apr-2020 @@ -17,6 +17,7 @@ #include // To check for NaN +#include "Battery.h" #include "DialInFlow.h" #include "Dialysis.h" #include "DGDefs.h" @@ -79,7 +80,8 @@ static F32 lgLoadCellBackupReadingsTotal[ NUM_OF_DG_RESERVOIRS ]; ///< Rolling total - used to calc large load cell moving average. // DG Dialysate flow rate -static F32 dgDialysateFlowRateMlMin = 0.0; ///< Latest dialysate flow rate reported by the DG. +static F32 dgDialysateFlowRateLMin; ///< Latest dialysate flow rate (in L/min) reported by the DG. +static F32 dgDialysateFlowRateRawLMin; ///< Latest raw dialysate flow rate (in L/min) reported by the DG. static BOOL dgDialysateFlowDataFreshFlag = FALSE; ///< Flag to signal the execDialInFlowMonitor() to process fresh flow rate data static BOOL dgLoadCellDataFreshFlag = FALSE; ///< Flag to signal the handleLoadCellReadingsFromDG() to process fresh load cell data static BOOL dgDialysateTemperatureDataFreshFlag = FALSE; ///< Flag to signal the handleTemperatureReadingsFromDG() to process fresh temperature data @@ -131,7 +133,8 @@ dgCurrentOpMode = DG_MODE_INIT; dgSubMode = 0; dgStartCommandSent = FALSE; - dgDialysateFlowRateMlMin = 0.0F; + dgDialysateFlowRateLMin = 0.0F; + dgDialysateFlowRateRawLMin = 0.0F; dgDialysateFlowDataFreshFlag = FALSE; dgHeatDisinfectTemp = 0.0F; @@ -223,23 +226,26 @@ *************************************************************************/ void execDGInterfaceMonitor( void ) { - // Trigger alarm if not receiving new load cell data message in timely manner - checkDGDataFreshness( ALARM_ID_HD_NEW_LOAD_CELL_DATA_MESSAGE_NOT_RECEIVE, &dgLoadCellDataFreshFlag ); + if ( isACPowerLost() != TRUE ) + { + // Trigger alarm if not receiving new load cell data message in timely manner + checkDGDataFreshness( ALARM_ID_HD_NEW_LOAD_CELL_DATA_MESSAGE_NOT_RECEIVE, &dgLoadCellDataFreshFlag ); - // Trigger alarm if not receiving new dialysate temperature data message in timely manner - checkDGDataFreshness( ALARM_ID_HD_NEW_DIALYSATE_TEMPERATURE_DATA_MESSAGE_NOT_RECEIVE, &dgDialysateTemperatureDataFreshFlag ); + // Trigger alarm if not receiving new dialysate temperature data message in timely manner + checkDGDataFreshness( ALARM_ID_HD_NEW_DIALYSATE_TEMPERATURE_DATA_MESSAGE_NOT_RECEIVE, &dgDialysateTemperatureDataFreshFlag ); - // Trigger alarm if not receiving new reservoirs data message in timely manner - checkDGDataFreshness( ALARM_ID_HD_NEW_RESERVOIRS_DATA_MESSAGE_NOT_RECEIVE, &dgReservoirsDataFreshFlag ); + // Trigger alarm if not receiving new reservoirs data message in timely manner + checkDGDataFreshness( ALARM_ID_HD_NEW_RESERVOIRS_DATA_MESSAGE_NOT_RECEIVE, &dgReservoirsDataFreshFlag ); - // Trigger alarm if not receiving new DG op mode message in timely manner - checkDGDataFreshness( ALARM_ID_HD_NEW_DG_OPERATION_MODE_MESSAGE_NOT_RECEIVE, &dgOpModeDataFreshFlag ); + // Trigger alarm if not receiving new DG op mode message in timely manner + checkDGDataFreshness( ALARM_ID_HD_NEW_DG_OPERATION_MODE_MESSAGE_NOT_RECEIVE, &dgOpModeDataFreshFlag ); - // Check to see if DG has restarted - checkDGRestart(); + // Check to see if DG has restarted + checkDGRestart(); - // Check the status of the trimmer heater - checkDGTrimmerHeaterStatus(); + // Check the status of the trimmer heater + checkDGTrimmerHeaterStatus(); + } } /*********************************************************************//** @@ -309,19 +315,34 @@ * @brief * The getDGDialysateFlowRateLMin function gets the latest dialysate flow * rate reported by the DG. - * @details Inputs: dgDialysateFlowRateMlMin + * @details Inputs: dgDialysateFlowRateLMin * @details Outputs: none * @return Latest dialysate flow rate (in L/min) reported by DG. *************************************************************************/ F32 getDGDialysateFlowRateLMin( void ) { - F32 result = dgDialysateFlowRateMlMin; + F32 result = dgDialysateFlowRateLMin; return result; } /*********************************************************************//** * @brief + * The getDGRawDialysateFlowRateLMin function gets the latest raw dialysate flow + * rate reported by the DG. + * @details Inputs: dgDialysateFlowRateRawLMin + * @details Outputs: none + * @return Latest dialysate flow rate (in L/min) reported by DG. + *************************************************************************/ +F32 getDGRawDialysateFlowRateLMin( void ) +{ + F32 result = dgDialysateFlowRateRawLMin; + + 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 @@ -569,19 +590,25 @@ * 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, dgDialysateFlowDataFreshFlag - * @param flowRate latest dialysate flow rate (mL/min) reported by DG + * @details Outputs: dgDialysateFlowRateLMin, dgDialysateFlowRateRawLMin, + * dgDialysateFlowDataFreshFlag + * @param flowRates latest DG flow rates (mL/min) reported by DG * @return none *************************************************************************/ -void setDialysateFlowData( F32 flowRate ) +void setDialysateFlowData( FLOW_SENSORS_DATA_T flowRates ) { // Check if the sent value by DG is a NaN - if ( isnan( flowRate ) ) + if ( isnan( flowRates.dialysateFlowRateLPM ) ) { - flowRate = 0.0; + flowRates.dialysateFlowRateLPM = 0.0F; } + if ( isnan( flowRates.dialysateRawFlowRateLPM ) ) + { + flowRates.dialysateRawFlowRateLPM = 0.0F; + } - dgDialysateFlowRateMlMin = flowRate; + dgDialysateFlowRateLMin = flowRates.dialysateFlowRateLPM; + dgDialysateFlowRateRawLMin = flowRates.dialysateRawFlowRateLPM; dgDialysateFlowDataFreshFlag = TRUE; } @@ -1157,18 +1184,21 @@ U32 trimmerState = dgHeatersData.trimmerHeaterState; DG_OP_MODE_T dgOp = getDGOpMode(); - if ( ( DG_MODE_GENE == dgOp ) || ( DG_MODE_FILL == dgOp ) || ( DG_MODE_DRAI == dgOp ) ) + if ( isACPowerLost() != TRUE ) { - // In heat disinfect and chemical disinfect, the trimmer heater is controlled by the DG itself so no commands from HD should be sent - // regarding the trimmer heater. - if ( ( TRUE == dgTrimmerHeaterOn ) && ( HEATER_EXEC_STATE_OFF == trimmerState ) ) + if ( ( DG_MODE_GENE == dgOp ) || ( DG_MODE_FILL == dgOp ) || ( DG_MODE_DRAI == dgOp ) ) { - cmdStartDGTrimmerHeater(); + // In heat disinfect and chemical disinfect, the trimmer heater is controlled by the DG itself so no commands from HD should be sent + // regarding the trimmer heater. + if ( ( TRUE == dgTrimmerHeaterOn ) && ( HEATER_EXEC_STATE_OFF == trimmerState ) ) + { + cmdStartDGTrimmerHeater(); + } + else if ( ( FALSE == dgTrimmerHeaterOn ) && ( trimmerState != HEATER_EXEC_STATE_OFF ) ) + { + cmdStopDGTrimmerHeater(); + } } - else if ( ( FALSE == dgTrimmerHeaterOn ) && ( trimmerState != HEATER_EXEC_STATE_OFF ) ) - { - cmdStopDGTrimmerHeater(); - } } }