Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -rf2cecb1dae0cfccc768b321f1d0cdec9a73c5824 -r8691c0722f9fa690de0b789a2c020b1ad8e86def --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision f2cecb1dae0cfccc768b321f1d0cdec9a73c5824) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 8691c0722f9fa690de0b789a2c020b1ad8e86def) @@ -23,6 +23,7 @@ #include "ModeTreatment.h" #include "ModeTreatmentParams.h" #include "OperationModes.h" +#include "PersistentAlarm.h" #include "SystemCommMessages.h" #include "Timers.h" @@ -33,15 +34,22 @@ // ********** private definitions ********** -#define START_DG_CMD TRUE ///< Parameter for DG start/stop command function. True = start. -#define STOP_DG_CMD FALSE ///< Parameter for DG start/stop command function. False = stop. +#define START_DG_CMD TRUE ///< Parameter for DG start/stop command function. True = start. +#define STOP_DG_CMD FALSE ///< Parameter for DG start/stop command function. False = stop. -#define RESERVOIR_SETTLE_TIME_MS 5000 ///< Time (in ms) allotted for reservoir to settle (after fill, before drain). +#define RESERVOIR_SETTLE_TIME_MS 5000 ///< Time (in ms) allotted for reservoir to settle (after fill, before drain). -#define MAX_RESERVOIR_VOLUME_ML 1950.0 ///< Maximum reservoir volume. Switch reservoirs if active reservoir exceeds this volume. +#define MAX_RESERVOIR_VOLUME_ML 1950.0 ///< Maximum reservoir volume. Switch reservoirs if active reservoir exceeds this volume. -#define SIZE_OF_LARGE_LOAD_CELL_AVG 32 ///< Large load cell moving average has 32 samples. +#define SIZE_OF_LARGE_LOAD_CELL_AVG 32 ///< Large load cell moving average has 32 samples. +#define DIALYSATE_TEMP_PERSISTENCE_PERIOD ( 3 * MS_PER_SECOND ) ///< Persistence period for dialysate temperature alarm. + +#define DIALYSATE_TEMP_RECOVERY_TOLERANCE_C 2.0 ///< Dialysate temperature recovery tolerance in degree C. +#define DIALYSATE_TEMP_TOLERANCE_C 4.0 ///< Dialysate temperature tolerance in degree C. +#define DIALYSATE_TEMP_HIGH_LIMIT_C 42.0 ///< Dialysate high temperature limit in degree C. +#define DIALYSATE_TEMP_LOW_LIMIT_C 33.0 ///< Dialysate low temperature limit in degree C. + /// States of the treatment reservoir management state machine. typedef enum TreatmentReservoirMgmt_States { @@ -161,6 +169,9 @@ lgLoadCellReadingsIdx = 0; lgLoadCellReadingsTotal[ DG_RESERVOIR_1 ] = 0.0; lgLoadCellReadingsTotal[ DG_RESERVOIR_2 ] = 0.0; + + initPersistentAlarm( ALARM_ID_DIALYSATE_TEMPERATURE_HIGH, DIALYSATE_TEMP_PERSISTENCE_PERIOD, DIALYSATE_TEMP_PERSISTENCE_PERIOD ); + initPersistentAlarm( ALARM_ID_DIALYSATE_TEMPERATURE_LOW, DIALYSATE_TEMP_PERSISTENCE_PERIOD, DIALYSATE_TEMP_PERSISTENCE_PERIOD ); } /*********************************************************************//** @@ -543,18 +554,6 @@ /*********************************************************************//** * @brief - * The getDialysateTemperature function gets the latest dialysate temperature. - * @details Inputs: dgDialysateTemp - * @details Outputs: none - * @return the current dialysate temperature - *************************************************************************/ -F32 getDialysateTemperature( void ) -{ - return dgDialysateTemp; -} - -/*********************************************************************//** - * @brief * The getDGDisinfectsStates function returns the DG disinfects readings. * @details Inputs: none * @details Outputs: disinfectsStatus @@ -567,6 +566,18 @@ /*********************************************************************//** * @brief + * The getDialysateTemperature function gets the latest dialysate temperature. + * @details Inputs: dgDialysateTemp + * @details Outputs: none + * @return the current dialysate temperature + *************************************************************************/ +F32 getDialysateTemperature( void ) +{ + return dgDialysateTemp; +} + +/*********************************************************************//** + * @brief * The getReservoirWeight function gets the load cell weight of a given reservoir. * @details Inputs: loadCellWeightInGrams[] * @details Outputs: none @@ -1114,6 +1125,47 @@ /*********************************************************************//** * @brief + * The checkDialysateTemperature function checks the dialysate temperature + * reported by DG and alarm if temperature is out of range. + * @details Inputs: dgTrimmerTempSet, dgDialysateTemp, dgRedundantDialysateTemp + * @details Outputs: alarm if dialysate temperature is out of accepted range + * @return none + *************************************************************************/ +void checkDialysateTemperature( void ) +{ + BOOL const dialysateHighTemp = ( ( ( dgDialysateTemp - dgTrimmerTempSet ) > DIALYSATE_TEMP_TOLERANCE_C ) || + ( dgDialysateTemp > DIALYSATE_TEMP_HIGH_LIMIT_C ) ); + + BOOL const dialysateLowTemp = ( ( ( dgTrimmerTempSet - dgDialysateTemp ) > DIALYSATE_TEMP_TOLERANCE_C ) || + ( dgDialysateTemp < DIALYSATE_TEMP_LOW_LIMIT_C ) ); + + BOOL const dialysateTempRecovered = fabs( dgDialysateTemp - dgTrimmerTempSet ) < DIALYSATE_TEMP_RECOVERY_TOLERANCE_C ? TRUE : FALSE; + +#ifndef DISABLE_DIALYSATE_TEMP_CHECK + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_DIALYSATE_TEMPERATURE_HIGH, dialysateHighTemp ) ) + { + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DIALYSATE_TEMPERATURE_HIGH, dgTrimmerTempSet, dgDialysateTemp ); + } + + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_DIALYSATE_TEMPERATURE_LOW, dialysateLowTemp ) ) + { + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DIALYSATE_TEMPERATURE_LOW, dgTrimmerTempSet, dgDialysateTemp ); + } + + if ( TRUE == isPersistentAlarmConditionCleared( ALARM_ID_DIALYSATE_TEMPERATURE_HIGH, dialysateHighTemp ) ) + { + clearAlarmCondition( ALARM_ID_DIALYSATE_TEMPERATURE_HIGH ); + } + + if ( TRUE == isPersistentAlarmConditionCleared( ALARM_ID_DIALYSATE_TEMPERATURE_LOW, dialysateTempRecovered ) ) + { + clearAlarmCondition( ALARM_ID_DIALYSATE_TEMPERATURE_LOW ); + } +#endif +} + +/*********************************************************************//** + * @brief * The checkDGRestart function checks to see if DG has restarted after started * by HD and triggers appropriate alarm. * @details Inputs: dgStarted Index: firmware/App/Controllers/DGInterface.h =================================================================== diff -u -rf2cecb1dae0cfccc768b321f1d0cdec9a73c5824 -r8691c0722f9fa690de0b789a2c020b1ad8e86def --- firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision f2cecb1dae0cfccc768b321f1d0cdec9a73c5824) +++ firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 8691c0722f9fa690de0b789a2c020b1ad8e86def) @@ -82,30 +82,30 @@ /// Payload record structure for DG temperature sensors data message. typedef struct { - F32 inletPrimaryHeater; ///< Inlet primary heater temperature sensor - F32 outletPrimaryHeater; ///< Outlet primary heater temperature sensor - F32 conductivitySensor1; ///< Conductivity sensor 1 temperature sensor - F32 conductivitySensor2; ///< Conductivity sensor 2 temperature sensor - F32 outletRedundant; ///< Outlet redundant temperature sensor - F32 inletDialysate; ///< Inlet dialysate temperature sensor - F32 primaryHeaterThermocouple; ///< Primary heaters thermocouple sensor - F32 trimmerHeaterThermocouple; ///< Trimmer heater thermocouple sensor - F32 priamyHeaterColdjunction; ///< Primary heaters cold junction temperature sensor - F32 trimmerHeaterColdjunction; ///< Trimmer heater cold junction temperature sensor - F32 primaryHeaterInternal; ///< Primary heaters internal temperature (calculated from thermocouple and cold junction) - F32 trimmerHeaterInternal; ///< Trimmer heater internal temperature (calculated from thermocouple and cold junction) - F32 fpgaBoard; ///< FPGA board temperature sensor - F32 loadCellA1B1; ///< Load cell A1/B1 temperature sensor - F32 loadCellA2B2; ///< Load cell A2/B2 temperature sensor - F32 internalTHDORTD; ///< THDo RTD channel temperature sensor - F32 internalTDIRTD; ///< TDI RTD channel temperature sensor - F32 internalCondSnsrTemp; ///< Conductivity Sensor internal temperature sensor - U32 primaryThermoCoupleRaw; ///< Primary heaters thermocouple raw ADC value - U32 primaryColdjuncRaw; ///< Primary heaters cold junction raw ADC value - U32 trimmerThermoCoupleRaw; ///< Trimmer heater thermocouple raw ADC value - U32 trimmerColdjuncRaw; ///< Trimmer heater cold junction raw ADC value - S32 cond1Raw; ///< Conductivity sensor 1 raw temperature ADC value - S32 cond2Raw; ///< Conductivity sensor 2 raw temperature ADC value + F32 TPi; ///< Inlet primary heaters temperature sensor + F32 TPo; ///< Outlet primary heaters temperature sensor + F32 TD1; ///< Conductivity sensor 1 temperature sensor + F32 TD2; ///< Conductivity sensor 2 temperature sensor + F32 TRo; ///< Outlet redundant temperature sensor + F32 TDi; ///< Inlet dialysate temperature sensor + F32 HtrPrimThermo; ///< Primary heaters internal temperature sensor + F32 HtrTrimThermo; ///< Trimmer heater internal temperature sensor + F32 HtrPrimColdJunc; ///< Primary heaters cold junction temperature sensor + F32 HtrTrimColdJunc; ///< Trimmer heater cold junction temperature sensor + F32 HtrPrimInternal; ///< Primary heaters internal temperature + F32 HtrTrimInternal; ///< Trimmer heater internal temperature + F32 DGBoardTemp; ///< DG board temperature + F32 ResOneLoadCellTemp; ///< Reservoir 1 load cell sensor temperature + F32 ResTwoLoadCellTemp; ///< Reservoir 2 load cell sensor temperature + F32 THDoInternalTemp; ///< THDo RTD channel temperature sensor + F32 TDiInternalTemp; ///< TDI RTD channel temperature sensor + F32 internalCondSnsrTemp; ///< Conductivity Sensor internal temperature sensor + U32 primaryThermoCoupleRaw; ///< Primary heaters thermocouple raw ADC value + U32 primaryColdjuncRaw; ///< Primary heaters cold junction raw ADC value + U32 trimmerThermoCoupleRaw; ///< Trimmer heater thermocouple raw ADC value + U32 trimmerColdjuncRaw; ///< Trimmer heater cold junction raw ADC value + S32 cond1Raw; ///< Conductivity sensor 1 raw temperature ADC value + S32 cond2Raw; ///< Conductivity sensor 2 raw temperature ADC value } TEMPERATURE_SENSORS_DATA_T; /// Payload record structure for a drain reservoir command message. @@ -154,8 +154,8 @@ F32 getLoadCellWeight( LOAD_CELL_ID_T loadCellID ); F32 getReservoirWeight( DG_RESERVOIR_ID_T resID ); F32 getReservoirWeightLargeFilter( DG_RESERVOIR_ID_T resID ); -F32 getDialysateTemperature( void ); DG_DISINFECT_UI_STATES_T getDGDisinfectsStates( void ); +F32 getDialysateTemperature( void ); void setDGOpMode( U32 opMode, U32 subMode ); void setDialysateTemperatureReadings( F32 temp1, F32 temp2 ); @@ -188,6 +188,8 @@ void handleDGCommandResponse( DG_CMD_RESPONSE_T *dgCmdRespPtr ); BOOL getDGCommandResponse( U32 commandID, DG_CMD_RESPONSE_T *cmdRespPtr ); +void checkDialysateTemperature( void ); + BOOL testSetDialOutLoadCellWeightOverride( U32 sensor, F32 value ); BOOL testResetDialOutLoadCellWeightOverride( U32 sensor ); Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -rcbb126cfd3a02c08436a66ffecb2bdf926263705 -r8691c0722f9fa690de0b789a2c020b1ad8e86def --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision cbb126cfd3a02c08436a66ffecb2bdf926263705) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 8691c0722f9fa690de0b789a2c020b1ad8e86def) @@ -797,7 +797,9 @@ if ( lastDialOutPumpDirectionCount != dirErrorCnt ) { lastDialOutPumpDirectionCount = dirErrorCnt; +#ifndef DISABLE_PUMP_DIRECTION_CHECKS SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_PUMP_DIRECTION_STATUS_ERROR, (U32)HD_PUMP_DIALYSATE_OUTLET_PUMP ) +#endif } dopMCDir = ( getMeasuredDialOutPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r2a60f0eba906f0641e22a5d7f5c7ba1750911dcd -r8691c0722f9fa690de0b789a2c020b1ad8e86def --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 2a60f0eba906f0641e22a5d7f5c7ba1750911dcd) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 8691c0722f9fa690de0b789a2c020b1ad8e86def) @@ -872,7 +872,7 @@ if ( ( DG_MODE_GENE == dgOpMode ) && ( DG_GEN_IDLE_MODE_STATE_FLUSH_WATER == dgSubMode ) ) { state = PRE_TREATMENT_RESERVOIR_MGMT_DRAIN_CMD_RESP_STATE; - cmdStartDGDrain( DRAIN_RESERVOIR_TO_VOLUME_ML, TRUE ); + cmdStartDGDrain( DRAIN_RESERVOIR_TO_VOLUME_ML, TRUE, FALSE ); } } Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -rcbb126cfd3a02c08436a66ffecb2bdf926263705 -r8691c0722f9fa690de0b789a2c020b1ad8e86def --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision cbb126cfd3a02c08436a66ffecb2bdf926263705) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 8691c0722f9fa690de0b789a2c020b1ad8e86def) @@ -610,6 +610,11 @@ activateAlarmNoData( ALARM_ID_TREATMENT_STOPPED_BY_USER ); } + if ( currentTreatmentState != TREATMENT_END_STATE ) + { + checkDialysateTemperature(); + } + // Treatment mode state machine switch ( currentTreatmentState ) {