/************************************************************************** * * 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 ModePreTreat.c * * @author (last) Sean Nash * @date (last) 29-May-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ #include "AlarmLamp.h" #include "BloodFlow.h" #include "DialInFlow.h" #include "DialOutFlow.h" #include "Buttons.h" #include "OperationModes.h" #include "ModePreTreat.h" #ifdef RM46_EVAL_BOARD_TARGET #include "Timers.h" static U32 start; #endif /** * @addtogroup HDPreTreatmentMode * @{ */ // ********** private data ********** // ********** private function prototypes ********** /*********************************************************************//** * @brief * The initPreTreatmentMode function initializes the Pre-Treatment Mode module. * @details * Inputs : none * Outputs : Pre-Treatment Mode module initialized. * @return none *************************************************************************/ void initPreTreatmentMode( void ) { } /*********************************************************************//** * @brief * The transitionToPreTreatmentMode function prepares for transition to * pre-treatment mode. * @details * Inputs : none * Outputs : none * @return none *************************************************************************/ void transitionToPreTreatmentMode( void ) { // temporary test code. TODO - remove later #ifndef UF_TEST_ENABLED #ifndef RUN_PUMPS_OPEN_LOOP setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); #else setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); #endif setDialOutPumpTargetRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); #else #endif #ifdef RM46_EVAL_BOARD_TARGET start = getMSTimerCount(); #endif } /*********************************************************************//** * @brief * The execFaultMode function executes the Pre-Treatment Mode state machine. * @details * Inputs : none * Outputs : none * @return current state (sub-mode) *************************************************************************/ U32 execPreTreatmentMode( void ) { BOOL stop = isStopButtonPressed(); #ifndef UF_TEST_ENABLED if ( TRUE == stop ) #endif { requestNewOperationMode( MODE_TREA ); } #ifdef RM46_EVAL_BOARD_TARGET if ( TRUE == didTimeout( start, 5000U ) ) { requestNewOperationMode( MODE_TREA ); } #endif return 0; // TODO - return current state } /**@}*/