wei
2021-07-09 068c68295cad1967f7aafb4e5e951260ef03d4ce
HDL_ON/Entity/Function/Function.cs
@@ -134,7 +134,6 @@
            else
            {
                attr.state = value.ToString();
                attr.curValue = value.ToString();
            }
            return true;
        }
@@ -271,12 +270,12 @@
                            max = 1,
                            min = 0,
                        };
                        _trait_on_off.curValue = "off";
                        _trait_on_off.state = "off";
                    }
                }
                if(_trait_on_off.curValue.ToString() != "on"&& _trait_on_off.curValue.ToString() != "off" && _trait_on_off.curValue.ToString() != "stop")
                if(_trait_on_off.state.ToString() != "on"&& _trait_on_off.state.ToString() != "off" && _trait_on_off.state.ToString() != "stop")
                {
                    _trait_on_off.curValue = "off";
                    _trait_on_off.state = "off";
                }
                return _trait_on_off;
            }
@@ -427,6 +426,19 @@
            var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
            FileUtlis.Files.WriteFileByBytes(savePath, ssd);
        }
        /// <summary>
        /// 通过状态列表组装属性里面的状态
        /// </summary>
        public void AssembleStatus()
        {
            foreach(var sta in status)
            {
                SetAttrState(sta.key, sta.value);
            }
        }
        /// <summary>
        /// 保存房间绑定信息
        /// </summary>
@@ -506,39 +518,39 @@
                    case FunctionAttributeKey.FanSpeed:
                    case FunctionAttributeKey.Percent:
                    //case FunctionAttributeKey.FadeTime:
                        if (attr.curValue.ToString() == "{}")
                        if (attr.state.ToString() == "{}")
                        {
                            if (attr.key == FunctionAttributeKey.OnOff)
                            {
                                attr.curValue = "off";
                                attr.state = "off";
                            }
                            else if (attr.key == FunctionAttributeKey.Mode )
                            {
                                if (DB_ResidenceData.Instance.GatewayType == 0)
                                {
                                    attr.curValue = "0";
                                    attr.state = "0";
                                }
                                else
                                {
                                    if (SPK.AcSpkList().Contains(spk))
                                    {
                                        attr.curValue = "cool";
                                        attr.state = "cool";
                                    }
                                    else if (SPK.FhSpkList().Contains(spk))
                                    {
                                        attr.curValue = "day";
                                        attr.state = "day";
                                    }
                                }
                            }
                            else 
                            {
                                attr.curValue = "0";
                                attr.state = "0";
                            }
                        }
                        if (attr.key == FunctionAttributeKey.SetTemp)
                        {
                            double vv = 16;
                            Double.TryParse(attr.curValue.ToString(), out vv);
                            Double.TryParse(attr.state.ToString(), out vv);
                            if (vv == 0)
                            {
                                vv = 26;
@@ -547,7 +559,7 @@
                        }
                        else
                        {
                            sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString() });
                            sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.state.ToString() });
                        }
                        break;
                }
@@ -681,6 +693,20 @@
        public string value = "";
    }
    public class attttttt
    {
        /// <summary>
        /// 当前状态
        /// </summary>
        public string state = "";
        /// <summary>
        /// 当前值
        /// </summary>
        public object curValue = new object();
    }
    /// <summary>
    /// 功能属性
    /// 属性字段解析:attri :属性内容,value 属性的值,max 最大值 min 最小值
@@ -712,10 +738,6 @@
        /// 当前状态
        /// </summary>
        public string state = "";
        /// <summary>
        /// 当前值
        /// </summary>
        public object curValue = new object();
    }
    /// <summary>