Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r1747702a2e89998cd3fa1348907eeb623e9c16c8 -r6d3a38303c448c14f9f64781dd39cbf2ac0fceec --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 1747702a2e89998cd3fa1348907eeb623e9c16c8) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 6d3a38303c448c14f9f64781dd39cbf2ac0fceec) @@ -174,10 +174,12 @@ * @param heater: heater ID that its target temperature is set * @param targetTemperature: target temperature of that the heater has to * heat the fluid - * @return none + * @return TRUE if the temperature was set otherwise, FALSE *************************************************************************/ -void setHeaterTargetTemperature( DG_HEATERS_T heater, F32 targetTemperature ) +BOOL setHeaterTargetTemperature( DG_HEATERS_T heater, F32 targetTemperature ) { + BOOL result = FALSE; + if( heater < NUM_OF_DG_HEATERS ) { #ifndef DISABLE_HEATERS_AND_TEMPS @@ -189,14 +191,16 @@ { heatersStatus[ heater ].targetTemp = targetTemperature; heatersStatus[ heater ].hasTargetTempChanged = TRUE; - // TODO alarm if temperature if out of range or just reject? + result = TRUE; } #endif } else { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_HEATERS_INVALID_HEATER_ID_SELECTED, heater ) } + + return result; } /*********************************************************************//** @@ -323,20 +327,21 @@ * @param heaterCmdPtr pointer to heater command data record * @return status *************************************************************************/ -void handleTrimmerHeaterCmd( TRIMMER_HEATER_CMD_T *heaterCmdPtr ) +void handleTrimmerHeaterCmd( TRIMMER_HEATER_CMD_T *heaterCmdPtr ) // TODo remove this function { DG_CMD_RESPONSE_T cmdResponse; - cmdResponse.commandID = DG_CMD_START_TRIMMER_HEATER; cmdResponse.rejected = TRUE; cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; if ( TRUE == heaterCmdPtr->startHeater ) { - if ( ( heaterCmdPtr->targetTemp >= MINIMUM_TARGET_TEMPERATURE ) && ( heaterCmdPtr->targetTemp <= MAXIMUM_TARGET_TEMPERATURE ) ) + F32 tempTrimmerTarget = getTrimmerHeaterTargetTemperature(); + + if ( ( tempTrimmerTarget >= MINIMUM_TARGET_TEMPERATURE ) && ( tempTrimmerTarget <= MAXIMUM_TARGET_TEMPERATURE ) ) { cmdResponse.rejected = FALSE; - heatersStatus[ DG_TRIMMER_HEATER ].targetTemp = heaterCmdPtr->targetTemp; // TODo do we need to remove this since the trimmer heater is set in the reservoirs + heatersStatus[ DG_TRIMMER_HEATER ].targetTemp = tempTrimmerTarget; #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_TRIMMER_HEATER ) != SW_CONFIG_ENABLE_VALUE ) @@ -462,23 +467,23 @@ if ( DG_MODE_FILL == opMode ) { // If the previous average fill flow rate is 0, use the nominal target RO flow from the RO pump - targetFlow = ( getAvgFillFlowRate() - 0.0 > NEARLY_ZERO ? getAvgFillFlowRate() : getTargetROPumpFlowRate() ); + targetFlow = ( getAvgFillFlowRate() - 0.0 > NEARLY_ZERO ? getAvgFillFlowRate() : getTargetROPumpFlowRateLPM() ); dutyCycle = calculatePrimaryHeaterDutyCycle( targetTemperature, inletTemperature, targetFlow, TRUE ); state = HEATER_EXEC_STATE_PRIMARY_CONTROL_TO_TARGET; } else if ( ( DG_MODE_GENE == opMode ) || ( DG_MODE_DRAI == opMode ) ) { targetTemperature += DELTA_TEMPERATURE_TIME_COSNTANT_C; // Use target flow rate during Idle and drain - targetFlow = getTargetROPumpFlowRate(); + targetFlow = getTargetROPumpFlowRateLPM(); dutyCycle = calculatePrimaryHeaterDutyCycle( targetTemperature, inletTemperature, targetFlow, FALSE ); state = HEATER_EXEC_STATE_PRIMARY_CONTROL_TO_TARGET; } else if ( ( DG_MODE_HEAT == opMode ) || ( DG_MODE_CHEM == opMode ) ) { // If the mode is any of the disinfects, especially heat, use the target flow rate instead of the avg. flow // Most of the times the heater should be running at 100% duty cycle since the target temperature is 81 C - targetFlow = getTargetROPumpFlowRate(); + targetFlow = getTargetROPumpFlowRateLPM(); dutyCycle = calculatePrimaryHeaterDutyCycle( targetTemperature, inletTemperature, targetFlow, FALSE ); state = HEATER_EXEC_STATE_CONTROL_TO_DISINFECT_TARGET; } @@ -576,7 +581,7 @@ if ( ( DG_MODE_FILL == opMode ) || ( DG_MODE_GENE == opMode ) || ( DG_MODE_DRAI == opMode ) ) { - currentTemperature = getReservoirActualTemperature(); + currentTemperature = getTrimmerHeaterTargetTemperature(); dutyCycle = calculateTrimmerHeaterDutyCycle( targetTemperature, currentTemperature, targetFlow, TRUE ); state = HEATER_EXEC_STATE_TRIMMER_CONTROL_TO_TARGET; } @@ -586,7 +591,7 @@ // Most of the times the heater should be running at 100% duty cycle since the target temperature is 81 C and // it is far from the inlet temperature. currentTemperature = getTemperatureValue( (U32)TEMPSENSORS_HEAT_DISINFECT ); - targetFlow = getTargetROPumpFlowRate(); + targetFlow = getTargetROPumpFlowRateLPM(); dutyCycle = calculateTrimmerHeaterDutyCycle( targetTemperature, currentTemperature, targetFlow, FALSE ); state = HEATER_EXEC_STATE_CONTROL_TO_DISINFECT_TARGET; } @@ -752,7 +757,7 @@ static BOOL haveHeaterControlConditionsChanged( DG_HEATERS_T heater ) { BOOL status = FALSE; - F32 targetFlow = ( DG_PRIMARY_HEATER == heater ? getTargetROPumpFlowRate() : getTargetDialysateFlowLPM() ); + F32 targetFlow = ( DG_PRIMARY_HEATER == heater ? getTargetROPumpFlowRateLPM() : getTargetDialysateFlowLPM() ); BOOL hasFlowChanged = ( fabs( targetFlow - heatersStatus[ heater ].targetROFlow ) > NEARLY_ZERO ? TRUE : FALSE ); // Check if the target flow has changed or the target temperature has changed.