/************************************************************************** * * 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 TreatmentRecirc.c * * @author (last) Sean Nash * @date (last) 14-Jan-2021 * * @author (original) Sean * @date (original) 14-Jan-2021 * ***************************************************************************/ #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 "TreatmentRecirc.h" #include "Valves.h" /** * @addtogroup TreatmentRecirculate * @{ */ // ********** private data ********** static TREATMENT_RECIRC_STATE_T treatmentRecircState; ///< Current state of the treatment re-circulate sub-mode. // ********** private function prototypes ********** static TREATMENT_RECIRC_STATE_T handleRecircRecircState( void ); static TREATMENT_RECIRC_STATE_T handleRecircStoppedState( void ); /*********************************************************************//** * @brief * The initTreatmentRecirc function initializes the Treatment Re-circulate sub-mode * module. * @details Inputs: none * @details Outputs: Treatment Re-circulate sub-mode module initialized. * @return none *************************************************************************/ void initTreatmentRecirc( void ) { treatmentRecircState = TREATMENT_RECIRC_RECIRC_STATE; } /*********************************************************************//** * @brief * The transitionToTreatmentRecirc function prepares for transition to treatment * re-circulate sub-mode. * @details Inputs: none * @details Outputs: none * @return none *************************************************************************/ void transitionToTreatmentRecirc( void ) { initTreatmentRecirc(); // 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 ); // 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 ); } /*********************************************************************//** * @brief * The execTreatmentRecirc function executes the Treatment circulate sub-mode * state machine. * @details Inputs: none * @details Outputs: none * @return none *************************************************************************/ void execTreatmentRecirc( void ) { switch ( treatmentRecircState ) { case TREATMENT_RECIRC_RECIRC_STATE: treatmentRecircState = handleRecircRecircState(); break; case TREATMENT_RECIRC_STOPPED_STATE: treatmentRecircState = handleRecircStoppedState(); break; default: // TODO - s/w fault break; } } static TREATMENT_RECIRC_STATE_T handleRecircRecircState( void ) { TREATMENT_RECIRC_STATE_T result = TREATMENT_RECIRC_RECIRC_STATE; return result; } static TREATMENT_RECIRC_STATE_T handleRecircStoppedState( void ) { TREATMENT_RECIRC_STATE_T result = TREATMENT_RECIRC_STOPPED_STATE; return result; } /*********************************************************************//** * @brief * The signalStopTreatmentRecirc function signals the treatment re-circulate * sub-mode to stop per an active alarm. * @details Inputs: none * @details Outputs: none * @return none *************************************************************************/ void signalStopTreatmentRecirc( void ) { } /*********************************************************************//** * @brief * The getCurrentTreatmentRecircState function returns the current state of the * treatment re-circulate sub-mode. * @details Inputs: treatmentRecircState * @details Outputs: none * @return treatmentRecircState *************************************************************************/ TREATMENT_RECIRC_STATE_T getCurrentTreatmentRecircState( void ) { return treatmentRecircState; } /**@}*/