Index: firmware/App/Controllers/BoostPump.c =================================================================== diff -u -r830213bc6dcc1a684610caf78c79d55f2cb41e93 -r00ee92f70b5f2748482955acfcf1ad246e53cfa3 --- firmware/App/Controllers/BoostPump.c (.../BoostPump.c) (revision 830213bc6dcc1a684610caf78c79d55f2cb41e93) +++ firmware/App/Controllers/BoostPump.c (.../BoostPump.c) (revision 00ee92f70b5f2748482955acfcf1ad246e53cfa3) @@ -51,20 +51,12 @@ #define DATA_PUBLISH_COUNTER_START_COUNT 10 ///< Data publish counter start count. -/// Enumeration of Boost pump states. -typedef enum BoostPump_States -{ - BOOST_PUMP_OFF_STATE = 0, ///< Boost pump off state. - BOOST_PUMP_CONTROL_TO_TARGET_FLOW_STATE, ///< Boost pump control to target flow state. - BOOST_PUMP_CONTROL_TO_TARGET_PRESSURE_STATE, ///< Boost pump control to max pressure state. - BOOST_PUMP_OPEN_LOOP_STATE, ///< Boost pump open loop state. - NUM_OF_Boost_PUMP_STATES ///< Number of Boost pump states. -} BOOST_PUMP_STATE_T; +/// PWM line equation for pressure. converted to percentage. +#define ROP_PRESSURE_TO_PWM_PCT(pres) ( ( BOOST_PRESSURE_TO_PWM_SLOPE * pres + BOOST_PRESSURE_TO_PWM_INTERCEPT ) / MAX_FLUID_PUMP_PWM_DUTY_CYCLE ) // ********** private data ********** static BOOST_PUMP_STATE_T boostPumpState; ///< Current state of pump controller state machine. -static PUMP_CONTROL_MODE_T boostPumpControlMode; ///< Requested pump control mode. static BOOL isBoostPumpOn; ///< Flag indicating whether pump is currently running. static BOOL stopPumpRequest; ///< Flag indicating pump stop is requested. static U32 boostPumpDataPublicationTimerCounter; ///< Used to schedule Boost pump data publication to CAN bus. @@ -90,7 +82,7 @@ /*********************************************************************//** * @brief * The initBoostPump function initializes the Boost Pump module. - * @details \b Inputs: boostPumpState, boostPumpControlMode, isBoostPumpOn, stopPumpRequest, + * @details \b Inputs: boostPumpState, isBoostPumpOn, stopPumpRequest, * boostControlTimerCounter, boostPumpDutyCyclePctSet, boostPumpOpenLoopTargetDutyCycle, boostPumpDataPublicationTimerCounter, * boostPumpDataPublishInterval, targetBoostPumpFlowRate, targetBoostPumpPressure * @details \b Outputs: Boost Pump controller unit initialized @@ -109,7 +101,6 @@ MIN_FLUID_PUMP_DUTY_CYCLE_PCT, MAX_FLUID_PUMP_DUTY_CYCLE_PCT, FALSE, 0 ); boostPumpState = BOOST_PUMP_OFF_STATE; - boostPumpControlMode = NUM_OF_PUMP_CONTROL_MODES; isBoostPumpOn = FALSE; stopPumpRequest = FALSE; boostControlTimerCounter = 0; @@ -180,7 +171,7 @@ * @brief * The handleBoostPumpOffState function handles the off state of the Boost pump * state machine. - * @details \b Inputs: isBoostPumpOn, boostPumpControlMode, boostPumpOpenLoopTargetDutyCycle + * @details \b Inputs: isBoostPumpOn, boostPumpOpenLoopTargetDutyCycle * @details \b Outputs: isBoostPumpOn, boostPumpDutyCyclePctSet * @return next state *************************************************************************/ @@ -193,7 +184,7 @@ if ( TRUE == isBoostPumpInstalled() ) { // If there is a target pressure set, transition to the PI controller and control to pressure. - if ( ( getTargetBoostPumpPressure() > 0.0F ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) + if ( getTargetBoostPumpPressure() > 0.0F ) { // Set pump to on isBoostPumpOn = TRUE; @@ -204,7 +195,7 @@ } // If there is a target flow set, transition to the PI controller and control to flow - else if ( ( getTargetBoostPumpFlowRateMLPM() > 0 ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) + else if ( getTargetBoostPumpFlowRateMLPM() > 0 ) { // Set pump to on isBoostPumpOn = TRUE; @@ -215,7 +206,7 @@ } // If the target duty cycle is greater than zero (minimum is 10%) and the mode has been set to open // loop, set the duty cycle - else if ( ( getTargetBoostPumpDutyCyclePCT() > 0.0F ) && ( PUMP_CONTROL_MODE_OPEN_LOOP == boostPumpControlMode ) ) + else if ( getTargetBoostPumpDutyCyclePCT() > 0.0F ) { setFluidPumpPctToPWMDutyCycle( P40_PUMP, getTargetBoostPumpDutyCyclePCT() ); boostPumpDutyCyclePctSet = getTargetBoostPumpDutyCyclePCT(); @@ -230,7 +221,7 @@ * @brief * The handleBoostPumpOpenLoopState function handles the open loop control * state of the Boost pump state machine. - * @details \b Inputs: stopPumpRequest, boostPumpControlMode, + * @details \b Inputs: stopPumpRequest, * boostPumpDutyCyclePctSet * @details \b Outputs: boostPumpState, stopPumpRequest * @return next state @@ -245,20 +236,24 @@ state = BOOST_PUMP_OFF_STATE; } // If there is a target pressure set, transition to the PI controller and control to pressure. - if ( ( getTargetBoostPumpPressure() > 0.0F ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) + if ( getTargetBoostPumpPressure() > 0.0F ) { // Transition to closed loop resetPIController( PI_CONTROLLER_ID_BOOST_PUMP_PRES, boostPumpDutyCyclePctSet, 0.0F ); state = BOOST_PUMP_CONTROL_TO_TARGET_PRESSURE_STATE; } // If there is a target flow set, transition to the PI controller and control to flow - else if ( ( getTargetBoostPumpFlowRateMLPM() > 0 ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) + else if ( getTargetBoostPumpFlowRateMLPM() > 0 ) { ///transition to closed loop resetPIController( PI_CONTROLLER_ID_BOOST_PUMP_FLOW, boostPumpDutyCyclePctSet, 0.0F ); state = BOOST_PUMP_CONTROL_TO_TARGET_FLOW_STATE; } + else if ( (F32)getTargetBoostPumpDutyCyclePCT() == 0.0F ) + { + signalBoostPumpHardStop(); + } return state; } @@ -267,7 +262,7 @@ * @brief * The handleBoostPumpControlToTargetFlowState function handles the control to * target flow state of the Boost pump controller state machine. - * @details \b Inputs: boostPumpPWMDutyCyclePctSet, boostControlTimerCounter, boostPumpControlMode + * @details \b Inputs: boostPumpPWMDutyCyclePctSet, boostControlTimerCounter * @details \b Outputs: boostPumpPWMDutyCyclePctSet, boostControlTimerCounter * @return next state of the controller state machine *************************************************************************/ @@ -276,27 +271,28 @@ BOOST_PUMP_STATE_T state = BOOST_PUMP_CONTROL_TO_TARGET_FLOW_STATE; // Check if need to switch control modes - if ( ( getTargetBoostPumpPressure() > 0.0F ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) + if ( getTargetBoostPumpPressure() > 0.0F ) { // Transition to target pressure resetPIController( PI_CONTROLLER_ID_BOOST_PUMP_PRES, boostPumpDutyCyclePctSet, 0 ); state = BOOST_PUMP_CONTROL_TO_TARGET_PRESSURE_STATE; } - else if ( ( getTargetBoostPumpDutyCyclePCT() > 0.0F ) && ( PUMP_CONTROL_MODE_OPEN_LOOP == boostPumpControlMode ) ) + else if ( getTargetBoostPumpDutyCyclePCT() > 0.0F ) { setFluidPumpPctToPWMDutyCycle( P40_PUMP, getTargetBoostPumpDutyCyclePCT() ); boostPumpDutyCyclePctSet = getTargetBoostPumpDutyCyclePCT(); state = BOOST_PUMP_OPEN_LOOP_STATE; } // Control at set interval or shut off - if ( ( (F32)getTargetBoostPumpFlowRateMLPM() == 0.0F ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) + if ( (F32)getTargetBoostPumpFlowRateMLPM() == 0.0F ) { signalBoostPumpHardStop(); } - else if ( ( ++boostControlTimerCounter >= BOOST_CONTROL_INTERVAL ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) + else if ( ++boostControlTimerCounter >= BOOST_CONTROL_INTERVAL ) { boostPumpDutyCyclePctSet = runPIController( PI_CONTROLLER_ID_BOOST_PUMP_FLOW, (F32)getTargetBoostPumpFlowRateMLPM(), getFilteredFlow( P7_FLOW ) ); + boostPumpDutyCyclePctSet = MIN( boostPumpDutyCyclePctSet, ( MAX_FLUID_PUMP_PWM_DUTY_CYCLE * MAX_FLUID_PUMP_DUTY_CYCLE_PCT ) ); setFluidPumpPctToPWMDutyCycle( P40_PUMP, boostPumpDutyCyclePctSet ); boostControlTimerCounter = 0; } @@ -308,7 +304,7 @@ * @brief * The handleBoostPumpControlToTargetPressureState function handles the control * to target pressure state of the Boost pump controller state machine. - * @details \b Inputs: boostPumpPWMDutyCyclePctSet, boostControlTimerCounter, boostPumpControlMode + * @details \b Inputs: boostPumpPWMDutyCyclePctSet, boostControlTimerCounter * @details \b Outputs: boostPumpPWMDutyCyclePctSet, boostControlTimerCounter * @return next state of the controller state machine *************************************************************************/ @@ -317,25 +313,25 @@ BOOST_PUMP_STATE_T state = BOOST_PUMP_CONTROL_TO_TARGET_PRESSURE_STATE; // Check if need to switch control modes - if ( ( getTargetBoostPumpFlowRateMLPM() > 0.0F ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) + if ( getTargetBoostPumpFlowRateMLPM() > 0.0F ) { ///transition to target flow resetPIController( PI_CONTROLLER_ID_BOOST_PUMP_FLOW, boostPumpDutyCyclePctSet, 0.0F ); state = BOOST_PUMP_CONTROL_TO_TARGET_FLOW_STATE; } - else if ( ( getTargetBoostPumpDutyCyclePCT() > 0.0F ) && ( PUMP_CONTROL_MODE_OPEN_LOOP == boostPumpControlMode ) ) + else if ( getTargetBoostPumpDutyCyclePCT() > 0.0F ) { setFluidPumpPctToPWMDutyCycle( P40_PUMP, getTargetBoostPumpDutyCyclePCT() ); boostPumpDutyCyclePctSet = getTargetBoostPumpDutyCyclePCT(); state = BOOST_PUMP_OPEN_LOOP_STATE; } // Control at set interval or shut off - if ( ( getTargetBoostPumpPressure() == 0.0F ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) + if ( getTargetBoostPumpPressure() == 0.0F ) { signalBoostPumpHardStop(); } - else if ( ( ++boostControlTimerCounter >= BOOST_CONTROL_INTERVAL ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) + else if ( ++boostControlTimerCounter >= BOOST_CONTROL_INTERVAL ) { boostPumpDutyCyclePctSet = runPIController( PI_CONTROLLER_ID_BOOST_PUMP_PRES, getTargetBoostPumpPressure(), getFilteredPressure( M3_PRES ) ); setFluidPumpPctToPWMDutyCycle( P40_PUMP, boostPumpDutyCyclePctSet ); @@ -350,35 +346,45 @@ * The setBoostPumpTargetFlowRateLPM function sets a new target flow rate for the * Boost pump. * @details \b Inputs: boostPumpOpenLoopTargetDutyCycle - * @details \b Outputs: targetBoostPumpFlowRate, boostPumpControlMode, boostPumpDutyCyclePctSet, + * @details \b Outputs: targetBoostPumpFlowRate, boostPumpDutyCyclePctSet, * boostControlTimerCounter, isBoostPumpOn * @param boostFlowRate which is target Boost flow rate in mL/min + * @param firmwareCall indicates whether the call initiated by firmware + * internally or by dialin * @return TRUE if new target flow rate is set successfully, FALSE if not *************************************************************************/ -BOOL setBoostPumpTargetFlowRateMLPM( U32 boostFlowRate ) +BOOL setBoostPumpTargetFlowRateMLPM( U32 boostFlowRate, BOOL firmwareCall ) { BOOL result = FALSE; + BOOL skipSet = FALSE; // First of all, the flow rate must be in range if ( boostFlowRate <= MAX_BOOST_FLOWRATE_MLPM ) { - targetBoostPumpFlowRate.data = boostFlowRate; - boostPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; - // Get the initial guess of the duty cycle - boostPumpDutyCyclePctSet = boostPumpFlowToPWM( getTargetBoostPumpFlowRateMLPM() ); - boostControlTimerCounter = 0; - isBoostPumpOn = TRUE; - - // Clear previous target data - if ( getTargetBoostPumpPressure() > 0.0F ) + if ( firmwareCall == TRUE ) // firmware call { - targetBoostPumpPressure.data = 0.0F; + // set the target duty cycle and pressure to zero if there are no active override + if ( ( targetBoostPumpFlowRate.override == OVERRIDE_RESET ) && ( targetBoostPumpPressure.override == OVERRIDE_RESET ) && ( boostPumpOpenLoopTargetDutyCycle.override == OVERRIDE_RESET ) ) + { + targetBoostPumpPressure.data = 0; + boostPumpOpenLoopTargetDutyCycle.data = 0.0F; + } + // skip the firmware set call if any override is active + else + { + result = TRUE; + skipSet = TRUE; + } } - if ( getTargetBoostPumpDutyCyclePCT() > 0.0F ) + if ( skipSet != TRUE ) { - boostPumpOpenLoopTargetDutyCycle.data = 0.0F; + targetBoostPumpFlowRate.data = boostFlowRate; + // Get the initial guess of the duty cycle + boostPumpDutyCyclePctSet = boostPumpFlowToPWM( getTargetBoostPumpFlowRateMLPM() ); + boostControlTimerCounter = 0; + isBoostPumpOn = TRUE; + result = TRUE; } - result = TRUE; } // Requested flow rate is out of range else @@ -395,35 +401,46 @@ * Boost pump. * @details \b Inputs: boostPumpOpenLoopTargetDutyCycle, targetBoostPumpFlowRate * @details \b Outputs: boostPumpOpenLoopTargetDutyCycle, targetBoostPumpFlowRate, isBoostPumpOn, - * boostControlTimerCounter, boostPumpDutyCyclePctSet, boostPumpControlMode, targetBoostPumpPressure + * boostControlTimerCounter, boostPumpDutyCyclePctSet, targetBoostPumpPressure * @param boostPressure which is target Boost pressure + * @param firmwareCall indicates whether the call initiated by firmware + * internally or by dialin * @return TRUE if new target flow rate is set successfully, FALSE if not *************************************************************************/ -BOOL setBoostPumpTargetPressure( F32 boostPressure ) +BOOL setBoostPumpTargetPressure( F32 boostPressure, BOOL firmwareCall ) { BOOL result = FALSE; + BOOL skipSet = FALSE; // First of all, the pressure must be in range if ( ( boostPressure <= MAX_BOOST_PRESSURE_PSI ) && ( boostPressure >= MIN_BOOST_PRESSURE_PSI ) ) { - targetBoostPumpPressure.data = boostPressure; - boostPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; - // Get the initial guess of the duty cycle - boostPumpDutyCyclePctSet = boostPumpPresToPWM( getTargetBoostPumpPressure() ); - boostControlTimerCounter = 0; - isBoostPumpOn = TRUE; - // Clear previous target data - if ( getTargetBoostPumpFlowRateMLPM() > 0 ) + if ( firmwareCall == TRUE ) { - targetBoostPumpFlowRate.data = 0.0F; + // set the target flow and duty cycle to zero if there are no active override + if ( ( targetBoostPumpFlowRate.override == OVERRIDE_RESET ) && ( targetBoostPumpPressure.override == OVERRIDE_RESET ) && ( boostPumpOpenLoopTargetDutyCycle.override == OVERRIDE_RESET ) ) + { + targetBoostPumpFlowRate.data = 0; + boostPumpOpenLoopTargetDutyCycle.data = 0.0F; + } + // skip the firmware set call if any override is active + else + { + result = TRUE; + skipSet = TRUE; + } } - if ( getTargetBoostPumpDutyCyclePCT() > 0.0F ) + if ( skipSet != TRUE ) { - boostPumpOpenLoopTargetDutyCycle.data = 0.0F; + targetBoostPumpPressure.data = boostPressure; + // Get the initial guess of the duty cycle + boostPumpDutyCyclePctSet = boostPumpPresToPWM( getTargetBoostPumpPressure() ); + boostControlTimerCounter = 0; + isBoostPumpOn = TRUE; + } - result = TRUE; } - // Requested flow rate is out of range + // Requested pressure is out of range else { SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, FP_FAULT_ID_FP_PUMP_INVALID_PRESSURE_SELECTED, boostPressure ) @@ -439,38 +456,59 @@ * @details \b Inputs: boostPumpOpenLoopTargetDutyCycle, boostPumpPWMDutyCyclePct, * targetBoostPumpPressure, targetBoostPumpFlowRate * @details \b Outputs: boostPumpOpenLoopTargetDutyCycle - * boostPumpControlMode, targetBoostPumpFlowRate, targetBoostPumpPressure + * targetBoostPumpFlowRate, targetBoostPumpPressure * @param duty which is the duty cycle + * @param firmwareCall indicates whether the call initiated by firmware + * internally or by dialin * @return none *************************************************************************/ -BOOL setBoostPumpTargetDutyCycle( F32 dutyCycle ) +BOOL setBoostPumpTargetDutyCycle( F32 dutyCycle, BOOL firmwareCall ) { - BOOL status = FALSE; + BOOL result = FALSE; + BOOL skipSet = FALSE; if ( ( dutyCycle >= MIN_FLUID_PUMP_DUTY_CYCLE_PCT ) && ( dutyCycle <= MAX_FLUID_PUMP_DUTY_CYCLE_PCT ) ) { - boostPumpOpenLoopTargetDutyCycle.data = dutyCycle; - boostPumpControlMode = PUMP_CONTROL_MODE_OPEN_LOOP; - status = TRUE; - - // Set the new duty cycle of the pump - setFluidPumpPctToPWMDutyCycle( P40_PUMP, boostPumpOpenLoopTargetDutyCycle.data ); - // Clear previous target data - if ( getTargetBoostPumpFlowRateMLPM() > 0 ) + if ( firmwareCall == TRUE ) // firmware call { - targetBoostPumpFlowRate.data = 0.0F; + // set the target flow and pressure to zero if there are no active override + if ( ( targetBoostPumpFlowRate.override == OVERRIDE_RESET ) && ( targetBoostPumpPressure.override == OVERRIDE_RESET ) && ( boostPumpOpenLoopTargetDutyCycle.override == OVERRIDE_RESET ) ) + { + targetBoostPumpFlowRate.data = 0; + targetBoostPumpPressure.data = 0.0F; + } + // skip the firmware set call if any override is active + else + { + result = TRUE; + skipSet = TRUE; + } } - if ( getTargetBoostPumpPressure() > 0.0F ) + if ( skipSet != TRUE ) { - targetBoostPumpPressure.data = 0.0F; + boostPumpOpenLoopTargetDutyCycle.data = dutyCycle; + result = TRUE; + //stop boost pump if duty cycle is set to zero + if ( dutyCycle == 0.0F ) + { + if ( ( targetBoostPumpFlowRate.data == 0 ) && ( targetBoostPumpPressure.data == 0.0F ) ) + { + signalBoostPumpHardStop(); + } + } + else + { + // Set the new duty cycle of the pump + setFluidPumpPctToPWMDutyCycle( P40_PUMP, getTargetBoostPumpDutyCyclePCT() ); + } } } else { SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, FP_FAULT_ID_FP_INVALID_PUMP_DUTY_CYCLE_SELECTED, dutyCycle ) } - return status; + return result; } /*********************************************************************//** @@ -605,7 +643,7 @@ static void stopBoostPump( void ) { isBoostPumpOn = FALSE; - boostPumpDutyCyclePctSet = 0.0F; +// boostPumpDutyCyclePctSet = 0.0F; // Set the new duty cycle of the pump setFluidPumpPWMDutyCycle( P40_PUMP, 0 ); } @@ -688,10 +726,40 @@ *************************************************************************/ BOOL testBoostPumpTargetPressureOverride( MESSAGE_T *message ) { - BOOL result = f32Override( message, &targetBoostPumpPressure ); + TEST_OVERRIDE_PAYLOAD_T payload; + OVERRIDE_TYPE_T ovType = getOverridePayloadFromMessage( message, &payload ); + BOOL result = FALSE; + // reset target pressure override + if ( ( ovType == OVERRIDE_RESET_OVERRIDE ) && ( targetBoostPumpPressure.override != OVERRIDE_RESET ) ) + { + // Restore previous flow, duty cycle and pressure values + targetBoostPumpPressure.data = targetBoostPumpPressure.ovInitData; + targetBoostPumpPressure.ovInitData = 0.0F; + targetBoostPumpPressure.ovData = targetBoostPumpPressure.ovInitData; + targetBoostPumpPressure.override = OVERRIDE_RESET; + if ( targetBoostPumpFlowRate.override == OVERRIDE_RESET && targetBoostPumpFlowRate.ovInitData != 0 ) + { + targetBoostPumpFlowRate.data = targetBoostPumpFlowRate.ovInitData; + } + if ( boostPumpOpenLoopTargetDutyCycle.override == OVERRIDE_RESET && boostPumpOpenLoopTargetDutyCycle.ovInitData != 0.0F ) + { + boostPumpOpenLoopTargetDutyCycle.data = boostPumpOpenLoopTargetDutyCycle.ovInitData; + } + } + // set target pressure override + else if ( ovType == OVERRIDE_OVERRIDE ) + { + targetBoostPumpPressure.ovData = payload.state.f32; + targetBoostPumpPressure.override = OVERRIDE_KEY; + if ( targetBoostPumpPressure.ovInitData == 0.0F ) + { + targetBoostPumpPressure.ovInitData = targetBoostPumpPressure.data; + } + handleFluidPumpF32Data( &boostPumpOpenLoopTargetDutyCycle ); + handleFluidPumpU32Data( &targetBoostPumpFlowRate ); + } + result = setBoostPumpTargetPressure(getTargetBoostPumpPressure(), FALSE); - setBoostPumpTargetPressure(getTargetBoostPumpPressure()); - return result; } @@ -707,10 +775,40 @@ *************************************************************************/ BOOL testBoostPumpTargetFlowOverride( MESSAGE_T *message ) { - BOOL result = u32Override( message, &targetBoostPumpFlowRate, MIN_BOOST_FLOWRATE_MLPM, MAX_BOOST_FLOWRATE_MLPM ); + TEST_OVERRIDE_PAYLOAD_T payload; + OVERRIDE_TYPE_T ovType = getOverridePayloadFromMessage( message, &payload ); + BOOL result = FALSE; + // reset target flow rate override + if ( ( ovType == OVERRIDE_RESET_OVERRIDE ) && ( targetBoostPumpFlowRate.override != OVERRIDE_RESET ) ) + { + // Restore previous flow, duty cycle and pressure values + targetBoostPumpFlowRate.data = targetBoostPumpFlowRate.ovInitData; + targetBoostPumpFlowRate.ovInitData = 0; + targetBoostPumpFlowRate.ovData = targetBoostPumpFlowRate.ovInitData; + targetBoostPumpFlowRate.override = OVERRIDE_RESET; + if ( boostPumpOpenLoopTargetDutyCycle.override == OVERRIDE_RESET && boostPumpOpenLoopTargetDutyCycle.ovInitData != 0.0F ) + { + boostPumpOpenLoopTargetDutyCycle.data = boostPumpOpenLoopTargetDutyCycle.ovInitData; + } + if ( targetBoostPumpPressure.override == OVERRIDE_RESET && targetBoostPumpPressure.ovInitData != 0.0F ) + { + targetBoostPumpPressure.data = targetBoostPumpPressure.ovInitData; + } + } + // set target flow rate override + else if ( ovType == OVERRIDE_OVERRIDE ) + { + targetBoostPumpFlowRate.ovData = payload.state.u32; + targetBoostPumpFlowRate.override = OVERRIDE_KEY; + if ( targetBoostPumpFlowRate.ovInitData == 0 ) + { + targetBoostPumpFlowRate.ovInitData = targetBoostPumpFlowRate.data; + } + handleFluidPumpF32Data( &boostPumpOpenLoopTargetDutyCycle ); + handleFluidPumpF32Data( &targetBoostPumpPressure ); + } + result = setBoostPumpTargetFlowRateMLPM(getTargetBoostPumpFlowRateMLPM(), FALSE); - setBoostPumpTargetFlowRateMLPM(getTargetBoostPumpFlowRateMLPM()); - return result; } @@ -726,10 +824,40 @@ *************************************************************************/ BOOL testBoostPumpTargetDutyCycleOverride( MESSAGE_T *message ) { - BOOL result = f32Override( message, &boostPumpOpenLoopTargetDutyCycle ); + TEST_OVERRIDE_PAYLOAD_T payload; + OVERRIDE_TYPE_T ovType = getOverridePayloadFromMessage( message, &payload ); + BOOL result = FALSE; + // reset target duty cycle override + if ( ( ovType == OVERRIDE_RESET_OVERRIDE ) && ( boostPumpOpenLoopTargetDutyCycle.override != OVERRIDE_RESET ) ) + { + // Restore previous flow, duty cycle and pressure values + boostPumpOpenLoopTargetDutyCycle.data = boostPumpOpenLoopTargetDutyCycle.ovInitData; + boostPumpOpenLoopTargetDutyCycle.ovInitData = 0.0F; + boostPumpOpenLoopTargetDutyCycle.ovData = boostPumpOpenLoopTargetDutyCycle.ovInitData; + boostPumpOpenLoopTargetDutyCycle.override = OVERRIDE_RESET; + if ( targetBoostPumpFlowRate.override == OVERRIDE_RESET && targetBoostPumpFlowRate.ovInitData != 0 ) + { + targetBoostPumpFlowRate.data = targetBoostPumpFlowRate.ovInitData; + } + if ( targetBoostPumpPressure.override == OVERRIDE_RESET && targetBoostPumpPressure.ovInitData != 0 ) + { + targetBoostPumpPressure.data = targetBoostPumpPressure.ovInitData; + } + } + // set target duty cycle override + else if ( ovType == OVERRIDE_OVERRIDE ) + { + boostPumpOpenLoopTargetDutyCycle.ovData = payload.state.f32; + boostPumpOpenLoopTargetDutyCycle.override = OVERRIDE_KEY; + if ( boostPumpOpenLoopTargetDutyCycle.ovInitData == 0.0F ) + { + boostPumpOpenLoopTargetDutyCycle.ovInitData = boostPumpOpenLoopTargetDutyCycle.data; + } + handleFluidPumpU32Data( &targetBoostPumpFlowRate ); + handleFluidPumpF32Data( &targetBoostPumpPressure ); + } + result = setBoostPumpTargetDutyCycle(getTargetBoostPumpDutyCyclePCT(), FALSE); - setBoostPumpTargetDutyCycle(getTargetBoostPumpDutyCyclePCT()); - return result; }