Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -r27f3db92495948d4c1192421c1b0c20338c4a034 -r7010cc605d12e424828fabb567102e4494901e70 --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 7010cc605d12e424828fabb567102e4494901e70) @@ -147,8 +147,7 @@ U32 diOccl = getMeasuredDialInPumpOcclusion(); U32 doOccl = getMeasuredDialOutPumpOcclusion(); - if ( ( bpOccl >= CARTRIDGE_LOADED_THRESHOLD ) && - ( diOccl >= CARTRIDGE_LOADED_THRESHOLD ) && + if ( ( bpOccl >= CARTRIDGE_LOADED_THRESHOLD ) && ( diOccl >= CARTRIDGE_LOADED_THRESHOLD ) && ( doOccl >= CARTRIDGE_LOADED_THRESHOLD ) ) { result = TRUE; @@ -159,6 +158,23 @@ /*********************************************************************//** * @brief + * The isCartridgeUnloaded function determines if a cartridge has been + * unloaded by looking at the 3 occlusion pressure sensors. + * @details Inputs: occlusion pressures for the pumps + * @details Outputs: none + * @return TRUE if all 3 occlusion sensors read below loaded threshold, FALSE if not. + *************************************************************************/ +BOOL isCartridgeUnloaded( void ) +{ + BOOL const bpOcclBelowLoadedThreshold = getMeasuredBloodPumpOcclusion() <= CARTRIDGE_LOADED_THRESHOLD; + BOOL const diOcclBelowLoadedThreshold = getMeasuredDialInPumpOcclusion() <= CARTRIDGE_LOADED_THRESHOLD; + BOOL const doOcclBelowLoadedThreshold = getMeasuredDialOutPumpOcclusion() <= CARTRIDGE_LOADED_THRESHOLD; + + return ( bpOcclBelowLoadedThreshold && diOcclBelowLoadedThreshold && doOcclBelowLoadedThreshold ); +} + +/*********************************************************************//** + * @brief * The isSalineBagEmpty function determines whether the saline bag is empty. * It is assumed that this function will only be called from mode handling * (General Task) when pumping (BP) from the saline bag. Index: firmware/App/Controllers/PresOccl.h =================================================================== diff -u -r27f3db92495948d4c1192421c1b0c20338c4a034 -r7010cc605d12e424828fabb567102e4494901e70 --- firmware/App/Controllers/PresOccl.h (.../PresOccl.h) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) +++ firmware/App/Controllers/PresOccl.h (.../PresOccl.h) (revision 7010cc605d12e424828fabb567102e4494901e70) @@ -73,6 +73,7 @@ U32 getMeasuredDialOutPumpOcclusion( void ); BOOL isCartridgeLoaded( void ); +BOOL isCartridgeUnloaded( void ); BOOL isSalineBagEmpty( void ); BOOL testSetPresOcclDataPublishIntervalOverride( U32 value ); Index: firmware/App/Modes/ModePostTreat.c =================================================================== diff -u -ra226711bd50ef8cc3c60e7de813b67cc8d02e5f6 -r7010cc605d12e424828fabb567102e4494901e70 --- firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision a226711bd50ef8cc3c60e7de813b67cc8d02e5f6) +++ firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 7010cc605d12e424828fabb567102e4494901e70) @@ -23,6 +23,7 @@ #include "DGInterface.h" #include "FPGA.h" #include "OperationModes.h" +#include "PresOccl.h" #include "ModePostTreat.h" #include "Timers.h" #include "Valves.h" @@ -35,7 +36,7 @@ // ********** private definitions ********** #define EMPTY_RESERVOIR_VOLUME_ML 0 ///< Empty reservoir volume in ml. -#define DIP_FLUSH_FLOW_RATE_ML_MIN 300 ///< Dialysate inlet pump flow rate during flush in mL/min. +#define DIP_FLUSH_FLOW_RATE_ML_MIN 150 ///< Dialysate inlet pump flow rate during flush in mL/min. #define LOAD_CELL_VOLUME_NOISE_TOLERANCE 0.05 ///< Allow 5% tolerance on load cell readings. #define LOAD_CELL_STEADY_VOLUME_TIME ( 10 * MS_PER_SECOND ) ///< Time load cell reading need to remain steady in ms. @@ -119,6 +120,8 @@ setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); setValveAirTrap( STATE_CLOSED ); + // TODO: Enable when have syringe pump driver + // stopSyringePump(); } /*********************************************************************//** @@ -211,6 +214,11 @@ if ( DE_PRIME_COMPLETE_STATE == currentDePrimeState ) { state = HD_POST_TREATMENT_UNLOAD_STATE; + + setValvePosition( VDI, VALVE_POSITION_A_INSERT_EJECT ); + setValvePosition( VDO, VALVE_POSITION_A_INSERT_EJECT ); + setValvePosition( VBA, VALVE_POSITION_A_INSERT_EJECT ); + setValvePosition( VBV, VALVE_POSITION_A_INSERT_EJECT ); } return state; @@ -230,7 +238,21 @@ if ( ( TRUE == disposableRemovalConfirmed ) && ( STATE_CLOSED == getFPGADoorState() ) ) { - state = HD_POST_TREATMENT_VERIFY_STATE; + disposableRemovalConfirmed = FALSE; + + if ( TRUE == isCartridgeUnloaded() ) + { + state = HD_POST_TREATMENT_VERIFY_STATE; + + setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); + setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); + } + else + { + activateAlarmNoData( ALARM_ID_CARTRIDGE_REMOVAL_FAILURE ); + } } return state; @@ -246,6 +268,25 @@ *************************************************************************/ static HD_POST_TREATMENT_STATE_T handlePostTreatmentVerifyState( void ) { + // TODO: Check DG doors and straws + if ( STATE_CLOSED == getFPGADoorState() ) + { + // TODO: Enable when have syringe pump driver +// if ( FALSE == isSyringeDetected() ) +// { +// retractSyringePump(); +// } +// +// if ( TRUE == isSyringePumpHome() ) +// { +// requestNewOperationMode( MODE_STAN ); +// } + } + else + { + activateAlarmNoData( ALARM_ID_CARTRIDGE_DOOR_OPENED ); + } + return HD_POST_TREATMENT_VERIFY_STATE; }