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 |  234 +++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 181 insertions(+), 53 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs b/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs
index 3c2d150..d51e6e2 100644
--- 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)
@@ -94,6 +95,22 @@
                         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);
             }
             return deviceUIlist;
@@ -108,7 +125,7 @@
             List<string> devicetypelist = new List<string>();
             devicetypelist.Clear();
 
-            var lightjosn = devicelist.Find((device) => device.Type == DeviceType.DimmableLight || 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));
@@ -166,6 +183,7 @@
             {
                 DeviceTypeList.Add(DeviceType.OnOffOutput);//0x0101鍗佽繘鍒�257
                 DeviceTypeList.Add(DeviceType.DimmableLight);
+                DeviceTypeList.Add(DeviceType.ColorTemperatureLight);
             }
             else if (devicetype == Language.StringByID(MyInternationalizationString.Curtains))
             {
@@ -260,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:
@@ -316,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;
@@ -350,6 +383,7 @@
                         deviceTypeList.Add(DeviceType.WindowCoveringDevice);
                         deviceTypeList.Add(DeviceType.Thermostat);
                         deviceTypeList.Add(DeviceType.AirSwitch);
+                        deviceTypeList.Add(DeviceType.ColorTemperatureLight);
                         ///闂ㄩ攣鐗规畩
                        // deviceTypeList.Add(DeviceType.DoorLock);
                     }
@@ -372,6 +406,7 @@
                         deviceTypeList.Add(DeviceType.WindowCoveringDevice);
                         deviceTypeList.Add(DeviceType.Thermostat);
                         deviceTypeList.Add(DeviceType.AirSwitch);
+                        deviceTypeList.Add(DeviceType.ColorTemperatureLight);
                         ///闂ㄩ攣鐗规畩
                       // deviceTypeList.Add(DeviceType.DoorLock);
                     }
@@ -559,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);
@@ -575,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) + ",";
-                                }
-
 
                             }
                         }
@@ -633,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;
             }
 
@@ -766,9 +794,50 @@
 
             if (Config.Instance.Home.IsVirtually)
             {
-                Send.Zj(LogicView.IfString.Tag, Common.Logic.CurrentLogic);
+                if (Common.Logic.LogicList.Count == 0)
+                {
+                    CurrentLogic.LogicId = 1;
+                    Common.Logic.LogicList.Add(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;
+                        }
+                    }
+
+                }
+
                 //鑷姩鍖栭�昏緫鍒楄〃
-                Common.Logic.LogicList.Add(CurrentLogic);
             }
             else
             {
@@ -792,7 +861,7 @@
                         }
                         if (LogicView.IfString._SoneLogic == if_logic)
                         {
-                            //Sone闂ㄩ攣鑱斿姩浜嬩欢閫昏緫鍒楄〃
+                            //Sone闂ㄩ攣甯稿紑妯″紡閫昏緫鍒楄〃
                             Common.Logic.SoneLogicList.Add(CurrentLogic);
 
                         }
@@ -825,6 +894,60 @@
             UserView.HomePage.Instance.RemoveViewByTag("Logic");//绉婚櫎鎵�鏈夋爣璁癓ogic鐣岄潰
             if (LogicView.IfString._Logic == if_logic)
             {
+
+                //鏌ヨ-褰撳墠閫昏緫-鏄惁娣诲姞鍦扮悊浣嶇疆浣滀负鏉′欢
+                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();
@@ -841,11 +964,13 @@
             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();
+                //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();
             }
 
         }
@@ -866,5 +991,8 @@
         /// 鐣岄潰楂樺害
         /// </summary>
         public static int H = 1922;
+
+
+
     }
 }

--
Gitblit v1.8.0