コード例 #1
0
        public static string ToOperationState(this clsThermostat thermostat)
        {
            string status = thermostat.HorC_StatusText();

            if (status.Contains("COOLING"))
            {
                return("cool");
            }
            else if (status.Contains("HEATING"))
            {
                return("heat");
            }
            else
            {
                return("idle");
            }
        }
コード例 #2
0
        public static ThermostatContract ToContract(this clsThermostat unit)
        {
            ThermostatContract ret = new ThermostatContract();

            ret.id   = (ushort)unit.Number;
            ret.name = unit.Name;

            ushort temp, heat, cool, humidity;

            ushort.TryParse(unit.TempText(), out temp);
            ushort.TryParse(unit.HeatSetpointText(), out heat);
            ushort.TryParse(unit.CoolSetpointText(), out cool);
            ushort.TryParse(unit.HumidityText(), out humidity);

            ret.temp         = temp;
            ret.humidity     = humidity;
            ret.heatsetpoint = heat;
            ret.coolsetpoint = cool;
            ret.mode         = unit.Mode;
            ret.fanmode      = unit.FanMode;
            ret.hold         = unit.HoldStatus;

            string status = unit.HorC_StatusText();

            if (status.Contains("COOLING"))
            {
                ret.status = "COOLING";
            }
            else if (status.Contains("HEATING"))
            {
                ret.status = "HEATING";
            }
            else
            {
                ret.status = "OFF";
            }

            return(ret);
        }