Index: trunk/Arduino/libraries/OT_Slave/OT_Slave.cpp
===================================================================
--- trunk/Arduino/libraries/OT_Slave/OT_Slave.cpp	(revision 18)
+++ trunk/Arduino/libraries/OT_Slave/OT_Slave.cpp	(revision 31)
@@ -26,9 +26,8 @@
   cbAction(0),
   chEnable(false),
-  chActive(false),
   chTemperature(0),
   dhwEnable(false),
-  dhwActive(false),
   dhwTemperature(0),
+  tRequest(0),
   tBoiler(28.0),
   tReturn(28.0)
@@ -128,86 +127,91 @@
 }
 
-void  OT_Slave::ConfigReq (OT_Action& action)
-{
-  action.response.type = OT_MSGTYPE_READ_ACK;
-  action.response.valueHB = 0; // 0x11;  //  slave configuration:
-  action.response.valueLB = 0;  //  Slave MemberID code
-}
-
-void  OT_Slave::StatusReq (OT_Action& action)
-{
-  action.response.type = OT_MSGTYPE_READ_ACK;
-  CH_Enable(action.request.valueHB & 0x01);
-  DHW_Enable(action.request.valueHB & 0x02);
-  action.response.valueLB = 0;  //  Slave status
-  if (chActive) {
-    action.response.valueLB |= 0x02;
-  } else {
-    action.response.valueLB &= ~0x02;
-  }
-  if (dhwActive) {
-    action.response.valueLB |= 0x04;
-  } else {
-    action.response.valueLB &= ~0x04;
-  }
-}
-
-void  OT_Slave::FaultReq (OT_Action& action)
-{
-  action.response.type = OT_MSGTYPE_READ_ACK;
-  action.response.valueHB = 0;  //  Application-specific fault flags
-  action.response.valueLB = 0;  //  OEM fault code 
-}
-
-bool  OT_Slave::CH_Enable (bool enable)
-{
-  chEnable = enable;
-  chActive = enable;
-  return chEnable;
-}
-
-bool  OT_Slave::CH_Disable ()
-{
-  chEnable = false;
-  chActive = false;
-  return chEnable;
-}
-
-void  OT_Slave::CH_Temperature (float temp)
-{
-  chTemperature = temp;
-}
-
-bool  OT_Slave::DHW_Enable (bool enable)
-{
-  dhwEnable = enable;
-  dhwActive = enable;
-  return dhwEnable;
-}
-
-bool  OT_Slave::DHW_Disable ()
-{
-  dhwEnable = false;
-  dhwActive = false;
-  return dhwEnable;
-}
-
-void  OT_Slave::DHW_Temperature (float temp)
-{
-  dhwTemperature = temp;
+void	OT_Slave::ConfigReq (OT_Action& action)
+{
+	action.response.type = OT_MSGTYPE_READ_ACK;
+	action.response.valueHB = 0; 			// 0x11;  //  slave configuration:
+	action.response.valueLB = 0;  			//  Slave MemberID code
+}
+
+void	OT_Slave::StatusReq (OT_Action& action)
+{
+	action.response.type = OT_MSGTYPE_READ_ACK;
+  	CH_Enable(action.request.valueHB & 0x01);
+  	DHW_Enable(action.request.valueHB & 0x02);
+  	action.response.valueLB = 0;			//  Slave status
+	if (chEnable & IsActive()) {
+		action.response.valueLB |= 0x02;
+	} else {
+		action.response.valueLB &= ~0x02;
+	}
+	if (dhwEnable & IsActive()) {
+		action.response.valueLB |= 0x04;
+	} else {
+		action.response.valueLB &= ~0x04;
+	}
+}
+
+void	OT_Slave::FaultReq (OT_Action& action)
+{
+	action.response.type = OT_MSGTYPE_READ_ACK;
+	action.response.valueHB = 0;			//  Application-specific fault flags
+	action.response.valueLB = 0;			//  OEM fault code 
+}
+
+bool	OT_Slave::CH_Enable (bool enable)
+{
+	chEnable = enable;
+	return chEnable;
+}
+
+bool	OT_Slave::CH_Disable ()
+{
+	return CH_Enable(false);
+}
+
+void	OT_Slave::CH_Temperature (float temp)
+{
+	chTemperature = temp;
+	SetRequestTemperature(IsEnabled() ? max(chTemperature, dhwTemperature) : min(chTemperature, dhwTemperature));
+}
+
+bool	OT_Slave::DHW_Enable (bool enable)
+{
+	dhwEnable = enable;
+	return dhwEnable;
+}
+
+bool	OT_Slave::DHW_Disable ()
+{
+	return DHW_Enable(false);
+}
+
+void	OT_Slave::DHW_Temperature (float temp)
+{
+	dhwTemperature = temp;
+	SetRequestTemperature(IsEnabled() ? max(chTemperature, dhwTemperature) : min(chTemperature, dhwTemperature));
+}
+
+bool	OT_Slave::IsEnabled ()
+{
+	return (chEnable || dhwEnable);
 }
 
 bool	OT_Slave::IsActive ()
 {
-	return (chActive || dhwActive);
+	return (chEnable || dhwEnable);
+}
+
+void	OT_Slave::SetRequestTemperature (float t)
+{
+	tRequest = t;
 }
 
 float   OT_Slave::GetBoilerTemperature ()
 {
-	if (IsActive()) {
+	if (IsEnabled()) {
 		// increase
-		float tTarget = (chTemperature > dhwTemperature) ? chTemperature : dhwTemperature;
-		if (tBoiler < tTarget) {
-			tBoiler = (tBoiler + 2.0 * tTarget) / 3.0;
+		if (tBoiler < tRequest) {
+			tBoiler = (tBoiler + 2.0 * tRequest) / 3.0;
 		}
 	} else {
@@ -229,12 +233,12 @@
 }
 
-void  OT_Slave::ListenAfterResponse () 
-{
-  if (Serial) {
-    Serial.print("<- ");
-    OPENTHERM::printToSerial(action.response);
-    Serial.println();
-    Serial.println();
-  }
-  OPENTHERM::listen(THERMOSTAT_IN, -1);
-}
+void	OT_Slave::ListenAfterResponse () 
+{
+	if (Serial) {
+		Serial.print("<- ");
+		OPENTHERM::printToSerial(action.response);
+		Serial.println();
+		Serial.println();
+	}
+	OPENTHERM::listen(THERMOSTAT_IN, -1);
+}
Index: trunk/Arduino/libraries/OT_Slave/OT_Slave.h
===================================================================
--- trunk/Arduino/libraries/OT_Slave/OT_Slave.h	(revision 18)
+++ trunk/Arduino/libraries/OT_Slave/OT_Slave.h	(revision 31)
@@ -23,13 +23,13 @@
   static OT_Action     action;
   OT_Action_CB  cbAction;
+
   bool          chEnable;   // ch : Central Heating
-  bool          chActive;
   float         chTemperature;
   bool          dhwEnable;  // dhw  : Domain Hot Water
-  bool          dhwActive;
   float         dhwTemperature;
 
-  float		tBoiler;	// max(ch,dhw,return)
-  float		tReturn;	// Troom (28.0)
+  float		tRequest;
+  float		tBoiler;	
+  float		tReturn;
 
 public:
@@ -51,6 +51,8 @@
   virtual void  DHW_Temperature (float);
 
+  virtual bool	IsEnabled ();
   virtual bool	IsActive ();
 
+  virtual void  SetRequestTemperature (float);
   virtual float GetBoilerTemperature ();
   virtual float GetReturnTemperature ();
