Index: firmware/App/Controllers/DryBiCart.c =================================================================== diff -u -rbd522c8ffdf75130571e5b6a79d1b1d6acd78b1c -rc67f50a3c737b65216f513477dbf91d8af044e58 --- firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision bd522c8ffdf75130571e5b6a79d1b1d6acd78b1c) +++ firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision c67f50a3c737b65216f513477dbf91d8af044e58) @@ -98,6 +98,7 @@ DRY_BICART_SUPPLY, ///< Dry bicart chamber fill DRY_BICART_DRAIN, ///< Dry bicart drain DRY_BICART_DEPRESSURIZE, ///< Dry bicart depressurize + DRY_BICART_PRE_GEN_CHAMBER_FILL, NUM_OF_DRY_BICART_OPERATION ///< Number of dry bicart operation } DRY_BICART_OPERATION_T; @@ -107,6 +108,7 @@ 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_DEPRESSURIZE_EXEC_STATE_T dryBiCartDepressurizeExecState; ///< Current state of dry bicart depressurize executive state machine +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T bicarbChamberPreGenFillExecState; // fill static U32 dryBiCartFillStartTime; ///< Dry bicart fill start time. static U32 biCartFillCycleCounter; ///< Number of drybicart fill cycle @@ -122,6 +124,7 @@ static OVERRIDE_U32_T bicarbChamberFillRequested; ///< Start/stop bicarb chamber fill. static OVERRIDE_U32_T dryBiCartDrainRequested; ///< Start/stop dry bicart drain. static OVERRIDE_U32_T dryBiCartDepressurizeRequested; ///< Start/stop dry bicart depressurize +static OVERRIDE_U32_T bicarbChamberPreGenFillRequested; ///< Start/stop bicarb chamber pre gen fill. // publish static OVERRIDE_U32_T dryBiCartDataPublishInterval; ///< Dry bicart data publish interval. static U32 dryBiCartDataPublicationTimerCounter; ///< Used to schedule drybicart data publication to CAN bus. @@ -130,14 +133,17 @@ // supply static U32 dryBiCarbSupplyStartTime; ///< Bicarb supply start time from bicart to Chamber F. // vent -static U32 dryBiCarbSypplyVentStartTime; ///< Bicarb supply vent start time for both bicart & Chamber F. +static U32 dryBiCarbSupplyVentStartTime; ///< Bicarb supply vent start time for both bicart & Chamber F. // drain static U32 dryBiCartDrainStartTime; ///< Drain overall start time (for max timeout) //TODO: implement draining //static U32 dryBiCartDrainLastCondSampleTime; ///< Last time conductivity was sampled //static U32 dryBiCartDrainCondStableCount; ///< Debounce counter for "zero" conductivity static U32 dryBiCartDrainTimePeriod; ///< Dry bicart drain time period +static U32 dryBiCarbPreGenSupplyStartTime; +static U32 dryBiCartPreGenPersistenceStartTime; +static U32 drybicartPreGenPersistenceOnLowercartPressureStartTime; ///< Dry bicart Persistence on lower cart pressure start time. static U32 dryBiCartPersistenceStartTime; ///< Dry bicart Persistence time. static U32 drybicartPersistenceOnLowercartPressureStartTime; ///< Dry bicart Persistence on lower cart pressure start time. static BOOL dryBiCartPressureDecayStartTimeFlag; ///< Dry bicart d66 pressure decay start timer. @@ -169,6 +175,14 @@ static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartFluidDrainState( void ); static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartFluidDrainDurationCheckState( void ); static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartFluidDrainEndState( void ); +// Pre Gen Supply & Vent +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenStartState( void ); +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenCartridgeFillWaterStartState( void ); +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenCartridgeFillWaterEndState( void ); +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenSupplyStart( void ); +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenPressureCheckState( void ); +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenSupplyVentStartState(void); +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenSupplyVentEndState(void); static DRY_BICART_DEPRESSURIZE_EXEC_STATE_T handleDryBicartDepressurizeStartState( void ); static DRY_BICART_DEPRESSURIZE_EXEC_STATE_T handleDryBicartDepressurizeVentStartState( void ); @@ -244,12 +258,14 @@ dryBiCartDataPublicationTimerCounter = 0; biCartFillCycleCounter = 0; dryBiCarbSupplyStartTime = 0; - dryBiCarbSypplyVentStartTime = 0; + dryBiCarbSupplyVentStartTime = 0; dryBiCartDrainStartTime = 0; //dryBiCartDrainLastCondSampleTime = 0; //dryBiCartDrainCondStableCount = 0; dryBiCartDrainTimePeriod = 0; dryBiCartPersistenceStartTime = 0; + dryBiCarbPreGenSupplyStartTime = 0; + dryBiCartPreGenPersistenceStartTime = 0; drybicartPersistenceOnLowercartPressureStartTime = 0; prevDryBicartState = DRY_BICART_IDLE; } @@ -309,6 +325,11 @@ execDryBicartDepressurize(); break; + case DRY_BICART_PRE_GEN_CHAMBER_FILL: + // Fill Bicarb chamber F exec + execBicarbChamberPreGenFillMode(); + break; + default: // software fault, dryBicartStartRequest = DRY_BICART_IDLE; @@ -505,6 +526,117 @@ /*********************************************************************//** * @brief + * The execBicarbChamberFillMode function executes the bicarb chamber fill + * (delivering bicarbonate from Bicart assembly to chamber F)state machine. + * @details \b Inputs: bicarbChamberFillExecState + * @details \b Outputs: bicarbChamberFillExecState + * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT when wrong bicarb chamber + * fill state invoked. + * @return current state. + *************************************************************************/ +U32 execBicarbChamberPreGenFillMode( void ) +{ + // TODO in pregen mode call hydChamberWaterInletControl(); + // execute bicarb chamber fill state machine + switch ( bicarbChamberPreGenFillExecState ) + { + case PRE_GEN_BICARB_CHAMBER_START_STATE: + bicarbChamberPreGenFillExecState = handleBicarbChamberPreGenStartState(); + break; + + case PRE_GEN_BICARB_CARTRIDGE_FILL_WATER_START_STATE: + bicarbChamberPreGenFillExecState = handleBicarbChamberPreGenCartridgeFillWaterStartState(); + break; + + case PRE_GEN_BICARB_CARTRIDGE_FILL_WATER_END_STATE: + bicarbChamberPreGenFillExecState = handleBicarbChamberPreGenCartridgeFillWaterEndState(); + break; + + case PRE_GEN_BICARB_CHAMBER_SUPPLY_STATE: + bicarbChamberPreGenFillExecState = handleBicarbChamberPreGenSupplyStart(); + break; + + case PRE_GEN_BICARB_CHAMBER_PRESSURE_CHECK_STATE: + bicarbChamberPreGenFillExecState = handleBicarbChamberPreGenPressureCheckState(); + break; + + case PRE_GEN_BICARB_SUPPLY_VENT_START_STATE: + bicarbChamberPreGenFillExecState = handleBicarbChamberPreGenSupplyVentStartState(); + break; + + case PRE_GEN_BICARB_SUPPLY_VENT_END_STATE: + bicarbChamberPreGenFillExecState = handleBicarbChamberPreGenSupplyVentEndState(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_BICARB_CHAMBER_FILL_INVALID_EXEC_STATE, bicarbChamberFillExecState ); + break; + } + + return bicarbChamberPreGenFillExecState; +} + +/*********************************************************************//** + * @brief + * The setBicartFillRequested function sets the bicart fill request + * flag value to be True. + * @details \b Inputs: bicarbChamberFillRequested, dryBiCartDrainRequested, + * dryBiCartDepressurizeRequested + * @details \b Outputs: dryBiCartFillRequested + * @return TRUE if successful, FALSE if not. + *************************************************************************/ +BOOL setBicartPreGenFillRequested( void ) +{ + BOOL result = FALSE; + BOOL requestStatus = getU32OverrideValue( &bicarbChamberPreGenFillRequested ) \ + || getU32OverrideValue( &dryBiCartDrainRequested ) || \ + getU32OverrideValue( &dryBiCartDepressurizeRequested ) ; + + //ensure that there is no other operation in progress before new request set to true + if ( FALSE == requestStatus ) + { + bicarbChamberPreGenFillRequested.data = TRUE; + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getBicartFillRequested function gets the bicart fill request + * flag value + * @details \b Inputs: dryBiCartFillRequested + * @details \b Outputs: none + * @return TRUE if successful, FALSE if not. + *************************************************************************/ +BOOL getBicartPreGenFillRequested( void ) +{ + BOOL result = FALSE; + + if ( ( TRUE == getU32OverrideValue( &bicarbChamberPreGenFillRequested ) ) ) + { + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getCurrentDryBiCartFillExecState function returns the current state + * of the dry bicart fill state. + * @details \b Inputs: dryBiCartFillExecState + * @details \b Outputs: none + * @return the current state of dry bicart fill exec state. + *************************************************************************/ +BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T getCurrentDryBiCartPreGenFillExecState( void ) +{ + return bicarbChamberPreGenFillExecState; +} + +/*********************************************************************//** + * @brief * The setBicarbChamberFillRequested function sets the chmaberFillRequest * flag value to be True. * @details \b Inputs: dryBiCartFillRequested, dryBiCartDrainRequested, @@ -515,7 +647,7 @@ BOOL setBicarbChamberFillRequested( void ) { BOOL result = FALSE; - BOOL requestStatus = getU32OverrideValue( &dryBiCartFillRequested ) ||\ + BOOL requestStatus = getU32OverrideValue( &bicarbChamberFillRequested ) ||\ getU32OverrideValue( &dryBiCartDrainRequested ) || \ getU32OverrideValue( &dryBiCartDepressurizeRequested ); @@ -757,6 +889,11 @@ { dryBicartStartRequest = DRY_BICART_DEPRESSURIZE; } + if ( TRUE == getBicartPreGenFillRequested() ) + { + // supply + dryBicartStartRequest = DRY_BICART_PRE_GEN_CHAMBER_FILL ; + } else { // idle @@ -1189,7 +1326,7 @@ setValveState( D85_VALV, VALVE_STATE_OPEN ); dryBiCarbSupplyStartTime = getMSTimerCount(); - dryBiCarbSypplyVentStartTime = getMSTimerCount(); + dryBiCarbSupplyVentStartTime = getMSTimerCount(); state = BICARB_SUPPLY_VENT_START_STATE; } @@ -1247,7 +1384,7 @@ BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_SUPPLY_VENT_START_STATE; F32 d66Pressure = getFilteredPressure( D66_PRES ); - if ( TRUE == didTimeout( dryBiCarbSypplyVentStartTime, DRY_BICART_SUPPLY_VENT_TIME_MS ) ) + if ( TRUE == didTimeout( dryBiCarbSupplyVentStartTime, DRY_BICART_SUPPLY_VENT_TIME_MS ) ) { //Vent chamber F to atmosphere setValveState( D64_VALV, VALVE_STATE_OPEN ); @@ -1269,7 +1406,7 @@ state = BICARB_SUPPLY_VENT_END_STATE; } } - else if ( ( TRUE == didTimeout( dryBiCarbSypplyVentStartTime, DRY_BICART_FILL_VENT_MAX_TIME_MS ) ) ) + else if ( ( TRUE == didTimeout( dryBiCarbSupplyVentStartTime, DRY_BICART_FILL_VENT_MAX_TIME_MS ) ) ) { setValveState( D85_VALV, VALVE_STATE_CLOSED ); dryBiCartPersistenceStartTime = 0; @@ -1515,7 +1652,7 @@ F32 d66Pressure = getFilteredPressure( D66_PRES ); - if ( TRUE == didTimeout( dryBiCarbSypplyVentStartTime, DRY_BICART_SUPPLY_VENT_TIME_MS ) ) + if ( TRUE == didTimeout( dryBiCarbSupplyVentStartTime, DRY_BICART_SUPPLY_VENT_TIME_MS ) ) { //Vent chamber F to atmosphere setValveState( D64_VALV, VALVE_STATE_OPEN ); @@ -1572,6 +1709,275 @@ /*********************************************************************//** * @brief + * The handleBicarbChamberStartState function wait for bicarb chamber fill request + * @details \b Inputs: bicarbChamberFillRequested + * @details \b Outputs: none + * @return the next drybicart fluid drain state. + *************************************************************************/ +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenStartState( void ) +{ + BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T state = PRE_GEN_BICARB_CHAMBER_START_STATE; + + dryBiCartPressureDecayStartTimeFlag = FALSE; + + if ( TRUE == getU32OverrideValue( &bicarbChamberPreGenFillRequested ) ) + { + state = PRE_GEN_BICARB_CARTRIDGE_FILL_WATER_START_STATE; + } + + return state; +} +/*********************************************************************//** + * @brief + * The handleBicarbChamberCartridgeFillWaterStartState function fill water in the dry bicart + * @details \b Inputs: none + * @details \b Outputs: valve states, dryBiCarbSupplyStartTime, dryBiCartPersistenceStartTime + * @return the next bicarb cartridge fill water end state. + *************************************************************************/ +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenCartridgeFillWaterStartState( void ) +{ + BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T state = PRE_GEN_BICARB_CARTRIDGE_FILL_WATER_END_STATE; + + // Close vent valves and descaling valve + setValveState( D80_VALV, VALVE_STATE_CLOSED ); + setValveState( D81_VALV, VALVE_STATE_CLOSED ); + setValveState( D85_VALV, VALVE_STATE_CLOSED ); + + // open inlet water to bicart + setValveState( D65_VALV, VALVE_STATE_OPEN ); + setValveState( D64_VALV, VALVE_STATE_OPEN ); + setValveState( D14_VALV, VALVE_STATE_OPEN ); + + dryBiCarbPreGenSupplyStartTime = getMSTimerCount(); + dryBiCartPreGenPersistenceStartTime = 0; + + return state; +} + +/*********************************************************************//** + * @brief + * The handleBicarbChamberCartridgeFillWaterStartState function stop water in the dry bicart + * @details \b Inputs: D66 pressure, dryBiCartPersistenceStartTime + * @details \b Outputs: valve states + * @return the next bicarb chamber check level state. + *************************************************************************/ +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenCartridgeFillWaterEndState( void ) +{ + BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T state = PRE_GEN_BICARB_CARTRIDGE_FILL_WATER_END_STATE; + F32 d66Pressure = getFilteredPressure( D66_PRES ); + F32 fillCompletePressure = GET_FILL_COMPLETE_PRESSURE_PSI; + + // check D66 pressure greater than or equal to 17 PSI + if ( d66Pressure >= fillCompletePressure ) + { + // start the persistence timer once d66 reaches 17 PSI + if ( 0 == dryBiCartPreGenPersistenceStartTime ) + { + dryBiCartPreGenPersistenceStartTime = getMSTimerCount(); + } + + // 200 ms persistence on D66 pressure since pressure overshoot just after D65 opening + if ( TRUE == didTimeout( dryBiCartPreGenPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) + { + // Close water inlet valve as D66 pressure reaches 1 PSI after persistence + setValveState( D65_VALV, VALVE_STATE_CLOSED ); + dryBiCartPreGenPersistenceStartTime = 0; + + state = PRE_GEN_BICARB_CHAMBER_SUPPLY_STATE; + } + } + else + { + dryBiCartPreGenPersistenceStartTime = 0; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleBicarbChamberSupplyStart function open the bicarb inlet valve (D80). + * @details \b Inputs: none + * @details \b Outputs: valve states, dryBiCarbSupplyStartTime + * @return the next bicarb chamber fill state. + *************************************************************************/ +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenSupplyStart( void ) +{ + BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T state = PRE_GEN_BICARB_CHAMBER_PRESSURE_CHECK_STATE; + + // TODO: set supply in progress to inform BC control to disable alarm + setValveState( D64_VALV, VALVE_STATE_OPEN ); + // Open the Bicarb chamber inlet valve + setValveState( D80_VALV, VALVE_STATE_OPEN ); + + // Start a timer when bicarb supply started to chamber F + dryBiCarbPreGenSupplyStartTime = getMSTimerCount(); + + // TODO: alarm + + return state; +} + +/*********************************************************************//** + * @brief + * The handleBicarbChamberPressureCheckStartState function actuates the vent valve + * present in the Bicart assembly. + * @details \b Inputs: D66 Pressure, D63 level, dryBiCarbSupplyStartTime, + * dryBiCarbSypplyVentStartTime, dryBiCartPersistenceStartTime, bicarbChamberLevel, + * dryBiCartPressureDecayStartTimeFlag, drybicartPersistenceOnLowercartPressureStartTime + * @details \b Outputs: dryBiCarbSypplyVentStartTime + * @return the next bicarb chamber Supply Vent Start state. + *************************************************************************/ +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenPressureCheckState( void ) +{ + BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T state = PRE_GEN_BICARB_CHAMBER_PRESSURE_CHECK_STATE; + F32 d66Pressure = getFilteredPressure( D66_PRES ); + LVL_STATE_T bicarbChamberLevel = getBicarbChamberLevelStatus(); + + // Once upper level reached high , close the valve, timeout is for safety in case level sensor didn't work(10 sec), or else its a time based filling (3 sec) + if ( ( LVL_STATE_HIGH == bicarbChamberLevel ) || + ( TRUE == didTimeout( dryBiCarbPreGenSupplyStartTime, DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ) ) ) + { + setValveState( D65_VALV, VALVE_STATE_CLOSED ); + + // start the timer for d66 pressure decay + if( FALSE == dryBiCartPressureDecayStartTimeFlag ) + { + dryBiCarbPreGenSupplyStartTime = getMSTimerCount(); + dryBiCartPressureDecayStartTimeFlag = TRUE; + } + // do not close the D80 valve, wait till d66 decays to 3 PSI + if ( TRUE == didTimeout( dryBiCarbPreGenSupplyStartTime, DRY_BICART_SUPPLY_COMPLETE_TIME_MS ) ) + { + if ( d66Pressure <= getDryBicartLowerCartPressure() ) + { + setValveState( D80_VALV, VALVE_STATE_CLOSED ); + setValveState( D85_VALV, VALVE_STATE_OPEN ); + + dryBiCarbPreGenSupplyStartTime = getMSTimerCount(); + dryBiCarbSupplyVentStartTime = getMSTimerCount(); + + state = PRE_GEN_BICARB_SUPPLY_VENT_START_STATE; + } + } + } + else if ( d66Pressure <= getDryBicartLowerCartPressure() ) + { + // start persistence timer + if ( 0 == drybicartPreGenPersistenceOnLowercartPressureStartTime ) + { + drybicartPreGenPersistenceOnLowercartPressureStartTime = getMSTimerCount(); + } + // 200 ms persistence on D66 pressure + if ( TRUE == didTimeout( drybicartPreGenPersistenceOnLowercartPressureStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) + { + setValveState( D65_VALV, VALVE_STATE_OPEN ); + drybicartPreGenPersistenceOnLowercartPressureStartTime = 0; + } + } + // Close water inlet valve as fill is complete. + else if ( d66Pressure >= getDryBicartUpperCartPressure() ) + { + // start persistence timer + if ( 0 == dryBiCartPreGenPersistenceStartTime ) + { + dryBiCartPreGenPersistenceStartTime = getMSTimerCount(); + } + + // 200 ms persistence on D66 pressure since pressure overshoot just after D65 opening + if ( TRUE == didTimeout( dryBiCartPreGenPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) + { + setValveState( D65_VALV, VALVE_STATE_CLOSED ); + dryBiCartPreGenPersistenceStartTime = 0; + } + } + else + { + dryBiCartPreGenPersistenceStartTime = 0; + drybicartPreGenPersistenceOnLowercartPressureStartTime = 0; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleBicarbChamberSupplyVentStartState function actuates the vent valve + * present in the Bicart assembly. + * @details \b Inputs: dryBiCarbSypplyVentStartTime, dryBiCartPersistenceStartTime + * @details \b Outputs: dryBiCarbSypplyVentStartTime + * @return the next bicarb chamber Supply Vent End state. + *************************************************************************/ +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenSupplyVentStartState(void) +{ + BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T state = PRE_GEN_BICARB_SUPPLY_VENT_START_STATE; + F32 d66Pressure = getFilteredPressure( D66_PRES ); + + if ( TRUE == didTimeout( dryBiCarbSupplyVentStartTime, 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 == dryBiCartPreGenPersistenceStartTime ) + { + dryBiCartPreGenPersistenceStartTime = getMSTimerCount(); + } + // 200 ms persistence on D66 pressure since pressure overshoot just after D65 opening + if ( TRUE == didTimeout( dryBiCartPreGenPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) + { + setValveState( D85_VALV, VALVE_STATE_CLOSED ); + dryBiCartPreGenPersistenceStartTime = 0; + + state = PRE_GEN_BICARB_SUPPLY_VENT_END_STATE; + } + } + else if ( ( TRUE == didTimeout( dryBiCarbSupplyVentStartTime, DRY_BICART_FILL_VENT_MAX_TIME_MS ) ) ) + { + setValveState( D85_VALV, VALVE_STATE_CLOSED ); + dryBiCartPreGenPersistenceStartTime = 0; + dryBiCartFillVentTimeOut = TRUE; + + state = PRE_GEN_BICARB_SUPPLY_VENT_END_STATE; + } + else + { + dryBiCartPreGenPersistenceStartTime = 0; + } + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleBicarbChamberSupplyVentEndState function actuates the vent valve + * present in the Bicart assembly. + * @details \b Inputs: dryBiCarbSypplyVentStartTime + * @details \b Outputs: bicarbChamberFillRequested + * @return the next bicarb chamber start state. + *************************************************************************/ +static BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T handleBicarbChamberPreGenSupplyVentEndState(void) +{ + BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T state = PRE_GEN_BICARB_SUPPLY_VENT_END_STATE; + + bicarbChamberPreGenFillRequested.data = FALSE; + // for this request override also cleared + bicarbChamberPreGenFillRequested.ovData = FALSE; + + dryBiCartPressureDecayStartTimeFlag = FALSE; + + state = PRE_GEN_BICARB_CHAMBER_START_STATE; + + dryBicartStartRequest = DRY_BICART_IDLE; + + return state; +} +/*********************************************************************//** + * @brief * The publishDryBicartData function broadcasts the dry bicart * data at defined interval. * @details \b Inputs: dryBiCartDataPublicationTimerCounter Index: firmware/App/Controllers/DryBiCart.h =================================================================== diff -u -ra631e128cd6be44aa232e23b58a229bfb8fe9043 -rc67f50a3c737b65216f513477dbf91d8af044e58 --- firmware/App/Controllers/DryBiCart.h (.../DryBiCart.h) (revision a631e128cd6be44aa232e23b58a229bfb8fe9043) +++ firmware/App/Controllers/DryBiCart.h (.../DryBiCart.h) (revision c67f50a3c737b65216f513477dbf91d8af044e58) @@ -59,13 +59,17 @@ U32 execBicarbChamberFillMode( void ); U32 execDryBicartDrainMode( void ); U32 execDryBicartDepressurize( void ); +U32 execBicarbChamberPreGenFillMode( void ); void execDryBicart( void ); BOOL setBicarbChamberFillRequested( void ); BOOL getBicarbChamberFillRequested( void ); BOOL setBicartFillRequested( void ); BOOL setBicartDrainRequested( void ); +BOOL setBicartPreGenFillRequested( void ); +BOOL getBicartPreGenFillRequested( void ); DRY_BICART_FILL_EXEC_STATE_T getCurrentDryBiCartFillExecState( void ); +BICARB_CHAMBER_PRE_GEN_FILL_EXEC_STATE_T getCurrentDryBiCartPreGenFillExecState( void ); BOOL testDryBiCartDataPublishIntervalOverride( MESSAGE_T *message ); BOOL testDryBiCartFillCycleMaxCountOverride( MESSAGE_T *message ); Index: firmware/App/Drivers/ConductivitySensors.c =================================================================== diff -u -rd47b9bcbd4796a8c51d9e87436422c5868292ac6 -rc67f50a3c737b65216f513477dbf91d8af044e58 --- firmware/App/Drivers/ConductivitySensors.c (.../ConductivitySensors.c) (revision d47b9bcbd4796a8c51d9e87436422c5868292ac6) +++ firmware/App/Drivers/ConductivitySensors.c (.../ConductivitySensors.c) (revision c67f50a3c737b65216f513477dbf91d8af044e58) @@ -1033,7 +1033,7 @@ calculatedConductivity = ( ( k / conductivitySensorStatus[ sensorNum ].calculatedResistance ) * ( 1 + ( alpha * ( COND_TEMP_OFFSET - conductivitySensorStatus[ sensorNum ].calculatedTemperature ) ) ) ); - currentConductivityReadings[ sensorNum ].data = calculatedConductivity * SIEMENS_TO_MICROSIEMENS_CONVERSION; + currentUncompenstatedConductivityReadings[ sensorNum ].data = calculatedConductivity * SIEMENS_TO_MICROSIEMENS_CONVERSION; } /*********************************************************************//** Index: firmware/App/Modes/ModePreGenDialysate.c =================================================================== diff -u -rbd522c8ffdf75130571e5b6a79d1b1d6acd78b1c -rc67f50a3c737b65216f513477dbf91d8af044e58 --- firmware/App/Modes/ModePreGenDialysate.c (.../ModePreGenDialysate.c) (revision bd522c8ffdf75130571e5b6a79d1b1d6acd78b1c) +++ firmware/App/Modes/ModePreGenDialysate.c (.../ModePreGenDialysate.c) (revision c67f50a3c737b65216f513477dbf91d8af044e58) @@ -19,13 +19,16 @@ #include "ConcentratePumps.h" #include "DialysatePumps.h" #include "DryBiCart.h" +#include "FPOperationModes.h" #include "Heaters.h" +#include "Level.h" #include "ModePreGenDialysate.h" #include "ModeGenDialysate.h" #include "ModeFault.h" #include "Messaging.h" #include "OperationModes.h" #include "Pressure.h" +#include "RinsePump.h" #include "TaskGeneral.h" #include "Timers.h" #include "Utilities.h" @@ -39,9 +42,18 @@ // ********** private definitions ********** /// Interval (ms/task time) at which the pre-treatment state data is published on the CAN bus. -#define PRE_GEN_DIALYSATE_DATA_PUB_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the pre-gen dialysate mode data published. -#define HYD_CHAMBER_PRES_CHECK_TIME_OUT ( 30 * MS_PER_SECOND ) ///< Time out period when hydraulics chamber pressure check initiated -#define NEG_PRES_PERSISTENCE_TIME_MS ( 1 * MS_PER_SECOND ) ///< Persistence time for Hydraulics chamber negative degassing pressure check. +#define PRE_GEN_DIALYSATE_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the pre-gen dialysate mode data published. +#define HYD_CHAMBER_PRES_CHECK_TIME_OUT ( 30 * MS_PER_SECOND ) ///< Time out period when hydraulics chamber pressure check initiated +#define NEG_PRES_PERSISTENCE_TIME_MS ( 1 * MS_PER_SECOND ) ///< Persistence time for Hydraulics chamber negative degassing pressure check. +#define PRE_GEN_DEFAULT_TIME_OUT ( 60 * MS_PER_SECOND ) +#define PRE_GEN_FILL_HYDRO_CHAMBER_TIMEOUT ( 120 * MS_PER_SECOND ) +#define PRE_GEN_PRIME_CONCENTRATE_TIMEOUT ( 120 * MS_PER_SECOND ) +#define PRE_GEN_PRIME_CONCENTRATE_PUMP_SPEED 100.0F +#define PRE_GEN_PRIME_CONCENTRATE_VOLUME 0xFFFF +#define PRE_GEN_PRIME_BAL_CHAMBER_CONCENTRATE_PUMP_SPEED 60.0F +#define PRE_GEN_PRIME_D12_RPM 1500.0F +#define PRE_GEN_PRIME_D48_RPM 2000.0F +#define PRE_GEN_PRIME_DIALYZER_CONCENTRATE_PUMP_SPEED 30.0F // ********** private data ********** @@ -53,13 +65,21 @@ static BOOL pendingStopDDPreGenDialRequest; ///< Flag indicating TD has requested DD stop the pre generation dialysate. static U32 preGenDialysatePublishTimerCounter; ///< Pre-Gen Dialysate data broadcast timer counter used to schedule when to transmit data. static OVERRIDE_U32_T preGenDialysateModePublishInterval; ///< Interval (in task intervals) at which to publish pre-gen dialysate mode data to CAN bus. +static U32 preGenAcidPrimeTimer; +static U32 preGenBicarbPrimeTimer; +static U32 preGenfillChamberCTimer; +static BOOL currentHydroChamberStatus; // ********** private function prototypes ********** static void publishPreGenDialysateState( void ); static DD_PRE_GEN_DIALYSATE_STATE_T handlePreGenDialysateFillCompleteCheckState( void ); -static DD_PRE_GEN_DIALYSATE_STATE_T handlePreGenWetSelfTestState( void ); static DD_PRE_GEN_DIALYSATE_STATE_T handleDryBicartInitialFillState( void ); +static DD_PRE_GEN_DIALYSATE_STATE_T handleFillChamberF( void ); +static DD_PRE_GEN_DIALYSATE_STATE_T handlePrimeBicarbLine( void ); +static DD_PRE_GEN_DIALYSATE_STATE_T handlePrimeAcidLine( void ); +static DD_PRE_GEN_DIALYSATE_STATE_T handleWaitForFPState( void ); +static void setModePreGenDialysateTransition( DD_PRE_GEN_DIALYSATE_STATE_T state ); //Wet Self test static void setModePreGenWetSelfStateTransition( DD_WET_SELF_TEST_STATE_T state ); @@ -77,7 +97,7 @@ *************************************************************************/ void initPreGenDialysateMode( void ) { - preGenDialysateState = DD_PRE_GEN_DIALYSATE_HYD_CHAMBER_FILL_CHECK; + preGenDialysateState = DD_PRE_GEN_WAIT_FOR_FP_GEN; wetSelfTestState = DD_WET_SELF_TEST_START; hydChamberPressureCheckStartTimeMS = 0; pressureCheckPersistanceStartTimeMS = 0; @@ -87,6 +107,11 @@ preGenDialysateModePublishInterval.ovData = PRE_GEN_DIALYSATE_DATA_PUB_INTERVAL; preGenDialysateModePublishInterval.ovInitData = 0; preGenDialysateModePublishInterval.override = OVERRIDE_RESET; + currentHydroChamberStatus = FALSE; + + preGenAcidPrimeTimer = 0; + preGenBicarbPrimeTimer = 0; + preGenfillChamberCTimer = 0; } /*********************************************************************//** @@ -121,40 +146,64 @@ *************************************************************************/ U32 execPreGenDialysateMode( void ) { - //Manage Inlet water control - hydChamberWaterInletControl(); + DD_PRE_GEN_DIALYSATE_STATE_T prevState = preGenDialysateState; - //TODO: To be placed in correct states once states defined. - if ( TRUE == pendingStartDDGenDialRequest ) + + + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_SKIP_PRE_GEN_PRIMING ) ) { - pendingStartDDGenDialRequest = FALSE; - requestNewOperationMode( DD_MODE_GEND ); + preGenDialysateState = DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND; } + + //Manage Inlet water control after hydro chamber fill + if( DD_PRE_GEN_DIALYSATE_HYD_CHAMBER_FILL_CHECK < preGenDialysateState ) + { + currentHydroChamberStatus = hydChamberWaterInletControl(); + } + //TODO: Transition to post gen dialysate if concentrate priming has been started - else if ( TRUE == pendingStopDDPreGenDialRequest ) + if ( TRUE == pendingStopDDPreGenDialRequest ) { pendingStopDDPreGenDialRequest = FALSE; requestNewOperationMode( DD_MODE_STAN ); } + else { // execute current pre-gen dialysate state switch ( preGenDialysateState ) { + case DD_PRE_GEN_WAIT_FOR_FP_GEN: + preGenDialysateState = handleWaitForFPState(); + break; + case DD_PRE_GEN_DIALYSATE_HYD_CHAMBER_FILL_CHECK: preGenDialysateState = handlePreGenDialysateFillCompleteCheckState(); break; - case DD_PRE_GEN_WET_SELF_TEST: - preGenDialysateState = handlePreGenWetSelfTestState(); - break; - case DD_PRE_GEN_DRY_BICART_INITIAL_FILL: preGenDialysateState = handleDryBicartInitialFillState(); break; + case DD_PRE_GEN_FILL_CHAMBER_F: + preGenDialysateState = handleFillChamberF(); + break; + + case DD_PRE_GEN_PRIME_BICARB_LINE: + preGenDialysateState = handlePrimeBicarbLine(); + break; + + case DD_PRE_GEN_PRIME_ACID_LINE: + preGenDialysateState = handlePrimeAcidLine(); + break; + case DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND: - // TODO : handle wait for Gen dialysate + + if ( TRUE == pendingStartDDGenDialRequest ) + { + pendingStartDDGenDialRequest = FALSE; + requestNewOperationMode( DD_MODE_GEND ); + } break; default: @@ -163,6 +212,12 @@ } } + if ( prevState != preGenDialysateState ) + { + setModePreGenDialysateTransition( preGenDialysateState ); + SEND_EVENT_WITH_2_U32_DATA( DD_EVENT_PRE_GEN_CHANGE, prevState, preGenDialysateState ) + } + publishPreGenDialysateState(); return preGenDialysateState; @@ -225,45 +280,63 @@ /*********************************************************************//** * @brief - * The handlePreGenDialysateFillCompleteCheckState function checks the - * hydrochamber fill and transition to next state. + * The handleWaitForFPState function checks the state of FP + * transition to next state. * @details \b Inputs: state * @details \b Outputs: none * @return current state of PreGenDialysate mode *************************************************************************/ -static DD_PRE_GEN_DIALYSATE_STATE_T handlePreGenDialysateFillCompleteCheckState( void ) +static DD_PRE_GEN_DIALYSATE_STATE_T handleWaitForFPState( void ) { - //TODO: define hydroblock fill complete process - DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_WET_SELF_TEST; + DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_WAIT_FOR_FP_GEN; + FP_OP_MODE_T fpMode = getCurrentFPOperationMode(); + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_RUN_SOLO ) ) + { + state = DD_PRE_GEN_DIALYSATE_HYD_CHAMBER_FILL_CHECK; + } + + else if ( ( FP_MODE_DEGP == fpMode ) || ( FP_MODE_GENP == fpMode ) ) + { + state = DD_PRE_GEN_DIALYSATE_HYD_CHAMBER_FILL_CHECK; + } + + //TODO: Should DD keep a timer and Alarm if FP never transitions? + return state; } /*********************************************************************//** * @brief - * The handlePreGenWetSelfTestState function executes the series of self - * tests with the conecentrates and dialysate. + * The handlePreGenDialysateFillCompleteCheckState function checks the + * hydrochamber fill and transition to next state. * @details \b Inputs: state * @details \b Outputs: none * @return current state of PreGenDialysate mode *************************************************************************/ -static DD_PRE_GEN_DIALYSATE_STATE_T handlePreGenWetSelfTestState( void ) +static DD_PRE_GEN_DIALYSATE_STATE_T handlePreGenDialysateFillCompleteCheckState( void ) { - //TODO: Change to wet self test state later - DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_DRY_BICART_INITIAL_FILL; + DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_DIALYSATE_HYD_CHAMBER_FILL_CHECK; - if ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) + if ( LVL_STATE_HIGH == getFloaterStatus( D6_LEVL ) ) { - setBicartFillRequested(); + state = DD_PRE_GEN_FILL_CHAMBER_F; + + //TODO: Rework disable dry bicarb config. Currently skipping + // all concentrate related priming + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) + { + state = DD_PRE_GEN_PRIME_BICARB_LINE; + } } - //execWetSelfTest(); + //TODO: Timeout alarm. 120s return state; } /*********************************************************************//** * @brief - * The handleDryBicartInitialFillState function executes intial dry bicart fill request + * The handleDryBicartInitialFillState function executes initial dry bicart fill request * @details \b Inputs: none * @details \b Outputs: none * @return current state of PreGenDialysate mode @@ -273,26 +346,187 @@ //TODO: Change to wet self test state later DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_DRY_BICART_INITIAL_FILL; - if ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) { + state = DD_PRE_GEN_FILL_CHAMBER_F; + } + + else + { // stay in this state till bicart fill complete. - if ( getCurrentDryBiCartFillExecState() == DRY_BICART_FILL_COMPLETE_STATE ) + if ( getCurrentDryBiCartPreGenFillExecState() == DRY_BICART_FILL_COMPLETE_STATE ) { - state = DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND; + state = DD_PRE_GEN_FILL_CHAMBER_F; } // TODO: Alarm if it is not completed within 1.5 minutes } - else + + return state; +} + +/*********************************************************************//** + * @brief + * The handleFillChamberF function checks the + * chamber F fill and transition to next state. + * @details \b Inputs: state + * @details \b Outputs: none + * @return current state of PreGenDialysate mode + *************************************************************************/ +static DD_PRE_GEN_DIALYSATE_STATE_T handleFillChamberF( void ) +{ + DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_FILL_CHAMBER_F; + + if ( PRE_GEN_BICARB_SUPPLY_VENT_END_STATE == getCurrentDryBiCartPreGenFillExecState() ) { - // not bicart fill, move to next state - state = DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND; + state = DD_PRE_GEN_PRIME_BICARB_LINE; } + //TODO: Timeout alarm. 120s return state; } /*********************************************************************//** * @brief + * The handlePrimeBicarbLine function handles priming the bicarb line + * and transition to next state. + * @details \b Inputs: state + * @details \b Outputs: none + * @return current state of PreGenDialysate mode + *************************************************************************/ +static DD_PRE_GEN_DIALYSATE_STATE_T handlePrimeBicarbLine( void ) +{ + DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_PRIME_BICARB_LINE; + + if ( TRUE == didTimeout( preGenBicarbPrimeTimer, PRE_GEN_PRIME_CONCENTRATE_TIMEOUT ) ) + { + state = DD_PRE_GEN_PRIME_ACID_LINE; + } + + return state; +} + +static DD_PRE_GEN_DIALYSATE_STATE_T handlePrimeAcidLine( void ) +{ + DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_PRIME_ACID_LINE; + + if ( TRUE == didTimeout( preGenAcidPrimeTimer, PRE_GEN_PRIME_CONCENTRATE_TIMEOUT ) ) + { + state = DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The setModeGenPDefTransition function sets the actuators and variables + * for the state transition in generate permeate mode. + * @details Inputs: none + * @details Outputs: Actuate valves, pumps as desired. + * @param state gen permeate state enum + * @return none + *************************************************************************/ +static void setModePreGenDialysateTransition( DD_PRE_GEN_DIALYSATE_STATE_T state ) +{ + // Execute on running state + switch( state ) + { + case DD_PRE_GEN_WAIT_FOR_FP_GEN: + break; + + case DD_PRE_GEN_DIALYSATE_HYD_CHAMBER_FILL_CHECK: + preGenfillChamberCTimer = getMSTimerCount(); + setValveState( D14_VALV, VALVE_STATE_CLOSED ); + setValveState( D3_VALV, VALVE_STATE_OPEN ); + break; + + case DD_PRE_GEN_DRY_BICART_INITIAL_FILL: + + if ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) + { + setBicartFillRequested(); + } + break; + + case DD_PRE_GEN_FILL_CHAMBER_F: + if ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) + { + setBicartPreGenFillRequested(); + } + setDialysatePumpTargetRPM( D12_PUMP, PRE_GEN_PRIME_D12_RPM, TRUE ); + + break; + + case DD_PRE_GEN_PRIME_BICARB_LINE: + preGenBicarbPrimeTimer = getMSTimerCount(); + // dialyzer bypass + setValveState( D34_VALV, VALVE_STATE_OPEN ); + setValveState( D91_VALV, VALVE_STATE_CLOSED ); + setValveState( D35_VALV, VALVE_STATE_CLOSED ); + setValveState( D40_VALV, VALVE_STATE_CLOSED ); + // open BC fresh side + setValveState( D19_VALV, VALVE_STATE_OPEN ); + setValveState( D20_VALV, VALVE_STATE_OPEN ); + setValveState( D21_VALV, VALVE_STATE_OPEN ); + setValveState( D22_VALV, VALVE_STATE_OPEN ); + // close BC spent side + setValveState( D23_VALV, VALVE_STATE_CLOSED ); + setValveState( D24_VALV, VALVE_STATE_CLOSED ); + setValveState( D25_VALV, VALVE_STATE_CLOSED ); + setValveState( D26_VALV, VALVE_STATE_CLOSED ); + //vent air to chamber h + setValveState( D47_VALV, VALVE_STATE_OPEN ); + setValveState( D14_VALV, VALVE_STATE_CLOSED ); + setValveState( D80_VALV, VALVE_STATE_CLOSED ); + //set bicarb concentrate pump and rinse pump + setRinsePumpState( RINSE_PUMP_STATE_ON ); + setConcentratePumpTargetSpeed( D10_PUMP, PRE_GEN_PRIME_CONCENTRATE_PUMP_SPEED, PRE_GEN_PRIME_CONCENTRATE_VOLUME ); + requestConcentratePumpOn( D10_PUMP ); + break; + + case DD_PRE_GEN_PRIME_ACID_LINE: + requestConcentratePumpOff( D10_PUMP, FALSE ); + //TODO: Merge concentrate line priming to one state. + preGenAcidPrimeTimer = getMSTimerCount(); + // dialyzer bypass + setValveState( D34_VALV, VALVE_STATE_OPEN ); + setValveState( D91_VALV, VALVE_STATE_CLOSED ); + setValveState( D35_VALV, VALVE_STATE_CLOSED ); + setValveState( D40_VALV, VALVE_STATE_CLOSED ); + // open BC fresh side + setValveState( D19_VALV, VALVE_STATE_OPEN ); + setValveState( D20_VALV, VALVE_STATE_OPEN ); + setValveState( D21_VALV, VALVE_STATE_OPEN ); + setValveState( D22_VALV, VALVE_STATE_OPEN ); + // close BC spent side + setValveState( D23_VALV, VALVE_STATE_CLOSED ); + setValveState( D24_VALV, VALVE_STATE_CLOSED ); + setValveState( D25_VALV, VALVE_STATE_CLOSED ); + setValveState( D26_VALV, VALVE_STATE_CLOSED ); + //vent air to chamber h + setValveState( D47_VALV, VALVE_STATE_OPEN ); + setValveState( D14_VALV, VALVE_STATE_CLOSED ); + setValveState( D80_VALV, VALVE_STATE_CLOSED ); + //set acid concentrate pump and rinse pump + setRinsePumpState( RINSE_PUMP_STATE_ON ); + setConcentratePumpTargetSpeed( D11_PUMP, PRE_GEN_PRIME_CONCENTRATE_PUMP_SPEED, PRE_GEN_PRIME_CONCENTRATE_VOLUME ); + requestConcentratePumpOn( D11_PUMP ); + break; + + case DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND: + //TODO: update to recirculation instead of off states. + requestConcentratePumpOff( D10_PUMP, FALSE ); + requestConcentratePumpOff( D11_PUMP, FALSE ); + setRinsePumpState( RINSE_PUMP_STATE_OFF ); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, FP_FAULT_ID_FP_INVALID_GENP_STATE, state ) + break; + } +} +/*********************************************************************//** + * @brief * The setModePreGenWetSelfStateTransition function sets the actuators and variables * for the state transition in pre-gen WetSlef test mode. * @details Inputs: Valve states, Pump speed @@ -529,8 +763,10 @@ { // TODO add validate condition after checking with Vinay case DD_PRE_GEN_DIALYSATE_HYD_CHAMBER_FILL_CHECK: - case DD_PRE_GEN_WET_SELF_TEST: case DD_PRE_GEN_DRY_BICART_INITIAL_FILL: + case DD_PRE_GEN_FILL_CHAMBER_F: + case DD_PRE_GEN_PRIME_BICARB_LINE: + case DD_PRE_GEN_PRIME_ACID_LINE: case DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND: result = TRUE; break; @@ -562,10 +798,12 @@ { // TODO add logic after checking with Vinay // Any of these state require no special handling - case DD_PRE_GEN_DIALYSATE_HYD_CHAMBER_FILL_CHECK: - case DD_PRE_GEN_WET_SELF_TEST: - case DD_PRE_GEN_DRY_BICART_INITIAL_FILL: - case DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND: + case DD_PRE_GEN_DIALYSATE_HYD_CHAMBER_FILL_CHECK: + case DD_PRE_GEN_DRY_BICART_INITIAL_FILL: + case DD_PRE_GEN_FILL_CHAMBER_F: + case DD_PRE_GEN_PRIME_BICARB_LINE: + case DD_PRE_GEN_PRIME_ACID_LINE: + case DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND: default: break; } Index: firmware/App/Monitors/Conductivity.c =================================================================== diff -u -rd47b9bcbd4796a8c51d9e87436422c5868292ac6 -rc67f50a3c737b65216f513477dbf91d8af044e58 --- firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision d47b9bcbd4796a8c51d9e87436422c5868292ac6) +++ firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision c67f50a3c737b65216f513477dbf91d8af044e58) @@ -277,6 +277,7 @@ return result; } + /*********************************************************************//** * @brief * The filterConductivitySensorReadings function filters the conductivity rates for