Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -rd91a24c730aeb5cd7e3eba9ef4eca78e442911f8 -r1a685471524555a374854c0c9ec8e208e71fe2df --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision d91a24c730aeb5cd7e3eba9ef4eca78e442911f8) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 1a685471524555a374854c0c9ec8e208e71fe2df) @@ -8,20 +8,23 @@ * @file ModePreTreat.c * * @author (last) Sean Nash -* @date (last) 28-Aug-2020 +* @date (last) 06-Oct-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ +#include "AirTrap.h" #include "AlarmLamp.h" #include "BloodFlow.h" #include "DialInFlow.h" #include "DialOutFlow.h" #include "Buttons.h" #include "OperationModes.h" +#include "SystemCommMessages.h" #include "ModePreTreat.h" +#include "SystemCommMessages.h" #ifdef RM46_EVAL_BOARD_TARGET #include "Timers.h" static U32 start; @@ -34,14 +37,15 @@ // ********** private data ********** +static BOOL treatStartReqReceived = FALSE; ///< Flag indicates user requests treatment begin. + // ********** private function prototypes ********** /*********************************************************************//** * @brief * The initPreTreatmentMode function initializes the Pre-Treatment Mode module. - * @details - * Inputs : none - * Outputs : Pre-Treatment Mode module initialized. + * @details Inputs: none + * @details Outputs: Pre-Treatment Mode module initialized. * @return none *************************************************************************/ void initPreTreatmentMode( void ) @@ -52,25 +56,14 @@ * @brief * The transitionToPreTreatmentMode function prepares for transition to * pre-treatment mode. - * @details - * Inputs : none - * Outputs : none + * @details Inputs: none + * @details 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 + treatStartReqReceived = FALSE; + #ifdef RM46_EVAL_BOARD_TARGET start = getMSTimerCount(); #endif @@ -79,21 +72,20 @@ /*********************************************************************//** * @brief * The execFaultMode function executes the Pre-Treatment Mode state machine. - * @details - * Inputs : none - * Outputs : none + * @details Inputs: none + * @details Outputs: none * @return current state (sub-mode) *************************************************************************/ U32 execPreTreatmentMode( void ) { - BOOL stop = isStopButtonPressed(); + BOOL stop = isStopButtonPressed(); -#ifndef UF_TEST_ENABLED - if ( TRUE == stop ) +#ifndef DISABLE_UI_TREATMENT_WORKFLOW + if ( TRUE == treatStartReqReceived ) #endif - { - requestNewOperationMode( MODE_TREA ); - } + { + requestNewOperationMode( MODE_TREA ); + } #ifdef RM46_EVAL_BOARD_TARGET if ( TRUE == didTimeout( start, 5000U ) ) { @@ -104,4 +96,26 @@ return 0; // TODO - return current state } +/*********************************************************************//** + * @brief + * The signalUserBeginningTreatment function handles user start of a + * treatment. + * @details Inputs: none + * @details Outputs: requested mode transition to treatment mode + * @return TRUE if signal accepted, FALSE if not + *************************************************************************/ +BOOL signalUserBeginningTreatment( void ) +{ + BOOL result = FALSE; + + if ( MODE_PRET == getCurrentOperationMode() ) + { + treatStartReqReceived = TRUE; + result = TRUE; + } + sendTreatmentStartResponseMsg( result, 0 ); // TODO - provide reason code if rejected + + return result; +} + /**@}*/