Index: firmware/App/Modes/ModePreGenDialysate.c =================================================================== diff -u -r3417933e6edf61a914c428e2fa944b3b349272a4 -re48bec7b1330b195afadcbf8bc58bdb4f1d5b03e --- firmware/App/Modes/ModePreGenDialysate.c (.../ModePreGenDialysate.c) (revision 3417933e6edf61a914c428e2fa944b3b349272a4) +++ firmware/App/Modes/ModePreGenDialysate.c (.../ModePreGenDialysate.c) (revision e48bec7b1330b195afadcbf8bc58bdb4f1d5b03e) @@ -17,6 +17,7 @@ #include "ConcentratePumps.h" #include "DialysatePumps.h" +#include "DryBiCart.h" #include "Heaters.h" #include "ModePreGenDialysate.h" #include "ModeGenDialysate.h" @@ -51,12 +52,14 @@ 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 BOOL dryBicartFillRequest; +static U32 StartTimeMS; // ********** 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 handleDryBicartFillCheckState( void ); //Wet Self test static void setModePreGenWetSelfStateTransition( DD_WET_SELF_TEST_STATE_T state ); @@ -78,8 +81,10 @@ wetSelfTestState = DD_WET_SELF_TEST_START; hydChamberPressureCheckStartTimeMS = 0; pressureCheckPersistanceStartTimeMS = 0; + StartTimeMS = 0; pendingStartDDGenDialRequest = FALSE; pendingStopDDPreGenDialRequest = FALSE; + dryBicartFillRequest = FALSE; preGenDialysateModePublishInterval.data = PRE_GEN_DIALYSATE_DATA_PUB_INTERVAL; preGenDialysateModePublishInterval.ovData = PRE_GEN_DIALYSATE_DATA_PUB_INTERVAL; preGenDialysateModePublishInterval.ovInitData = 0; @@ -144,6 +149,10 @@ preGenDialysateState = handlePreGenWetSelfTestState(); break; + case DD_PRE_GEN_DRY_BICART_FILL_CHECK: + preGenDialysateState = handleDryBicartFillCheckState(); + break; + case DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND: // TODO : handle wait for Gen dialysate break; @@ -241,15 +250,60 @@ static DD_PRE_GEN_DIALYSATE_STATE_T handlePreGenWetSelfTestState( void ) { //TODO: Change to wet self test state later - DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND; + DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_DRY_BICART_FILL_CHECK; + if ( getTestConfigStatus( TEST_CONFIG_ENABLE_DRY_BICART_FILL ) == TRUE ) + { + setValveState( D14_VALV, VALVE_STATE_OPEN ); + setDialysatePumpTargetRPM( D12_PUMP, FRESH_DIAL_PUMP_INITIAL_RPM, TRUE ); + + StartTimeMS = getMSTimerCount(); + } + //execWetSelfTest(); return state; } + /*********************************************************************//** * @brief + * The handleDryBicartFillCheckState function executes intial dryy bicart fill request + * @details \b Inputs: state + * @details \b Outputs: none + * @return current state of PreGenDialysate mode + *************************************************************************/ +static DD_PRE_GEN_DIALYSATE_STATE_T handleDryBicartFillCheckState( void ) +{ + //TODO: Change to wet self test state later + DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_DRY_BICART_FILL_CHECK; + U32 currentFillDurationInMS; + + if ( getTestConfigStatus( TEST_CONFIG_ENABLE_DRY_BICART_FILL ) == TRUE ) + { + // if ( FALSE == dryBicartFillRequest ) + { + setBicartFillRequested(); + + dryBicartFillRequest = TRUE; + } + + if ( getCurrentDryBiCartFillExecState() == DRY_BICART_FILL_COMPLETE_STATE ) + { + currentFillDurationInMS = calcTimeSince( StartTimeMS ); + state = DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND; + } + } + else + { + state = DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND; + } + + return state; +} + +/*********************************************************************//** + * @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