| | |
| | | |
| | | namespace Shared.SimpleControl.Phone |
| | | { |
| | | /// <summary> |
| | | /// 空调控制界面 |
| | | /// </summary> |
| | | public class UserACPage : FrameLayout |
| | | { |
| | | /// <summary> |
| | | /// 当前视图 |
| | | /// </summary> |
| | | static UserACPage curView; |
| | | FrameLayout acBodyView; |
| | | AC ac; |
| | | Room room; |
| | | ACMethod acM; |
| | | Button btnInterior; |
| | | Button btnACSwitch; |
| | | Button btnSetTemperature; |
| | | Button btnModeIcon; |
| | | Button btnWindIcon; |
| | | Button btnModeText; |
| | | Button btnWindModeText; |
| | | Button btnReduceTemperature; |
| | | Button BtnAddTemperature; |
| | | Button btnACModeRight; |
| | | Button btnACModeLeft; |
| | | Button btnACWindRight; |
| | | Button btnACWindLeft; |
| | | /// <summary> |
| | | /// 空调控制界面 |
| | | /// </summary> |
| | | public class UserACPage : FrameLayout |
| | | { |
| | | /// <summary> |
| | | /// 当前视图 |
| | | /// </summary> |
| | | static UserACPage curView; |
| | | FrameLayout acBodyView; |
| | | AC ac; |
| | | Room room; |
| | | ACMethod acM; |
| | | Button btnInterior; |
| | | Button btnACSwitch; |
| | | Button btnSetTemperature; |
| | | Button btnModeIcon; |
| | | Button btnWindIcon; |
| | | Button btnModeText; |
| | | Button btnWindModeText; |
| | | Button btnReduceTemperature; |
| | | Button BtnAddTemperature; |
| | | Button btnACModeRight; |
| | | Button btnACModeLeft; |
| | | Button btnACWindRight; |
| | | Button btnACWindLeft; |
| | | |
| | | /// <summary> |
| | | /// 构造函数 |
| | | /// </summary> |
| | | /// <param name="room">Room.</param> |
| | | public UserACPage (AC ac, Room room) |
| | | { |
| | | this.ac = ac; |
| | | this.room = room; |
| | | curView = this; |
| | | acM = new ACMethod (); |
| | | /// <summary> |
| | | /// 构造函数 |
| | | /// </summary> |
| | | /// <param name="room">Room.</param> |
| | | public UserACPage (AC ac, Room room) |
| | | { |
| | | this.ac = ac; |
| | | this.room = room; |
| | | curView = this; |
| | | acM = new ACMethod (); |
| | | |
| | | BackgroundColor = SkinStyle.Current.MainColor; |
| | | readStatus (ac); |
| | | } |
| | | readStatus (ac); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新空调 |
| | | /// </summary> |
| | | /// <param name="subnetID">Subnet identifier.</param> |
| | | /// <param name="deviceID">Device identifier.</param> |
| | | /// <param name="acHostBytesForUpdata">Ac host bytes for updata.</param> |
| | | public static void UpdateStatus (AC ac) |
| | | { |
| | | Application.RunOnMainThread (() => { |
| | | if (curView == null) { |
| | | return; |
| | | } |
| | | if (curView.ac != ac) { |
| | | return; |
| | | } |
| | | for (int i = 0; i < curView.acBodyView.ChildrenCount; i++) { |
| | | try { |
| | | if (ac.Power == 1) { |
| | | curView.btnACSwitch.IsSelected = true; |
| | | curView.btnInterior.Text = ac.IndoorTemperature.ToString () + "°C"; |
| | | curView.acM.UpdataACHostModeIcon (ac.SetMode, curView.btnModeIcon, curView.btnModeText); |
| | | curView.acM.UpdataACHostWindIcon (ac.SetFanSpeed, curView.btnWindIcon, curView.btnWindModeText); |
| | | curView.acM.UpdataACModeTemperature (ac, ac.SetMode, curView.btnSetTemperature); |
| | | /// <summary> |
| | | /// 更新空调 |
| | | /// </summary> |
| | | /// <param name="subnetID">Subnet identifier.</param> |
| | | /// <param name="deviceID">Device identifier.</param> |
| | | /// <param name="acHostBytesForUpdata">Ac host bytes for updata.</param> |
| | | public static void UpdateStatus (AC ac) |
| | | { |
| | | Application.RunOnMainThread (() => { |
| | | if (curView == null) { |
| | | return; |
| | | } |
| | | if (curView.ac != ac) { |
| | | return; |
| | | } |
| | | for (int i = 0; i < curView.acBodyView.ChildrenCount; i++) { |
| | | try { |
| | | if (ac.Power == 1) { |
| | | curView.btnACSwitch.IsSelected = true; |
| | | curView.btnInterior.Text = ac.IndoorTemperature.ToString () + "°C"; |
| | | curView.acM.UpdataACHostModeIcon (ac.SetMode, curView.btnModeIcon, curView.btnModeText); |
| | | curView.acM.UpdataACHostWindIcon (ac.SetFanSpeed, curView.btnWindIcon, curView.btnWindModeText); |
| | | curView.acM.UpdataACModeTemperature (ac, ac.SetMode, curView.btnSetTemperature); |
| | | |
| | | //考虑到其他人控制的情况下,得使当前界面更新的数据和别人控制的一样 |
| | | curView.btnReduceTemperature.Enable = true; |
| | | curView.BtnAddTemperature.Enable = true; |
| | | curView.btnACModeLeft.Enable = true; |
| | | curView.btnACModeRight.Enable = true; |
| | | curView.btnACWindRight.Enable = true; |
| | | curView.btnACWindLeft.Enable = true; |
| | | } else { |
| | | curView.btnACSwitch.IsSelected = false; |
| | | curView.btnReduceTemperature.Enable = false; |
| | | curView.BtnAddTemperature.Enable = false; |
| | | curView.btnACModeLeft.Enable = false; |
| | | curView.btnACModeRight.Enable = false; |
| | | curView.btnACWindRight.Enable = false; |
| | | curView.btnACWindLeft.Enable = false; |
| | | } |
| | | } catch(Exception ex ){ |
| | | Console.WriteLine (ex.ToString ()); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | //考虑到其他人控制的情况下,得使当前界面更新的数据和别人控制的一样 |
| | | curView.btnReduceTemperature.Enable = true; |
| | | curView.BtnAddTemperature.Enable = true; |
| | | curView.btnACModeLeft.Enable = true; |
| | | curView.btnACModeRight.Enable = true; |
| | | curView.btnACWindRight.Enable = true; |
| | | curView.btnACWindLeft.Enable = true; |
| | | } else { |
| | | curView.btnACSwitch.IsSelected = false; |
| | | curView.btnReduceTemperature.Enable = false; |
| | | curView.BtnAddTemperature.Enable = false; |
| | | curView.btnACModeLeft.Enable = false; |
| | | curView.btnACModeRight.Enable = false; |
| | | curView.btnACWindRight.Enable = false; |
| | | curView.btnACWindLeft.Enable = false; |
| | | } |
| | | } catch (Exception ex) { |
| | | Utlis.WriteLine (ex.ToString ()); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 显示出当前房间所有的空调 |
| | | /// </summary> |
| | | /// <summary> |
| | | /// 显示出当前房间所有的空调 |
| | | /// </summary> |
| | | public void showRoomAC () |
| | | { |
| | | { |
| | | #region 标题 |
| | | var topView = new FrameLayout () { |
| | | Y = Application.GetRealHeight (36), |
| | | Y = Application.GetRealHeight (36), |
| | | Height = Application.GetRealHeight (90), |
| | | Width = Application.GetRealWidth(640), |
| | | }; |
| | | AddChidren (topView); |
| | | Width = Application.GetRealWidth (640), |
| | | }; |
| | | AddChidren (topView); |
| | | |
| | | var title = new Button () { |
| | | TextAlignment = TextAlignment.Center, |
| | |
| | | (Parent as PageLayout).PageIndex -= 1; |
| | | curView = null; |
| | | }; |
| | | #endregion |
| | | #endregion |
| | | |
| | | acBodyView = new FrameLayout { |
| | | Width = Application.GetRealWidth(640), |
| | | Height = Application.GetRealHeight (1136 - 126), |
| | | Y = Application.GetRealHeight (126) |
| | | acBodyView = new FrameLayout { |
| | | Width = Application.GetRealWidth (640), |
| | | Height = Application.GetRealHeight (1136 - 126), |
| | | Y = Application.GetRealHeight (126) |
| | | }; |
| | | AddChidren (acBodyView); |
| | | #region roomBackgroundImage |
| | | var roomBackgroundImageView = new FrameLayout () { |
| | | Height = Application.GetRealHeight (360), |
| | | Width = Application.GetRealWidth(640), |
| | | }; |
| | | acBodyView.AddChidren (roomBackgroundImageView); |
| | | roomBackgroundImageView.BackgroundImagePath = room.BackGroundImage; |
| | | #region roomBackgroundImage |
| | | var roomBackgroundImageView = new FrameLayout () { |
| | | Height = Application.GetRealHeight (360), |
| | | Width = Application.GetRealWidth (640), |
| | | }; |
| | | acBodyView.AddChidren (roomBackgroundImageView); |
| | | roomBackgroundImageView.BackgroundImagePath = room.BackGroundImage; |
| | | |
| | | if (ac.Type == DeviceType.ACInfrared) { |
| | | Button btnDownIRCode = new Button () { |
| | |
| | | btnDownIRCode.MouseUpEventHandler += (sender, e) => { |
| | | var downIRCodeDialog = new ConfigIRCode (); |
| | | downIRCodeDialog.Show (); |
| | | downIRCodeDialog.ShowSystemInfrared (ac,true); |
| | | downIRCodeDialog.ShowSystemInfrared (ac, true); |
| | | }; |
| | | } |
| | | |
| | | FrameLayout setACTemp = new FrameLayout () { |
| | | Height = Application.GetMinRealAverage (106), |
| | | Width = Application.GetRealWidth(640), |
| | | BackgroundColor = SkinStyle.Current.MainColor, |
| | | Y = Application.GetMinRealAverage (360), |
| | | }; |
| | | Height = Application.GetMinRealAverage (106), |
| | | Width = Application.GetRealWidth (640), |
| | | BackgroundColor = SkinStyle.Current.MainColor, |
| | | Y = Application.GetMinRealAverage (360), |
| | | }; |
| | | acBodyView.AddChidren (setACTemp); |
| | | |
| | | btnACSwitch = new Button () { |
| | | Width = Application.GetMinRealAverage (115), |
| | | Height = Application.GetMinRealAverage (115), |
| | | X = Application.GetRealWidth (640 - 152), |
| | | UnSelectedImagePath = "FH/FH_Switch.png", |
| | | SelectedImagePath = "FH/FH_Switch_on.png", |
| | | }; |
| | | btnACSwitch.IsSelected = ac.Power == 1; |
| | | btnACSwitch.MouseUpEventHandler += (sender, e) => { |
| | | btnACSwitch = new Button () { |
| | | Width = Application.GetMinRealAverage (115), |
| | | Height = Application.GetMinRealAverage (115), |
| | | X = Application.GetRealWidth (640 - 152), |
| | | UnSelectedImagePath = "FH/FH_Switch.png", |
| | | SelectedImagePath = "FH/FH_Switch_on.png", |
| | | }; |
| | | btnACSwitch.IsSelected = ac.Power == 1; |
| | | btnACSwitch.MouseUpEventHandler += (sender, e) => { |
| | | btnACSwitch.IsSelected = !btnACSwitch.IsSelected; |
| | | ac.Power = btnACSwitch.IsSelected ? (byte)1 : (byte)0; |
| | | UpdateStatus (ac); |
| | | if (ac.Type == DeviceType.ACPanel) { |
| | | Control.ControlBytesSend (Command.InstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 3, ac.Power, ac.LoopID }); |
| | | //Control.ControlBytesSend (Command.InstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 3, ac.Power, ac.LoopID }); |
| | | SendControlACPanel (ac, new byte [] { 3, ac.Power, ac.LoopID }); |
| | | } else if (ac.Type == DeviceType.ACDevice || ac.Type == DeviceType.ACInfrared || ac.Type == DeviceType.HVAC) { |
| | | Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { 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 }); |
| | | //Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { 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 }); |
| | | SendControlHVAC (ac); |
| | | } else if (ac.Type == DeviceType.CustomAC) { |
| | | var acCommon = ac as CustomAC; |
| | | var controlCommand = acCommon.customACControlLists.Find ((obj) => obj.UniversalModeType == ac.Power); |
| | |
| | | } |
| | | } |
| | | }; |
| | | setACTemp.AddChidren (btnACSwitch); |
| | | setACTemp.AddChidren (btnACSwitch); |
| | | |
| | | var btnText = new Button () { |
| | | Width = Application.GetRealWidth (150), |
| | | Height = Application.GetRealHeight (40), |
| | | X = Application.GetRealWidth (15), |
| | | Y = Application.GetRealHeight (22), |
| | | TextID = R.MyInternationalizationString.ACInterior, |
| | | TextAlignment = TextAlignment.BottomCenter, |
| | | var btnText = new Button () { |
| | | Width = Application.GetRealWidth (150), |
| | | Height = Application.GetRealHeight (40), |
| | | X = Application.GetRealWidth (15), |
| | | Y = Application.GetRealHeight (22), |
| | | TextID = R.MyInternationalizationString.ACInterior, |
| | | TextAlignment = TextAlignment.BottomCenter, |
| | | TextColor = SkinStyle.Current.TextColor1 |
| | | }; |
| | | setACTemp.AddChidren (btnText); |
| | | }; |
| | | setACTemp.AddChidren (btnText); |
| | | |
| | | btnInterior = new Button () { |
| | | Width = Application.GetRealWidth (150), |
| | | Height = Application.GetRealHeight (40), |
| | | X = Application.GetRealWidth (10), |
| | | Y = btnText.Bottom, |
| | | Text = ac.IndoorTemperature.ToString () + "°C", |
| | | TextSize = 14, |
| | | TextAlignment = TextAlignment.Center, |
| | | btnInterior = new Button () { |
| | | Width = Application.GetRealWidth (150), |
| | | Height = Application.GetRealHeight (40), |
| | | X = Application.GetRealWidth (10), |
| | | Y = btnText.Bottom, |
| | | Text = ac.IndoorTemperature.ToString () + "°C", |
| | | TextSize = 14, |
| | | TextAlignment = TextAlignment.Center, |
| | | TextColor = SkinStyle.Current.TextColor1 |
| | | }; |
| | | setACTemp.AddChidren (btnInterior); |
| | | }; |
| | | setACTemp.AddChidren (btnInterior); |
| | | |
| | | //长按更换背景 |
| | | //长按更换背景 |
| | | roomBackgroundImageView.MouseLongEventHandler += (sender, e) => { |
| | | Camera.SelectPicture ((obj) => { |
| | | if (obj != null) { |
| | | Camera.SelectPicture ((obj) => { |
| | | if (obj != null) { |
| | | room.BackGroundImage = obj; |
| | | roomBackgroundImageView.BackgroundImagePath = obj; |
| | | room.Save (typeof (Room).Name + "_" + room.Name); |
| | | } |
| | | }, room.Name); |
| | | } |
| | | }, room.Name); |
| | | |
| | | }; |
| | | }; |
| | | |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region acTemperature |
| | | #region acTemperature |
| | | FrameLayout acTemperatureView = new FrameLayout () { |
| | | Height = Application.GetRealHeight (550 / 3 - 40), |
| | | Width = Application.GetRealWidth(640), |
| | | BackgroundColor = SkinStyle.Current.ViewColor, |
| | | Height = Application.GetRealHeight (550 / 3 - 40), |
| | | Width = Application.GetRealWidth (640), |
| | | BackgroundColor = SkinStyle.Current.ViewColor, |
| | | Y = setACTemp.Bottom, |
| | | }; |
| | | acBodyView.AddChidren (acTemperatureView); |
| | | }; |
| | | acBodyView.AddChidren (acTemperatureView); |
| | | |
| | | var btnACTemp = new Button () { |
| | | Width = Application.GetRealWidth (200), |
| | | Height = Application.GetRealHeight (30), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight (19), |
| | | TextID = R.MyInternationalizationString.Temperature, |
| | | var btnACTemp = new Button () { |
| | | Width = Application.GetRealWidth (200), |
| | | Height = Application.GetRealHeight (30), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight (19), |
| | | TextID = R.MyInternationalizationString.Temperature, |
| | | TextColor = SkinStyle.Current.ButtonColor, |
| | | }; |
| | | acTemperatureView.AddChidren (btnACTemp); |
| | | }; |
| | | acTemperatureView.AddChidren (btnACTemp); |
| | | |
| | | btnSetTemperature = new Button () { |
| | | Width = Application.GetMinRealAverage (120), |
| | | Y = Application.GetRealHeight(10), |
| | | Y = Application.GetRealHeight (10), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Text = ac.SetTemperature.ToString () + "°C", |
| | | TextSize = 20, |
| | |
| | | Enable = false, |
| | | TextColor = SkinStyle.Current.TextColor1 |
| | | }; |
| | | acTemperatureView.AddChidren (btnSetTemperature); |
| | | acTemperatureView.AddChidren (btnSetTemperature); |
| | | |
| | | btnReduceTemperature = new Button () { |
| | | Width = Application.GetMinRealAverage (129), |
| | | Height = Application.GetMinRealAverage (129), |
| | | X = Application.GetRealWidth (30), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "AC/ac-1.png", |
| | | SelectedImagePath = "AC/ac_on-.png", |
| | | }; |
| | | acTemperatureView.AddChidren (btnReduceTemperature); |
| | | btnReduceTemperature.MouseDownEventHandler += (sender, e) => { |
| | | btnReduceTemperature.IsSelected = true; |
| | | }; |
| | | btnReduceTemperature.MouseUpEventHandler += (sender, e) => { |
| | | btnReduceTemperature.IsSelected = false; |
| | | btnReduceTemperature = new Button () { |
| | | Width = Application.GetMinRealAverage (129), |
| | | Height = Application.GetMinRealAverage (129), |
| | | X = Application.GetRealWidth (30), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "AC/ac-1.png", |
| | | SelectedImagePath = "AC/ac_on-.png", |
| | | }; |
| | | acTemperatureView.AddChidren (btnReduceTemperature); |
| | | btnReduceTemperature.MouseDownEventHandler += (sender, e) => { |
| | | btnReduceTemperature.IsSelected = true; |
| | | }; |
| | | btnReduceTemperature.MouseUpEventHandler += (sender, e) => { |
| | | btnReduceTemperature.IsSelected = false; |
| | | if (ac.SetMode == 2) { |
| | | return; |
| | | } |
| | | if (ac.SetTemperature <= 0) { |
| | | ac.SetTemperature = 16; |
| | | } |
| | | if (--ac.SetTemperature <= 16) { |
| | | ac.SetTemperature = 16; |
| | | } |
| | | if (ac.SetTemperature <= 0) { |
| | | ac.SetTemperature = 16; |
| | | } |
| | | if (--ac.SetTemperature <= 16) { |
| | | ac.SetTemperature = 16; |
| | | } |
| | | byte modeKey = 4; |
| | | switch (ac.SetMode) { |
| | | //cooling |
| | | case 0: |
| | | ac.CoolTemperature = ac.SetTemperature; |
| | | switch (ac.SetMode) { |
| | | //cooling |
| | | case 0: |
| | | ac.CoolTemperature = ac.SetTemperature; |
| | | modeKey = 4; |
| | | break; |
| | | //Heating |
| | | case 1: |
| | | ac.HeatTemperature = ac.SetTemperature; |
| | | break; |
| | | //Heating |
| | | case 1: |
| | | ac.HeatTemperature = ac.SetTemperature; |
| | | modeKey = 7; |
| | | break; |
| | | //Fan |
| | | case 2: |
| | | ac.IndoorTemperature = ac.SetTemperature; |
| | | break; |
| | | //Fan |
| | | case 2: |
| | | ac.IndoorTemperature = ac.SetTemperature; |
| | | modeKey = 2; |
| | | break; |
| | | // Auto |
| | | case 3: |
| | | ac.AutoTemperature = ac.SetTemperature; |
| | | break; |
| | | // Auto |
| | | case 3: |
| | | ac.AutoTemperature = ac.SetTemperature; |
| | | modeKey = 8; |
| | | break; |
| | | //Dry |
| | | case 4: |
| | | ac.ChuShiTemperature = ac.SetTemperature; |
| | | break; |
| | | //Dry |
| | | case 4: |
| | | ac.ChuShiTemperature = ac.SetTemperature; |
| | | modeKey = 19; |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | UpdateStatus (ac); |
| | | if (ac.Type == DeviceType.ACPanel) { |
| | | 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 [] { modeKey, ac.SetTemperature, ac.LoopID }); |
| | | SendControlACPanel (ac, new byte [] { modeKey, ac.SetTemperature, ac.LoopID }); |
| | | } else if (ac.Type == DeviceType.ACDevice || ac.Type == DeviceType.ACInfrared || ac.Type == DeviceType.HVAC) { |
| | | Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, btnACSwitch.IsSelected ? (byte)1 : (byte)0, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode }); |
| | | //Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, btnACSwitch.IsSelected ? (byte)1 : (byte)0, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode }); |
| | | ac.Power = btnACSwitch.IsSelected ? (byte)1 : (byte)0; |
| | | SendControlHVAC (ac); |
| | | } else if (ac.Type == DeviceType.CustomAC) { |
| | | var acCommon = ac as CustomAC; |
| | | var controlCommand = acCommon.customACControlLists.Find ((obj) => obj.UniversalModeType == ac.Power && obj.UniversalFanSpeed == ac.SetFanSpeed && obj.UniversalTemp == ac.SetTemperature); |
| | |
| | | IO.FileUtils.SaveEquipmentMessage (acCommon, acCommon.LoopID.ToString ()); |
| | | } |
| | | } |
| | | }; |
| | | }; |
| | | |
| | | BtnAddTemperature = new Button () { |
| | | Width = Application.GetMinRealAverage (129), |
| | | Height = Application.GetMinRealAverage (129), |
| | | X = Application.GetRealWidth (640 - 129 - 30), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "AC/ac+1.png", |
| | | SelectedImagePath = "AC/ac_on+.png", |
| | | }; |
| | | acTemperatureView.AddChidren (BtnAddTemperature); |
| | | BtnAddTemperature.MouseDownEventHandler += (sender, e) => { |
| | | BtnAddTemperature.IsSelected = true; |
| | | }; |
| | | BtnAddTemperature.MouseUpEventHandler += (sender, e) => { |
| | | BtnAddTemperature.IsSelected = false; |
| | | BtnAddTemperature = new Button () { |
| | | Width = Application.GetMinRealAverage (129), |
| | | Height = Application.GetMinRealAverage (129), |
| | | X = Application.GetRealWidth (640 - 129 - 30), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "AC/ac+1.png", |
| | | SelectedImagePath = "AC/ac_on+.png", |
| | | }; |
| | | acTemperatureView.AddChidren (BtnAddTemperature); |
| | | BtnAddTemperature.MouseDownEventHandler += (sender, e) => { |
| | | BtnAddTemperature.IsSelected = true; |
| | | }; |
| | | BtnAddTemperature.MouseUpEventHandler += (sender, e) => { |
| | | BtnAddTemperature.IsSelected = false; |
| | | if (ac.SetMode == 2) { |
| | | return; |
| | | } |
| | | if (++ac.SetTemperature > 30) { |
| | | ac.SetTemperature = 30; |
| | | } |
| | | if (++ac.SetTemperature > 30) { |
| | | ac.SetTemperature = 30; |
| | | } |
| | | |
| | | byte modeKey = 4; |
| | | switch (ac.SetMode) { |
| | | //cooling |
| | | case 0: |
| | | ac.CoolTemperature = ac.SetTemperature; |
| | | switch (ac.SetMode) { |
| | | //cooling |
| | | case 0: |
| | | ac.CoolTemperature = ac.SetTemperature; |
| | | modeKey = 4; |
| | | break; |
| | | //Heating |
| | | case 1: |
| | | ac.HeatTemperature = ac.SetTemperature; |
| | | break; |
| | | //Heating |
| | | case 1: |
| | | ac.HeatTemperature = ac.SetTemperature; |
| | | modeKey = 7; |
| | | break; |
| | | //Fan |
| | | case 2: |
| | | ac.IndoorTemperature = ac.SetTemperature; |
| | | break; |
| | | // Auto |
| | | case 3: |
| | | ac.AutoTemperature = ac.SetTemperature; |
| | | break; |
| | | //Fan |
| | | case 2: |
| | | ac.IndoorTemperature = ac.SetTemperature; |
| | | break; |
| | | // Auto |
| | | case 3: |
| | | ac.AutoTemperature = ac.SetTemperature; |
| | | modeKey = 8; |
| | | break; |
| | | //Dry |
| | | case 4: |
| | | ac.ChuShiTemperature = ac.SetTemperature; |
| | | break; |
| | | //Dry |
| | | case 4: |
| | | ac.ChuShiTemperature = ac.SetTemperature; |
| | | modeKey = 19; |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | UpdateStatus (ac); |
| | | if (ac.Type == DeviceType.ACPanel) { |
| | | 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 [] { modeKey, ac.SetTemperature, ac.LoopID }); |
| | | SendControlACPanel (ac, new byte [] { modeKey, ac.SetTemperature, ac.LoopID }); |
| | | } else if (ac.Type == DeviceType.ACDevice || ac.Type == DeviceType.ACInfrared || ac.Type == DeviceType.HVAC) { |
| | | Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, btnACSwitch.IsSelected ? (byte)1 : (byte)0, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode }); |
| | | //Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, btnACSwitch.IsSelected ? (byte)1 : (byte)0, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode }); |
| | | ac.Power = btnACSwitch.IsSelected ? (byte)1 : (byte)0; |
| | | SendControlHVAC (ac); |
| | | } else if (ac.Type == DeviceType.CustomAC) { |
| | | var acCommon = ac as CustomAC; |
| | | var controlCommand = acCommon.customACControlLists.Find ((obj) => obj.UniversalModeType == ac.Power && obj.UniversalFanSpeed == ac.SetFanSpeed && obj.UniversalTemp == ac.SetTemperature); |
| | |
| | | IO.FileUtils.SaveEquipmentMessage (acCommon, acCommon.LoopID.ToString ()); |
| | | } |
| | | } |
| | | }; |
| | | }; |
| | | #endregion |
| | | Button btnTNull = new Button () { |
| | | Button btnTNull = new Button () { |
| | | Height = 1, |
| | | BackgroundColor = SkinStyle.Current.MainColor, |
| | | Y = acTemperatureView.Bottom, |
| | | }; |
| | | acBodyView.AddChidren (btnTNull); |
| | | |
| | | #region 模式 |
| | | var acModeView = new FrameLayout () { |
| | | Height = Application.GetRealHeight (550 / 3 + 20), |
| | | Width = Application.GetRealWidth(640), |
| | | #region 模式 |
| | | var acModeView = new FrameLayout () { |
| | | Height = Application.GetRealHeight (550 / 3 + 20), |
| | | Width = Application.GetRealWidth (640), |
| | | BackgroundColor = SkinStyle.Current.ViewColor, |
| | | Y = btnTNull.Bottom, |
| | | }; |
| | | acBodyView.AddChidren (acModeView); |
| | | }; |
| | | acBodyView.AddChidren (acModeView); |
| | | |
| | | btnACModeLeft = new Button () { |
| | | Width = Application.GetMinRealAverage (129), |
| | | Height = Application.GetMinRealAverage (129), |
| | | X = Application.GetRealWidth (30), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "AC/ac_left.png", |
| | | SelectedImagePath = "AC/ACLeftSelected.png", |
| | | }; |
| | | acModeView.AddChidren (btnACModeLeft); |
| | | var btnModeName = new Button () { |
| | | Width = Application.GetRealWidth (200), |
| | | Height = Application.GetRealHeight (30), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight (25), |
| | | TextID = R.MyInternationalizationString.UserACMode, |
| | | TextColor = SkinStyle.Current.ButtonColor, |
| | | }; |
| | | acModeView.AddChidren (btnModeName); |
| | | btnModeIcon = new Button () { |
| | | Width = Application.GetMinRealAverage (110), |
| | | Height = Application.GetMinRealAverage (112), |
| | | Gravity = Gravity.Center, |
| | | Y = btnModeName.Bottom + Application.GetRealHeight (10), |
| | | UnSelectedImagePath = "AC/ACRefrigeration.png", |
| | | }; |
| | | acModeView.AddChidren (btnModeIcon); |
| | | btnACModeLeft = new Button () { |
| | | Width = Application.GetMinRealAverage (129), |
| | | Height = Application.GetMinRealAverage (129), |
| | | X = Application.GetRealWidth (30), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "AC/ac_left.png", |
| | | SelectedImagePath = "AC/ACLeftSelected.png", |
| | | }; |
| | | acModeView.AddChidren (btnACModeLeft); |
| | | var btnModeName = new Button () { |
| | | Width = Application.GetRealWidth (200), |
| | | Height = Application.GetRealHeight (30), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight (25), |
| | | TextID = R.MyInternationalizationString.UserACMode, |
| | | TextColor = SkinStyle.Current.ButtonColor, |
| | | }; |
| | | acModeView.AddChidren (btnModeName); |
| | | btnModeIcon = new Button () { |
| | | Width = Application.GetMinRealAverage (110), |
| | | Height = Application.GetMinRealAverage (112), |
| | | Gravity = Gravity.Center, |
| | | Y = btnModeName.Bottom + Application.GetRealHeight (10), |
| | | UnSelectedImagePath = "AC/ACRefrigeration.png", |
| | | }; |
| | | acModeView.AddChidren (btnModeIcon); |
| | | btnModeText = new Button () { |
| | | Width = Application.GetRealWidth (200), |
| | | Height = Application.GetRealHeight (50), |
| | | TextID = R.MyInternationalizationString.Cool, |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = btnModeIcon.Bottom - Application.GetRealHeight (20), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = btnModeIcon.Bottom - Application.GetRealHeight (20), |
| | | TextColor = SkinStyle.Current.TextColor1 |
| | | }; |
| | | acModeView.AddChidren (btnModeText); |
| | | btnACModeRight = new Button () { |
| | | Width = Application.GetMinRealAverage (129), |
| | | Height = Application.GetMinRealAverage (129), |
| | | X = Application.GetRealWidth (640 - 129 - 30), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "AC/ac_right.png", |
| | | SelectedImagePath = "AC/ACRightSelected.png", |
| | | }; |
| | | acModeView.AddChidren (btnACModeRight); |
| | | }; |
| | | acModeView.AddChidren (btnModeText); |
| | | btnACModeRight = new Button () { |
| | | Width = Application.GetMinRealAverage (129), |
| | | Height = Application.GetMinRealAverage (129), |
| | | X = Application.GetRealWidth (640 - 129 - 30), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "AC/ac_right.png", |
| | | SelectedImagePath = "AC/ACRightSelected.png", |
| | | }; |
| | | acModeView.AddChidren (btnACModeRight); |
| | | |
| | | btnACModeRight.MouseDownEventHandler += (sender, e) => { |
| | | btnACModeRight.IsSelected = true; |
| | | }; |
| | | btnACModeRight.MouseUpEventHandler += (sender, e) => { |
| | | btnACModeRight.IsSelected = false; |
| | | if (++ac.SetMode > 4) { |
| | | ac.SetMode = 0; |
| | | } |
| | | btnACModeRight.MouseDownEventHandler += (sender, e) => { |
| | | btnACModeRight.IsSelected = true; |
| | | }; |
| | | btnACModeRight.MouseUpEventHandler += (sender, e) => { |
| | | btnACModeRight.IsSelected = false; |
| | | if (++ac.SetMode > 4) { |
| | | ac.SetMode = 0; |
| | | } |
| | | UpdateStatus (ac); |
| | | if (ac.Type == DeviceType.ACPanel) { |
| | | 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 [] { 6, ac.SetMode, ac.LoopID }); |
| | | SendControlACPanel (ac, new byte [] { 6, ac.SetMode, ac.LoopID }); |
| | | |
| | | } else if (ac.Type == DeviceType.ACDevice || ac.Type == DeviceType.ACInfrared || ac.Type == DeviceType.HVAC) { |
| | | Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, btnACSwitch.IsSelected ? (byte)1 : (byte)0, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode }); |
| | | //Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, btnACSwitch.IsSelected ? (byte)1 : (byte)0, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode }); |
| | | ac.Power = btnACSwitch.IsSelected ? (byte)1 : (byte)0; |
| | | SendControlHVAC (ac); |
| | | } else if (ac.Type == DeviceType.CustomAC) { |
| | | var acCommon = ac as CustomAC; |
| | | var controlCommand = acCommon.customACControlLists.Find ((obj) => obj.UniversalModeType == ac.Power && obj.UniversalFanSpeed == ac.SetFanSpeed && obj.UniversalTemp == ac.SetTemperature); |
| | |
| | | IO.FileUtils.SaveEquipmentMessage (acCommon, acCommon.LoopID.ToString ()); |
| | | } |
| | | } |
| | | }; |
| | | btnACModeLeft.MouseDownEventHandler += (sender, e) => { |
| | | btnACModeLeft.IsSelected = true; |
| | | }; |
| | | btnACModeLeft.MouseUpEventHandler += (sender, e) => { |
| | | btnACModeLeft.IsSelected = false; |
| | | try { |
| | | if (ac.SetMode == 0 ) |
| | | ac.SetMode = 4; |
| | | else{ |
| | | }; |
| | | btnACModeLeft.MouseDownEventHandler += (sender, e) => { |
| | | btnACModeLeft.IsSelected = true; |
| | | }; |
| | | btnACModeLeft.MouseUpEventHandler += (sender, e) => { |
| | | btnACModeLeft.IsSelected = false; |
| | | try { |
| | | if (ac.SetMode == 0) |
| | | ac.SetMode = 4; |
| | | else { |
| | | ac.SetMode--; |
| | | } |
| | | } catch { |
| | | ac.SetMode = 4; |
| | | } |
| | | UpdateStatus (ac); |
| | | acM.UpdataACHostModeIcon (ac.SetMode, btnModeIcon); |
| | | ac.SetMode = 4; |
| | | } |
| | | UpdateStatus (ac); |
| | | acM.UpdataACHostModeIcon (ac.SetMode, btnModeIcon); |
| | | if (ac.Type == DeviceType.ACPanel) { |
| | | 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 [] { 6, ac.SetMode, ac.LoopID }); |
| | | SendControlACPanel (ac, new byte [] { 6, ac.SetMode, ac.LoopID }); |
| | | |
| | | } else if (ac.Type == DeviceType.ACDevice || ac.Type == DeviceType.ACInfrared || ac.Type == DeviceType.HVAC) { |
| | | Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, btnACSwitch.IsSelected ? (byte)1 : (byte)0, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode }); |
| | | //Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, btnACSwitch.IsSelected ? (byte)1 : (byte)0, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode }); |
| | | ac.Power = btnACSwitch.IsSelected ? (byte)1 : (byte)0; |
| | | SendControlHVAC (ac); |
| | | } else if (ac.Type == DeviceType.CustomAC) { |
| | | var acCommon = ac as CustomAC; |
| | | var controlCommand = acCommon.customACControlLists.Find ((obj) => obj.UniversalModeType == ac.Power && obj.UniversalFanSpeed == ac.SetFanSpeed && obj.UniversalTemp == ac.SetTemperature); |
| | |
| | | IO.FileUtils.SaveEquipmentMessage (acCommon, acCommon.LoopID.ToString ()); |
| | | } |
| | | } |
| | | }; |
| | | #endregion |
| | | }; |
| | | #endregion |
| | | |
| | | var btnLine1 = new Button () { |
| | | var btnLine1 = new Button () { |
| | | Height = 1, |
| | | BackgroundColor = SkinStyle.Current.MainColor, |
| | | Y = acModeView.Bottom, |
| | | }; |
| | | BackgroundColor = SkinStyle.Current.MainColor, |
| | | Y = acModeView.Bottom, |
| | | }; |
| | | acBodyView.AddChidren (btnLine1); |
| | | |
| | | #region 风速 |
| | | var acWindView = new FrameLayout () { |
| | | Height = Application.GetRealHeight (230), |
| | | Width = Application.GetRealWidth(640), |
| | | Y = btnLine1.Bottom, |
| | | #region 风速 |
| | | var acWindView = new FrameLayout () { |
| | | Height = Application.GetRealHeight (230), |
| | | Width = Application.GetRealWidth (640), |
| | | Y = btnLine1.Bottom, |
| | | BackgroundColor = SkinStyle.Current.ViewColor, |
| | | }; |
| | | acBodyView.AddChidren (acWindView); |
| | | }; |
| | | acBodyView.AddChidren (acWindView); |
| | | |
| | | btnACWindLeft = new Button () { |
| | | Width = Application.GetMinRealAverage (129), |
| | | Height = Application.GetMinRealAverage (129), |
| | | X = Application.GetRealWidth (30), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "AC/ac_left.png", |
| | | SelectedImagePath = "AC/ACLeftSelected.png", |
| | | }; |
| | | acWindView.AddChidren (btnACWindLeft); |
| | | var btnWindName = new Button () { |
| | | Width = Application.GetRealWidth (200), |
| | | Height = Application.GetRealHeight (30), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight (21), |
| | | TextID = R.MyInternationalizationString.Speed, |
| | | btnACWindLeft = new Button () { |
| | | Width = Application.GetMinRealAverage (129), |
| | | Height = Application.GetMinRealAverage (129), |
| | | X = Application.GetRealWidth (30), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "AC/ac_left.png", |
| | | SelectedImagePath = "AC/ACLeftSelected.png", |
| | | }; |
| | | acWindView.AddChidren (btnACWindLeft); |
| | | var btnWindName = new Button () { |
| | | Width = Application.GetRealWidth (200), |
| | | Height = Application.GetRealHeight (30), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight (21), |
| | | TextID = R.MyInternationalizationString.Speed, |
| | | TextColor = SkinStyle.Current.ButtonColor, |
| | | }; |
| | | acWindView.AddChidren (btnWindName); |
| | | btnWindIcon = new Button () { |
| | | Width = Application.GetMinRealAverage (110), |
| | | Height = Application.GetMinRealAverage (112), |
| | | X = Application.GetRealWidth (262), |
| | | Y = Application.GetMinRealAverage (44), |
| | | UnSelectedImagePath = "AC/ACAuto.png", |
| | | }; |
| | | acWindView.AddChidren (btnWindIcon); |
| | | btnWindModeText = new Button () { |
| | | Width = Application.GetRealWidth (200), |
| | | Height = Application.GetRealHeight (50), |
| | | TextID = R.MyInternationalizationString.High, |
| | | Gravity = Gravity.CenterHorizontal, |
| | | }; |
| | | acWindView.AddChidren (btnWindName); |
| | | btnWindIcon = new Button () { |
| | | Width = Application.GetMinRealAverage (110), |
| | | Height = Application.GetMinRealAverage (112), |
| | | X = Application.GetRealWidth (262), |
| | | Y = Application.GetMinRealAverage (44), |
| | | UnSelectedImagePath = "AC/ACAuto.png", |
| | | }; |
| | | acWindView.AddChidren (btnWindIcon); |
| | | btnWindModeText = new Button () { |
| | | Width = Application.GetRealWidth (200), |
| | | Height = Application.GetRealHeight (50), |
| | | TextID = R.MyInternationalizationString.High, |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | Y = btnWindIcon.Bottom - Application.GetRealHeight (16), |
| | | }; |
| | | acWindView.AddChidren (btnWindModeText); |
| | | btnACWindRight = new Button () { |
| | | Width = Application.GetMinRealAverage (129), |
| | | Height = Application.GetMinRealAverage (129), |
| | | X = btnACModeRight.X, |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "AC/ac_right.png", |
| | | SelectedImagePath = "AC/ACRightSelected.png", |
| | | }; |
| | | btnACWindLeft.MouseDownEventHandler += (sender, e) => { |
| | | btnACWindLeft.IsSelected = true; |
| | | }; |
| | | btnACWindLeft.MouseUpEventHandler += (sender, e) => { |
| | | btnACWindLeft.IsSelected = false; |
| | | if (++ac.SetFanSpeed > 3) |
| | | ac.SetFanSpeed = 0; |
| | | //acM.UpdataACHostWindIcon (ac.SetFanSpeed, btnWindIcon); |
| | | Y = btnWindIcon.Bottom - Application.GetRealHeight (16), |
| | | }; |
| | | acWindView.AddChidren (btnWindModeText); |
| | | btnACWindRight = new Button () { |
| | | Width = Application.GetMinRealAverage (129), |
| | | Height = Application.GetMinRealAverage (129), |
| | | X = btnACModeRight.X, |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "AC/ac_right.png", |
| | | SelectedImagePath = "AC/ACRightSelected.png", |
| | | }; |
| | | btnACWindLeft.MouseDownEventHandler += (sender, e) => { |
| | | btnACWindLeft.IsSelected = true; |
| | | }; |
| | | btnACWindLeft.MouseUpEventHandler += (sender, e) => { |
| | | btnACWindLeft.IsSelected = false; |
| | | if (++ac.SetFanSpeed > 3) |
| | | ac.SetFanSpeed = 0; |
| | | //acM.UpdataACHostWindIcon (ac.SetFanSpeed, btnWindIcon); |
| | | UpdateStatus (ac); |
| | | if (ac.Type == DeviceType.ACPanel) { |
| | | 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 [] { 5, ac.SetFanSpeed, ac.LoopID }); |
| | | SendControlACPanel (ac, new byte [] { 5, ac.SetFanSpeed, ac.LoopID }); |
| | | |
| | | } else if (ac.Type == DeviceType.ACDevice || ac.Type == DeviceType.ACInfrared || ac.Type == DeviceType.HVAC) { |
| | | Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, btnACSwitch.IsSelected ? (byte)1 : (byte)0, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode }); |
| | | //Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, btnACSwitch.IsSelected ? (byte)1 : (byte)0, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode }); |
| | | ac.Power = btnACSwitch.IsSelected ? (byte)1 : (byte)0; |
| | | SendControlHVAC (ac); |
| | | } else if (ac.Type == DeviceType.CustomAC) { |
| | | var acCommon = ac as CustomAC; |
| | | var controlCommand = acCommon.customACControlLists.Find ((obj) => obj.UniversalModeType == ac.Power && obj.UniversalFanSpeed == ac.SetFanSpeed && obj.UniversalTemp == ac.SetTemperature); |
| | |
| | | } |
| | | } |
| | | |
| | | }; |
| | | acWindView.AddChidren (btnACWindRight); |
| | | btnACWindRight.MouseDownEventHandler += (sender, e) => { |
| | | btnACWindRight.IsSelected = true; |
| | | }; |
| | | btnACWindRight.MouseUpEventHandler += (sender, e) => { |
| | | btnACWindRight.IsSelected = false; |
| | | try { |
| | | ac.SetFanSpeed--; |
| | | if (ac.SetFanSpeed < 0 || ac.SetFanSpeed > 3) |
| | | ac.SetFanSpeed = 3; |
| | | } catch { |
| | | ac.SetFanSpeed = 3; |
| | | } |
| | | }; |
| | | acWindView.AddChidren (btnACWindRight); |
| | | btnACWindRight.MouseDownEventHandler += (sender, e) => { |
| | | btnACWindRight.IsSelected = true; |
| | | }; |
| | | btnACWindRight.MouseUpEventHandler += (sender, e) => { |
| | | btnACWindRight.IsSelected = false; |
| | | try { |
| | | ac.SetFanSpeed--; |
| | | if (ac.SetFanSpeed < 0 || ac.SetFanSpeed > 3) |
| | | ac.SetFanSpeed = 3; |
| | | } catch { |
| | | ac.SetFanSpeed = 3; |
| | | } |
| | | |
| | | UpdateStatus (ac); |
| | | if (ac.Type == DeviceType.ACPanel) { |
| | | 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 [] { 5, ac.SetFanSpeed, ac.LoopID }); |
| | | SendControlACPanel (ac, new byte [] { 5, ac.SetFanSpeed, ac.LoopID }); |
| | | |
| | | } else if (ac.Type == DeviceType.ACDevice || ac.Type == DeviceType.ACInfrared || ac.Type == DeviceType.HVAC) { |
| | | Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, btnACSwitch.IsSelected ? (byte)1 : (byte)0, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode }); |
| | | //Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, btnACSwitch.IsSelected ? (byte)1 : (byte)0, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode }); |
| | | ac.Power = btnACSwitch.IsSelected ? (byte)1 : (byte)0; |
| | | SendControlHVAC (ac); |
| | | } else if (ac.Type == DeviceType.CustomAC) { |
| | | var acCommon = ac as CustomAC; |
| | | var controlCommand = acCommon.customACControlLists.Find ((obj) => obj.UniversalModeType == ac.Power && obj.UniversalFanSpeed == ac.SetFanSpeed && obj.UniversalTemp == ac.SetTemperature); |
| | |
| | | IO.FileUtils.SaveEquipmentMessage (acCommon, acCommon.LoopID.ToString ()); |
| | | } |
| | | } |
| | | }; |
| | | }; |
| | | |
| | | #endregion |
| | | #endregion |
| | | |
| | | UpdateStatus (ac); |
| | | } |
| | | UpdateStatus (ac); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 读取设备状态 |
| | | /// </summary> |
| | | static void readStatus (AC ac) |
| | | { |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | /// <summary> |
| | | /// 读取设备状态 |
| | | /// </summary> |
| | | static void readStatus (AC ac) |
| | | { |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | if (ac.LastUpdateTime.AddMinutes (Common.Time) <= DateTime.Now) { |
| | | if (ac.Type == DeviceType.ACPanel) { |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 3, ac.LoopID , ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 4, ac.LoopID , ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 5, ac.LoopID , ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 6, ac.LoopID , ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 7, ac.LoopID , ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 8, ac.LoopID , ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 19, ac.LoopID, ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 3, ac.LoopID, ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 4, ac.LoopID, ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 5, ac.LoopID, ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 6, ac.LoopID, ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 7, ac.LoopID, ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 8, ac.LoopID, ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 19, ac.LoopID, ac.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadPanleTemp, ac.SubnetID, ac.DeviceID, new byte [] { ac.LoopID }, SendCount.Zero); |
| | | } else if (ac.Type == DeviceType.HVAC || ac.Type == DeviceType.ACInfrared) { |
| | | Control.ControlBytesSendHasReturn (Command.ReadACMode, ac.SubnetID, ac.DeviceID, new byte [] { ac.LoopID }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 空调控制,带返回结果 |
| | | /// </summary> |
| | | /// <param name="mAcData"></param> |
| | | void SendControlACPanel (AC mAcData, byte[] sendBytes) |
| | | { |
| | | MainPage.Loading.Start ("Sending..."); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | byte [] returnBytes = Control.ControlBytesSendHasReturn (Command.InstructionPanelKey, mAcData.SubnetID, mAcData.DeviceID, sendBytes); |
| | | |
| | | Application.RunOnMainThread (() => { |
| | | if (returnBytes == null) { |
| | | new Alert ("", mAcData.Name + ErrorCode.ControlFailure, "Close").Show (); |
| | | } |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 空调控制,带返回结果 |
| | | /// </summary> |
| | | /// <param name="mAcData"></param> |
| | | void SendControlHVAC (AC mAcData) |
| | | { |
| | | |
| | | MainPage.Loading.Start ("Sending..."); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | byte [] returnBytes = Control.ControlBytesSendHasReturn (Command.SetACMode, mAcData.SubnetID, mAcData.DeviceID, new [] { mAcData.LoopID, mAcData.TemperatureMode, mAcData.IndoorTemperature, mAcData.CoolTemperature, mAcData.HeatTemperature, mAcData.AutoTemperature, mAcData.ChuShiTemperature, mAcData.RealModeAndFanSpeed, mAcData.Power, mAcData.SetMode, mAcData.SetFanSpeed, mAcData.SetTemperature, mAcData.ShaoFanMode }); |
| | | |
| | | Application.RunOnMainThread (() => { |
| | | if (returnBytes == null) { |
| | | new Alert ("", mAcData.Name + ErrorCode.ControlFailure, "Close").Show (); |
| | | } |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |