Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -r4cabd64c4ff295eb985f0a62132fef94c4e92921 -rdc3647b737971d298748796d2455b3e021325d8a --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 4cabd64c4ff295eb985f0a62132fef94c4e92921) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision dc3647b737971d298748796d2455b3e021325d8a) @@ -26,6 +26,7 @@ #include "ModeGenDialysate.h" #include "ModeStandby.h" #include "OperationModes.h" +#include "PersistentAlarm.h" #include "Pressure.h" #include "TaskGeneral.h" #include "TDInterface.h" @@ -40,15 +41,23 @@ // ********** private definitions ********** -#define HYD_CHAMBER_FLUID_TEMP_C_MIN 35.0F ///< Minimum hydraulics fluid temperature in deg celcius -#define GEN_DIALYSATE_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the gen dialysate mode data published. +#define HYD_CHAMBER_FLUID_TEMP_C_MIN 35.0F ///< Minimum hydraulics fluid temperature in deg celcius +#define GEN_DIALYSATE_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the gen dialysate mode data published. +#define DIALYSATE_TEMP_OUT_OF_TARGET_CLEAR_TOL_C 2.0F ///< Dialysate temperature clear alarm tolerance C +#define DIALYSATE_TEMP_OUT_OF_TARGET_TOL_C 4.0F ///< Dialysate temperature out of target tolerance C. +#define DIALYSATE_TEMP_OUT_OF_TARGET_TIMEOUT_MS ( 90 * MS_PER_SECOND ) ///< Dialysate temperature out of target timeout in milliseconds. +#define DIALYSATE_TEMP_UPPER_MAX_SAFETY_LIMIT_C 46.0F ///< Dialysate upper bound maximum temperature limit in C. +#define DIALYSATE_TEMP_UPPER_MAX_SAFETY_TIMEOUT_MS ( 1 * MS_PER_SECOND ) ///< Dialysate temperature upper bound maximum safety timeout in milliseconds. +#define DIALYSATE_TEMP_UPPER_SAFETY_LIMIT_C 42.0F ///< Dialysate upper bound safety temperature limit in C. +#define DIALYSATE_TEMP_LOWER_SAFETY_LIMIT_C 33.0F ///< Dialysate lower bound safety temperature limit in C. +#define DIALYSATE_TEMP_CLEAR_TIMEOUT_MS ( 10 * MS_PER_SECOND ) ///< Dialysate temperature clear persistence timeout. //Testing -#define DELAY_BC_SWITCHING_AT_START_UP ( 3 * MS_PER_SECOND ) ///< Provide a balancing chamber switching start up delay to stabilize pump speed etc., +#define DELAY_BC_SWITCHING_AT_START_UP ( 3 * MS_PER_SECOND ) ///< Provide a balancing chamber switching start up delay to stabilize pump speed etc., /// Payload record structure for Gen dialysate execution state set request typedef struct { - U32 execStateSet; ///< Gen dialysate execution state machine set request + U32 execStateSet; ///< Gen dialysate execution state machine set request } GEND_EXEC_STATE_SET_CMD_PAYLOAD_T; // ********** private data ********** @@ -73,6 +82,7 @@ static DD_GEND_MODE_STATE_T handleGenDDialysateDeliveryPauseState( void ); static DD_GEND_MODE_STATE_T handleGenDDialysateIsolatedUFState( void ); static F32 getGenDialysateTargetTemperature( void ); +static void checkDialysateTemperature( void ); static void publishGenDialysateModeData( void ); /*********************************************************************//** @@ -113,6 +123,10 @@ //Initialize balancing chamber module initBalanceChamber(); + + initPersistentAlarm( ALARM_ID_DD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP, DIALYSATE_TEMP_CLEAR_TIMEOUT_MS, DIALYSATE_TEMP_OUT_OF_TARGET_TIMEOUT_MS ); + initPersistentAlarm( ALARM_ID_DD_DIALYSATE_TEMP_BELOW_TARGET_TEMP, DIALYSATE_TEMP_CLEAR_TIMEOUT_MS, DIALYSATE_TEMP_OUT_OF_TARGET_TIMEOUT_MS ); + initPersistentAlarm( ALARM_ID_DD_DIALYSATE_TEMP_ABOVE_SAFETY_TEMP, DIALYSATE_TEMP_CLEAR_TIMEOUT_MS, DIALYSATE_TEMP_UPPER_MAX_SAFETY_TIMEOUT_MS ); } /*********************************************************************//** @@ -264,6 +278,9 @@ // Update any dynamic treatment parameter changes updateTreatmentSettings(); + //Check Dialysate Temperature + checkDialysateTemperature(); + //TODO: Transition to post gen dialysate then standby. if ( TRUE == getU32OverrideValue( &pendingStopDDGenDialRequest ) ) { @@ -591,6 +608,63 @@ /*********************************************************************//** * @brief + * The checkDialysateTemperature function checks the dialysate temperature + * against the target temperature and alarm if temperature is out of range. + * @details \b Inputs: targetTemp, dialysateTemp + * @details \b Outputs: none + * @details \b Alarms: ALARM_ID_DD_DIALYSATE_TEMP_ABOVE_SAFETY_TEMP when + * dialysate temp goes beyound high safety temperature limit + * @details \b Alarms: ALARM_ID_DD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP when + * dialysate temp goes beyound high temperature limit + * @details \b Alarms: ALARM_ID_DD_DIALYSATE_TEMP_BELOW_TARGET_TEMP when + * dialysate temp goes beyound low temperature limit + * @return none + *************************************************************************/ +static void checkDialysateTemperature( void ) +{ + F32 dialysateTemp = getConductivityTemperatureValue( D29_COND ); // Assuming the closest temp sensor to dialyzer + F32 targetTemp = getTDTargetDialysateTemperature(); + BOOL isDialTempAboveHighSafety = ( dialysateTemp >= DIALYSATE_TEMP_UPPER_MAX_SAFETY_LIMIT_C ? TRUE : FALSE ); + BOOL isDialTempAboveLowSafety = ( dialysateTemp > DIALYSATE_TEMP_UPPER_SAFETY_LIMIT_C ? TRUE : FALSE ); + BOOL isDialTempBelowLowSafety = ( dialysateTemp < DIALYSATE_TEMP_LOWER_SAFETY_LIMIT_C ? TRUE : FALSE ); + F32 dialHigh = targetTemp + DIALYSATE_TEMP_OUT_OF_TARGET_TOL_C; + BOOL isDialTempAboveDialysateTarget = ( dialysateTemp > dialHigh ? TRUE : FALSE ); + F32 dialLow = targetTemp - DIALYSATE_TEMP_OUT_OF_TARGET_TOL_C; + BOOL isDialTempBelowDialysateTarget = ( dialysateTemp < dialLow ? TRUE : FALSE ); + BOOL isTempBelowTrigger = (BOOL)( isDialTempBelowLowSafety || isDialTempBelowDialysateTarget ); + BOOL isTempAboveTrigger = (BOOL)( isDialTempAboveLowSafety || isDialTempAboveDialysateTarget ); + + if ( DD_GEND_DIALYSATE_DELIVERY_STATE == genDialysateState ) + { + // check clear condition first + if ( TRUE == isAlarmActive( ALARM_ID_DD_DIALYSATE_TEMP_ABOVE_SAFETY_TEMP ) ) + { + isDialTempAboveHighSafety = ( dialysateTemp <= ( targetTemp + DIALYSATE_TEMP_OUT_OF_TARGET_CLEAR_TOL_C ) ? FALSE : TRUE ); + } + checkPersistentAlarm(ALARM_ID_DD_DIALYSATE_TEMP_ABOVE_SAFETY_TEMP, isDialTempAboveHighSafety, dialysateTemp, targetTemp ); + + if ( TRUE == isAlarmActive( ALARM_ID_DD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP ) ) + { + isTempAboveTrigger = ( dialysateTemp <= ( targetTemp + DIALYSATE_TEMP_OUT_OF_TARGET_CLEAR_TOL_C ) ? FALSE : TRUE ); + } + checkPersistentAlarm(ALARM_ID_DD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP, isTempAboveTrigger, dialysateTemp, targetTemp ); + + if ( TRUE == isAlarmActive( ALARM_ID_DD_DIALYSATE_TEMP_BELOW_TARGET_TEMP ) ) + { + isTempBelowTrigger = ( dialysateTemp >= ( targetTemp - DIALYSATE_TEMP_OUT_OF_TARGET_CLEAR_TOL_C ) ? FALSE : TRUE ); + } + checkPersistentAlarm(ALARM_ID_DD_DIALYSATE_TEMP_BELOW_TARGET_TEMP, isTempBelowTrigger, dialysateTemp, targetTemp ); + } + else + { + checkPersistentAlarm(ALARM_ID_DD_DIALYSATE_TEMP_ABOVE_SAFETY_TEMP, FALSE, dialysateTemp, targetTemp ); + checkPersistentAlarm(ALARM_ID_DD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP, FALSE, dialysateTemp, targetTemp ); + checkPersistentAlarm(ALARM_ID_DD_DIALYSATE_TEMP_BELOW_TARGET_TEMP, FALSE, dialysateTemp, targetTemp ); + } +} + +/*********************************************************************//** + * @brief * The publishGenDialysateModeData function broadcasts the generate dialysate * mode data at defined interval. * @details \b Inputs: genDialysateDataPublicationTimerCounter Index: firmware/App/Monitors/Conductivity.c =================================================================== diff -u -ra9983d3e6b07e7c927fab3d16e80b715594fe221 -rdc3647b737971d298748796d2455b3e021325d8a --- firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision a9983d3e6b07e7c927fab3d16e80b715594fe221) +++ firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision dc3647b737971d298748796d2455b3e021325d8a) @@ -104,6 +104,7 @@ data.d27Cond = getConductivityValue( D27_COND ); data.d29Cond = getConductivityValue( D29_COND ); data.d43Cond = getConductivityValue( D43_COND ); + data.d74Cond = getConductivityValue( D74_COND ); conductivityPublishTimerCounter = 0; broadcastData( MSG_ID_DD_CONDUCTIVITY_DATA, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&data, sizeof( CONDUCTIVITY_DATA_T ) ); Index: firmware/App/Monitors/Conductivity.h =================================================================== diff -u -r313982ccc772f1bbe182877dff7e00381b04e0f4 -rdc3647b737971d298748796d2455b3e021325d8a --- firmware/App/Monitors/Conductivity.h (.../Conductivity.h) (revision 313982ccc772f1bbe182877dff7e00381b04e0f4) +++ firmware/App/Monitors/Conductivity.h (.../Conductivity.h) (revision dc3647b737971d298748796d2455b3e021325d8a) @@ -40,6 +40,7 @@ F32 d27Cond; ///< CD2 conductivity sensor value F32 d29Cond; ///< CD3 conductivity sensor value F32 d43Cond; ///< CD4 conductivity sensor value + F32 d74Cond; ///< CD5 conductivity sensor value } CONDUCTIVITY_DATA_T; // ********** public function prototypes **********