Index: firmware/App/Modes/Rinseback.c =================================================================== diff -u -rc539499ea2dee6d62194d573ac93b313d9e2936d -rfa356a2bce909141f45c6832659fa1ceea5bfbba --- firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision c539499ea2dee6d62194d573ac93b313d9e2936d) +++ firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision fa356a2bce909141f45c6832659fa1ceea5bfbba) @@ -16,7 +16,11 @@ ***************************************************************************/ #include "AirTrap.h" +#include "BloodFlow.h" #include "Buttons.h" +#include "DGInterface.h" +#include "DialInFlow.h" +#include "DialOutFlow.h" #include "ModeTreatment.h" #include "OperationModes.h" #include "Rinseback.h" @@ -33,6 +37,12 @@ // ********** private function prototypes ********** +static RINSEBACK_STATE_T handleRinsebackStopInitState( void ); +static RINSEBACK_STATE_T handleRinsebackRunState( void ); +static RINSEBACK_STATE_T handleRinsebackPausedState( void ); +static RINSEBACK_STATE_T handleRinsebackStoppedState( void ); +static RINSEBACK_STATE_T handleRinsebackRunAdditionalState( void ); + /*********************************************************************//** * @brief * The initRinseback function initializes the Rinseback sub-mode module. @@ -57,17 +67,25 @@ { initRinseback(); + // Set user alarm recovery actions allowed in this sub-mode + setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); + setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); + setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); + // Set valves to safe 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 ); - // Reset saline bolus state in case alarm interrupted one - resetSalineBolus(); - // Stop air trap control - endAirTrapControl(); - // Should always have stopped alarm active in treatment stop sub-mode so that user can take action - activateAlarmNoData( ALARM_ID_TREATMENT_STOPPED_BY_USER ); + setValvePosition( VBA, VALVE_POSITION_B_OPEN ); + setValvePosition( VBV, VALVE_POSITION_B_OPEN ); + + // Ensure all pumps except DPi stopped + signalBloodPumpHardStop(); + signalDialOutPumpHardStop(); + // TODO - stop Heparin pump + + // Re-circulate dialysate side of dialyzer w/ heating to maintain temperature + setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_RECIRC, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + cmdStartDGTrimmerHeater(); } /*********************************************************************//** @@ -79,7 +97,95 @@ *************************************************************************/ void execRinseback( void ) { - // TODO - implement + switch ( rinsebackState ) + { + case RINSEBACK_STOP_INIT_STATE: + rinsebackState = handleRinsebackStopInitState(); + //setBloodIsPrimed( FALSE ); TODO - call in handler when transition to RB run + break; + + case RINSEBACK_RUN_STATE: + rinsebackState = handleRinsebackRunState(); + //setRinsebackIsCompleted( TRUE ); TODO - call in handler when rinseback is done + break; + + case RINSEBACK_PAUSED_STATE: + rinsebackState = handleRinsebackPausedState(); + break; + + case RINSEBACK_STOP_STATE: + rinsebackState = handleRinsebackStoppedState(); + break; + + case RINSEBACK_RUN_ADDITIONAL_STATE: + rinsebackState = handleRinsebackRunAdditionalState(); + break; + + default: + // TODO - s/w fault + break; + } } +static RINSEBACK_STATE_T handleRinsebackStopInitState( void ) +{ + RINSEBACK_STATE_T result = RINSEBACK_STOP_INIT_STATE; + + return result; +} + +static RINSEBACK_STATE_T handleRinsebackRunState( void ) +{ + RINSEBACK_STATE_T result = RINSEBACK_RUN_STATE; + + return result; +} + +static RINSEBACK_STATE_T handleRinsebackPausedState( void ) +{ + RINSEBACK_STATE_T result = RINSEBACK_PAUSED_STATE; + + return result; +} + +static RINSEBACK_STATE_T handleRinsebackStoppedState( void ) +{ + RINSEBACK_STATE_T result = RINSEBACK_STOP_STATE; + + return result; +} + +static RINSEBACK_STATE_T handleRinsebackRunAdditionalState( void ) +{ + RINSEBACK_STATE_T result = RINSEBACK_RUN_ADDITIONAL_STATE; + + return result; +} + +/*********************************************************************//** + * @brief + * The signalStopRinseback function signals the rinseback sub-mode + * to stop per an active alarm. + * @details Inputs: none + * @details Outputs: none + * @return none + *************************************************************************/ +void signalStopRinseback( void ) +{ + +} + +/*********************************************************************//** + * @brief + * The getCurrentRinsebackState function returns the current state of the + * rinseback sub-mode. + * @details Inputs: rinsebackState + * @details Outputs: none + * @return rinsebackState + *************************************************************************/ +RINSEBACK_STATE_T getCurrentRinsebackState( void ) +{ + return rinsebackState; +} + /**@}*/