Exemple #1
0
        /// <summary>
        /// Commands the pool/spa device to return the thermostat mode (Pool or Spa).
        /// </summary>
        /// <returns>True if the device responds with an ACK</returns>
        public bool TryGetThermostatMode(out PoolAndSpaThermostatMode thermostatMode)
        {
            bool result = false;
            byte retrievedThermostatMode = 0;

            base.Plm.exceptionHandler(() =>
            {
                byte[] responseAck = base.Plm.sendStandardLengthMessageAndWait4Response(
                    base.DeviceId, Constants.MSG_FLAGS_DIRECT, 0x54, 0x02);
                byte flags = DeviceMessage.MessageFlags(responseAck);
                result     = (flags & Constants.MSG_FLAGS_DIRECT_ACK) > 0;
                retrievedThermostatMode = DeviceMessage.Command2(responseAck);
            });
            switch (retrievedThermostatMode)
            {
            case 1:
                thermostatMode = PoolAndSpaThermostatMode.Spa;
                break;

            default:
                thermostatMode = PoolAndSpaThermostatMode.Pool;
                break;
            }
            return(result);
        }
 /// <summary>
 /// Commands the pool/spa device to return the thermostat mode (Pool or Spa).
 /// </summary>
 /// <returns>True if the device responds with an ACK</returns>
 public bool TryGetThermostatMode(out PoolAndSpaThermostatMode thermostatMode)
 {
     bool result = false;
     byte retrievedThermostatMode = 0;
     base.Plm.exceptionHandler(() =>
     {
         byte[] responseAck = base.Plm.sendStandardLengthMessageAndWait4Response(
                 base.DeviceId, Constants.MSG_FLAGS_DIRECT, 0x54, 0x02);
         byte flags = DeviceMessage.MessageFlags(responseAck);
         result = (flags & Constants.MSG_FLAGS_DIRECT_ACK) > 0;
         retrievedThermostatMode = DeviceMessage.Command2(responseAck);
     });
     switch(retrievedThermostatMode)
     {
         case 1:
             thermostatMode = PoolAndSpaThermostatMode.Spa;
             break;
         default:
             thermostatMode = PoolAndSpaThermostatMode.Pool;
             break;
     }
     return result;
 }