Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -ra57af2726f27208a2de96e9331678caf022d927d -rf4da3db4393f4f58c032365580cdba1e1e20d2e8 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision a57af2726f27208a2de96e9331678caf022d927d) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision f4da3db4393f4f58c032365580cdba1e1e20d2e8) @@ -33,7 +33,6 @@ #include "Switches.h" #include "SyringePump.h" #include "SystemCommTD.h" -#include "SyringePump.h" #include "TxParams.h" #include "Valve3Way.h" #include "Valves.h" @@ -56,16 +55,16 @@ static FLUID_TYPE_T fluidType; ///< Fluid type assigned based on user selection. static TREATMENT_TYPE_T modality; ///< Modality from the treatment initiation. static BOOL heatDisinfectionStartConfirmed; +static BOOL ddHeatDisinfectionStarted; ///< Flag indicates DD has entered Heat Disinfection mode. static DD_COMMAND_T requestedDisinfectionCommand = DD_CMD_NONE; // ********** private function prototypes ********** static TD_STANDBY_STATE_T handleStandbyModeStartState( void ); static TD_STANDBY_STATE_T handleStandbyModeWaitForTreatmentState( void ); -static void setRequestedCleaningMode( DISINFECT_SELECTION_T opMode ); static TD_STANDBY_STATE_T handleStandbyModeWaitForDisinfectState( void ); static TD_STANDBY_STATE_T handleStandbyModeWaitForDDCleaningModeCmdResponseState( void ); -static TD_STANDBY_STATE_T handleStandbyModeWaitForDDCleaningModeStartState( void ); +//static TD_STANDBY_STATE_T handleStandbyModeWaitForDDCleaningModeStartState( void ); static TD_STANDBY_STATE_T handleStandbyModeDDCleaningModeInProgressState( void ); static void setStandbyStateTransition( void ); @@ -82,6 +81,7 @@ treatStartReqReceived = FALSE; homingInitiated = FALSE; heatDisinfectionStartConfirmed = FALSE; + ddHeatDisinfectionStarted = FALSE; fluidType = FLUID_TYPE_UNKNOWN; modality = TREATMENT_MODALITY_HD_SALINE_FLUID; } @@ -178,9 +178,9 @@ currentStandbyState = handleStandbyModeWaitForDDCleaningModeCmdResponseState(); break; - case STANDBY_WAIT_FOR_DD_CLEANING_MODE_TO_START_STATE: - currentStandbyState = handleStandbyModeWaitForDDCleaningModeStartState(); - break; +// case STANDBY_WAIT_FOR_DD_CLEANING_MODE_TO_START_STATE: +// currentStandbyState = handleStandbyModeWaitForDDCleaningModeStartState(); +// break; case STANDBY_CLEANING_MODE_IN_PROGRESS_STATE: currentStandbyState = handleStandbyModeDDCleaningModeInProgressState(); @@ -229,16 +229,18 @@ retractSyringePump(); } + homeEjector(); homingInitiated = TRUE; } else if ( ( VALVE_STATE_IDLE == getValveState( H1_VALV ) ) && - ( VALVE_STATE_IDLE == getValveState( H19_VALV ) ) ) - { + ( VALVE_STATE_IDLE == getValveState( H19_VALV ) ) && + ( TRUE == isSyringePumpHome() ) ) + { // After homing completes, move both pinch valves to Position A. setValvePosition( H1_VALV, VALVE_POSITION_A_INSERT_EJECT ); setValvePosition( H19_VALV, VALVE_POSITION_A_INSERT_EJECT ); homingInitiated = FALSE; - state = STANDBY_WAIT_FOR_TREATMENT_STATE; + // Determine the next Standby state from the Post-Treatment // disinfection selection. switch ( requestedDisinfectionCommand ) @@ -253,12 +255,16 @@ break; case DD_CMD_START_DISINFECT_HEAT: - state = STANDBY_WAIT_FOR_DISINFECT_STATE; + // Instruction screen is not implemented yet. + // Start Heat Disinfection directly after Standby initialization. + cmdSendDDCommand( DD_CMD_START_DISINFECT_HEAT ); + + state = STANDBY_WAIT_FOR_DD_CLEANING_MODE_CMD_RESPONSE_STATE; break; default: - state = STANDBY_WAIT_FOR_TREATMENT_STATE; requestedDisinfectionCommand = DD_CMD_NONE; + state = STANDBY_WAIT_FOR_TREATMENT_STATE; break; } } @@ -279,31 +285,7 @@ TD_STANDBY_STATE_T state = STANDBY_WAIT_FOR_TREATMENT_STATE; F32 bicarbConvFactor = BICARBONATE_CONVERSION_FACTOR; TD_VERSIONS_T payload; - //TODO -// DD_OP_MODE_T ddOperationMode = getDDOpMode(); -// switch ( ddOperationMode ) -// { -// case DD_MODE_GENE: -// // If DD is in idle generation state while we are in standby mode, transition DD to standby too -// cmdStopDD(); -// break; -// -// // If DD is any of the cleaning modes, set the TD standby to be in the corresponding cleaning mode -// case DD_MODE_HEAT: -// case DD_MODE_HCOL: -// case DD_MODE_ROPS: -// setRequestedCleaningMode( ddOperationMode ); -// state = STANDBY_WAIT_FOR_DD_CLEANING_MODE_TO_START_STATE; -// // DD cleaning mode handling is not enabled yet. -// // Stay in Wait For Treatment until DD returns to a supported standby state. -// break; -// -// default: -// // Do nothing. There are other DD modes that TD standby does not need to act upon them. -// break; -// } - // If DD is communicating and we don't yet have DD version info, request it. if ( TRUE == isDDCommunicating() ) { @@ -399,62 +381,70 @@ { if ( FALSE == ddCmdResp.rejected ) { - state = STANDBY_WAIT_FOR_DD_CLEANING_MODE_TO_START_STATE; + ddHeatDisinfectionStarted = FALSE; + + activateAlarmNoData( ALARM_ID_TD_HEAT_DISINFECTION_IN_PROGRESS ); + + state = STANDBY_CLEANING_MODE_IN_PROGRESS_STATE; } else { // DD rejected the Heat Disinfection start request. - // Return to the setup confirmation state so the request - // may be retried. - state = STANDBY_WAIT_FOR_DISINFECT_STATE; + requestedDisinfectionCommand = DD_CMD_NONE; + ddHeatDisinfectionStarted = FALSE; + + state = STANDBY_WAIT_FOR_TREATMENT_STATE; } } return state; } -/*********************************************************************//** - * @brief - * The handleStandbyModeWaitForDDCleaningModeStartState function handles - * the standby mode wait for DD cleaning mode to start state. - * @details \b Inputs: DD operation mode - * @details \b Outputs: none - * @return next state of the standby mode state machine - *************************************************************************/ -static TD_STANDBY_STATE_T handleStandbyModeWaitForDDCleaningModeStartState( void ) -{ - TD_STANDBY_STATE_T state = STANDBY_WAIT_FOR_DD_CLEANING_MODE_TO_START_STATE; +///*********************************************************************//** +// * @brief +// * The handleStandbyModeWaitForDDCleaningModeStartState function handles +// * the standby mode wait for DD cleaning mode to start state. +// * @details \b Inputs: DD operation mode +// * @details \b Outputs: none +// * @return next state of the standby mode state machine +// *************************************************************************/ +//static TD_STANDBY_STATE_T handleStandbyModeWaitForDDCleaningModeStartState( void ) +//{ +// TD_STANDBY_STATE_T state = STANDBY_WAIT_FOR_DD_CLEANING_MODE_TO_START_STATE; +// +// // Wait until DD reports that Heat Disinfection has started. +// if ( DD_MODE_HEAT == getDDOpMode() ) +// { +// state = STANDBY_CLEANING_MODE_IN_PROGRESS_STATE; +// } +// +// return state; +//} - // Wait until DD reports that Heat Disinfection has started. - if ( DD_MODE_HEAT == getDDOpMode() ) - { - state = STANDBY_CLEANING_MODE_IN_PROGRESS_STATE; - } - - return state; -} - /*********************************************************************//** * @brief * The handleStandbyModeDDCleaningModeInProgressState function handles * Heat Disinfection while DD cleaning is in progress. - * @details \b Inputs: DD operation mode and DD sub-mode. - * @details \b Outputs: requestedDisinfectionCommand, - * heatDisinfectionStartConfirmed. + * @details \b Inputs: DD operation mode. + * @details \b Outputs: ddHeatDisinfectionStarted, + * requestedDisinfectionCommand. * @return Next Standby mode state. *************************************************************************/ static TD_STANDBY_STATE_T handleStandbyModeDDCleaningModeInProgressState( void ) { TD_STANDBY_STATE_T state = STANDBY_CLEANING_MODE_IN_PROGRESS_STATE; - // DD transitions back to Standby when Heat Disinfection is complete. - if ( DD_MODE_STAN == getDDOpMode() ) + if ( DD_MODE_HEAT == getDDOpMode() ) { - // Clear Heat Disinfection in-progress alarm. - // clearAlarm( ); + ddHeatDisinfectionStarted = TRUE; + } + else if ( ( TRUE == ddHeatDisinfectionStarted ) && + ( DD_MODE_STAN == getDDOpMode() ) ) + { + clearAlarm( ALARM_ID_TD_HEAT_DISINFECTION_IN_PROGRESS ); requestedDisinfectionCommand = DD_CMD_NONE; - heatDisinfectionStartConfirmed = FALSE; + ddHeatDisinfectionStarted = FALSE; state = STANDBY_WAIT_FOR_TREATMENT_STATE; } @@ -516,10 +506,6 @@ // No additional actuator changes required. break; - case STANDBY_WAIT_FOR_DD_CLEANING_MODE_TO_START_STATE: - // No additional actuator changes required. - break; - case STANDBY_CLEANING_MODE_IN_PROGRESS_STATE: // No additional actuator changes required. break; @@ -772,14 +758,19 @@ { if ( DISINFECT_SEL_SKIP == options ) { - requestedDisinfectionCommand = DD_CMD_START_DISINFECT_SKIP; - currentStandbyState = STANDBY_WAIT_FOR_TREATMENT_STATE; + requestedDisinfectionCommand = DD_CMD_NONE; result = TRUE; } else if ( DISINFECT_SEL_HEAT == options ) { requestedDisinfectionCommand = DD_CMD_START_DISINFECT_HEAT; - currentStandbyState = STANDBY_WAIT_FOR_DISINFECT_STATE; + + // Instruction screen is not implemented yet. + // Start Heat Disinfection directly. + cmdSendDDCommand( DD_CMD_START_DISINFECT_HEAT ); + + currentStandbyState = STANDBY_WAIT_FOR_DD_CLEANING_MODE_CMD_RESPONSE_STATE; + result = TRUE; } } @@ -794,12 +785,12 @@ /*********************************************************************//** * @brief - * The handleDisinfectionConfirmCmd function handles user selection - * of the Post-Treatment disinfection operation. - * @details \b Inputs: Disinfection selection message. - * @details \b Outputs: Acceptance response and selected disinfection command. + * The handleDisinfectionConfirmCmd function handles user confirmation + * of the Heat Disinfection setup instructions in Standby mode. + * @details \b Inputs: Heat Disinfection confirmation message. + * @details \b Outputs: heatDisinfectionStartConfirmed and response to UI. * @param message Pointer to the message to handle. - * @return TRUE if the selection is accepted, FALSE otherwise. + * @return TRUE if the confirmation is accepted, FALSE otherwise. *************************************************************************/ BOOL handleDisinfectionConfirmCmd( MESSAGE_T *message ) { @@ -811,22 +802,28 @@ if ( sizeof( U32 ) == message->hdr.payloadLen ) { - if ( ( STANDBY_WAIT_FOR_DISINFECT_STATE == currentStandbyState ) && - ( DD_CMD_START_DISINFECT_HEAT == requestedDisinfectionCommand ) ) + if ( MODE_STAN != mode ) { + response.rejectionReason = + REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE; + } + else if ( ( STANDBY_WAIT_FOR_DISINFECT_STATE == currentStandbyState ) && + ( DD_CMD_START_DISINFECT_HEAT == requestedDisinfectionCommand ) ) + { // User confirmed Heat Disinfection setup screen. heatDisinfectionStartConfirmed = TRUE; result = TRUE; } else { - result = FALSE; - response.rejectionReason = REQUEST_REJECT_REASON_CONFIRMATION_NOT_EXPECTED; + response.rejectionReason = + REQUEST_REJECT_REASON_CONFIRMATION_NOT_EXPECTED; } } else { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + response.rejectionReason = + REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } response.accepted = result;