Index: firmware/App/Modes/BalancingChamber.c =================================================================== diff -u -rbbd8ef64eb4b178ca76a9721908fee7347a71c6a -r6679a2cd813b21a8cb4c58b3eeb721e0eef9a10b --- firmware/App/Modes/BalancingChamber.c (.../BalancingChamber.c) (revision bbd8ef64eb4b178ca76a9721908fee7347a71c6a) +++ firmware/App/Modes/BalancingChamber.c (.../BalancingChamber.c) (revision 6679a2cd813b21a8cb4c58b3eeb721e0eef9a10b) @@ -48,8 +48,6 @@ static U32 currentBalChamberSwitchingCounter; ///< Counter (in task interval) to monitor the timing spent during balancing chamber fill/drain operation. static BOOL isBalChamberFillInProgress; ///< Flag indicating balancing chamber fill/drain is in progress. static BOOL isPressureStalbilizedDuringFill; ///< Flag indicating that the pressure is stablized due to fill complete. -static BOOL isDialysateGoodtoDeliver; ///< Flag indicating whether ready to deliver dialysate or not. -static OVERRIDE_U32_T isDialDeliveryInProgress; ///< To indicate dialysate started delivering to dialyzer for treatment (overrideable) static BAL_CHAMBER_SW_STATE_T balChamberSWState; ///< Current balancing chamber switching state ( state 1 or state 2). static U32 balChamberDataPublicationTimerCounter; ///< Used to schedule balancing chamber data publication to CAN bus. static OVERRIDE_U32_T balChamberDataPublishInterval; ///< Balancing chamber data publish interval. @@ -61,8 +59,6 @@ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1FillEnd(void); static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState2FillStart( void ); static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState2FillEnd(void); -static BAL_CHAMBER_EXEC_STATE_T handleBalChamberDialDeliveryPause( void ); -static void balChamberDialDeliveryBypassCheck( void ); static void publishBalChamberData( void ); static U32 getBalChamberDataPublishInterval( void ); @@ -81,10 +77,6 @@ balChamberSwitchingFreq.ovData = 0.0F; balChamberSwitchingFreq.ovInitData = 0.0F; balChamberSwitchingFreq.override = OVERRIDE_RESET; - isDialDeliveryInProgress.data = FALSE; - isDialDeliveryInProgress.ovData = FALSE; - isDialDeliveryInProgress.ovInitData = FALSE; - isDialDeliveryInProgress.override = OVERRIDE_RESET; balChamberDataPublishInterval.data = BAL_CHAMBER_DATA_PUBLISH_INTERVAL; balChamberDataPublishInterval.ovData = BAL_CHAMBER_DATA_PUBLISH_INTERVAL; balChamberDataPublishInterval.ovInitData = 0; @@ -93,7 +85,6 @@ isBalChamberFillInProgress = FALSE; currentBalChamberSwitchingCounter = 0; isPressureStalbilizedDuringFill = FALSE; - isDialysateGoodtoDeliver = FALSE; balChamberDataPublicationTimerCounter = 0; } @@ -133,34 +124,6 @@ /*********************************************************************//** * @brief - * The execBalancingChamberMonitor function monitors the balancing chamber fill - * operations and alarm if temperature and conductivity is not in range. - * @details \b Inputs: balChamberExecState - * @details \b Outputs: balChamberExecState - * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT when wrong balancing chamber state invoked. - * @return current state. - *************************************************************************/ -void execBalancingChamberMonitor( void ) -{ - // Read temperature and conducitivity - //F32 hydChamberTemperature = getTemperatureValue( TEMPSENSORS_HYDRAULICS_PRIMARY_HEATER ); - //F32 biCarbConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD1_SENSOR ); - //F32 acidBicarbMixConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD3_SENSOR ); - - // Monitor critical parameter while balancing chamber fill is in progress - if ( TRUE == isBalChamberFillInProgress ) - { - // Temperature range check - - // Coductivity range check - - // Also, TD confirms to deliver dialysate - isDialysateGoodtoDeliver = TRUE; - } -} - -/*********************************************************************//** - * @brief * The execBalancingChamberControl function executes the balancing chamber state machine. * @details \b Inputs: balChamberExecState * @details \b Outputs: balChamberExecState @@ -172,8 +135,7 @@ // Increment counter during fill time only, Also check dialysate needs to be bypassed. if ( TRUE == isBalChamberFillInProgress ) { - balChamberDialDeliveryBypassCheck(); - currentBalChamberSwitchingCounter += 1; + currentBalChamberSwitchingCounter += 1; } // execute current balancing chamber exec state @@ -207,10 +169,6 @@ balChamberExecState = handleBalChamberState2FillEnd(); break; - case BAL_CHAMBER_DIAL_DELIVERY_PAUSE: - balChamberExecState = handleBalChamberDialDeliveryPause(); - break; - default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_BAL_CHAMBER_INVALID_EXEC_STATE, balChamberExecState ) balChamberExecState = BAL_CHAMBER_STATE_START; @@ -328,6 +286,29 @@ /*********************************************************************//** * @brief + * The valveControlForBCOpenState function open the all balancing + * chamber valves. + * @details \b Inputs: none + * @details \b Outputs: valve states + * @return none. + *************************************************************************/ +void valveControlForBCOpenState( void ) +{ + // Open balancing chamber valve combinations V1,V6 and V4,V7 + setValveState( BCV1, VALVE_STATE_OPEN ); + setValveState( BCV6, VALVE_STATE_OPEN ); + setValveState( BCV4, VALVE_STATE_OPEN ); + setValveState( BCV7, VALVE_STATE_OPEN ); + + //Open balancing chamber valve combinations V2,V5 and V3,V8 + setValveState( BCV2, VALVE_STATE_OPEN ); + setValveState( BCV5, VALVE_STATE_OPEN ); + setValveState( BCV3, VALVE_STATE_OPEN ); + setValveState( BCV8, VALVE_STATE_OPEN ); +} + +/*********************************************************************//** + * @brief * The handleBalChamberState1FillStart function handles the balancing chamber * state 1 fill and time to fill chamber counter being updated. * @details \b Inputs: Pressure @@ -527,64 +508,28 @@ /*********************************************************************//** * @brief - * The handleBalChamberDialDeliveryBypassCheck function decides closing the - * bypass valve and open up the dialyzer valves for treatment. - * @details \b Inputs: isDialysateGoodtoDeliver - * @details \b Outputs: isDialysateGoodtoDeliver,isDialDeliveryInProgress - * @return none. - *************************************************************************/ -static void balChamberDialDeliveryBypassCheck( void ) -{ - if ( TRUE == isDialysateGoodtoDeliver ) - { - // Close bypass valve and Open VDI, VDo valves - setValveState( VDB2, VALVE_STATE_CLOSED ); - setValveState( VDI, VALVE_STATE_OPEN ); - setValveState( VDO, VALVE_STATE_OPEN ); - - // update dialysate delivery status. - isDialDeliveryInProgress.data = TRUE; - } - else - { - // Open bypass valve and raise alarm - setValveState( VDI, VALVE_STATE_CLOSED ); - setValveState( VDO, VALVE_STATE_CLOSED ); - setValveState( VDB2, VALVE_STATE_OPEN ); - - // update dialysate delivery status. - isDialDeliveryInProgress.data = FALSE; - } -} - -/*********************************************************************//** - * @brief - * The handleBalChamberDialDeliveryPause function pauses the dialysate - * delivery due to alarm conditions. - * @details \b Inputs: none + * The getCurrentBalancingChamberExecState function returns the current state + * of the balancing chamber. + * @details \b Inputs: balChamberExecState * @details \b Outputs: none - * @return next balancing chamber state. + * @return the current state of balancing chamber states. *************************************************************************/ -static BAL_CHAMBER_EXEC_STATE_T handleBalChamberDialDeliveryPause( void ) +BAL_CHAMBER_EXEC_STATE_T getCurrentBalancingChamberExecState( void ) { - BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_DIAL_DELIVERY_PAUSE; - - //TODO : handle any pause state actions - - return state; + return balChamberExecState; } /*********************************************************************//** * @brief - * The getCurrentBalancingChamberExecState function returns the current state - * of the balancing chamber. - * @details \b Inputs: balChamberExecState + * The getBalancingChamberFillinProgressStatus function returns the current + * balancing chamber fill in progress status. + * @details \b Inputs: isBalChamberFillInProgress * @details \b Outputs: none - * @return the current state of balancing chamber states. + * @return the current balancing chamber fill in progress. *************************************************************************/ -BAL_CHAMBER_EXEC_STATE_T getCurrentBalancingChamberExecState( void ) +BOOL getBalancingChamberFillinProgressStatus( void ) { - return balChamberExecState; + return isBalChamberFillInProgress; } /*********************************************************************//** @@ -609,26 +554,6 @@ /*********************************************************************//** * @brief - * The getDialDeliveryProgressStatus function gets the dialysate delivery - * progress status. - * @details \b Inputs: isDialDeliveryInProgress - * @details \b Outputs: none - * @return the current status of dialysate delivery - *************************************************************************/ -U32 getDialDeliveryProgressStatus( void ) -{ - U32 result = isDialDeliveryInProgress.data; - - if ( OVERRIDE_KEY == isDialDeliveryInProgress.override ) - { - result = isDialDeliveryInProgress.ovData; - } - - return result; -} - -/*********************************************************************//** - * @brief * The getBalChamberDataPublishInterval function gets the balancing chamber * data publish interval. * @details \b Inputs: balChamberDataPublishInterval @@ -666,12 +591,10 @@ data.balChamberExecState = (U32)balChamberExecState; data.balChamberSWState = (U32)balChamberSWState; data.balChamberSWFreq = getBalChamberSwitchingFreq(); - data.isDialDelInProgress = (BOOL)getDialDeliveryProgressStatus(); data.balChamberSwPeriod = balChamberSwitchingPeriod; data.isBalChamberFillInProgress = isBalChamberFillInProgress; data.currentBalChamberSwitchingCounter = currentBalChamberSwitchingCounter; data.isPressureStalbilizedDuringFill = isPressureStalbilizedDuringFill; - data.isDialysateGoodtoDeliver = isDialysateGoodtoDeliver; broadcastData( MSG_ID_DD_BAL_CHAMBER_DATA, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&data, sizeof( BAL_CHAMBER_DATA_T ) ); @@ -704,23 +627,6 @@ /*********************************************************************//** * @brief - * The testDialDeliveryInProgressOverride function sets the override value - * of the dialysate delivery In progress flag. - * @details Inputs: isDialDeliveryInProgress - * @details Outputs: isDialDeliveryInProgress - * @param message Override message from Dialin which includes the override - * value to override the dialysate delivery in progress flag. - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testDialDeliveryInProgressOverride( MESSAGE_T *message ) -{ - BOOL result = u32Override( message, &isDialDeliveryInProgress, 0, TRUE ); - - return result; -} - -/*********************************************************************//** - * @brief * The testBalChamberSwFreqOverride function sets the override value * of the balancing chamber switching frequency. * @details Inputs: balChamberSwitchingFreq