wxr
2023-07-30 d76b0e40e5bb127fd33aa1f7842447a1df0628d5
HDL_ON/Entity/Function/Function.cs
@@ -100,7 +100,7 @@
        /// <returns></returns>
        public FunctionAttributes GetAttribute(string key)
        {
            var attr = attributes.Find((a) => a.key == key);
            var attr = GetFunctionAttributes().Find((a) => a.key == key);
            return attr;
        }
@@ -109,7 +109,7 @@
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public string GetAttrState(string key , string defaultValue = "0")
        public string GetAttrState(string key, string defaultValue = "0")
        {
            //一级查询keyValue值
            var attrState = attributes.Find((s) => s.key == key.ToString());
@@ -171,6 +171,9 @@
                string iconPath = spk.Replace(".", "");
                switch (spk)
                {
                    case SPK.AirSwitchP3:
                        iconPath = "electricalbreaker";
                        break;
                    case SPK.PanelSocket:
                        iconPath = "electricalsocket";
                        break;
@@ -279,7 +282,7 @@
        /// <summary>
        /// 物理设备(模块)型号
        /// </summary>
        public string omodel =string.Empty;
        public string omodel = string.Empty;
        /// <summary>
        /// 设备spk
        /// </summary>
@@ -372,6 +375,39 @@
        /// attri
        /// </summary>
        public List<FunctionAttributes> attributes = new List<FunctionAttributes>();
        public List<FunctionAttributes> GetFunctionAttributes()
        {
            if (spk == SPK.GroupControl)
            {
                var list = new List<FunctionAttributes>();
                var gc = FunctionList.List.groupControls.Find((obj) => obj.sid == sid);
                if (gc != null)
                {
                    foreach (var temp in gc.sids)
                    {
                        var light = FunctionList.List.GetLightList().Find((obj) => obj.sid == temp.sid);
                        if (light != null)
                        {
                            foreach (var attr in light.attributes)
                            {
                                if (list.Find((obj) => obj.key == attr.key) == null)
                                {
                                    list.Add(attr);
                                }
                            }
                        }
                    }
                }
                return list;
            }
            else
            {
                return attributes;
            }
        }
        /// <summary>
        /// 房间ID列表
@@ -694,9 +730,9 @@
        /// <summary>
        /// 保存房间绑定信息
        /// </summary>
        public void UpdataRoomIds()
        public async void UpdataRoomIds()
        {
            new System.Threading.Thread(() =>
            new System.Threading.Thread( () =>
            {
                var pack = ApiUtlis.Ins.HttpRequest.UpdataDevcieBindRoomInfo(this);
                //直接保存本地,
@@ -766,7 +802,38 @@
        public SceneFunction ConvertSceneFunction()
        {
            var sFunc = new SceneFunction();
            foreach (var attr in attributes)
            var list = new List<FunctionAttributes>();
            if (spk == SPK.GroupControl)
            {
                lock (list)
                {
                    var gc = FunctionList.List.groupControls.Find((obj) => obj.sid == sid);
                    if (gc != null)
                    {
                        foreach (var temp in gc.sids)
                        {
                            var light = FunctionList.List.GetLightList().Find((obj) => obj.sid == temp.sid);
                            if (light != null)
                            {
                                foreach (var attr in light.attributes)
                                {
                                    if (list.Find((obj) => obj.key == attr.key) == null)
                                    {
                                        list.Add(attr);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                list.AddRange(attributes);
            }
            foreach (var attr in list)
            {
                //窗帘同时发送开关跟百分比会有问题,
                if(spk == SPK.CurtainRoller || spk == SPK.CurtainTrietex || spk == SPK.CurtainDream)
@@ -778,7 +845,35 @@
                            continue;
                        }
                    }
                }else if (spk == SPK.GroupControl)
                {
                    sFunc.type = "5";
                }
                string us = "";
                switch (attr.key)
                {
                    case FunctionAttributeKey.SetTemp:
                    case FunctionAttributeKey.RoomTemp:
                        us = "°C";
                        var tempType = attributes.Find((obj) => obj.key == FunctionAttributeKey.TempType);
                        if (tempType != null)
                        {
                            us = tempType.curValue.ToString();
                        }
                        break;
                    case FunctionAttributeKey.Percent:
                    case FunctionAttributeKey.Brightness:
                        us = "%";
                        break;
                    case FunctionAttributeKey.CCT:
                        us = "K";
                        break;
                    case FunctionAttributeKey.Angle:
                        us = "°";
                        break;
                }
                switch (attr.key)
                {
@@ -791,11 +886,15 @@
                    case FunctionAttributeKey.CCT:
                    case FunctionAttributeKey.RGB:
                    case FunctionAttributeKey.Angle:
                    case FunctionAttributeKey.Colorful:
                    case FunctionAttributeKey.ColorfulBegin:
                    case FunctionAttributeKey.ColorfulEnd:
                    case FunctionAttributeKey.ColorfulTime:
                    case "security":
                        //case FunctionAttributeKey.FadeTime:
                        if (attr.curValue.ToString() == "{}")
                        {
                            if (attr.key == FunctionAttributeKey.OnOff)
                            if (attr.key == FunctionAttributeKey.OnOff || attr.key == FunctionAttributeKey.Colorful)
                            {
                                attr.curValue = "off";
                            }
@@ -834,13 +933,16 @@
                            {
                                vv = 26;
                            }
                            sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = Convert.ToInt32(vv).ToString(), max = attr.max, min = attr.min });
                            sFunc.status.Add(new SceneFunctionStatus() {
                                UintString = us,
                                key = attr.key, value = Convert.ToInt32(vv).ToString(), max = attr.max, min = attr.min }) ;
                        }
                        else
                        {
                            sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString(), max = attr.max, min = attr.min });
                            sFunc.status.Add(new SceneFunctionStatus() {
                                UintString = us,
                                key = attr.key, value = attr.curValue.ToString(), max = attr.max, min = attr.min });
                        }
                        break;
                }
            }
@@ -1045,6 +1147,10 @@
        /// 当前值
        /// </summary>
        public object curValue = new object();
        /// <summary>
        /// 属性单位
        /// </summary>
        public string unit=string.Empty;
    }
    /// <summary>
@@ -1052,6 +1158,79 @@
    /// </summary>
    public static class FunctionAttributeKey
    {
        #region 三相空开属性
        /// <summary>
        /// A相功率
        /// </summary>
        public const string PowerA = "power_a";
        /// <summary>
        /// B相功率
        /// </summary>
        public const string PowerB = "power_b";
        /// <summary>
        /// C相功率
        /// </summary>
        public const string PowerC = "power_c";
        /// <summary>
        /// A相电压
        /// </summary>
        public const string VoltageA = "voltage_a";
        /// <summary>
        /// B相电压
        /// </summary>
        public const string VoltageB = "voltage_b";
        /// <summary>
        /// C相电压
        /// </summary>
        public const string VoltageC = "voltage_c";
        /// <summary>
        /// A相电流
        /// </summary>
        public const string CurrentA = "current_a";
        /// <summary>
        /// B相电流
        /// </summary>
        public const string CurrentB = "current_b";
        /// <summary>
        /// C相电流
        /// </summary>
        public const string CurrentC = "current_c";
        /// <summary>
        /// A相温度
        /// </summary>
        public const string TempA = "temp_a";
        /// <summary>
        /// B相温度
        /// </summary>
        public const string TempB = "temp_b";
        /// <summary>
        /// C相温度
        /// </summary>
        public const string TempC = "temp_c";
        /// <summary>
        /// 过流值
        /// </summary>
        public const string MaxCurrent = "max_current";
        /// <summary>
        /// 过温值
        /// </summary>
        public const string MaxTemp = "max_temp";
        /// <summary>
        /// A相电量
        /// </summary>
        public const string ElectricityA = "electricity_a";
        /// <summary>
        /// B相电量
        /// </summary>
        public const string ElectricityB = "electricity_b";
        /// <summary>
        /// C相电量
        /// </summary>
        public const string ElectricityC = "electricity_c";
        #endregion
        public const string _null = "";
        /// <summary>
        /// 安防布防状态
@@ -1065,6 +1244,22 @@
        /// 亮度
        /// </summary>
        public const string Brightness = "brightness";
        /// <summary>
        /// 炫彩开关
        /// </summary>
        public const string Colorful = "colorful";
        /// <summary>
        /// 炫彩开启颜色
        /// </summary>
        public const string ColorfulBegin = "colorful_begin";
        /// <summary>
        /// 炫彩结束颜色
        /// </summary>
        public const string ColorfulEnd = "colorful_end";
        /// <summary>
        /// 炫彩运行时间
        /// </summary>
        public const string ColorfulTime = "colorful_time";
        /// <summary>
        /// 颜色
        /// </summary>
@@ -1376,11 +1571,15 @@
        /// <summary>
        /// 群控(自定义)
        /// </summary>
        public const string GroupControl = "GroupControl";
        public const string GroupControl = "groupControl";
        /// <summary>
        /// 通用开关
        /// </summary>
        public const string OtherCommon = "other.common";
        /// <summary>
        /// 序列
        /// </summary>
        public const string CommonSeries = "other.series";
        /// <summary>
        /// 大华摄像头
        /// </summary>
@@ -1418,9 +1617,14 @@
        
        /// <summary>
        /// 猫眼
        /// 猫眼(旧spk)
        /// </summary>
        public const string Peephole = "peephole";
        /// <summary>
        /// 猫眼(新spk 暂时没用)
        /// </summary>
        //public const string PeepholeEz = "security.peephole.ez";
        /// <summary>
        /// 萤石视频门锁
        /// </summary>
@@ -1681,6 +1885,10 @@
        /// </summary>
        public const string SensorPir = "sensor.pir";
        /// <summary>
        /// 人体存在传感器
        /// </summary>
        public const string SensorPirHold = "sensor.pir_hold";
        /// <summary>
        /// (门窗传感器)
        /// </summary>
        public const string SensorDoorWindow = "sensor.doorwindow";
@@ -1735,6 +1943,7 @@
            var spkList = new List<string>();
            //spkList.Add(SensorLight);
            spkList.Add(SensorPir);
            spkList.Add(SensorPirHold);
            spkList.Add(SensorHelp);
            spkList.Add(SensorDoorWindow);
            spkList.Add(SensorSmoke);
@@ -1925,6 +2134,10 @@
        /// 智能空开
        /// </summary>
        public const string AirSwitch = "electrical.breaker";
        /// <summary>
        /// 三相智能空开
        /// </summary>
        public const string AirSwitchP3 = "electrical.breakerP3";
        #region 涂鸦
        /// <summary>
@@ -1978,6 +2191,7 @@
            spkList.Add(ElectricTuyaWaterValve);
            spkList.Add(ElectricTuyaWaterValve2);
            spkList.Add(AirSwitch);
            spkList.Add(AirSwitchP3);
            return spkList;
        }