Index: firmware/App/Controllers/Switches.c =================================================================== diff -u -rbb5280946ac08388b456c7c1848d7797c4a28038 -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Controllers/Switches.c (.../Switches.c) (revision bb5280946ac08388b456c7c1848d7797c4a28038) +++ firmware/App/Controllers/Switches.c (.../Switches.c) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -49,10 +49,14 @@ static OVERRIDE_U32_T switchesDataPublishInterval = { SWITCHES_DATA_PUB_INTERVAL, SWITCHES_DATA_PUB_INTERVAL, 0, 0 }; ///< Interval (in ms) at which to publish switches data to CAN bus. static SWITCH_STATUS_T switchesStatus[ NUM_OF_DOORS_AND_SWITCHES ]; ///< Switches status array. +static BOOL requireDoorClosed; ///< Flag indicates whether door is required to be closed in current state. +static BOOL requirePumpTrackLocked; ///< Flag indicates whether pump track is required to be locked in current state. + // ********** private function prototypes ********** static void publishSwitchesData( void ); +static void handleSwitchAlarms( void ); static U32 getPublishSwitchesDataInterval( void ); /*********************************************************************//** @@ -67,6 +71,8 @@ U08 i; switchesDataPublicationCounter = DATA_PUBLISH_COUNTER_START_COUNT; + requireDoorClosed = FALSE; + requirePumpTrackLocked = FALSE; // Initialize all the switches for ( i = 0; i < NUM_OF_DOORS_AND_SWITCHES; i++ ) @@ -112,55 +118,93 @@ #endif } - // Check if the current switch status is not the same as the recorded data - if ( currentSwitchStatus != switchesStatus[ i ].status.data ) +#ifndef _RELEASE_ + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_SWITCHES_MONITOR ) ) { - // If the debounce time is 0, start the timer - if ( 0 == switchesStatus[ i ].debounceStartTime ) + switchesStatus[ i ].status.data = STATE_CLOSED; + } + else +#endif + { + // Check if the current switch status is not the same as the recorded data + if ( currentSwitchStatus != switchesStatus[ i ].status.data ) { - switchesStatus[ i ].debounceStartTime = getMSTimerCount(); - } - // If the debounce time has been elapsed, update the switch status to the new status - else if ( TRUE == didTimeout( switchesStatus[ i ].debounceStartTime, SWITCHES_DEBOUNCE_TIME_MS ) ) - { - if ( FRONT_DOOR == i ) + // If the debounce time is 0, start the timer + if ( 0 == switchesStatus[ i ].debounceStartTime ) { - // Log front door switch change - sendTreatmentLogEventData( FRONT_DOOR_SWITCH_CHANGED_EVENT, (F32)switchesStatus[ i ].status.data, (F32)currentSwitchStatus ); + switchesStatus[ i ].debounceStartTime = getMSTimerCount(); } - else if ( PUMP_TRACK_SWITCH == i ) + // If the debounce time has been elapsed, update the switch status to the new status + else if ( TRUE == didTimeout( switchesStatus[ i ].debounceStartTime, SWITCHES_DEBOUNCE_TIME_MS ) ) { - // Log pump track switch change - sendTreatmentLogEventData( PUMP_TRACK_SWITCH_CHANGED_EVENT, (F32)switchesStatus[ i ].status.data, (F32)currentSwitchStatus ); + if ( FRONT_DOOR == i ) + { + // Log front door switch change + sendTreatmentLogEventData( FRONT_DOOR_SWITCH_CHANGED_EVENT, (F32)switchesStatus[ i ].status.data, (F32)currentSwitchStatus ); + } + else if ( PUMP_TRACK_SWITCH == i ) + { + // Log pump track switch change + sendTreatmentLogEventData( PUMP_TRACK_SWITCH_CHANGED_EVENT, (F32)switchesStatus[ i ].status.data, (F32)currentSwitchStatus ); + } + // If the bit is 0, the door switch is open, because it is normally open switch + switchesStatus[ i ].debounceStartTime = 0; + switchesStatus[ i ].status.data = currentSwitchStatus; } - // If the bit is 0, the door switch is open, because it is normally open switch + } + else + { switchesStatus[ i ].debounceStartTime = 0; - switchesStatus[ i ].status.data = currentSwitchStatus; } } - else - { - switchesStatus[ i ].debounceStartTime = 0; - } } + handleSwitchAlarms(); + publishSwitchesData(); +} + +/*********************************************************************//** + * @brief + * The getSwitchStatus function returns the status of the called switch. + * @details Inputs: switchStatus + * @details Outputs: switchStatus, requireDoorClosed, requirePumpTrackLocked + * @param switchId which is the switch that its status is requested + * @return switch status + *************************************************************************/ +static void handleSwitchAlarms( void ) +{ #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SWITCHES_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) #endif { - // Clear active Alarms - if ( STATE_CLOSED == getSwitchStatus( FRONT_DOOR ) ) + // Check for door closed alarm + if ( TRUE == requireDoorClosed ) { + if ( getSwitchStatus( FRONT_DOOR ) != STATE_CLOSED ) + { + activateAlarmNoData( ALARM_ID_CARTRIDGE_DOOR_OPENED ); + } + } + // Check for pump track unlocked alarm + if ( TRUE == requirePumpTrackLocked ) + { + if ( getSwitchStatus( PUMP_TRACK_SWITCH ) != STATE_CLOSED ) + { + activateAlarmNoData( ALARM_ID_PUMP_TRACK_LATCH_OPENED ); + } + } + + // Handle clearing alarm conditions + if ( ( STATE_CLOSED == getSwitchStatus( FRONT_DOOR ) ) || ( requireDoorClosed != TRUE ) ) + { clearAlarmCondition( ALARM_ID_CARTRIDGE_DOOR_OPENED ); } - if ( STATE_CLOSED == getSwitchStatus( PUMP_TRACK_SWITCH ) ) + if ( ( STATE_CLOSED == getSwitchStatus( PUMP_TRACK_SWITCH ) ) || ( requirePumpTrackLocked != TRUE ) ) { clearAlarmCondition( ALARM_ID_PUMP_TRACK_LATCH_OPENED ); } } - - publishSwitchesData(); } /*********************************************************************//** @@ -192,6 +236,23 @@ return (OPN_CLS_STATE_T)status; } +/*********************************************************************//** + * @brief + * The doorClosedRequired function sets flags that determine whether door + * and pump tracks should be closed/locked in current state. Associated + * alarms will be triggered if switches not in required state. + * @details Inputs: none + * @details Outputs: requireDoorClosed, requirePumpTrackLocked + * @param door is door required to be closed in current state? + * @param pumpTrack is pump track required to be locked in current state? + * @return none + *************************************************************************/ +void doorClosedRequired( BOOL door, BOOL pumpTrack ) +{ + requireDoorClosed = door; + requirePumpTrackLocked = pumpTrack; +} + // ********** private functions ********** /*********************************************************************//** Index: firmware/App/Controllers/Switches.h =================================================================== diff -u -r3d72b777cf1ceb673d118341c46e2d6d5b7b75f5 -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Controllers/Switches.h (.../Switches.h) (revision 3d72b777cf1ceb673d118341c46e2d6d5b7b75f5) +++ firmware/App/Controllers/Switches.h (.../Switches.h) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -52,6 +52,7 @@ void execSwitches( void ); OPN_CLS_STATE_T getSwitchStatus( SWITCH_T switchId ); +void doorClosedRequired( BOOL door, BOOL pumpTrack ); BOOL testSetSwitchesDataPublishIntervalOverride( U32 value ); BOOL testResetSwitchesDataPublishIntervalOverrid( void ); Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r19a8bf98a7154e24c35da25225d4b55bf70ddd09 -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 19a8bf98a7154e24c35da25225d4b55bf70ddd09) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -621,13 +621,6 @@ VALVE_STATE_T state = VALVE_STATE_HOMING_NOT_STARTED; OPN_CLS_STATE_T frontDoor = getSwitchStatus( FRONT_DOOR ); -#ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_SWITCHES_MONITOR ) ) - { - frontDoor = STATE_CLOSED; - } -#endif - // If homing has been requested or POST is completed and the door has been close for the specified // Period of time, start the homing process if ( ( VALVE_SELF_TEST_COMPLETE == valveSelfTestState ) && ( ( TRUE == valvesStatus[ valve ].hasHomingBeenRequested ) || ( STATE_CLOSED == frontDoor ) ) Index: firmware/App/Modes/BloodPrime.c =================================================================== diff -u -r5501a435ad36f528817eb7efb24fcb17ef3da68c -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision 5501a435ad36f528817eb7efb24fcb17ef3da68c) +++ firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -129,6 +129,8 @@ *************************************************************************/ void transitionToBloodPrime( void ) { + doorClosedRequired( TRUE, TRUE ); + // Set valves setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r19a8bf98a7154e24c35da25225d4b55bf70ddd09 -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 19a8bf98a7154e24c35da25225d4b55bf70ddd09) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -186,6 +186,8 @@ { PUMP_CONTROL_MODE_T mode = PUMP_CONTROL_MODE_CLOSED_LOOP; + doorClosedRequired( TRUE, TRUE ); + // Set last UF timestamp so UF ref is resumed from this time lastUFTimeStamp = getMSTimerCount(); // Send dialysate outlet pump latest UF volumes Index: firmware/App/Modes/ModePostTreat.c =================================================================== diff -u -r19a8bf98a7154e24c35da25225d4b55bf70ddd09 -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 19a8bf98a7154e24c35da25225d4b55bf70ddd09) +++ firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -125,6 +125,8 @@ setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); + doorClosedRequired( FALSE, FALSE ); + cmdStopDGTrimmerHeater(); setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); @@ -345,6 +347,7 @@ { // Done with draining the reservoirs state = HD_POST_TREATMENT_PATIENT_DISCONNECTION_STATE; + doorClosedRequired( TRUE, TRUE ); } return state; @@ -368,14 +371,6 @@ OPN_CLS_STATE_T frontDoor = getSwitchStatus( FRONT_DOOR ); OPN_CLS_STATE_T pumpTrack = getSwitchStatus( PUMP_TRACK_SWITCH ); -#ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_SWITCHES_MONITOR ) ) - { - frontDoor = STATE_CLOSED; - pumpTrack = STATE_CLOSED; - } -#endif - if ( ( STATE_CLOSED == frontDoor ) && ( STATE_CLOSED == pumpTrack ) ) { #ifndef _RELEASE_ @@ -399,25 +394,15 @@ homeDialInPump(); homeDialOutPump(); + doorClosedRequired( FALSE, FALSE ); + if ( ( bolusVol > 0.0 ) || ( hepRate > 0.0 ) ) { retractSyringePump(); } } } - else - { - if ( STATE_OPEN == frontDoor ) - { - activateAlarmNoData( ALARM_ID_CARTRIDGE_DOOR_OPENED ); - } - if ( STATE_OPEN == pumpTrack ) - { - activateAlarmNoData( ALARM_ID_PUMP_TRACK_LATCH_OPENED ); - } - } - return state; } Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -rb36fc8801adfc9d2f402450abffe721e71f9a5e5 -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision b36fc8801adfc9d2f402450abffe721e71f9a5e5) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -91,6 +91,7 @@ static void resetSignalFlags( void ); static void transitionToCartridgeInstallation( void ); static void transitionToPatientConnection( void ); +static void verifySwitchStatus( void ); static HD_PRE_TREATMENT_MODE_STATE_T handleWaterSampleState( void ); static HD_PRE_TREATMENT_MODE_STATE_T handleSelfTestConsumableState( void ); @@ -179,6 +180,8 @@ setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE ); + doorClosedRequired( FALSE, FALSE ); + return currentPreTreatmentState; } @@ -269,27 +272,12 @@ * @details Outputs: Alarm * @return none *************************************************************************/ -void verifySwitchStatus( void ) +static void verifySwitchStatus( void ) { F32 bolusVol = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ); F32 hepRate = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_DISPENSE_RATE ); #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SWITCHES_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) -#endif - { - if ( STATE_OPEN == getSwitchStatus( FRONT_DOOR ) ) - { - activateAlarmNoData( ALARM_ID_CARTRIDGE_DOOR_OPENED ); - } - - if ( STATE_OPEN == getSwitchStatus( PUMP_TRACK_SWITCH ) ) - { - activateAlarmNoData( ALARM_ID_PUMP_TRACK_LATCH_OPENED ); - } - } - -#ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { @@ -325,14 +313,6 @@ OPN_CLS_STATE_T frontDoor = getSwitchStatus( FRONT_DOOR ); OPN_CLS_STATE_T pumpTrack = getSwitchStatus( PUMP_TRACK_SWITCH ); -#ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_SWITCHES_MONITOR ) ) - { - frontDoor = STATE_CLOSED; - pumpTrack = STATE_CLOSED; - } -#endif - if ( STATE_CLOSED == pumpTrack ) { if ( STATE_CLOSED == frontDoor ) @@ -587,6 +567,8 @@ { VALVE_T valve; + doorClosedRequired( FALSE, FALSE ); + // Set valves for ( valve = VDI; valve < NUM_OF_VALVES; ++valve ) { @@ -616,6 +598,8 @@ patientConnectionConfirm = FALSE; treatmentStartRequested = FALSE; + doorClosedRequired( FALSE, FALSE ); + for ( valve = VDI; valve < NUM_OF_VALVES; ++valve ) { setValvePosition( valve, VALVE_POSITION_C_CLOSE ); Index: firmware/App/Modes/PreTreatmentRecirc.c =================================================================== diff -u -r3d72b777cf1ceb673d118341c46e2d6d5b7b75f5 -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Modes/PreTreatmentRecirc.c (.../PreTreatmentRecirc.c) (revision 3d72b777cf1ceb673d118341c46e2d6d5b7b75f5) +++ firmware/App/Modes/PreTreatmentRecirc.c (.../PreTreatmentRecirc.c) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -21,6 +21,7 @@ #include "BloodFlow.h" #include "DGInterface.h" #include "PreTreatmentRecirc.h" +#include "Switches.h" #include "Valves.h" /** @@ -30,8 +31,8 @@ // ********** private definitions ********** -#define BLOOD_PUMP_RECIRC_FLOW_RATE 100 ///< Blood pump flow rate during recirculation in mL/min. -#define DIALYSATE_PUMP_RECIRC_FLOW_RATE 100 ///< Dialysate pump flow rate during recirculation in mL/min. +#define BLOOD_PUMP_RECIRC_FLOW_RATE 100 ///< Blood pump flow rate during recirculation in mL/min. +#define DIALYSATE_PUMP_RECIRC_FLOW_RATE 100 ///< Dialysate pump flow rate during recirculation in mL/min. // ********** private data ********** @@ -152,6 +153,8 @@ *************************************************************************/ static void setupPreTreatmentRecirculate( void ) { + doorClosedRequired( TRUE, TRUE ); + setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); setValvePosition( VBA, VALVE_POSITION_B_OPEN ); Index: firmware/App/Modes/Prime.c =================================================================== diff -u -r99415e8a0738b8fc7582382222aca4cd61590423 -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Modes/Prime.c (.../Prime.c) (revision 99415e8a0738b8fc7582382222aca4cd61590423) +++ firmware/App/Modes/Prime.c (.../Prime.c) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -166,6 +166,8 @@ setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE ); + doorClosedRequired( TRUE, TRUE ); + // Pumps should be off signalBloodPumpHardStop(); signalDialInPumpHardStop(); Index: firmware/App/Modes/Rinseback.c =================================================================== diff -u -r19a8bf98a7154e24c35da25225d4b55bf70ddd09 -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision 19a8bf98a7154e24c35da25225d4b55bf70ddd09) +++ firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -173,6 +173,8 @@ { initRinseback(); + doorClosedRequired( TRUE, TRUE ); + // Set user alarm recovery actions allowed in this sub-mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); Index: firmware/App/Modes/SelfTests.c =================================================================== diff -u -r19a8bf98a7154e24c35da25225d4b55bf70ddd09 -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 19a8bf98a7154e24c35da25225d4b55bf70ddd09) +++ firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -233,6 +233,8 @@ selfTestStartTime = getMSTimerCount(); selfTestPreviousPublishDataTime = getMSTimerCount(); + doorClosedRequired( TRUE, TRUE ); + // Pumps should be off signalBloodPumpHardStop(); signalDialInPumpHardStop(); @@ -359,6 +361,8 @@ selfTestStartTime = getMSTimerCount(); selfTestPreviousPublishDataTime = getMSTimerCount(); + doorClosedRequired( TRUE, TRUE ); + // Pumps should be off signalBloodPumpHardStop(); signalDialInPumpHardStop(); @@ -666,14 +670,6 @@ signalDialOutPumpHardStop(); selfTestStartTime = getMSTimerCount(); -#ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_SWITCHES_MONITOR ) ) - { - frontDoor = STATE_CLOSED; - pumpTrack = STATE_CLOSED; - } -#endif - // TODO: Use appropriate sensor driver if ( ( STATE_CLOSED == frontDoor ) && ( STATE_CLOSED == pumpTrack ) ) { @@ -830,13 +826,16 @@ { NO_CART_SELF_TESTS_STATE_T state = NO_CART_SELF_TESTS_STOPPED_STATE; + doorClosedRequired( FALSE, FALSE ); + // Restart self-test start time selfTestStartTime = getMSTimerCount(); if ( TRUE == selfTestsResumeRequested ) { selfTestsResumeRequested = FALSE; havePumpsStarted = FALSE; + doorClosedRequired( TRUE, TRUE ); state = NO_CART_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE; } @@ -860,14 +859,6 @@ // Restart self-test start time selfTestStartTime = getMSTimerCount(); -#ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_SWITCHES_MONITOR ) ) - { - frontDoor = STATE_CLOSED; - pumpTrack = STATE_CLOSED; - } -#endif - // TODO: Use appropriate sensor driver if (( STATE_CLOSED == frontDoor ) && (STATE_CLOSED == pumpTrack ) ) { @@ -1126,12 +1117,15 @@ { DRY_SELF_TESTS_STATE_T state = DRY_SELF_TESTS_STOPPED_STATE; + doorClosedRequired( FALSE, FALSE ); + // Restart self-test start time selfTestStartTime = getMSTimerCount(); if ( TRUE == selfTestsResumeRequested ) { selfTestsResumeRequested = FALSE; + doorClosedRequired( TRUE, TRUE ); #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_DRY_SELF_TESTS ) != SW_CONFIG_ENABLE_VALUE ) { Index: firmware/App/Modes/TreatmentEnd.c =================================================================== diff -u -r94940c975556f32d5b13f98aea84e83f8441f41d -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Modes/TreatmentEnd.c (.../TreatmentEnd.c) (revision 94940c975556f32d5b13f98aea84e83f8441f41d) +++ firmware/App/Modes/TreatmentEnd.c (.../TreatmentEnd.c) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -111,26 +111,18 @@ // Stop any DG fill that may be in progress cmdStopDGFill(); - // Set valves + // Set user alarm recovery actions allowed in this sub-mode + setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, TRUE ); + setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE ); + + // Set valves, pumps and heater setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); - setValvePosition( VBA, VALVE_POSITION_B_OPEN ); - setValvePosition( VBV, VALVE_POSITION_B_OPEN ); - - // Ensure all pumps except BP stopped signalDialInPumpHardStop(); signalDialOutPumpHardStop(); stopSyringePump(); - setBloodPumpTargetFlowRate( TX_END_BP_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); cmdStopDGTrimmerHeater(); - - // Continue air trap control - startAirTrapControl(); - - // Set user alarm recovery actions allowed in this sub-mode - setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); // Resume in this sub-mode indicates resume wait for user rinseback request (not resume treatment) - setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, TRUE ); - setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE ); + setupForTxEndWait4RinsebackState(); } /*********************************************************************//** @@ -144,15 +136,16 @@ *************************************************************************/ static void setupForTxEndWait4RinsebackState( void ) { + doorClosedRequired( TRUE, TRUE ); // No resume alarm action allowed - setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); + setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); // Resume in this sub-mode indicates resume wait for user rinseback request (not resume treatment) // Open VBA and VBV valves to allow flow from/to patient setValvePosition( VBA, VALVE_POSITION_B_OPEN ); setValvePosition( VBV, VALVE_POSITION_B_OPEN ); // Start blood pump at Tx End slow flow rate setBloodPumpTargetFlowRate( TX_END_BP_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); bloodSittingTimerCtr = 0; - // Start air trap leveling control + // Continue air trap leveling control startAirTrapControl(); } @@ -167,6 +160,7 @@ *************************************************************************/ static void setupForTxEndPausedState( void ) { + doorClosedRequired( FALSE, FALSE ); // Resume alarm action will take us back to TxEndWait4RinsebackState setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); // Stop blood pump Index: firmware/App/Modes/TreatmentRecirc.c =================================================================== diff -u -r3d72b777cf1ceb673d118341c46e2d6d5b7b75f5 -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision 3d72b777cf1ceb673d118341c46e2d6d5b7b75f5) +++ firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -117,6 +117,8 @@ { initTreatmentRecirc(); + doorClosedRequired( TRUE, TRUE ); + // Set valves to safe state setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r19a8bf98a7154e24c35da25225d4b55bf70ddd09 -r9bf209fc5813b7e806f51f408ece77174a336c9b --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 19a8bf98a7154e24c35da25225d4b55bf70ddd09) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 9bf209fc5813b7e806f51f408ece77174a336c9b) @@ -143,6 +143,7 @@ static void setupForDialysateRecirculationState( void ) { // Re-circulate dialysate side of dialyzer w/ heating to maintain temperature + doorClosedRequired( TRUE, TRUE ); setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_RECIRC, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); cmdStartDGTrimmerHeater(); } @@ -158,6 +159,7 @@ *************************************************************************/ static void setupForBloodRecirculationState( void ) { + doorClosedRequired( TRUE, TRUE ); // Open VBA and VBV valves to patient for blood recirculation setValvePosition( VBA, VALVE_POSITION_B_OPEN ); setValvePosition( VBV, VALVE_POSITION_B_OPEN ); @@ -361,6 +363,8 @@ { TREATMENT_STOP_STATE_T result = TREATMENT_STOP_NO_RECIRC_STATE; + doorClosedRequired( FALSE, FALSE ); + handleTreatmentStopBloodSittingTimer(); result = handleTreatmentStopAlarmsAndSignals(result);