Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -racb534a5d5921959493304a26dbc21d2b03338e0 -r573a26b2a0273a4983b1de1cbff5bed63e01dce0 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision acb534a5d5921959493304a26dbc21d2b03338e0) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 573a26b2a0273a4983b1de1cbff5bed63e01dce0) @@ -65,6 +65,7 @@ static U32 balChamberFillCompleteStablePressureCounter; ///< Counter to check balancing chamber fill complete and stable pressure is met. static OVERRIDE_U32_T balChamberDataPublishInterval; ///< Balancing chamber data publish interval. static BOOL balanceChamberSwitchingOnly; ///< Balancing chamber switching without any pressure check and dosing delivery. +static BOOL isFirstCycleBCSwitchingCompleted; ///< Flag indicating that first time balancing chamber swithcing is done to trigger alarms from next cycle onwards. static OVERRIDE_F32_T acidDoseVolume; ///< Acid concentrate volume in ml ( overrideable). static OVERRIDE_F32_T bicarbDoseVolume; ///< Bicarb concentrate volume in ml ( overrideable). static F32 lastTdDialysateFlowrate; ///< Previous TD dialysate flow rate @@ -116,6 +117,7 @@ balChamberDataPublicationTimerCounter = 0; balChamberFillPressureDropCounter = 0; balChamberFillCompleteStablePressureCounter = 0; + isFirstCycleBCSwitchingCompleted = FALSE; } /*********************************************************************//** @@ -158,6 +160,9 @@ //Update last td dialysate flow rate lastTdDialysateFlowrate = tdDialysateFlowrate; + //Reset the BC switching flag for new Qd. + isFirstCycleBCSwitchingCompleted = FALSE; + //Update heater control on dialysate flow change signalHeaterControlOnQDUpdate( D5_HEAT ); @@ -396,8 +401,8 @@ F32 spentDialPressure = getFilteredPressure( D51_PRES ); F32 acidVolume = getF32OverrideValue( &acidDoseVolume ); F32 bicarbVolume = getF32OverrideValue( &bicarbDoseVolume ); + // Check fresh and spent dialysate pressure in range or BC switch only flag set - //TODO : comment the pressure check //if ( 1 ) if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) || @@ -443,10 +448,18 @@ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberConcentrateControl( void ) { BAL_CHAMBER_EXEC_STATE_T state; - F32 freshDialPressure = getFilteredPressure( D18_PRES ); F32 spentDialPressure = getFilteredPressure( D51_PRES ); + if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) + { + state = BAL_CHAMBER_STATE1_BICARB_ACID_DOSING_CNTRL; + } + else + { + state = BAL_CHAMBER_STATE2_BICARB_ACID_DOSING_CNTRL; + } + // Pressure drop check during fill process helps to find if there is any issue with valves opening if ( ( freshDialPressure <= BC_FRESH_FILL_PRESSURE_PSIG ) && ( spentDialPressure <= BC_SPENT_FILL_PRESSURE_PSIG ) ) { @@ -494,7 +507,6 @@ F32 spentDialPressure = getFilteredPressure( D51_PRES ); // Check fresh and spent dialysate pressure back in range to indicate fill complete. - //TODO : comment the pressure check //if ( 1 ) //if ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && @@ -506,7 +518,6 @@ isPressureStalbilizedDuringFill = TRUE; isBalChamberFillInProgress = FALSE; } - // isPressureStalbilizedDuringFill = FALSE; } // Switching time met or pressure in range, close valves @@ -525,7 +536,7 @@ if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { - if ( TRUE != isPressureDroppedDuringFill ) + if ( ( TRUE != isPressureDroppedDuringFill ) && ( TRUE == isFirstCycleBCSwitchingCompleted ) ) { //#ifdef ENABLE_ALARM_2 // When fill initiated, pressure is not dropped to the expected range, possible valve failures. @@ -582,7 +593,6 @@ F32 bicarbVolume = getF32OverrideValue( &bicarbDoseVolume ); // Check fresh and spent dialysate pressure in range - //TODO : comment the pressure check //if ( 1 ) if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) || @@ -636,7 +646,6 @@ F32 spentDialPressure = getFilteredPressure( D51_PRES ); // Check fresh and spent dialysate pressure back in range to indicate fill complete. - //TODO : comment the pressure check //if ( 1 ) //if ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && @@ -668,7 +677,7 @@ // Pressure alarm check if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { - if ( TRUE != isPressureDroppedDuringFill ) + if ( ( TRUE != isPressureDroppedDuringFill ) && ( TRUE == isFirstCycleBCSwitchingCompleted ) ) { //#ifdef ENABLE_ALARM_2 // When fill initiated, pressure is not dropped to the expected range, possible valve failures. @@ -686,6 +695,11 @@ { // Move to next state when pressure is in range. state = BAL_CHAMBER_STATE1_FILL_START; + + if ( FALSE == isFirstCycleBCSwitchingCompleted ) + { + isFirstCycleBCSwitchingCompleted = TRUE; + } } //TODO : Temporarily allow to proceed next state even though pressure is not stabilized. Index: firmware/App/Controllers/BalancingChamber.h =================================================================== diff -u -racb534a5d5921959493304a26dbc21d2b03338e0 -r573a26b2a0273a4983b1de1cbff5bed63e01dce0 --- firmware/App/Controllers/BalancingChamber.h (.../BalancingChamber.h) (revision acb534a5d5921959493304a26dbc21d2b03338e0) +++ firmware/App/Controllers/BalancingChamber.h (.../BalancingChamber.h) (revision 573a26b2a0273a4983b1de1cbff5bed63e01dce0) @@ -35,8 +35,8 @@ #define FRESH_DIAL_PRESSURE_MAX_PSIG 28.0F ///< Maximum fresh dialysate pressure (D18) limit for balancing chamber fill operations. #define SPENT_DIAL_PRESSURE_MIN_PSIG 33.0F ///< Minimum spent dialysate pressure (D51) limit for balancing chamber fill operations. #define SPENT_DIAL_PRESSURE_MAX_PSIG 37.0F ///< Maximum spent dialysate pressure (D51) limit for balancing chamber fill operations. -#define BC_FRESH_FILL_PRESSURE_PSIG 13.0F ///< Fresh side pressure (drop) during balancing chamber switching, indicates fill has been started / in progress. -#define BC_SPENT_FILL_PRESSURE_PSIG 26.0F ///< Spent side pressure (drop) during balancing chamber switching, indicates fill has been started / in progress. +#define BC_FRESH_FILL_PRESSURE_PSIG 14.0F ///< Fresh side pressure (drop) during balancing chamber switching, indicates fill has been started / in progress. +#define BC_SPENT_FILL_PRESSURE_PSIG 29.0F ///< Spent side pressure (drop) during balancing chamber switching, indicates fill has been started / in progress. #define BAL_CHAMBER_FILL_VOLUME_ML 30.0F ///< Balancing chamber fill/drain volume per batch operation. /// balancing chamber data structure Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -racb534a5d5921959493304a26dbc21d2b03338e0 -r573a26b2a0273a4983b1de1cbff5bed63e01dce0 --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision acb534a5d5921959493304a26dbc21d2b03338e0) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 573a26b2a0273a4983b1de1cbff5bed63e01dce0) @@ -549,18 +549,17 @@ if ( D11_PUMP == pumpId ) { setFPGAD11PumpRevolutionCount( getConcPumpTargetRevolutionCount( pumpId ) ); - isDosingCompleted [ D11_PUMP ] = FALSE; } else if ( D10_PUMP == pumpId ) { setFPGAD10PumpRevolutionCount( getConcPumpTargetRevolutionCount( pumpId ) ); - isDosingCompleted [ D10_PUMP ] = FALSE; } else { setFPGAD76PumpRevolutionCount( getConcPumpTargetRevolutionCount( pumpId ) ); - isDosingCompleted [ D76_PUMP ] = FALSE; } + + isDosingCompleted [ pumpId ] = FALSE; } /* @@ -619,12 +618,24 @@ * for a given concentrate pump. * @details \b Inputs: concentratePumps * @details \b Outputs: none + * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT when invalid pump ID is seen. * @param pumpId concentrate pump id to get current dosing status * @return TRUE if dosing completed otherwise,FALSE. *************************************************************************/ BOOL isConcentratePumpDosingCompleted( CONCENTRATE_PUMPS_T pumpId ) { - return isDosingCompleted[ pumpId ]; + BOOL status = FALSE; + + if ( pumpId < NUM_OF_CONCENTRATE_PUMPS ) + { + status = isDosingCompleted[ pumpId ]; + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_CONCENTRATE_PUMP_INVALID_PUMP_ID, pumpId ); + } + + return status; } /*********************************************************************//** Index: firmware/App/DDCommon.h =================================================================== diff -u -racb534a5d5921959493304a26dbc21d2b03338e0 -r573a26b2a0273a4983b1de1cbff5bed63e01dce0 --- firmware/App/DDCommon.h (.../DDCommon.h) (revision acb534a5d5921959493304a26dbc21d2b03338e0) +++ firmware/App/DDCommon.h (.../DDCommon.h) (revision 573a26b2a0273a4983b1de1cbff5bed63e01dce0) @@ -43,7 +43,7 @@ //#define __PITEST__ 1 //Uncomment below if diener concentrate pump used -#define __DIENER_CONC_PUMP__ 1 +//#define __DIENER_CONC_PUMP__ 1 //Uncomment below if beta hardware is used //#define __BETA_HW_VER__ 1 Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -racb534a5d5921959493304a26dbc21d2b03338e0 -r573a26b2a0273a4983b1de1cbff5bed63e01dce0 --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision acb534a5d5921959493304a26dbc21d2b03338e0) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 573a26b2a0273a4983b1de1cbff5bed63e01dce0) @@ -60,7 +60,7 @@ #define LOW_DIAL_FLOW_RATE 150.0F ///< Dialysate flow rate lesser than 150 considered to be low Qds. //Testing -#define DELAY_BC_SWITCHING_AT_START_UP ( 10 * MS_PER_SECOND ) ///< Provide a balancing chamber switching start up delay to stabilize pump speed etc., +#define DELAY_BC_SWITCHING_AT_START_UP ( 10 * MS_PER_SECOND ) ///< Provide a balancing chamber switching start up delay to stabilize pump speed etc., /// Payload record structure for Gen dialysate execution state set request typedef struct { Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r25dbc6221b63e20fe61b2af0ce9c9f56bf13e807 -r573a26b2a0273a4983b1de1cbff5bed63e01dce0 --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 25dbc6221b63e20fe61b2af0ce9c9f56bf13e807) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 573a26b2a0273a4983b1de1cbff5bed63e01dce0) @@ -144,7 +144,7 @@ { MSG_ID_DD_HEATERS_START_STOP_OVERRIDE_REQUEST, &testHeaterStartStopOverride }, { MSG_ID_DD_VALVES_OPEN_CLOSE_STATE_OVERRIDE_REQUEST, &testValveOpenCloseStateOverride }, { MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA, &handleDialysateDeliveryRequestMsg }, - { MSD_ID_DD_FP_COMMUNICATION_STATUS_OVERRIDE_REQUEST, &testROCommunicationStatusOverride }, + { MSD_ID_DD_FP_COMMUNICATION_STATUS_OVERRIDE_REQUEST, &testFPCommunicationStatusOverride }, { MSG_ID_DD_BAL_CHAMBER_DATA_PUBLISH_OVERRIDE_REQUEST, &testDDBalChamberDataPublishIntervalOverride }, { MSG_ID_DD_BAL_CHAMBER_SWITCH_FREQ_OVERRIDE_REQUEST, &testBalChamberSwFreqOverride }, { MSG_ID_DD_DIAL_DELIVERY_IN_PROGRESS_OVERRIDE_REQUEST, &testDialDeliveryInProgressOverride }, Index: firmware/App/Services/SystemCommDD.c =================================================================== diff -u -re0102a0a08c0d83bcc8e959551079063e2e60d9f -r573a26b2a0273a4983b1de1cbff5bed63e01dce0 --- firmware/App/Services/SystemCommDD.c (.../SystemCommDD.c) (revision e0102a0a08c0d83bcc8e959551079063e2e60d9f) +++ firmware/App/Services/SystemCommDD.c (.../SystemCommDD.c) (revision 573a26b2a0273a4983b1de1cbff5bed63e01dce0) @@ -37,7 +37,7 @@ // ********** private definitions ********** #define TD_COMM_TIMEOUT_IN_MS 2000 ///< TD has not sent any broadcast messages for this much time -#define RO_COMM_TIMEOUT_IN_MS 2000 ///< RO has not sent any broadcast messages for this much time +#define FP_COMM_TIMEOUT_IN_MS 2000 ///< FP has not sent any broadcast messages for this much time #define MAX_COMM_CRC_FAILURES 5 ///< maximum number of CRC errors within window period before alarm #define MAX_COMM_CRC_FAILURE_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< CRC error window @@ -74,8 +74,8 @@ static volatile BOOL ddIsOnlyCANNode = TRUE; ///< flag indicating whether DG is alone on CAN bus. static OVERRIDE_U32_T tdCommunicationStatus = {0, 0, 0, 0}; ///< has TD sent a message since last check static volatile U32 timeOfLastTDCheckIn = 0; ///< last time we received an TD broadcast -static OVERRIDE_U32_T fpCommunicationStatus = {0, 0, 0, 0}; ///< has RO sent a message since last check -static volatile U32 timeOfLastROCheckIn = 0; ///< last time we received an RO broadcast +static OVERRIDE_U32_T fpCommunicationStatus = {0, 0, 0, 0}; ///< has FP sent a message since last check +static volatile U32 timeOfLastFPCheckIn = 0; ///< last time we received an FP broadcast // ********** private function prototypes ********** @@ -119,20 +119,20 @@ /*********************************************************************//** * @brief - * The checkInFromRO function checks in the RO with the DD - indicating that - * the RO is communicating. + * The checkInFromFP function checks in the FP with the DD - indicating that + * the FP is communicating. * @details \b Inputs: none - * @details \b Outputs: fpCommunicationStatus, timeOfLastROCheckIn + * @details \b Outputs: fpCommunicationStatus, timeOfLastFPCheckIn * @return none *************************************************************************/ -void checkInFromRO( void ) +void checkInFromFP( void ) { fpCommunicationStatus.data = TRUE; - timeOfLastROCheckIn = getMSTimerCount(); + timeOfLastFPCheckIn = getMSTimerCount(); -// if ( TRUE == isAlarmActive( ALARM_ID_DD_RO_COMM_TIMEOUT ) ) +// if ( TRUE == isAlarmActive( ALARM_ID_DD_FP_COMM_TIMEOUT ) ) // { -// clearAlarmCondition( ALARM_ID_DD_RO_COMM_TIMEOUT ); +// clearAlarmCondition( ALARM_ID_DD_FP_COMM_TIMEOUT ); // } } @@ -151,11 +151,11 @@ /*********************************************************************//** * @brief - * The isFPCommunicating function determines whether the RO is communicating + * The isFPCommunicating function determines whether the FP is communicating * with the DD. * @details \b Inputs: fpCommunicationStatus * @details \b Outputs: none - * @return TRUE if RO has broadcast since last call, FALSE if not + * @return TRUE if FP has broadcast since last call, FALSE if not *************************************************************************/ BOOL isFPCommunicating( void ) { @@ -208,7 +208,7 @@ /*********************************************************************//** * @brief * The checkForCommTimeouts function checks for sub-system communication timeout errors. - * @details \b Inputs: timeOfLastTDCheckIn, timeOfLastROCheckIn + * @details \b Inputs: timeOfLastTDCheckIn, timeOfLastFPCheckIn * @details \b Outputs: possibly a comm t/o alarm * @return none *************************************************************************/ @@ -221,10 +221,10 @@ //stopHeater( DG_TRIMMER_HEATER ); // If TD off or not connected, ensure trimmer heater is off. } - if ( TRUE == didTimeout( timeOfLastROCheckIn, RO_COMM_TIMEOUT_IN_MS ) ) + if ( TRUE == didTimeout( timeOfLastFPCheckIn, FP_COMM_TIMEOUT_IN_MS ) ) { fpCommunicationStatus.data = FALSE; - //setROOperationMode( 0, 0 ); // If RO off or not connected, consider RO mode is fault. + //setFPOperationMode( 0, 0 ); // If FP off or not connected, consider FP mode is fault. } } @@ -341,15 +341,15 @@ /*********************************************************************//** * @brief - * The testROCommunicationStatusOverride function sets the override - * of the RO communication status. + * The testFPCommunicationStatusOverride function sets the override + * of the FP communication status. * @details \b Inputs: none * @details \b Outputs: fpCommunicationStatus * @param message Override message from Dialin which includes the flag - * value to override for the RO communication status. + * value to override for the FP communication status. * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testROCommunicationStatusOverride( MESSAGE_T *message ) +BOOL testFPCommunicationStatusOverride( MESSAGE_T *message ) { BOOL result = u32Override( message, &fpCommunicationStatus, FALSE, TRUE ); Index: firmware/App/Services/SystemCommDD.h =================================================================== diff -u -r4b09605126f35b80406e95d079f3822c51a3ba25 -r573a26b2a0273a4983b1de1cbff5bed63e01dce0 --- firmware/App/Services/SystemCommDD.h (.../SystemCommDD.h) (revision 4b09605126f35b80406e95d079f3822c51a3ba25) +++ firmware/App/Services/SystemCommDD.h (.../SystemCommDD.h) (revision 573a26b2a0273a4983b1de1cbff5bed63e01dce0) @@ -48,15 +48,15 @@ BOOL isTDCommunicating( void ); BOOL isFPCommunicating( void ); void checkInFromTD( void ); -void checkInFromRO( void ); +void checkInFromFP( void ); BOOL isOnlyCANNode( void ); void setOnlyCANNode( BOOL only ); void clearCANXmitBuffers( void ); void checkForCommTimeouts( void ); void checkTooManyBadMsgCRCs( void ); BOOL testTDCommunicationStatusOverride( MESSAGE_T *message ); -BOOL testROCommunicationStatusOverride( MESSAGE_T *message ); +BOOL testFPCommunicationStatusOverride( MESSAGE_T *message ); /**@}*/