wxr
2023-07-20 d3189eaa6be7c70ed5ac783efe68f43211a90d27
HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
@@ -162,6 +162,7 @@
                                //空调
                                case SPK.AcStandard:
                                case SPK.HvacAC:
                                case SPK.AcIr:
                                //地热
                                case SPK.HvacFloorHeat:
                                case SPK.FloorHeatStandard:
@@ -246,7 +247,7 @@
                                        {
                                            inputView.btnState.Text = Language.StringByID(StringId.kaiqi);
                                        }
                                    }
                                    break;
                                case SPK.SensorUtrasonic:
@@ -306,12 +307,14 @@
                                    {
                                        string value = this.GetValue(dicList);
                                        inputView.btnState.Text = Language.StringByID(StringId.wuren);
                                        if (value == "fall") {
                                        if (value == "fall")
                                        {
                                            inputView.btnState.Text = Language.StringByID(StringId.diedao);
                                        }
                                    }
                                    break;
                                case SPK.SensorEnvironment:
                                case SPK.SensorEnvironmentHailin:
                                case SPK.SensorEnvironment2:
                                case SPK.SensorEnvironment3:
                                    {
@@ -375,7 +378,7 @@
                                case SPK.SensorTemperature:
                                    {
                                        string str =this.GetText(dicList, "temperature");
                                        string str = this.GetText(dicList, "temperature");
                                        inputView.btnState.Text = str;
                                    }
                                    break;
@@ -406,18 +409,53 @@
                                        }
                                    }
                                    break;
                                case SPK.VideoDoorLock:
                                    {
                                        string s = string.Empty;
                                        string tag = string.Empty;
                                        for (int b = 0; b < dicList.Count; b++)
                                        {
                                            var dic = dicList[b];
                                            //var userId = dic["value"].ToString();
                                            //var FaceItem = this.GetVideoDoorLockUserItem(userId, device);
                                            //s += FaceItem.userName;
                                            //s += ",";
                                            //tag += FaceItem.userId;
                                            //tag += "_";
                                            var userName = dic["value"].ToString();
                                            s += userName;
                                            s += ",";
                                        }
                                        inputView.btnState.Text = s;
                                    }
                                    break;
                                case SPK.doorgate:
                                    {
                                        string s = string.Empty;
                                        if (inputCondition.identifier == "door_call_cloud_event")
                                        {
                                            inputView.btnState.Text = Language.StringByID(StringId.shipintonghuahujiao);
                                            s = Language.StringByID(StringId.shipintonghuahujiao);
                                        }
                                        else
                                        {
                                            string userId = this.GetKeyValue("user_id",dicList);
                                            var FaceItem = this.GetFaceItem(userId, device.deviceId);
                                            inputView.btnState.Text = FaceItem.userName;
                                            for (int b = 0; b < dicList.Count; b++)
                                            {
                                                var dic = dicList[b];
                                                var key = dic["key"].ToString();
                                                if (key != "user_id")
                                                {
                                                    continue;
                                                }
                                                var userId = dic["value"].ToString();
                                                var FaceItem = this.GetFaceItem(userId, device.deviceId);
                                                s += FaceItem.userName;
                                                s += ",";
                                            }
                                        }
                                        inputView.btnState.Text = s;
                                    }
                                    break;
                                case SPK.IpCam_Imou:
@@ -426,7 +464,38 @@
                                        {
                                            inputView.btnState.Text = Language.StringByID(StringId.quyuruqingaojing);
                                        }
                                    }
                                    break;
                                case SPK.Ev_Ipcam:
                                    if (inputCondition.identifier == "pir_event")
                                    {
                                        inputView.btnState.Text = Language.StringByID(StringId.On);
                                    }
                                    break;
                                case SPK.SensorPirHold:
                                    {
                                        string value = this.GetKeyValue("people_status", dicList);
                                        if (string.IsNullOrEmpty(value))
                                        {
                                            inputView.btnState.Text = inputCondition.hold_time + "s";
                                            break;
                                        }
                                        inputView.btnState.Text = Language.StringByID(StringId.wuren);
                                        if (value == "true")
                                        {
                                            inputView.btnState.Text = Language.StringByID(StringId.youren);
                                        }
                                        if (!string.IsNullOrEmpty(inputCondition.hold_time) && int.Parse(inputCondition.hold_time) > 0)
                                        {
                                            inputView.btnState.Text += "持续" + inputCondition.hold_time + "s";
                                        }
                                    }
                                    break;
                            }
@@ -672,7 +741,7 @@
                            {
                                //用sid找到设备;
                                var device = LogicMethod.Current.GetDevice(inputCondition.sid);
                                if (device.spk == SPK.SensorEnvironment
                                if (device.spk == SPK.SensorEnvironment || device.spk == SPK.SensorEnvironmentHailin
                                || device.spk == SPK.SensorEnvironment2
                                || device.spk == SPK.SensorEnvironment3
                                )
@@ -757,6 +826,12 @@
                                {
                                    this.SensorView(thisView, device, "co2", indexVulae);
                                }
                                else if (device.spk == SPK.SensorPm10)
                                {
                                    this.SensorView(thisView, device, "pm10", indexVulae);
                                }
                                else if (device.spk == SPK.SensorPm25)
@@ -933,7 +1008,10 @@
                            //区别不同设备,显示不同设备状态
                            switch (device.spk)
                            {
                                case SPK.CommonSeries:
                                    targetView.btnIcon.UnSelectedImagePath = "FunctionIcon/Icon/groupControl.png";
                                    stateStr = GetKeyValue("on_off", dicList) == "on" ? Language.StringByID(StringId.onLogic) : Language.StringByID(StringId.offLogic);
                                    break;
                                //插座(有USB)
                                case SPK.PanelSocket:
                                    {
@@ -976,6 +1054,24 @@
                                case SPK.LightCCT:
                                case SPK.LightDimming:
                                    {
                                        if(device.spk == SPK.LightRGB)
                                        {
                                            string colorful = GetKeyValue(FunctionAttributeKey.Colorful, dicList);
                                            if (!string.IsNullOrEmpty(colorful))
                                            {
                                                targetView.btnIcon.UnSelectedImagePath = "FunctionIcon/Icon/groupControl.png";
                                                if (colorful == "on")
                                                {
                                                    stateStr = Language.StringByID(StringId.onLogic);
                                                }
                                                else if (colorful == "off")
                                                {
                                                    stateStr = Language.StringByID(StringId.offLogic);
                                                }
                                                break;
                                            }
                                        }
                                        string on_off = GetKeyValue("on_off", dicList);
                                        string brightness = GetKeyValue("brightness", dicList);
                                        if (on_off == "on" && brightness != "")
@@ -1002,9 +1098,28 @@
                                                stateStr += "," +GetKeyValue("cct", dicList) + "k";
                                            }
                                        }
                                        if (device.spk == SPK.LightRGB)
                                        {
                                            string rgb = GetKeyValue("rgb", dicList);
                                            if (!string.IsNullOrEmpty(rgb) && rgb.Length > 6)
                                            {
                                                targetView.btnStateColor.Visible = true;
                                                targetView.btnStateColor.BackgroundColor = new LogicView.RGBColorView().GetBackgroundColor(rgb);
                                            }
                                        }
                                        if (device.spk == SPK.LightRGBW)
                                        {
                                            string rgb = GetKeyValue("rgbw", dicList);
                                            if (!string.IsNullOrEmpty(rgb) && rgb.Length > 6)
                                            {
                                                targetView.btnStateColor.Visible = true;
                                                targetView.btnStateColor.BackgroundColor = new LogicView.RGBColorView().GetBackgroundColor(rgb);
                                            }
                                        }
                                    }
                                    break;
                                case SPK.CurtainSwitch:
                                    {
                                        foreach (var dic in dicList)
@@ -1075,6 +1190,7 @@
                                    break;
                                case SPK.AcStandard:
                                case SPK.HvacAC:
                                case SPK.AcIr:
                                    {
                                        string on_off = GetKeyValue("on_off", dicList);
                                        string set_temp = GetKeyValue("set_temp", dicList);
@@ -1100,8 +1216,8 @@
                                        if (set_temp != "")
                                        {
                                            stateStr += set_temp + "℃,";
                                            string unit =GetTemperatureUnit(device);
                                            stateStr += set_temp + unit + ",";
                                        }
                                        if (mode != "")
@@ -1198,8 +1314,8 @@
                                        }
                                        if (set_temp != "")
                                        {
                                            stateStr += set_temp + "℃,";
                                            string unit = GetTemperatureUnit(device);
                                            stateStr += set_temp + unit + ",";
                                        }
                                        if (mode != "")
                                        {
@@ -1485,7 +1601,7 @@
                //开关灯光
                case SPK.AirSwitch:
                case SPK.LightSwitch:
                    //机械手
                //机械手
                case SPK.MechanicalArm:
                    {
                        foreach (var dic in dicList)
@@ -1544,6 +1660,22 @@
                                        button3.Text = value + "k";
                                    }
                                    break;
                                case "rgb":
                                case "rgbw":
                                    {
                                        if (button3 == null)
                                        {
                                            //怕调试软件乱上东西导致抛异常
                                            break;
                                        }
                                        if (!string.IsNullOrEmpty(value) && value.Length > 6)
                                        {
                                            button3.BackgroundColor = new LogicView.RGBColorView().GetBackgroundColor(value);
                                            button3.Tag = value;
                                        }
                                    }
                                    break;
                            }
                        }
@@ -1656,6 +1788,7 @@
                    break;
                case SPK.AcStandard:
                case SPK.HvacAC:
                case SPK.AcIr:
                    {
                        foreach (var dic in dicList)
                        {
@@ -1686,7 +1819,7 @@
                                            //怕调试软件乱上东西导致抛异常
                                            break;
                                        }
                                        button2.Text = value + "℃";
                                        button2.Text = value + GetTemperatureUnit(device); ;
                                    }
                                    break;
                                case "mode":
@@ -1799,7 +1932,7 @@
                                            //怕调试软件乱上东西导致抛异常
                                            break;
                                        }
                                        button2.Text = value + "℃";
                                        button2.Text = value + GetTemperatureUnit(device); ;
                                    }
                                    break;
                                case "mode":
@@ -1934,6 +2067,7 @@
                        }
                    }
                    break;
                case SPK.SensorGas:
                case SPK.SensorSmoke:
                    {
@@ -2000,6 +2134,23 @@
                                button1.Text = Language.StringByID(StringId.wuren);
                            }
                        }
                    }
                    break;
                case SPK.SensorPirHold:
                    {
                        foreach (var dic in dicList)
                        {
                            string value = dic["value"];
                            if (value == "true")
                            {
                                button1.Text = Language.StringByID(StringId.youren);
                            }
                            else
                            {
                                button1.Text = Language.StringByID(StringId.wuren);
                            }
                        }
                    }
                    break;
                case SPK.SensorDoorWindow:
@@ -2122,6 +2273,27 @@
                        }
                    }
                    break;
                case SPK.VideoDoorLock:
                    {
                        string s = string.Empty;
                        string tag = string.Empty;
                        for (int b = 0; b < dicList.Count; b++)
                        {
                            var dic = dicList[b];
                            //var userId = dic["value"].ToString();
                            //var FaceItem = this.GetVideoDoorLockUserItem(userId, device);
                            //s += FaceItem.userName;
                            //s += ",";
                            //tag += FaceItem.userId;
                            //tag += "_";
                            var userName = dic["value"].ToString();
                            s += userName;
                            s += ",";
                        }
                        button1.Text = s;
                        button1.Tag = tag;
                    }
                    break;
                case SPK.MusicStandard:
                case SPK.AvMusic:
                    {
@@ -2140,11 +2312,28 @@
                    break;
                case SPK.doorgate:
                    {
                        string value = this.GetKeyValue("user_id", dicList);
                        button2.Text = this.GetFaceItem(value, device.deviceId).userName;
                        string s = string.Empty;
                        string tag = string.Empty;
                        for (int b = 0; b < dicList.Count; b++)
                        {
                            var dic = dicList[b];
                            var key = dic["key"].ToString();
                            if (key != "user_id")
                            {
                                continue;
                            }
                            var userId = dic["value"].ToString();
                            var FaceItem = this.GetFaceItem(userId, device.deviceId);
                            s += FaceItem.userName;
                            s += ",";
                            tag += FaceItem.userId;
                            tag += "_";
                        }
                        button2.Text = s;
                        button2.Tag = tag;
                    }
                    break;
            }
        }
        /// <summary>
@@ -2193,6 +2382,25 @@
                return "";
            }
            return dicList[0]["value"].ToString();
        }
        /// <summary>
        /// 获取温度单位
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public string GetTemperatureUnit(Entity.Function device)
        {
            string unit = string.Empty;
            if (device.GetAttribute("temperature_type") != null && device.GetAttribute("temperature_type").value.Count > 0)
            {
                unit = device.GetAttribute("temperature_type").value[0];
            }
            if (string.IsNullOrEmpty(unit))
            {
                //调试软件有空能上传为空
                unit = "℃";
            }
            return unit;
        }
        /// <summary>
        ///获取自动化名称
@@ -2321,6 +2529,7 @@
                                    break;
                                case SPK.AcStandard:
                                case SPK.HvacAC:
                                case SPK.AcIr:
                                case SPK.FloorHeatStandard:
                                case SPK.HvacFloorHeat:
                                    {
@@ -2514,6 +2723,11 @@
                            strtext = Language.StringByID(StringId.co2) + new PublicInterface { }.GetString("co2", value);
                        }
                        break;
                    case "pm10":
                        {
                            strtext = Language.StringByID(StringId.pm10) + new PublicInterface { }.GetString("pm25", value);
                        }
                        break;
                    case "pm25":
                        {
                            strtext = Language.StringByID(StringId.pm25) + new PublicInterface { }.GetString("pm25", value);
@@ -2540,8 +2754,9 @@
            Input inputedit = Logic.currlogic.input[indexVulae];
            ///状态值
            string stateValue = "";
            foreach (var dic in inputedit.condition)
            for (int i=0;i<inputedit.condition.Count;i++)
            {
                var dic = inputedit.condition[i];
                string comparator = dic["comparator"];
                stateValue = dic["value"];
                switch (key)
@@ -2580,6 +2795,11 @@
                            ConditionDeviceFunList.Current.PmCo2TvocAction(thisView, device, "co2", StringId.co2, indexVulae, true, stateValue);
                        }
                        break;
                    case "pm10":
                        {
                            ConditionDeviceFunList.Current.PmCo2TvocAction(thisView, device, "pm10", StringId.pm10, indexVulae, true, stateValue);
                        }
                        break;
                    case "pm25":
                        {
                            ConditionDeviceFunList.Current.PmCo2TvocAction(thisView, device, "pm25", StringId.pm25, indexVulae, true, stateValue);
@@ -2599,7 +2819,7 @@
            }
        }
        /// <summary>
        /// 查找指定userId
        /// 查找指定可视对讲userId
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns> 
@@ -2616,6 +2836,24 @@
            }
            return face;
        }
        /// <summary>
        /// 查找指定萤石视频门锁userId
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public Face GetVideoDoorLockUserItem(string userId, Function device)
        {
            if (Send.Current.VideoDoorLockUserListInfo.Count == 0)
            {
                Send.Current.GetVideoDoorLockUserListInfo(device);
            }
            var face = Send.Current.VideoDoorLockUserListInfo.Find((o) => { return o.userId == userId; });
            if (face == null)
            {
                face = new Face();
            }
            return face;
        }
    }
}