using System; namespace Shared.SimpleControl.Phone { public class ACMethod { public byte SetACTemperatureText (byte [] setBytes, Button btnSetTemperature) { byte temperature = setBytes [11]; btnSetTemperature.Text = temperature.ToString () + "°"; if (setBytes [1] == 1) { btnSetTemperature.Text = btnSetTemperature.Text.Replace ('C', 'F'); } return temperature; } public void UpdataACHostWindIcon (byte windByte, Button btn = null, Button btn2 = null) { switch (windByte) { case 0: if (btn != null) btn.UnSelectedImagePath = "AC/ACAuto.png"; if (btn2 != null) btn2.TextID = R.MyInternationalizationString.Auto; break; case 3: if (btn != null) btn.UnSelectedImagePath = "AC/ACLowWind.png"; if (btn2 != null) btn2.TextID = R.MyInternationalizationString.Low; break; case 2: if (btn != null) btn.UnSelectedImagePath = "AC/ACStroke.png"; if (btn2 != null) btn2.TextID = R.MyInternationalizationString.Stroke; break; case 1: if (btn != null) btn.UnSelectedImagePath = "AC/ACHighWind.png"; if (btn2 != null) btn2.TextID = R.MyInternationalizationString.High; break; } } public void UpdataACHostModeIcon (byte modeByte, Button btn = null, Button btn2 = null) { switch (modeByte) { case 0: if (btn != null) btn.UnSelectedImagePath = "AC/ACRefrigeration.png"; if (btn2 != null) btn2.TextID = R.MyInternationalizationString.Cool; break; case 1: if (btn != null) btn.UnSelectedImagePath = "AC/ACHeating.png"; if (btn2 != null) btn2.TextID = R.MyInternationalizationString.Heating; break; case 2: if (btn != null) btn.UnSelectedImagePath = "AC/ACModeAuto.png"; if (btn2 != null) btn2.TextID = R.MyInternationalizationString.Ventila; break; case 3: if (btn != null) btn.UnSelectedImagePath = "AC/ACAuto.png"; if (btn2 != null) btn2.TextID = R.MyInternationalizationString.Auto; break; case 4: if (btn != null) btn.UnSelectedImagePath = "AC/ACDehumidification.png"; if (btn2 != null) btn2.TextID = R.MyInternationalizationString.Dehumidify; break; } } public void UpdataACModeTemperature (AC ac, byte modeByte, Button btn,bool showTempType = true) { switch (modeByte) { case 0: ac.SetTemperature = ac.CoolTemperature; break; case 1: ac.SetTemperature = ac.HeatTemperature; break; case 2: ac.SetTemperature = ac.CoolTemperature; break; case 3: ac.SetTemperature = ac.AutoTemperature; break; case 4: ac.SetTemperature = ac.ChuShiTemperature; break; } btn.Text = ac.SetTemperature.ToString () + "°"; if (showTempType) { if (ac.TemperatureMode == 0) { btn.Text = ac.SetTemperature.ToString () + "°C"; } else { btn.Text = ac.SetTemperature.ToString () + "°F"; } } } /// /// 控制空调 /// public void ControlAC (AC ac,bool onlyPower = false) { if (ac.Type == DeviceType.ACPanel) { byte modeKey = 4; switch (ac.SetMode) { //cooling case 0: modeKey = 4; break; //Heating case 1: modeKey = 7; break; //Fan case 2: modeKey = 2; break; // Auto case 3: modeKey = 8; break; //Dry case 4: modeKey = 19; break; } if (!onlyPower) { Control.ControlBytesSend (Command.InstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { modeKey, ac.SetTemperature, ac.LoopID }); Control.ControlBytesSend (Command.InstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 6, ac.SetMode, ac.LoopID }); Control.ControlBytesSend (Command.InstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 5, ac.SetFanSpeed, ac.LoopID }); } Control.ControlBytesSend (Command.InstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 3, ac.Power, ac.LoopID }); } else if (ac.Type == DeviceType.ACDevice || ac.Type == DeviceType.HVAC || ac.Type == DeviceType.ACInfrared) { Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new byte [] {ac.LoopID,ac.TemperatureMode,ac.IndoorTemperature,ac.CoolTemperature,ac.HeatTemperature,ac.AutoTemperature, ac.ChuShiTemperature,ac.RealModeAndFanSpeed,ac.Power,ac.SetMode,ac.SetFanSpeed,ac.SetTemperature,ac.ShaoFanMode}); } else if (ac.Type == DeviceType.LongXiAC) { if ((ac as LongXiAC).LongXiDeviceType == 1 || (ac as LongXiAC).LongXiDeviceType == 2) {//新风 Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new byte [] {ac.LoopID,ac.TemperatureMode,ac.IndoorTemperature,ac.CoolTemperature,ac.HeatTemperature,ac.AutoTemperature, ac.ChuShiTemperature,ac.RealModeAndFanSpeed,ac.Power,ac.SetMode,ac.SetFanSpeed,ac.SetTemperature,(ac as LongXiAC).Wave,0xAB,0xCD, (ac as LongXiAC).ElectricHeating,(ac as LongXiAC).Antifreeze,0,0,0,0,0,0}); //var ac = common as LongXiAC; //ac.TemperatureMode = usefullBytes [1]; //ac.IndoorTemperature = usefullBytes [2]; //ac.CoolTemperature = usefullBytes [3]; //ac.HeatTemperature = usefullBytes [4]; //ac.AutoTemperature = usefullBytes [5]; //ac.ChuShiTemperature = usefullBytes [6]; //ac.RealModeAndFanSpeed = usefullBytes [7]; //ac.Power = usefullBytes [8]; //ac.SetMode = usefullBytes [9]; //ac.SetFanSpeed = usefullBytes [10]; //ac.Wave = usefullBytes [12]; //if (usefullBytes.Length == 23) {//首城珑玺定制的新风空调固件是不一样的 // ac.ElectricHeating = usefullBytes [15]; // ac.Antifreeze = usefullBytes [16]; // ac.OutTemp = usefullBytes [17]; // ac.Humidity = usefullBytes [18]; // ac.TVOC = usefullBytes [19 * 256] + usefullBytes [20]; // ac.PM25 = usefullBytes [21 * 256] + usefullBytes [22]; //} } else {//二次过滤if ((ac as LongXiAC).LongXiDeviceType == 3 || (ac as LongXiAC).LongXiDeviceType == 4) Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new byte [] {ac.LoopID,ac.TemperatureMode,ac.IndoorTemperature,ac.CoolTemperature,ac.HeatTemperature,ac.AutoTemperature, ac.ChuShiTemperature,ac.RealModeAndFanSpeed,ac.Power,ac.SetMode,ac.SetFanSpeed,ac.SetTemperature,0}); } } } } }