| | |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.SwitchRegionSuccessfully), |
| | | Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | this.InitRoomView (roomFilePath); |
| | | EquipmentPublicClass.CheckLinkRemote (2); |
| | | EquipmentPublicClass.CheckLinkRemote (UserConfig.Instance.internetStatus); |
| | | }); |
| | | } catch (Exception ex) { |
| | | Application.RunOnMainThread (() => { |
| | |
| | | }; |
| | | acRowView.AddChidren (tempSiwtch); |
| | | tempSiwtch.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSiwtch.IsSelected = !tempSiwtch.IsSelected; |
| | | ac.Power = tempSiwtch.IsSelected ? (byte)1 : (byte)0; |
| | | if (ac.Type == DeviceType.ACPanel) { |
| | | 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 [] { 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 }); |
| | | } |
| | | //tempSiwtch.IsSelected = !tempSiwtch.IsSelected; |
| | | //ac.Power = tempSiwtch.IsSelected ? (byte)1 : (byte)0; |
| | | |
| | | SendControlAc (ac, tempSiwtch.IsSelected ? (byte)0 : (byte)1); |
| | | //if (ac.Type == DeviceType.ACPanel) { |
| | | // //2020-02-10 待修改 |
| | | // 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) { |
| | | // //2020-02-10 待修改 |
| | | // 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 }); |
| | | //} |
| | | }; |
| | | |
| | | if (0 < ac.Power) { |
| | |
| | | fh.Status = tempSiwtch.IsSelected ? (byte)1 : (byte)0; |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | if (fh.Type == DeviceType.FoolHeatPanel) { |
| | | //2020-02-10 待修改 |
| | | Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 20, fh.Status, fh.LoopID }); |
| | | } else if (fh.Type == DeviceType.FoolHeat) { |
| | | //2020-02-10 待修改 |
| | | fh = fh.Serverx_FH_CMD (FoolHeat.CommandType.Switch); |
| | | } |
| | | }); |
| | |
| | | }; |
| | | tempSwitch.IsSelected = fanModule.Switch == 0 ? false : true; |
| | | tempSwitch.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | if (tempSwitch.IsSelected) { |
| | | fanModule.Switch = fanModule.WindSpeed; |
| | | } else { |
| | | fanModule.Switch = 0; |
| | | } |
| | | Control.ControlBytesSend (Command.SetSingleLight, fanModule.SubnetID, fanModule.DeviceID, new byte [] { fanModule.LoopID, fanModule.Switch }); |
| | | IO.FileUtils.SaveEquipmentMessage (fanModule, fanModule.LoopID.ToString ()); |
| | | //tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | //if (tempSwitch.IsSelected) { |
| | | // fanModule.Switch = fanModule.WindSpeed; |
| | | //} else { |
| | | // fanModule.Switch = 0; |
| | | //} |
| | | //Control.ControlBytesSend (Command.SetSingleLight, fanModule.SubnetID, fanModule.DeviceID, new byte [] { fanModule.LoopID, fanModule.Switch }); |
| | | |
| | | int mSetSwitch = tempSwitch.IsSelected ? 0 : fanModule.WindSpeed; |
| | | SendControl.SendControlSetSingleLight (fanModule, new byte [] { fanModule.LoopID, (byte)mSetSwitch }); |
| | | //IO.FileUtils.SaveEquipmentMessage (fanModule, fanModule.LoopID.ToString ()); |
| | | }; |
| | | #endregion |
| | | } else if (devcieCommon.Type == DeviceType.LightDimming || devcieCommon.Type == DeviceType.LightDALI) { |
| | |
| | | }; |
| | | |
| | | tempSwitch.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | if (tempSwitch.IsSelected) { |
| | | Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, dimming.LastOpenBrightness, 0, 0 }); |
| | | tempLightSeekBar.Progress = dimming.CurrentBrightness = dimming.LastOpenBrightness; |
| | | tempLightSeekBar.ThumbColor = SkinStyle.Current.SelectedColor; |
| | | //tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | if (!tempSwitch.IsSelected) { |
| | | SendControl.SendControlSetSingleLight (dimming, new byte [] { dimming.LoopID, dimming.LastOpenBrightness, 0, 0 }); |
| | | |
| | | //Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, dimming.LastOpenBrightness, 0, 0 }); |
| | | //tempLightSeekBar.Progress = dimming.CurrentBrightness = dimming.LastOpenBrightness; |
| | | //tempLightSeekBar.ThumbColor = SkinStyle.Current.SelectedColor; |
| | | //dimming.CurrentBrightness = dimming.LastOpenBrightness; |
| | | } else { |
| | | Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, 0, 0, 0 }); |
| | | tempLightSeekBar.Progress = 0; |
| | | tempLightSeekBar.ThumbColor = SkinStyle.Current.ThumbColor; |
| | | dimming.CurrentBrightness = 0; |
| | | SendControl.SendControlSetSingleLight (dimming, new byte [] { dimming.LoopID, 0, 0, 0 }); |
| | | |
| | | //Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, 0, 0, 0 }); |
| | | //tempLightSeekBar.Progress = 0; |
| | | //tempLightSeekBar.ThumbColor = SkinStyle.Current.ThumbColor; |
| | | //dimming.CurrentBrightness = 0; |
| | | } |
| | | btnValues.Text = dimming.CurrentBrightness + "%"; |
| | | //btnValues.Text = dimming.CurrentBrightness + "%"; |
| | | }; |
| | | if (dimming.CurrentBrightness > 0) { |
| | | tempSwitch.IsSelected = true; |
| | |
| | | |
| | | tempSwitch.IsSelected = dimming.CurrentBrightness > 0 ? true : false; |
| | | tempSwitch.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | if (tempSwitch.IsSelected) { |
| | | Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 100, 0, 0 }); |
| | | //tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | if (!tempSwitch.IsSelected) { |
| | | SendControl.SendControlSetSingleLight (dimming, new byte [] { dimming.PhysicsLoopID, 100, 0, 0 }); |
| | | |
| | | //Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 100, 0, 0 }); |
| | | } else { |
| | | Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 0, 0, 0 }); |
| | | SendControl.SendControlSetSingleLight (dimming, new byte [] { dimming.PhysicsLoopID, 0, 0, 0 }); |
| | | |
| | | //Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 0, 0, 0 }); |
| | | } |
| | | }; |
| | | #endregion |
| | |
| | | btnIcon.SelectedImagePath = "Item/Light.png"; |
| | | tempSwitch.IsSelected = dimming.CurrentBrightness > 0 ? true : false; |
| | | tempSwitch.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | if (tempSwitch.IsSelected) { |
| | | dimming.CurrentBrightness = 100; |
| | | Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 100, 0, 0 }); |
| | | //tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | if (!tempSwitch.IsSelected) { |
| | | //dimming.CurrentBrightness = 100; |
| | | SendControl.SendControlSetSingleLight (dimming, new byte [] { dimming.PhysicsLoopID, 100, 0, 0 }); |
| | | |
| | | //Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 100, 0, 0 }); |
| | | } else { |
| | | dimming.CurrentBrightness = 0; |
| | | Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 0, 0, 0 }); |
| | | //dimming.CurrentBrightness = 0; |
| | | SendControl.SendControlSetSingleLight (dimming, new byte [] { dimming.PhysicsLoopID, 0, 0, 0 }); |
| | | //Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 0, 0, 0 }); |
| | | } |
| | | }; |
| | | #endregion |
| | |
| | | lightLigicBytes [6] = e2 [0]; |
| | | lightLigicBytes [7] = e2 [1]; |
| | | lightLigicBytes [8] = e2 [2]; |
| | | //2020-02-10 待修改 |
| | | Control.ControlBytesSend (Command.SetLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, lightLigicBytes, SendCount.Zero); |
| | | colorChangeTime = DateTime.Now; |
| | | btnColor.BackgroundColor = (uint)(0xFF000000 + lightLigicBytes [6] * 256 * 256 + lightLigicBytes [7] * 256 + lightLigicBytes [8]); |
| | |
| | | tempSwitch.IsSelected = rgbLight.CurrentBrightness > 0 ? true : false; |
| | | |
| | | tempSwitch.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | if (tempSwitch.IsSelected) { |
| | | rgbLight.CurrentBrightness = 100; |
| | | Control.ControlBytesSend (Command.SetSingleLight, rgbLight.SubnetID, rgbLight.DeviceID, new byte [] { rgbLight.LoopID, 100, 0, 0 }); |
| | | //tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | if (!tempSwitch.IsSelected) { |
| | | //rgbLight.CurrentBrightness = 100; |
| | | SendControl.SendControlSetSingleLight (rgbLight, new byte [] { rgbLight.LoopID, 100, 0, 0 }); |
| | | |
| | | //Control.ControlBytesSend (Command.SetSingleLight, rgbLight.SubnetID, rgbLight.DeviceID, new byte [] { rgbLight.LoopID, 100, 0, 0 }); |
| | | } else { |
| | | rgbLight.CurrentBrightness = 0; |
| | | Control.ControlBytesSend (Command.SetSingleLight, rgbLight.SubnetID, rgbLight.DeviceID, new byte [] { rgbLight.LoopID, 0, 0, 0 }); |
| | | //rgbLight.CurrentBrightness = 0; |
| | | SendControl.SendControlSetSingleLight (rgbLight, new byte [] { rgbLight.LoopID, 0, 0, 0 }); |
| | | |
| | | //Control.ControlBytesSend (Command.SetSingleLight, rgbLight.SubnetID, rgbLight.DeviceID, new byte [] { rgbLight.LoopID, 0, 0, 0 }); |
| | | } |
| | | }; |
| | | #endregion |
| | |
| | | DeviceRowView.AddChidren (btnElectric); |
| | | } |
| | | tempSwitch.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | if (tempSwitch.IsSelected) { |
| | | switchLight.CurrentBrightness = 100; |
| | | Control.ControlBytesSend (Command.SetSingleLight, switchLight.SubnetID, switchLight.DeviceID, new byte [] { switchLight.LoopID, 100, 0, 0 }); |
| | | //tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | if (!tempSwitch.IsSelected) { |
| | | //switchLight.CurrentBrightness = 100; |
| | | SendControl.SendControlSetSingleLight (switchLight, new byte [] { switchLight.LoopID, 100, 0, 0 }); |
| | | |
| | | //Control.ControlBytesSend (Command.SetSingleLight, switchLight.SubnetID, switchLight.DeviceID, new byte [] { switchLight.LoopID, 100, 0, 0 }); |
| | | } else { |
| | | switchLight.CurrentBrightness = 0; |
| | | Control.ControlBytesSend (Command.SetSingleLight, switchLight.SubnetID, switchLight.DeviceID, new byte [] { switchLight.LoopID, 0, 0, 0 }); |
| | | //switchLight.CurrentBrightness = 0; |
| | | SendControl.SendControlSetSingleLight (switchLight, new byte [] { switchLight.LoopID, 0, 0, 0 }); |
| | | //Control.ControlBytesSend (Command.SetSingleLight, switchLight.SubnetID, switchLight.DeviceID, new byte [] { switchLight.LoopID, 0, 0, 0 }); |
| | | } |
| | | new System.Threading.Thread (() => { |
| | | Control.ControlBytesSend (Command.ReadAnalogValue, switchLight.SubnetID, switchLight.DeviceID, new byte [] { 10, switchLight.LoopID }, SendCount.Zero); |
| | |
| | | tempSwitch.MouseUpEventHandler += (sender3, e3) => { |
| | | infraredTV.isOpen = tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | int RandKey = new Random ().Next (0, 255); |
| | | //2020-02-10 待修改 |
| | | Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.Power, 0, 0, (byte)RandKey }); |
| | | IO.FileUtils.SaveEquipmentMessage (infraredTV, infraredTV.LoopID.ToString ()); |
| | | }; |
| | |
| | | DeviceRowView.AddChidren (tempON); |
| | | tempON.MouseUpEventHandler += (sender3, e3) => { |
| | | if (udDevice.UniversalType == 0xE01C) { |
| | | //2020-02-10 待修改 |
| | | Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 255 }, SendCount.Zero); |
| | | } |
| | | DeviceRowView.BorderColor = SkinStyle.Current.Transparent; |
| | |
| | | tempSwitch.MouseUpEventHandler += (sender3, e3) => { |
| | | if (udDevice.UniversalType == 0xE01C) { |
| | | if (udDevice.ActionType == 0) { |
| | | //2020-02-10 待修改 |
| | | Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 255 }, SendCount.Zero); |
| | | } else if (udDevice.ActionType == 1) { |
| | | Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 0 }, SendCount.Zero); |
| | |
| | | } catch (Exception ex) { |
| | | Console.WriteLine ("exddd :" + ex.ToString ()); |
| | | } finally { |
| | | //2020-02-14 增加读状态操作 |
| | | UserMiddle.ReadAllDeviceStatus (false, true); |
| | | |
| | | readEnergyThead = new Thread ((obj) => { |
| | | while (readEnergy) { |
| | | System.Threading.Thread.Sleep (500); |
| | | while (readEnergy && !Control.IsEnterBackground) { |
| | | |
| | | try { |
| | | for(int i=0;i<EnergtLightList.Count;i++){ |
| | | |
| | | var c = EnergtLightList [i]; |
| | | Control.ControlBytesSend (Command.ReadAnalogValue, c.SubnetID, c.DeviceID, new byte [] { 10, c.LoopID }, SendCount.Zero); |
| | | Control.ControlBytesSend (Command.ReadAnalogValue, c.SubnetID, c.DeviceID, new byte [] { 11, c.LoopID }, SendCount.Zero); |
| | |
| | | Console.WriteLine ($"读取 { c.Name } 电能"); |
| | | }); |
| | | #endif |
| | | System.Threading.Thread.Sleep (500); |
| | | } |
| | | System.Threading.Thread.Sleep (9500); |
| | | System.Threading.Thread.Sleep (10000); |
| | | } catch { |
| | | EnergtLightList = new List<Common> (); |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 空调控制,带返回结果 |
| | | /// </summary> |
| | | /// <param name="mAcData"></param> |
| | | /// <param name="bPower"></param> |
| | | void SendControlAc (AC mAcData, byte bPower) |
| | | { |
| | | MainPage.Loading.Start ("Sending..."); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | byte [] returnBytes = null; |
| | | if (mAcData.Type == DeviceType.ACPanel) { |
| | | returnBytes = Control.ControlBytesSendHasReturn (Command.InstructionPanelKey, mAcData.SubnetID, mAcData.DeviceID, new byte [] { 3, bPower, mAcData.LoopID }); |
| | | } else if (mAcData.Type == DeviceType.ACDevice || mAcData.Type == DeviceType.HVAC || mAcData.Type == DeviceType.ACInfrared) { |
| | | |
| | | 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, bPower, mAcData.SetMode, mAcData.SetFanSpeed, mAcData.SetTemperature, mAcData.ShaoFanMode }); |
| | | } |
| | | |
| | | Application.RunOnMainThread (() => { |
| | | if (returnBytes == null) { |
| | | new Alert ("", mAcData.Name + ErrorCode.ControlFailure, "Close").Show (); |
| | | } |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | } |