Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r4632ea37f1eabe4ee30524633eb24ccb6997ee98 -rd51921b4d923754ab63db79923d28c09c27af5aa --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 4632ea37f1eabe4ee30524633eb24ccb6997ee98) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision d51921b4d923754ab63db79923d28c09c27af5aa) @@ -107,6 +107,13 @@ BOOL isThisFirstFill; ///< Fill flag to indicate whether it is the first fill or not. } FILL_CONDITION_STATUS_T; +/// Fill acid and bicarb types +typedef struct +{ + DG_ACID_TYPES_T acidType; ///< Acid type. + DG_BICARB_TYPES_T bicarbType; ///< Bicarb type. +} FILL_ACID_BICARB_TYPES_T; + static U32 dataPublishCounter; ///< Used to schedule dialysate fill data publication to CAN bus. static DG_FILL_MODE_STATE_T fillState; ///< Currently active fill state. static U32 dialysateFillStartTime; ///< Current time when starting to fill dialysate. @@ -139,6 +146,8 @@ static U32 pumpSpeedIndex; ///< Index used to access the desired pump speed in roPumpFlushBubblesSpeed table. static BOOL havePauseActuatorsBeenSet; ///< Flag to indicate the actuators have been set to pause for the first time. +static FILL_ACID_BICARB_TYPES_T chemicalsTypes; ///< Chemicals Types (acid and bicarb). + // NOTE: This variable should be initialized here because the init function is called every time and then this variable is set to FALSE even if the settings from the // UI wants the RO only mode. static BOOL hasROOnlyModeBeenEnabled = FALSE; ///< Flag to indicate the RO only mode has been set or not. @@ -479,6 +488,22 @@ /*********************************************************************//** * @brief + * The setAcidAndBicarbType function sets the acid and bicarb types to be + * used in filling. + * @details Inputs: none + * @details Outputs: chemicalsTypes + * @param acid which is the type of acid + * @param bicarb which is the type of bicarb + * @return none + *************************************************************************/ +void setAcidAndBicarbType( U32 acid, U32 bicarb ) +{ + chemicalsTypes.acidType = (DG_ACID_TYPES_T)acid; + chemicalsTypes.bicarbType = (DG_BICARB_TYPES_T)bicarb; +} + +/*********************************************************************//** + * @brief * The handleTestInletWaterState function tests for inlet water quality * and if this is the first fill of a treatment, prime the acid and bicarb * lines before jumping to dialysate production state. @@ -618,11 +643,18 @@ if ( TRUE == didTimeout( concentrateTestStartTime, CONCENTRATE_TEST_TIME_OUT_MS ) ) { + DG_CHEMICALS_FILL_COND_CAL_RECORD_T chemicalsCond; + F32 bicarbCondUSPerCM = 0.0F; BOOL isConductivityInRange = FALSE; + getFillChemicalCondRecord( &chemicalsCond ); + + // In the bicarb test, the acid value is 0, so it is not queried + bicarbCondUSPerCM = chemicalsCond.fillCondValues[ chemicalsTypes.acidType ][ FILL_COND_BICARB_TEST ].bicarbConduSPerCM; + averageBicarbConductivity = totalBicarbConductivity / bicarbConductivitySampleCount; - if ( TRUE == isValueWithinPercentRange( averageBicarbConductivity, BICARB_TEST_CD2_TCD, FIVE_PERCENT_FACTOR ) ) + if ( TRUE == isValueWithinPercentRange( averageBicarbConductivity, bicarbCondUSPerCM, FIVE_PERCENT_FACTOR ) ) { isConductivityInRange = TRUE; } @@ -685,14 +717,19 @@ if ( TRUE == didTimeout( concentrateTestStartTime, CONCENTRATE_TEST_TIME_OUT_MS ) ) { - BOOL haveTestsPassed = FALSE; + DG_CHEMICALS_FILL_COND_CAL_RECORD_T chemicalsCond; + F32 acidCondUSPerCM = 0.0F; + BOOL haveTestsPassed = FALSE; + getFillChemicalCondRecord( &chemicalsCond ); + + acidCondUSPerCM = chemicalsCond.fillCondValues[ chemicalsTypes.acidType ][ FILL_COND_ACID_TEST ].acidConduSPerCM; averageBicarbConductivity = totalBicarbConductivity / bicarbConductivitySampleCount; averageAcidConductivity = totalAcidConductivity / acidConductivitySampleCount; pctDiffInConductivity = fabs( 2.0F * ( averageAcidConductivity - averageBicarbConductivity ) / - ( averageAcidConductivity + averageBicarbConductivity ) ); + ( averageAcidConductivity + averageBicarbConductivity ) ); - if ( ( TRUE == isValueWithinPercentRange( averageAcidConductivity, ACID_TEST_CD2_TCD, FIVE_PERCENT_FACTOR ) ) && + if ( ( TRUE == isValueWithinPercentRange( averageAcidConductivity, acidCondUSPerCM, FIVE_PERCENT_FACTOR ) ) && ( pctDiffInConductivity < FIVE_PERCENT_FACTOR ) ) { haveTestsPassed = TRUE; @@ -855,12 +892,16 @@ // If we've reached our target fill to volume (by weight), we're done filling - go back to generation idle mode // SRSDG 398 if ( TRUE == hasTargetFillVolumeBeenReached( inactiveRsrvr ) ) { + DG_CHEMICALS_FILL_COND_CAL_RECORD_T chemicalsCond; + + getFillChemicalCondRecord( &chemicalsCond ); + F32 filledVolumeML = getReservoirWeight( inactiveRsrvr ) - reservoirBaseWeight; F32 integratedVolumeToLoadCellReadingPercent = fabs( 1.0F - ( filledVolumeML / getIntegratedVolumeML() ) ); F32 avgAcidConductivity = acidConductivityTotal / conductivitySampleCount; F32 avgBicarbConductivity = bicarbConductivityTotal / conductivitySampleCount; - F32 acidNormalConductivity = acid.acidConcentrate[ CAL_DATA_ACID_CONCENTRATE_1 ].acidConductivityUSPerCM; - F32 bicarbNormalConductivity = bicarb.bicarbConcentrate[ CAL_DATA_BICARB_CONCENTRATE_1 ].bicarbConductivityUSPerCM; + F32 acidNormalConductivity = chemicalsCond.fillCondValues[ chemicalsTypes.acidType ][ FILL_COND_NORMAL_OP ].acidConduSPerCM; + F32 bicarbNormalConductivity = chemicalsCond.fillCondValues[ chemicalsTypes.acidType ][ FILL_COND_NORMAL_OP ].bicarbConduSPerCM; SEND_EVENT_WITH_2_F32_DATA( DG_EVENT_AVG_DIALYSATE_FILL_COND_VALUES, avgAcidConductivity, avgBicarbConductivity ) SEND_EVENT_WITH_2_F32_DATA( DG_EVENT_RESERVOIR_FILL_VALUES, reservoirBaseWeight, filledVolumeML )