Index: firmware/App/Modes/Prime.c =================================================================== diff -u -r5bca4ee9a6eb137ea7093b8007584c3fdd353fa8 -rce64f27cc40a432ce45badf365af3e20283e0a7f --- firmware/App/Modes/Prime.c (.../Prime.c) (revision 5bca4ee9a6eb137ea7093b8007584c3fdd353fa8) +++ firmware/App/Modes/Prime.c (.../Prime.c) (revision ce64f27cc40a432ce45badf365af3e20283e0a7f) @@ -45,7 +45,7 @@ #define DIALYSATE_PUMP_PRIME_FLOW_RATE_ML_MIN 300 ///< Dialysate pump flow rate during priming fluid path. #define LOAD_CELL_VOLUME_NOISE_TOLERANCE 0.05 ///< Allow 5% tolerance on load cell readings. -#define LOAD_CELL_VOLUME_SALINE_READING 10.0 ///< Load cell readings of 10 grams ( 10 mL ) +#define PRIME_SALINE_DIALYZER_STOP_WEIGHT 10.0 ///< Load cell readings of 10 grams ( 10 mL ) used in prime saline dialyzer state #define NO_AIR_DETECTED_COUNT ( 20 * MS_PER_SECOND ) ///< No air detected time period count. #define PURGE_AIR_TIME_OUT_COUNT ( 60 * MS_PER_SECOND ) ///< Time period count for purge air time out. @@ -89,7 +89,7 @@ static U32 primeDialysateDialyzerStartTime; ///< Starting time of priming dialysate dialyzer circuit. static U32 primeDialysateBypassStartTime; ///< Starting time of priming dialysate bypass circuit. static U32 previousLoadCellReading; ///< Previous load cell reading. -static U32 initialLoadCellReading; ///< Initial load cell reading. +static U32 primeSalineDializerInitialLoadCellReading; ///< Initial load cell reading in the prime saline dialyzer state. static U32 loadcellSteadyVolumeStartTime; ///< Load cell steady volume starting time. static BOOL runBloodCircuitPrimeAgain; ///< Flag indicates HD should run blood circuit prime once more time. @@ -98,7 +98,7 @@ static void resetPrimeFlags(); static void setupForPrimePause( void ); static void broadcastPrimingStatus( void ); -static void purgeAirDialyserBloodPumpControl( void ); +static void purgeAirDialyzerBloodPumpControl( void ); static void purgeAirValvesBloodPumpControl( void ); static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimeWaitForUserStartState( void ); @@ -107,10 +107,10 @@ static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimeSalineSetupState( void ); static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimePurgeAirState( void ); static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimeCircBloodCircuitState( void ); -static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimeReservoirOneFillCompleteState( void ); -static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimeDialysateDialyzerState( void ); static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimeReservoirTwoFillCompleteState( void ); static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimeDialysateBypassState( void ); +static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimeReservoirOneFillCompleteState( void ); +static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimeDialysateDialyzerState( void ); static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimeWetSelfTestsState( void ); static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimePause( void ); @@ -343,19 +343,19 @@ /*********************************************************************//** * @brief - * The purgeAirDialyserBloodPumpControl function controls valves and blood pump + * The purgeAirDialyzerBloodPumpControl function controls valves and blood pump * to purge air by priming the saline dialyzer fluid path. * @details Inputs: none * @details Outputs: run blood pump, close VDI, VDO, VBA and VBV valves, open VBT valve * @return current state (sub-mode) *************************************************************************/ -static void purgeAirDialyserBloodPumpControl( void ) +static void purgeAirDialyzerBloodPumpControl( void ) { setValvePosition( VDI, VALVE_POSITION_A_INSERT_EJECT ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); - setValveAirTrap( STATE_OPEN ); + setValveAirTrap( STATE_CLOSED ); signalDialOutPumpHardStop(); signalDialInPumpHardStop(); @@ -415,16 +415,16 @@ * The handlePrimeSalineDialyzerSetupState function implements the setup * prior to transition to the prime the saline dialyzer state. * @details Inputs: primeStartReqReceived - * @details Outputs: initialLoadCellReading, primeSalineDialyzerStartTime + * @details Outputs: primeSalineDializerInitialLoadCellReading, primeSalineDialyzerStartTime * @return current state *************************************************************************/ static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimeSalineDialyzerSetupState( void ) { HD_PRE_TREATMENT_PRIME_STATE_T state = HD_PRIME_SALINE_DIALYZER_STATE; - initialLoadCellReading = getLoadCellWeight( LOAD_CELL_RESERVOIR_2_PRIMARY ); + primeSalineDializerInitialLoadCellReading = getLoadCellWeight( LOAD_CELL_RESERVOIR_2_PRIMARY ); primeSalineDialyzerStartTime = getMSTimerCount(); - purgeAirDialyserBloodPumpControl(); + purgeAirDialyzerBloodPumpControl(); if ( TRUE == doesAlarmStatusIndicateStop() ) { @@ -449,19 +449,14 @@ F32 const loadcellWeight = getLoadCellWeight( LOAD_CELL_RESERVOIR_2_PRIMARY ); - if ( (loadcellWeight - initialLoadCellReading) > LOAD_CELL_VOLUME_SALINE_READING ) + if ( (loadcellWeight - primeSalineDializerInitialLoadCellReading) > PRIME_SALINE_DIALYZER_STOP_WEIGHT ) { state = HD_PRIME_SALINE_SETUP_STATE; } - else - { - primeSalineDialyzerStartTime = getMSTimerCount(); - } if ( TRUE == didTimeout( primeSalineDialyzerStartTime, PRIME_SALINE_DIALYZER_TIME_LIMIT ) ) { - // SET_ALARM_WITH_1_U32_DATA( ALARM_ID_PRIME_SALINE_DIALYZER_TIME_OUT, PRIME_SALINE_DIALYZER_TIME_LIMIT ); TODO - // if 5 minutes timeout occurs, what state should we go to? + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_PRIME_SALINE_DIALYZER_TIME_OUT, PRIME_SALINE_DIALYZER_TIME_LIMIT ); } if ( TRUE == doesAlarmStatusIndicateStop() ) @@ -637,10 +632,8 @@ { if ( TRUE == didTimeout( loadcellSteadyVolumeStartTime, MIN_LOAD_CELL_STEADY_VOLUME_TIME ) ) { - //transitionToWetSelfTests(); - //state = HD_PRIME_WET_SELF_TESTS_STATE; - if ( TRUE == runBloodCircuitPrimeAgain ) - { + if ( TRUE == runBloodCircuitPrimeAgain ) // TODO: Determine if we still need to go to HD_PRIME_SALINE_SETUP_STATE the first time + { // since a new state HD_PRIME_SALINE_DIALYZER_STATE has been added runBloodCircuitPrimeAgain = FALSE; state = HD_PRIME_SALINE_SETUP_STATE; // should we go to HD_PRIME_SALINE_SETUP_STATE or HD_PRIME_SALINE_DIALYZER_SETUP_STATE? }