Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r145fd716a856f864f39fb0f9884865f6e45b9256 -r3aa700c036437377bca1de55bc01307705abf0a5 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 145fd716a856f864f39fb0f9884865f6e45b9256) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 3aa700c036437377bca1de55bc01307705abf0a5) @@ -241,6 +241,34 @@ /*********************************************************************//** * @brief + * TThe getBicarbDoseVol function gets the bicarb dose volume + * @details \b Inputs: bicarbDoseVolume + * @details \b Outputs: none + * @return TRUE if successful, FALSE if not. + *************************************************************************/ +F32 getBicarbDoseVol( void ) +{ + F32 result = getF32OverrideValue( &bicarbDoseVolume ); + + return result; +} + +/*********************************************************************//** + * @brief + * The getAcidDoseVol function gets acid mix volume + * @details \b Inputs: acidDoseVolume + * @details \b Outputs: none + * @return TRUE if successful, FALSE if not. + *************************************************************************/ +F32 getAcidDoseVol( void ) +{ + F32 result = getF32OverrideValue( &acidDoseVolume ); + + return result; +} + +/*********************************************************************//** + * @brief * The applyBalChamberSwitchingPeriod function applies the active balancing * chamber switching time based on the provided dialysis flow rate. * @details \b Inputs: Dialysis flow rate. Index: firmware/App/Controllers/BalancingChamber.h =================================================================== diff -u -ra6737c3bcc8286c153b778c2c395f465e76aaafb -r3aa700c036437377bca1de55bc01307705abf0a5 --- firmware/App/Controllers/BalancingChamber.h (.../BalancingChamber.h) (revision a6737c3bcc8286c153b778c2c395f465e76aaafb) +++ firmware/App/Controllers/BalancingChamber.h (.../BalancingChamber.h) (revision 3aa700c036437377bca1de55bc01307705abf0a5) @@ -72,6 +72,8 @@ BOOL getBalChamberSwitchingOnlyStatus( void ); // Get balancing chamber switching only status void setBalChamberSwitchingOnlyStatus( BOOL OnOff ); // Set balancing chamber switching only status U32 getBalChamberSwitchingPeriod( void ); // Get balancing chamber switching period +F32 getBicarbDoseVol( void ); // Get liquid bicarb dose volume +F32 getAcidDoseVol( void ); // Get acid dose volume BOOL testDDBalChamberDataPublishIntervalOverride( MESSAGE_T *message ); // To override the balancing chamber data publish interval BOOL testBalChamberSwFreqOverride( MESSAGE_T *message ); // To override the balancing chamber switching frequency 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 Index: firmware/App/Controllers/DryBiCart.h =================================================================== diff -u -r145fd716a856f864f39fb0f9884865f6e45b9256 -r3aa700c036437377bca1de55bc01307705abf0a5 --- firmware/App/Controllers/DryBiCart.h (.../DryBiCart.h) (revision 145fd716a856f864f39fb0f9884865f6e45b9256) +++ firmware/App/Controllers/DryBiCart.h (.../DryBiCart.h) (revision 3aa700c036437377bca1de55bc01307705abf0a5) @@ -58,6 +58,7 @@ U32 execDryBicartFillMode( void ); U32 execBicarbChamberFillMode( void ); U32 execDryBicartDrainMode( void ); +U32 execDryBicartDepressurise( void ); void execDryBicart( void ); BOOL setBicarbChamberFillRequested( void ); BOOL getBicarbChamberFillRequested( void ); @@ -71,6 +72,7 @@ BOOL testDryBiCartFillRequestOverride( MESSAGE_T *message ); BOOL testBiCarbChamberFillRequestOverride( MESSAGE_T *message ); BOOL testDryBiCartDrainRequestOverride( MESSAGE_T *message ); +BOOL testDryBiCartDepressuriseRequestOverride( MESSAGE_T *message ); BOOL testDryBiCartTypeOverride( MESSAGE_T *message ); BOOL testDryBiCartUpperCartPressureOverride( MESSAGE_T *message ); Index: firmware/App/Services/AlarmMgmtSWFaults.h =================================================================== diff -u -r9eae2f683887bededd2240f51ddfc667d8c1d566 -r3aa700c036437377bca1de55bc01307705abf0a5 --- firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 9eae2f683887bededd2240f51ddfc667d8c1d566) +++ firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 3aa700c036437377bca1de55bc01307705abf0a5) @@ -160,6 +160,7 @@ SW_FAULT_ID_MODE_UPDATE_INVALID_STATE = 129, SW_FAULT_ID_SUBSTITUTION_PUMP_INVALID_ID = 130, SW_FAULT_ID_SUBSTITUTION_PUMP_EXEC_INVALID_STATE = 131, + SW_FAULT_ID_DRY_BICART_DEPRESURISE_INVALID_EXEC_STATE = 132, NUM_OF_SW_FAULT_IDS } DD_SW_FAULT_ID_T; Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r7c29e738c37a25cc72d68686d852e087f2f1577d -r3aa700c036437377bca1de55bc01307705abf0a5 --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 7c29e738c37a25cc72d68686d852e087f2f1577d) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 3aa700c036437377bca1de55bc01307705abf0a5) @@ -298,6 +298,7 @@ { MSG_ID_DD_CONDUCTIVITY_SENSOR_CAL_REQUEST, &testHandleConductivitySensorCalRequest }, { MSG_ID_FP_CONDUCTIVITY_SENSOR_CAL_REQUEST, &testHandleConductivitySensorCalRequest }, { MSG_ID_DD_MIXING_CONTROL_DATA_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testMixingControlDataPublishIntervalOverride }, + { MSG_ID_DD_BICART_DEPRESSURISE_REQUEST_OVERRIDE_REQUEST, &testDryBiCartDepressuriseRequestOverride }, }; /// Calculation for number of entries in the incoming message function handler look-up table. Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r145fd716a856f864f39fb0f9884865f6e45b9256 -r3aa700c036437377bca1de55bc01307705abf0a5 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 145fd716a856f864f39fb0f9884865f6e45b9256) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 3aa700c036437377bca1de55bc01307705abf0a5) @@ -102,8 +102,11 @@ { // manage drybicart state machines execDryBicart(); + execDryBicartDepressurise(); } + execMixingControl(); + // Control RO pump execROPumpController();