Ignore:
Timestamp:
Oct 17, 2019, 8:55:57 AM (7 years ago)
Author:
markus
Message:

Prototype OT and VC40 Adapter

Location:
trunk/Arduino/libraries/OT_Slave
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Arduino/libraries/OT_Slave/OT_Slave.cpp

    r18 r31  
    2626  cbAction(0),
    2727  chEnable(false),
    28   chActive(false),
    2928  chTemperature(0),
    3029  dhwEnable(false),
    31   dhwActive(false),
    3230  dhwTemperature(0),
     31  tRequest(0),
    3332  tBoiler(28.0),
    3433  tReturn(28.0)
    … …  
    128127}
    129128
    130 void  OT_Slave::ConfigReq (OT_Action& action)
    131 {
    132   action.response.type = OT_MSGTYPE_READ_ACK;
    133   action.response.valueHB = 0; // 0x11;  //  slave configuration:
    134   action.response.valueLB = 0;  //  Slave MemberID code
    135 }
    136 
    137 void  OT_Slave::StatusReq (OT_Action& action)
    138 {
    139   action.response.type = OT_MSGTYPE_READ_ACK;
    140   CH_Enable(action.request.valueHB & 0x01);
    141   DHW_Enable(action.request.valueHB & 0x02);
    142   action.response.valueLB = 0;  //  Slave status
    143   if (chActive) {
    144     action.response.valueLB |= 0x02;
    145   } else {
    146     action.response.valueLB &= ~0x02;
    147   }
    148   if (dhwActive) {
    149     action.response.valueLB |= 0x04;
    150   } else {
    151     action.response.valueLB &= ~0x04;
    152   }
    153 }
    154 
    155 void  OT_Slave::FaultReq (OT_Action& action)
    156 {
    157   action.response.type = OT_MSGTYPE_READ_ACK;
    158   action.response.valueHB = 0;  //  Application-specific fault flags
    159   action.response.valueLB = 0;  //  OEM fault code
    160 }
    161 
    162 bool  OT_Slave::CH_Enable (bool enable)
    163 {
    164   chEnable = enable;
    165   chActive = enable;
    166   return chEnable;
    167 }
    168 
    169 bool  OT_Slave::CH_Disable ()
    170 {
    171   chEnable = false;
    172   chActive = false;
    173   return chEnable;
    174 }
    175 
    176 void  OT_Slave::CH_Temperature (float temp)
    177 {
    178   chTemperature = temp;
    179 }
    180 
    181 bool  OT_Slave::DHW_Enable (bool enable)
    182 {
    183   dhwEnable = enable;
    184   dhwActive = enable;
    185   return dhwEnable;
    186 }
    187 
    188 bool  OT_Slave::DHW_Disable ()
    189 {
    190   dhwEnable = false;
    191   dhwActive = false;
    192   return dhwEnable;
    193 }
    194 
    195 void  OT_Slave::DHW_Temperature (float temp)
    196 {
    197   dhwTemperature = temp;
     129void    OT_Slave::ConfigReq (OT_Action& action)
     130{
     131        action.response.type = OT_MSGTYPE_READ_ACK;
     132        action.response.valueHB = 0;                    // 0x11;  //  slave configuration:
     133        action.response.valueLB = 0;                    //  Slave MemberID code
     134}
     135
     136void    OT_Slave::StatusReq (OT_Action& action)
     137{
     138        action.response.type = OT_MSGTYPE_READ_ACK;
     139        CH_Enable(action.request.valueHB & 0x01);
     140        DHW_Enable(action.request.valueHB & 0x02);
     141        action.response.valueLB = 0;                    //  Slave status
     142        if (chEnable & IsActive()) {
     143                action.response.valueLB |= 0x02;
     144        } else {
     145                action.response.valueLB &= ~0x02;
     146        }
     147        if (dhwEnable & IsActive()) {
     148                action.response.valueLB |= 0x04;
     149        } else {
     150                action.response.valueLB &= ~0x04;
     151        }
     152}
     153
     154void    OT_Slave::FaultReq (OT_Action& action)
     155{
     156        action.response.type = OT_MSGTYPE_READ_ACK;
     157        action.response.valueHB = 0;                    //  Application-specific fault flags
     158        action.response.valueLB = 0;                    //  OEM fault code
     159}
     160
     161bool    OT_Slave::CH_Enable (bool enable)
     162{
     163        chEnable = enable;
     164        return chEnable;
     165}
     166
     167bool    OT_Slave::CH_Disable ()
     168{
     169        return CH_Enable(false);
     170}
     171
     172void    OT_Slave::CH_Temperature (float temp)
     173{
     174        chTemperature = temp;
     175        SetRequestTemperature(IsEnabled() ? max(chTemperature, dhwTemperature) : min(chTemperature, dhwTemperature));
     176}
     177
     178bool    OT_Slave::DHW_Enable (bool enable)
     179{
     180        dhwEnable = enable;
     181        return dhwEnable;
     182}
     183
     184bool    OT_Slave::DHW_Disable ()
     185{
     186        return DHW_Enable(false);
     187}
     188
     189void    OT_Slave::DHW_Temperature (float temp)
     190{
     191        dhwTemperature = temp;
     192        SetRequestTemperature(IsEnabled() ? max(chTemperature, dhwTemperature) : min(chTemperature, dhwTemperature));
     193}
     194
     195bool    OT_Slave::IsEnabled ()
     196{
     197        return (chEnable || dhwEnable);
    198198}
    199199
    200200bool    OT_Slave::IsActive ()
    201201{
    202         return (chActive || dhwActive);
     202        return (chEnable || dhwEnable);
     203}
     204
     205void    OT_Slave::SetRequestTemperature (float t)
     206{
     207        tRequest = t;
    203208}
    204209
    205210float   OT_Slave::GetBoilerTemperature ()
    206211{
    207         if (IsActive()) {
     212        if (IsEnabled()) {
    208213                // increase
    209                 float tTarget = (chTemperature > dhwTemperature) ? chTemperature : dhwTemperature;
    210                 if (tBoiler < tTarget) {
    211                         tBoiler = (tBoiler + 2.0 * tTarget) / 3.0;
     214                if (tBoiler < tRequest) {
     215                        tBoiler = (tBoiler + 2.0 * tRequest) / 3.0;
    212216                }
    213217        } else {
    … …  
    229233}
    230234
    231 void  OT_Slave::ListenAfterResponse ()
    232 {
    233   if (Serial) {
    234     Serial.print("<- ");
    235     OPENTHERM::printToSerial(action.response);
    236     Serial.println();
    237     Serial.println();
    238   }
    239   OPENTHERM::listen(THERMOSTAT_IN, -1);
    240 }
     235void    OT_Slave::ListenAfterResponse ()
     236{
     237        if (Serial) {
     238                Serial.print("<- ");
     239                OPENTHERM::printToSerial(action.response);
     240                Serial.println();
     241                Serial.println();
     242        }
     243        OPENTHERM::listen(THERMOSTAT_IN, -1);
     244}
  • trunk/Arduino/libraries/OT_Slave/OT_Slave.h

    r17 r31  
    2323  static OT_Action     action;
    2424  OT_Action_CB  cbAction;
     25
    2526  bool          chEnable;   // ch : Central Heating
    26   bool          chActive;
    2727  float         chTemperature;
    2828  bool          dhwEnable;  // dhw  : Domain Hot Water
    29   bool          dhwActive;
    3029  float         dhwTemperature;
    3130
    32   float         tBoiler;        // max(ch,dhw,return)
    33   float         tReturn;        // Troom (28.0)
     31  float         tRequest;
     32  float         tBoiler;       
     33  float         tReturn;
    3434
    3535public:
    … …  
    5151  virtual void  DHW_Temperature (float);
    5252
     53  virtual bool  IsEnabled ();
    5354  virtual bool  IsActive ();
    5455
     56  virtual void  SetRequestTemperature (float);
    5557  virtual float GetBoilerTemperature ();
    5658  virtual float GetReturnTemperature ();
Note: See TracChangeset for help on using the changeset viewer.