/************************************************************************** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file TreatmentStop.c * * @author (last) Sean Nash * @date (last) 24-Sep-2020 * * @author (original) Sean * @date (original) 15-Jan-2020 * ***************************************************************************/ #include "AirTrap.h" #include "Buttons.h" #include "ModeTreatment.h" #include "OperationModes.h" #include "TreatmentStop.h" #include "Valves.h" /** * @addtogroup TreatmentStop * @{ */ // ********** private data ********** // ********** private function prototypes ********** /*********************************************************************//** * @brief * The initTreatmentStop function initializes the Treatment Stop sub-mode * module. * @details Inputs: none * @details Outputs: Treatment Stop sub-mode module initialized. * @return none *************************************************************************/ void initTreatmentStop( void ) { } /*********************************************************************//** * @brief * The transitionToTreatmentStop function prepares for transition to treatment * stop sub-mode. * @details Inputs: none * @details Outputs: none * @return none *************************************************************************/ void transitionToTreatmentStop( void ) { // 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 an alarm active in treatment stop sub-mode so that user can take action if ( FALSE == isAnyAlarmActive() ) { if ( FALSE == getRinsebackCompleted() ) { activateAlarmNoData( ALARM_ID_TREATMENT_STOPPED_AFTER_RINSEBACK ); } else { activateAlarmNoData( ALARM_ID_TREATMENT_STOPPED_BY_USER ); } // coming back to stop state via non-alarm path, so no audio - just want alarm for its options signalAlarmSilence( ALARM_SILENCE_CMD_CANCEL ); } // Set user alarm recovery actions allowed in this sub-mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); if ( TRUE == getRinsebackCompleted() ) { // block rinseback action if already done setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); } else { setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, TRUE ); } setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE ); } /*********************************************************************//** * @brief * The execTreatmentStop function executes the Treatment Stop sub-mode * state machine. * @details Inputs: none * @details Outputs: none * @return none *************************************************************************/ void execTreatmentStop( void ) { // TODO - implement } /**@}*/