From 652243206427f35a256400a149a1734085824cb9 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期三, 02 九月 2020 17:35:03 +0800 Subject: [PATCH] 2020-09-02-4 --- ZigbeeApp/Shared/Phone/Device/Logic/Method.cs | 386 +++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 305 insertions(+), 81 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs b/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs old mode 100755 new mode 100644 index db4d658..d51e6e2 --- a/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs @@ -46,7 +46,7 @@ { ///鍖哄垎鍑鸿緭鍏ユ潯浠跺拰杈撳嚭鐩爣璁惧 var listdevicetype = GetDevice(type); - var listdevice = GetDeviceUIList(listAllRoom[i], listdevicetype); + var listdevice = GetDeviceUIList(listAllRoom[i], listdevicetype, type); if (listdevice.Count == 0) { ///杩囨护鎺夋病鏈夎澶囩殑鎴块棿 @@ -68,8 +68,9 @@ /// </summary> /// <param name="room">褰撳墠鎴块棿</param> /// <param name="deviceTypelist">璁惧绫诲瀷</param> + /// /// <param name="type">閫昏緫绫诲瀷</param> /// <returns></returns> - public static List<CommonDevice> GetDeviceUIList(Common.Room room, List<DeviceType> deviceTypelist) + public static List<CommonDevice> GetDeviceUIList(Common.Room room, List<DeviceType> deviceTypelist,string type) { var deviceUIlist = new List<CommonDevice>(); foreach (var deviceKey in room.ListDevice) @@ -83,6 +84,32 @@ { //杩囨护鎺変笉鏀寔鐨勮澶� continue; + } + if (device.Type == DeviceType.DoorLock) + { + var myInfo = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); + if (myInfo.ConcreteType == DeviceConcreteType.IntelligentLocks_Sone) + { + //鏆傛椂涓嶆敮鎸丼-one闂ㄩ攣; + //杩囨护鎺変笉鏀寔S-one闂ㄩ攣璁惧; + continue; + } + } + if (type == "condition_mould") + { + if (device.Type == DeviceType.IASZone) + { + if (device.IasDeviceType != 13) + {//鑷姩鍖栨ā鏉垮彧鏀寔绾㈠浼犳劅鍣� + continue; + } + if (device.ModelIdentifier == "MSPIRB-ZB.10") + { + //鑷姩鍖栨ā鏉夸笉鏀寔鍏夌収搴� + continue; + } + + } } deviceUIlist.Add(device); } @@ -91,47 +118,53 @@ /// <summary> /// 鎺掑垪鎵�鏈夎澶囩被鍨嬬殑鍒楄〃 /// </summary> - /// <param name="type">鍒ゆ柇瀛楃涓�</param> /// <param name="devicelist">璁惧鍒楄〃</param> /// <returns></returns> - public static List<string> GetDeviceTypeList(string type, List<CommonDevice> devicelist) + public static List<string> GetDeviceTypeList(List<CommonDevice> devicelist) { List<string> devicetypelist = new List<string>(); devicetypelist.Clear(); - var lightjosn = devicelist.Find((device) => device.Type == DeviceType.ColorDimmableLight || device.Type == DeviceType.OnOffOutput); + + var lightjosn = devicelist.Find((device) => device.Type == DeviceType.DimmableLight || device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.ColorTemperatureLight); if (lightjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Lights)); } - var iASZonejosn = devicelist.Find((device) => device.Type == DeviceType.IASZone || device.Type == DeviceType.TemperatureSensor); - if (iASZonejosn != null) - { - devicetypelist.Add(Language.StringByID(MyInternationalizationString.sensor)); - } - var onOffSwitchjson = devicelist.Find((device) => device.Type == DeviceType.OnOffSwitch); - if (onOffSwitchjson != null) - { - devicetypelist.Add(Language.StringByID(MyInternationalizationString.OnOffSwitch)); - } - var doorLock = devicelist.Find((device) => device.Type == DeviceType.DoorLock); - if (doorLock != null) - { - devicetypelist.Add(Language.StringByID(MyInternationalizationString.doorLock)); - } + var curtainjosn = devicelist.Find((device) => device.Type == DeviceType.WindowCoveringDevice); if (curtainjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains)); } + var ac = devicelist.Find((device) => device.Type == DeviceType.Thermostat); if (ac != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.AC)); } + + var onOffSwitchjson = devicelist.Find((device) => device.Type == DeviceType.OnOffSwitch); + if (onOffSwitchjson != null) + { + devicetypelist.Add(Language.StringByID(MyInternationalizationString.OnOffSwitch)); + } + + var doorLock = devicelist.Find((device) => device.Type == DeviceType.DoorLock); + if (doorLock != null) + { + devicetypelist.Add(Language.StringByID(MyInternationalizationString.doorLock)); + } + var airSwitch = devicelist.Find((device) => device.Type == DeviceType.AirSwitch); if (airSwitch != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Airswitch)); + } + + var iASZonejosn = devicelist.Find((device) => device.Type == DeviceType.IASZone || device.Type == DeviceType.TemperatureSensor); + if (iASZonejosn != null) + { + devicetypelist.Add(Language.StringByID(MyInternationalizationString.sensor)); } return devicetypelist; @@ -150,6 +183,7 @@ { DeviceTypeList.Add(DeviceType.OnOffOutput);//0x0101鍗佽繘鍒�257 DeviceTypeList.Add(DeviceType.DimmableLight); + DeviceTypeList.Add(DeviceType.ColorTemperatureLight); } else if (devicetype == Language.StringByID(MyInternationalizationString.Curtains)) { @@ -244,8 +278,17 @@ { break; } - patm = $"ZigeeLogic/sensor{iASZonedevice.IasDeviceType}.png"; - selectedpatm = $"ZigeeLogic/selectedsensor{iASZonedevice.IasDeviceType}.png"; + + if (device.ModelIdentifier == "MSPIRB-ZB.10") + { + patm = $"ZigeeLogic/sensor541.png"; + selectedpatm = $"ZigeeLogic/selectedsensor541.png"; + } + else + { + patm = $"ZigeeLogic/sensor{iASZonedevice.IasDeviceType}.png"; + selectedpatm = $"ZigeeLogic/selectedsensor{iASZonedevice.IasDeviceType}.png"; + } } break; case DeviceType.TemperatureSensor: @@ -300,6 +343,12 @@ selectedpatm = "ZigeeLogic/selectedairswitch.png"; } break; + case DeviceType.ColorTemperatureLight: + { + patm = "ZigeeLogic/nightLight.png"; + selectedpatm = "ZigeeLogic/nightLightSelected.png"; + } + break; } button.UnSelectedImagePath = patm; button.SelectedImagePath = selectedpatm; @@ -326,12 +375,17 @@ } break; case "action_logic": - { //鑷姩鍖栨敮鎸佺殑鐩爣璁惧 + { + + //鑷姩鍖栨敮鎸佺殑鐩爣璁惧 deviceTypeList.Add(DeviceType.OnOffOutput); deviceTypeList.Add(DeviceType.DimmableLight); deviceTypeList.Add(DeviceType.WindowCoveringDevice); deviceTypeList.Add(DeviceType.Thermostat); deviceTypeList.Add(DeviceType.AirSwitch); + deviceTypeList.Add(DeviceType.ColorTemperatureLight); + ///闂ㄩ攣鐗规畩 + // deviceTypeList.Add(DeviceType.DoorLock); } break; case "condition_mould": @@ -352,6 +406,9 @@ deviceTypeList.Add(DeviceType.WindowCoveringDevice); deviceTypeList.Add(DeviceType.Thermostat); deviceTypeList.Add(DeviceType.AirSwitch); + deviceTypeList.Add(DeviceType.ColorTemperatureLight); + ///闂ㄩ攣鐗规畩 + // deviceTypeList.Add(DeviceType.DoorLock); } break; @@ -537,7 +594,9 @@ }; break; case 5: { - string len = "", text = ""; + string len = ""; + string text = ""; + string weekStr = Language.StringByID(MyInternationalizationString.week1); List<int> listvalueInt = new List<int>(); listvalueInt.Clear(); var maxvalue = Convert.ToString(currentLogic.TimeAttribute.WeekDay, 2); @@ -553,44 +612,36 @@ if (strvalue == "1") { listvalueInt.Add(j + 1); - - - if ((j + 1) == 1) - { - text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.mon1) + ","; - //text += Language.StringByID(MyInternationalizationString.mon) + ","; + switch ((j + 1)) { + case 1: { + text += weekStr + Language.StringByID(MyInternationalizationString.mon1) + ","; + } + break; + case 2: { + text += weekStr + Language.StringByID(MyInternationalizationString.tue1) + ","; + } + break; + case 3: { + text += weekStr + Language.StringByID(MyInternationalizationString.wed1) + ","; + } + break; + case 4: { + text += weekStr + Language.StringByID(MyInternationalizationString.thu1) + ","; + } + break; + case 5: { + text += weekStr + Language.StringByID(MyInternationalizationString.frl1) + ","; + } + break; + case 6: { + text += weekStr + Language.StringByID(MyInternationalizationString.sat1) + ","; + } + break; + case 7: { + text += weekStr + Language.StringByID(MyInternationalizationString.sun1) + ","; + } + break; } - else if ((j + 1) == 2) - { - text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.tue1) + ","; - //text += Language.StringByID(MyInternationalizationString.tue) + ","; - } - else if ((j + 1) == 3) - { - text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.wed1) + ","; - //text += Language.StringByID(MyInternationalizationString.wed) + ","; - } - else if ((j + 1) == 4) - { - text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.thu1) + ","; - //text += Language.StringByID(MyInternationalizationString.thu) + ","; - } - else if ((j + 1) == 5) - { - text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.frl1) + ","; - //text += Language.StringByID(MyInternationalizationString.frl) + ","; - } - else if ((j + 1) == 6) - { - text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.sat1) + ","; - //text += Language.StringByID(MyInternationalizationString.sat) + ","; - } - else if ((j + 1) == 7) - { - text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.sun1) + ","; - //text += Language.StringByID(MyInternationalizationString.sun) + ","; - } - } } @@ -611,8 +662,7 @@ //{ // btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.week1) + text.Replace(Language.StringByID(MyInternationalizationString.week1), "").TrimEnd(','); //} - button.Text = Language.StringByID(MyInternationalizationString.week1) + text.Replace(Language.StringByID(MyInternationalizationString.week1), "").TrimEnd(','); - //btndisplaycycle.Text = text.TrimEnd(','); + button.Text = weekStr + text.Replace(weekStr, "").TrimEnd(','); }; break; } @@ -649,6 +699,7 @@ custompushview.iconBtn.Visible = true; custompushview.iconBtn.UnSelectedImagePath = "ZigeeLogic/next.png"; custompushview.titleBtn.TextID = MyInternationalizationString.custompush; + custompushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor; middle.AddChidren(custompushview.AddDeviceView()); EventHandler<MouseEventArgs> customclick = (sender, e) => @@ -669,6 +720,7 @@ LogicView.IfString.Tag = true; custompushview.frameLayout.Height = Application.GetRealHeight(160); Common.Logic.CurrentLogic.LogicIsCustomPushText = 1; + pushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor; } else @@ -676,8 +728,13 @@ LogicView.IfString.Tag = false; custompushview.frameLayout.Height = Application.GetRealHeight(0); Common.Logic.CurrentLogic.LogicIsCustomPushText = 0; + pushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor; } - Send.Zj(LogicView.IfString.Tag, Common.Logic.CurrentLogic); + if (!Config.Instance.Home.IsVirtually) + { + Send.Zj(LogicView.IfString.Tag, Common.Logic.CurrentLogic); + + } }; if (Common.Logic.CurrentLogic.LogicIsCustomPushText == 0) @@ -685,12 +742,14 @@ LogicView.IfString.Tag = false; pushview.switchBtn.IsSelected = false; custompushview.frameLayout.Height = Application.GetRealHeight(0); + pushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor; } else { LogicView.IfString.Tag = true; pushview.switchBtn.IsSelected = true; custompushview.frameLayout.Height = Application.GetRealHeight(160); + pushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor; } } /// <summary> @@ -702,6 +761,16 @@ /// <param name="CurrentLogic">褰撳墠閫昏緫</param> public async static void SaveLogic(string if_logic, string name, bool tag, Common.Logic CurrentLogic) { + + if (CurrentLogic.Conditions.Count == 0 || CurrentLogic.Actions.Count == 0) + { + var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal, + Language.StringByID(MyInternationalizationString.addnull), + Language.StringByID(MyInternationalizationString.confrim)); + alert.Show(); + return; + } + if (string.IsNullOrEmpty(name)) { var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal, @@ -722,28 +791,94 @@ bool succeed = false; //鍒ゆ柇鏄柊娣诲姞閫昏緫(榛樿0)杩樻槸淇敼閫昏緫 CommonPage.Loading.Start(); - if (CurrentLogic.LogicId == 0) + + if (Config.Instance.Home.IsVirtually) { - //鍙戦�佹坊鍔犻�昏緫鍛戒护 - var logicifon = await Send.AddModifyLogic(CurrentLogic); - if (logicifon != null && logicifon.LogicId != 0) + if (Common.Logic.LogicList.Count == 0) { - succeed = true; - CurrentLogic.LogicId = logicifon.LogicId; + CurrentLogic.LogicId = 1; Common.Logic.LogicList.Add(CurrentLogic); - if (tag) - { - Send.Zj(tag, CurrentLogic); - } } + + if (CurrentLogic.LogicId == 0) + { + bool d = false; + for (int i = 1; i < 50; i++) + { + + for (int j = 0; j < Common.Logic.LogicList.Count; j++) + { + if (i != Common.Logic.LogicList[j].LogicId) + { + CurrentLogic.LogicId = i; + Common.Logic.LogicList.Add(CurrentLogic); + d = true; + break; + } + } + if (d) + { + break; + } + } + + } + else + { + for (int j = 0; j < Common.Logic.LogicList.Count; j++) + { + if (CurrentLogic.LogicId == Common.Logic.LogicList[j].LogicId) + { + Common.Logic.LogicList.RemoveAt(j); + Common.Logic.LogicList.Insert(j,CurrentLogic); + break; + } + } + + } + + //鑷姩鍖栭�昏緫鍒楄〃 } else { - //鍙戦�佷慨鏀归�昏緫鍛戒护锛� - //淇敼鍛戒护涓嶉渶瑕佺瓑寰呭洖澶嶏紱 - Send.AddModifyLogic(CurrentLogic); - //缂栬緫榛樿鎴愬姛锛堜笉鑰冭檻缃戠粶鎯呭喌锛夛紱 - succeed = true; + if (CurrentLogic.LogicId == 0) + { + //鍙戦�佹坊鍔犻�昏緫鍛戒护 + var logicifon = await Send.AddModifyLogic(CurrentLogic); + if (logicifon != null && logicifon.LogicId != 0) + { + succeed = true; + CurrentLogic.LogicId = logicifon.LogicId; + if (LogicView.IfString._Logic == if_logic || LogicView.IfString._SoneLogic == if_logic) + { + //鑷姩鍖栭�昏緫鍒楄〃 + Common.Logic.LogicList.Add(CurrentLogic); + } + if (LogicView.IfString._LockLogic == if_logic) + { + //闂ㄩ攣鑱斿姩浜嬩欢閫昏緫鍒楄〃 + Common.Logic.LockLogicList.Add(CurrentLogic); + } + if (LogicView.IfString._SoneLogic == if_logic) + { + //Sone闂ㄩ攣甯稿紑妯″紡閫昏緫鍒楄〃 + Common.Logic.SoneLogicList.Add(CurrentLogic); + + } + if (tag) + { + Send.Zj(tag, CurrentLogic); + } + } + } + else + { + //鍙戦�佷慨鏀归�昏緫鍛戒护锛� + //淇敼鍛戒护涓嶉渶瑕佺瓑寰呭洖澶嶏紱 + Send.AddModifyLogic(CurrentLogic); + //缂栬緫榛樿鎴愬姛锛堜笉鑰冭檻缃戠粶鎯呭喌锛夛紱 + succeed = true; + } } CommonPage.Loading.Hide(); @@ -755,20 +890,109 @@ //TipView("娣诲姞鑷姩鍖栧け璐�"); //return; } - UserView.HomePage.Instance.RemoveViewByTag("Logic"); + + UserView.HomePage.Instance.RemoveViewByTag("Logic");//绉婚櫎鎵�鏈夋爣璁癓ogic鐣岄潰 if (LogicView.IfString._Logic == if_logic) { - Category.Category.instance?.RefreshBodyView(); + + //鏌ヨ-褰撳墠閫昏緫-鏄惁娣诲姞鍦扮悊浣嶇疆浣滀负鏉′欢 + var exist = Common.Logic.CurrentLogic.Conditions.Find((obj) => obj["Type"] == "7"); + if (exist==null) + { + bool if_type = false; + //鏌ヨ-閫昏緫鍒楄〃-鏄惁娣诲姞杩囧湴鐞嗕綅缃綔涓烘潯浠� + for (int a = 0; a < Common.Logic.LogicList.Count; a++) + { + var logic = Common.Logic.LogicList[a]; + var exist_logic = logic.Conditions.Find((obj) => obj["Type"] == "7"); + if (exist_logic != null) + { + //鏄惁瀛樺湪鍦扮悊浣嶇疆鏉′欢 + if_type = true; + //閫�鍑篺or寰幆 + break; + } + } + if (if_type) + { + //鏌ヨ涔嬪墠鐘舵�佹槸鍚﹀凡缁忓紑鍚疓PS鏈嶅姟(浠ユ湰鍦板瓨鍌ㄧ姸鎬佷负涓� 0:娌″紑鍚�; 1锛氬紑鍚�) + if (Send.If_Exist == "0") + { + //寮�鍚疓PS鏈嶅姟 + Application.StartGPSLocationService(); + //淇濆瓨GPS鏈嶅姟寮�鍚姸鎬� + Send.SaveLocalFile(Config.Instance.HomeId + "_GPS_File", "1"); + } + + } + else + { + //濡傛灉鎵句笉鍒板湴鐞嗕綅缃綔涓烘潯浠剁殑璇�,鍏抽棴GPS鏈嶅姟(鍑忓皯鑰楃數) + if (Send.If_Exist == "1") + { + //鍏抽棴GPS鏈嶅姟 + Application.StopGPSLocationService(); + //淇濆瓨GPS鏈嶅姟鍏抽棴鐘舵�� + Send.SaveLocalFile(Config.Instance.HomeId + "_GPS_File", "0"); + } + } + } + else + { + //鏌ヨ涔嬪墠鐘舵�佹槸鍚﹀凡缁忓紑鍚疓PS鏈嶅姟(浠ユ湰鍦板瓨鍌ㄧ姸鎬佷负涓� 0:娌″紑鍚�; 1锛氬紑鍚�) + if (Send.If_Exist == "0") + { + //寮�鍚疓PS鏈嶅姟 + Application.StartGPSLocationService(); + //淇濆瓨GPS鏈嶅姟寮�鍚姸鎬� + Send.SaveLocalFile(Config.Instance.HomeId + "_GPS_File", "1"); + } + } + //鍙埛鏂板垎绫�-鑷姩鍖栦笂涓嬫粦鍔╲iew锛� + Phone.Category.CategoryMainForm.instance?.RefreshBodyView(); + // Category.Category.instance?.RefreshBodyView(); } else if (LogicView.IfString._LockLogic == if_logic) { + //璺冲埌闂ㄩ攣鑱斿姩浜嬩欢鍒楄〃鐣岄潰 + UserView.HomePage.Instance.RemoveViewByTag("LockListView");//绉婚櫎鎵�鏈夋爣璁癓ockListView鐣岄潰 var doorLockLogicList = new DoorLockLogic.LockLogicList(); UserView.HomePage.Instance.AddChidren(doorLockLogicList); UserView.HomePage.Instance.PageIndex += 1; doorLockLogicList.Show(); } + else if (LogicView.IfString._SoneLogic == if_logic) + { + //璺冲埌Sone闂ㄩ攣鑱斿姩浜嬩欢鍒楄〃鐣岄潰 + //UserView.HomePage.Instance.RemoveViewByTag("SoneLogic");//绉婚櫎鎵�鏈夋爣璁癓ockListView鐣岄潰 + //var soneLogicList = new SoneLogicList(); + //UserView.HomePage.Instance.AddChidren(soneLogicList); + //UserView.HomePage.Instance.PageIndex += 1; + //soneLogicList.Show(); + + SoneLogicList.soneLogicList?.RefreshView(); + } } + /// <summary> + /// 璺冲叆杈撳嚭鐩爣鍔熻兘鐣岄潰鐨勬柟娉� + /// </summary> + /// <param name="str1">璁惧鐣岄潰璇嗗埆瀛楃涓�</param> + /// <param name="str2">鍦烘櫙鐣岄潰璇嗗埆瀛楃涓�</param> + public static void View(string str1, string str2) + { + var deviceTarget = new DeviceTarget(); + UserView.HomePage.Instance.AddChidren(deviceTarget); + UserView.HomePage.Instance.PageIndex += 1; + deviceTarget.Show(str1, str2); + } + + /// <summary> + /// 鐣岄潰楂樺害 + /// </summary> + public static int H = 1922; + + } } -- Gitblit v1.8.0