Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rcbaa57803fa8359407a799fca0cde6ae2c486bd7 -rcb832b3a86cc2a3147e8447f33fc99f34a2b0011 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision cbaa57803fa8359407a799fca0cde6ae2c486bd7) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision cb832b3a86cc2a3147e8447f33fc99f34a2b0011) @@ -30,10 +30,13 @@ #include "ModeTreatment.h" #include "ModeTreatmentParams.h" #include "OperationModes.h" +#include "Switches.h" +#include "SyringePump.h" #include "SystemComm.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "Timers.h" +#include "Valves.h" #ifdef EMC_TEST_BUILD // TODO - test code #include "FPGA.h" #endif @@ -64,6 +67,7 @@ // ********** private function prototypes ********** +static HD_STANDBY_STATE_T handleStandbyModeStartState( void ); static HD_STANDBY_STATE_T handleStandbyModeWaitForTreatmentState( void ); static HD_STANDBY_STATE_T handleStandbyModeWaitForDisinfectState( void ); @@ -160,7 +164,7 @@ switch ( currentStandbyState ) { case STANDBY_START_STATE: - currentStandbyState = STANDBY_WAIT_FOR_TREATMENT_STATE; + currentStandbyState = handleStandbyModeStartState();; break; case STANDBY_WAIT_FOR_TREATMENT_STATE: @@ -510,6 +514,46 @@ /*********************************************************************//** * @brief + * The handleStandbyModeStartState function handles the standby start state. + * This state waits for the door to be closed and then initiates homing of + * pumps and valves and transitions to the wait for treatment state. + * @details Inputs: + * @details Outputs: + * @return next state of the standby mode state machine + *************************************************************************/ +static HD_STANDBY_STATE_T handleStandbyModeStartState( void ) +{ + HD_STANDBY_STATE_T state = STANDBY_START_STATE; + + // Wait for door to be closed so we can home actuators + if ( STATE_CLOSED == getSwitchStatus( FRONT_DOOR ) ) + { + VALVE_T valve; + + // Home pumps and valves + for ( valve = VDI; valve < NUM_OF_VALVES; ++valve ) + { + homeValve( valve ); + } + homeBloodPump(); + homeDialInPump(); + homeDialOutPump(); + retractSyringePump(); + + // Go to wait for treatment state + state = STANDBY_WAIT_FOR_TREATMENT_STATE; + } + else + { + // Trigger door open alarm to prompt user to close the door + activateAlarmNoData( ALARM_ID_CARTRIDGE_DOOR_OPENED ); + } + + return state; +} + +/*********************************************************************//** + * @brief * The handleStandbyModeWaitForTreatmentState function handles wait for * treatment state. * @details Inputs: treatStartReqReceived