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 ) Index: firmware/App/Modes/ModeFill.h =================================================================== diff -u -r5652568f680408e60fe5fb84eee926e8804c07d7 -rd51921b4d923754ab63db79923d28c09c27af5aa --- firmware/App/Modes/ModeFill.h (.../ModeFill.h) (revision 5652568f680408e60fe5fb84eee926e8804c07d7) +++ firmware/App/Modes/ModeFill.h (.../ModeFill.h) (revision d51921b4d923754ab63db79923d28c09c27af5aa) @@ -75,6 +75,8 @@ void setROMode( BOOL enableROOnlyMode ); BOOL isROOnlyModeEnabled( void ); +void setAcidAndBicarbType( U32 acid, U32 bicarb ); + BOOL testSetUsedAcidVolumeMLOverride( F32 value ); BOOL testResetUsedAcidVolumeMLOverride( void ); Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rc230be1bd4296324bf5dfc288c212eb7c2ce5d2d -rd51921b4d923754ab63db79923d28c09c27af5aa --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision c230be1bd4296324bf5dfc288c212eb7c2ce5d2d) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision d51921b4d923754ab63db79923d28c09c27af5aa) @@ -407,7 +407,7 @@ *************************************************************************/ BOOL requestDGStart( void ) { - BOOL result = FALSE; + BOOL result = FALSE; if ( DG_STANDBY_MODE_STATE_IDLE == standbyState ) { Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -ra069a798bc85ad39afb0df9b440457c1f18f2ba3 -rd51921b4d923754ab63db79923d28c09c27af5aa --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision a069a798bc85ad39afb0df9b440457c1f18f2ba3) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision d51921b4d923754ab63db79923d28c09c27af5aa) @@ -159,6 +159,8 @@ getNVRecord2Driver( GET_CAL_HEATING_RECORD, (U08*)&heatingConstsCalRecord, sizeof( heatingConstsCalRecord ), NUM_OF_CAL_DATA_RSRVRS, ALARM_ID_DG_HEATING_INVALID_CAL_RECORD ); + + getNVRecord2Driver( GET_CAL_FILL_CONDUCTIVITIES_RECORD, (U08*)&fillCondCalRecord, sizeof( fillCondCalRecord ), 0, ALARM_ID_NO_ALARM ); } // If the mode is fault or it is standby and the RO volume has not been written already, write it @@ -228,6 +230,8 @@ calStatus |= getNVRecord2Driver( GET_CAL_BICARB_CONCENTRATES, (U08*)&bicarbConcentrateCalRecord, sizeof( bicarbConcentrateCalRecord ), NUM_OF_ACID_AND_BICARB_NV_DATA_TO_CHECK, ALARM_ID_DG_BICARB_CONCENTRATE_INVALID_CAL_RECORD ); + calStatus |= getNVRecord2Driver( GET_CAL_FILL_CONDUCTIVITIES_RECORD, (U08*)&fillCondCalRecord, sizeof( fillCondCalRecord ), 0, ALARM_ID_NO_ALARM ); + if ( TRUE == calStatus ) { result = SELF_TEST_STATUS_PASSED; @@ -804,6 +808,20 @@ /*********************************************************************//** * @brief + * The getFillChemicalCondRecord function fills the provided buffer with + * the fill conductivities record. + * @details Inputs: fillCondCalRecord + * @details Outputs: none + * @param fillRecord which is the pointer to the provided buffer + * @return none + *************************************************************************/ +void getFillChemicalCondRecord( DG_CHEMICALS_FILL_COND_CAL_RECORD_T* fillRecord ) +{ + memcpy( fillRecord, &fillCondCalRecord, sizeof( DG_CHEMICALS_FILL_COND_CAL_RECORD_T ) ); +} + +/*********************************************************************//** + * @brief * The hasTargetFillVolumeReached function checks if the target fill volume * for specific reservoir has been reached. * @details Inputs: fillVolumeTargetMl Index: firmware/App/Services/Reservoirs.h =================================================================== diff -u -r2b47dd2e7974618d8899527cdbff80fa93ebc9fa -rd51921b4d923754ab63db79923d28c09c27af5aa --- firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision 2b47dd2e7974618d8899527cdbff80fa93ebc9fa) +++ firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision d51921b4d923754ab63db79923d28c09c27af5aa) @@ -119,6 +119,7 @@ DG_RESERVOIR_VOLUME_RECORD_T getReservoirsCalRecord( void ); void getAcidConcentrateCalRecord( DG_ACID_CONCENTRATES_RECORD_T* acidRecord ); void getBicarbConcentrateCalRecord( DG_BICARB_CONCENTRATES_RECORD_T* bicarbRecord ); +void getFillChemicalCondRecord( DG_CHEMICALS_FILL_COND_CAL_RECORD_T* fillRecord ); BOOL hasTargetFillVolumeBeenReached( DG_RESERVOIR_ID_T reservoirId ); BOOL hasTargetDrainVolumeBeenReached( DG_RESERVOIR_ID_T reservoirId, U32 timeout ); Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r5652568f680408e60fe5fb84eee926e8804c07d7 -rd51921b4d923754ab63db79923d28c09c27af5aa --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 5652568f680408e60fe5fb84eee926e8804c07d7) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision d51921b4d923754ab63db79923d28c09c27af5aa) @@ -1083,18 +1083,20 @@ { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof( BOOL ) ) + if ( message->hdr.payloadLen == sizeof( DG_START_STOP_CMD_T ) ) { - BOOL startingTreatment; + DG_START_STOP_CMD_T startingTreatment; DG_OP_MODE_T dgMode = getCurrentOperationMode(); - memcpy( &startingTreatment, message->payload, sizeof( BOOL ) ); + memcpy( &startingTreatment, message->payload, sizeof( DG_START_STOP_CMD_T ) ); - if ( ( DG_MODE_STAN == dgMode ) && ( TRUE == startingTreatment ) ) + if ( ( DG_MODE_STAN == dgMode ) && ( TRUE == startingTreatment.startDG ) ) { + // If the command is start DG, set the acid and bicarb types to be used, otherwise in the stop command it does not matter + setAcidAndBicarbType( startingTreatment.acidType, startingTreatment.bicarbType ); result = requestDGStart(); } - else if ( ( dgMode >= DG_MODE_GENE ) && ( dgMode <= DG_MODE_DRAI ) && ( FALSE == startingTreatment ) ) + else if ( ( dgMode >= DG_MODE_GENE ) && ( dgMode <= DG_MODE_DRAI ) && ( FALSE == startingTreatment.startDG ) ) { result = requestDGStop(); }