Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r22176ce95e49213c48454f34ddf5d29b8109f2cb -r669f36cf32c3b500aa2fd5b08c58ee5e6b2e7f08 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 22176ce95e49213c48454f34ddf5d29b8109f2cb) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 669f36cf32c3b500aa2fd5b08c58ee5e6b2e7f08) @@ -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 ) { // Assume the target temperature has not changed @@ -188,13 +190,15 @@ { heatersStatus[ heater ].targetTemp = targetTemperature; heatersStatus[ heater ].hasTargetTempChanged = TRUE; - // TODO alarm if temperature if out of range or just reject? + result = TRUE; } } else { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_HEATERS_INVALID_HEATER_ID_SELECTED, heater ) } + + return result; } /*********************************************************************//** @@ -318,20 +322,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 ) @@ -457,23 +462,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; } @@ -571,7 +576,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; } @@ -581,7 +586,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; } @@ -747,7 +752,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.