Index: firmware/App/Controllers/DryBiCart.c =================================================================== diff -u -rb134ecc440d93f07fadeb0101f2898ed876d5341 -r3aa700c036437377bca1de55bc01307705abf0a5 --- firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision b134ecc440d93f07fadeb0101f2898ed876d5341) +++ firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision 3aa700c036437377bca1de55bc01307705abf0a5) @@ -104,6 +104,7 @@ static DRY_BICART_FILL_EXEC_STATE_T dryBiCartFillExecState; ///< Current state of dry bicart fill executive state machine. static BICARB_CHAMBER_FILL_EXEC_STATE_T bicarbChamberFillExecState; ///< Current state of bicarb chamber fill executive state machine. static DRY_BICART_DRAIN_EXEC_STATE_T dryBiCartDrainExecState; ///< Current state of dry bicart drain executive state machine +static DRY_BICART_DEPRESSURISE_EXEC_STATE_T dryBiCartDepressuriseExecState; ///< Current state of dry bicart depressurise executive state machine // fill static U32 dryBiCartFillStartTime; ///< Dry bicart fill start time. static U32 biCartFillCycleCounter; ///< Number of drybicart fill cycle @@ -118,6 +119,7 @@ static OVERRIDE_U32_T dryBiCartFillRequested; ///< Start/stop dry bicart fill. static OVERRIDE_U32_T bicarbChamberFillRequested; ///< Start/stop bicarb chamber fill. static OVERRIDE_U32_T dryBiCartDrainRequested; ///< Start/stop dry bicart drain. +static OVERRIDE_U32_T dryBiCartDepressuriseRequested; ///< Start/stop dry bicart depressurise // publish static OVERRIDE_U32_T dryBiCartDataPublishInterval; ///< Dry bicart data publish interval. static U32 dryBiCartDataPublicationTimerCounter; ///< Used to schedule drybicart data publication to CAN bus. @@ -163,6 +165,10 @@ static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartFluidDrainDurationCheckState( void ); static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartFluidDrainEndState( void ); +static DRY_BICART_DEPRESSURISE_EXEC_STATE_T handleDryBicartDepressuriseStartState( void ); +static DRY_BICART_DEPRESSURISE_EXEC_STATE_T handleDryBicartDepressuriseVentStartState( void ); +static DRY_BICART_DEPRESSURISE_EXEC_STATE_T handleDryBicartDepressuriseVentEndState( void ); + static F32 getDryBicartLowerCartPressure( void ); static F32 getDryBicartUpperCartPressure( void ); @@ -267,9 +273,6 @@ *************************************************************************/ void execDryBicart( void ) { - - execMixingControl(); - // top level state machine selection DRY_BICART_OPERATION_T dryBicartState = dryBicartStartRequest; @@ -451,6 +454,40 @@ /*********************************************************************//** * @brief + * The execDryBicartDepressurise function executes the dry bicart depressurise state machine. + * @details \b Inputs: dryBiCartDepressuriseExecState + * @details \b Outputs: dryBiCartDepressuriseExecState + * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT when wrong dry bicart depressurise state + * invoked. + * @return current state. + *************************************************************************/ +U32 execDryBicartDepressurise( void ) +{ + // execute drybicart drain state machine + switch ( dryBiCartDepressuriseExecState ) + { + case DRY_BICART_DEPRESSURISE_START_STATE: + dryBiCartDepressuriseExecState = handleDryBicartDepressuriseStartState(); + break; + + case DRY_BICART_DEPRESSURISE_VENT_START_STATE: + dryBiCartDepressuriseExecState = handleDryBicartDepressuriseVentStartState(); + break; + + case DRY_BICART_DEPRESSURISE_VENT_END_STATE: + dryBiCartDepressuriseExecState = handleDryBicartDepressuriseVentEndState(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_DRY_BICART_DEPRESURISE_INVALID_EXEC_STATE, dryBiCartDepressuriseExecState ); + break; + } + + return dryBiCartDepressuriseExecState; +} + +/*********************************************************************//** + * @brief * The setBicarbChamberFillRequested function sets the chmaberFillRequest * flag value to be True. * @details \b Inputs: dryBiCartFillRequested, dryBiCartDrainRequested @@ -1376,6 +1413,103 @@ /*********************************************************************//** * @brief + * The handleDryBicartDepressuriseStartState function set the one time actuation + * for drybicart de-pressurise request. + * @details \b Inputs: dryBiCartDepressuriseRequested + * @details \b Outputs: none + * @return the next drybicart depressurise state. + *************************************************************************/ +static DRY_BICART_DEPRESSURISE_EXEC_STATE_T handleDryBicartDepressuriseStartState( void ) +{ + DRY_BICART_DEPRESSURISE_EXEC_STATE_T state = DRY_BICART_DEPRESSURISE_START_STATE; + + if ( TRUE == getU32OverrideValue( &dryBiCartDepressuriseRequested ) ) + { + setValveState( D85_VALV, VALVE_STATE_OPEN ); + + state = DRY_BICART_DEPRESSURISE_VENT_START_STATE; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleDryBicartDepressuriseVentStartState function handles the vent start state for + * drybicart de-pressurise + * @details \b Inputs: dryBiCarbSypplyVentStartTime, dryBiCartPersistenceStartTime + * @details \b Outputs: none + * @return the next drybicart depressurise state. + *************************************************************************/ +static DRY_BICART_DEPRESSURISE_EXEC_STATE_T handleDryBicartDepressuriseVentStartState( void ) +{ + DRY_BICART_DEPRESSURISE_EXEC_STATE_T state = DRY_BICART_DEPRESSURISE_VENT_START_STATE; + + F32 d66Pressure = getFilteredPressure( D66_PRES ); + + if ( TRUE == didTimeout( dryBiCarbSypplyVentStartTime, DRY_BICART_SUPPLY_VENT_TIME_MS ) ) + { + //Vent chamber F to atmosphere + setValveState( D64_VALV, VALVE_STATE_OPEN ); + + // D66 pressure drops to below 1.5 PSI or time out + if ( ( d66Pressure <= DRY_BICART_FILL_VENT_COMPLETE_PRESSURE_PSI ) ) + { + // start the persistence timer once d66 reaches if it drops below 1.5 + if ( 0 == dryBiCartPersistenceStartTime ) + { + dryBiCartPersistenceStartTime = getMSTimerCount(); + } + // 200 ms persistence on D66 pressure since pressure overshoot just after D65 opening + if ( TRUE == didTimeout( dryBiCartPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) + { + setValveState( D85_VALV, VALVE_STATE_CLOSED ); + dryBiCartPersistenceStartTime = 0; + + state = DRY_BICART_DEPRESSURISE_VENT_END_STATE; + } + } + else if ( ( TRUE == didTimeout( dryBiCarbSypplyVentStartTime, DRY_BICART_FILL_VENT_MAX_TIME_MS ) ) ) + { + setValveState( D85_VALV, VALVE_STATE_CLOSED ); + dryBiCartPersistenceStartTime = 0; + dryBiCartFillVentTimeOut = TRUE; + + state = DRY_BICART_DEPRESSURISE_VENT_END_STATE; + } + else + { + dryBiCartPersistenceStartTime = 0; + } + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleDryBicartDepressuriseVentEndState function handles the vent end state for + * drybicart de-pressurise + * @details \b Inputs: none + * @details \b Outputs: dryBiCartDepressuriseRequested + * @return the next drybicart depressurise state. + *************************************************************************/ +static DRY_BICART_DEPRESSURISE_EXEC_STATE_T handleDryBicartDepressuriseVentEndState( void ) +{ + DRY_BICART_DEPRESSURISE_EXEC_STATE_T state = DRY_BICART_DEPRESSURISE_VENT_END_STATE; + + // Go idle + dryBiCartDepressuriseRequested.data = FALSE; + // for this request override also cleared + dryBiCartDepressuriseRequested.ovData = FALSE; + + state = DRY_BICART_DEPRESSURISE_START_STATE; + + return state; +} + +/*********************************************************************//** + * @brief * The publishDryBicartData function broadcasts the dry bicart * data at defined interval. * @details \b Inputs: dryBiCartDataPublicationTimerCounter @@ -1502,6 +1636,23 @@ /*********************************************************************//** * @brief + * The testDryBiCartDepressuriseRequestOverride function starts/stops the bicart + * depressurise request + * @details \b Inputs: dryBiCartDepressuriseRequested + * @details \b Outputs: dryBiCartDepressuriseRequested + * @param message set message from Dialin which includes the bicart + * depressurise request start/stop. + * @return TRUE if set request is successful, FALSE if not + *************************************************************************/ +BOOL testDryBiCartDepressuriseRequestOverride( MESSAGE_T *message ) +{ + BOOL result = u32Override( message, &dryBiCartDepressuriseRequested, FALSE, TRUE ); + + return result; +} + +/*********************************************************************//** + * @brief * The testDryBiCartTypeOverride function selects small/large cartridge type * @details \b Inputs: dryBiCartType * @details \b Outputs: dryBiCartType