wxr
2021-01-28 48c07e0a371f67b97abc7c2e61d7f23d060324fc
HDL_ON/Entity/Function/Function.cs
old mode 100644 new mode 100755
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using HDL_ON.Common;
using HDL_ON.DAL.Server;
@@ -70,39 +70,82 @@
        /// 设备spk
        /// </summary>
        public string spk = "";
        /// <summary>
        /// 功能类别
        /// 如:空调类、灯光类、窗帘类
        /// </summary>
        public FunctionCategory functionCategory
        {
            get
            {
                try
                {
                    var _functionCategoryString = sid.Substring(16, 2);
                    var _functionCategory = Convert.ToInt32(_functionCategoryString, 16);
                    return (FunctionCategory)Enum.ToObject(typeof(FunctionCategory), _functionCategory);
                }
                catch (Exception ex)
                {
                    MainPage.Log($"get FunctionCategory error : {ex.Message}");
                    return FunctionCategory.UnKown;
                }
            }
        }
        ///// <summary>
        ///// 功能类别
        ///// 如:空调类、灯光类、窗帘类
        ///// </summary>
        //public FunctionCategory Spk_Prefix
        //{
        //    get
        //    {
        //        try
        //        {
        //            var _functionCategoryString = sid.Substring(16, 2);
        //            var _functionCategory = Convert.ToInt32(_functionCategoryString, 16);
        //            return (FunctionCategory)Enum.ToObject(typeof(FunctionCategory), _functionCategory);
        //        }
        //        catch (Exception ex)
        //        {
        //            MainPage.Log($"get FunctionCategory error : {ex.Message}");
        //            return FunctionCategory.UnKown;
        //        }
        //    }
        //}
        ///// <summary>
        ///// 功能类型
        ///// </summary>
        public FunctionType functionType
        //public FunctionType spk
        //{
        //    get
        //    {
        //        var _functionTypeString = sid.Substring(16, 4);
        //        return (FunctionType)Enum.ToObject(typeof(FunctionType), Convert.ToInt32(_functionTypeString, 16));
        //    }
        //}
        string spk_Prefix;
        /// <summary>
        /// spk前缀
        /// 大类
        /// 功能类别
        /// 如:空调类、灯光类、窗帘类
        /// </summary>
        public string Spk_Prefix
        {
            get
            {
                var _functionTypeString = sid.Substring(16, 4);
                return (FunctionType)Enum.ToObject(typeof(FunctionType), Convert.ToInt32(_functionTypeString, 16));
                if (string.IsNullOrEmpty(spk_Prefix))
                {
                    spk_Prefix = spk.Split(".")[0];
                }
                return spk_Prefix;
            }
        }
        string spk_Suffix;
        ///// <summary>
        ///// spk后缀
        ///// 小类
        ///// 功能类型
        ///// </summary>
        //public string spk
        //{
        //    get
        //    {
        //        if (string.IsNullOrEmpty(spk_Suffix))
        //        {
        //            try
        //            {
        //                spk_Suffix = spk.Split(".")[1];
        //            }
        //            catch
        //            {
        //                spk_Suffix = "";
        //            }
        //        }
        //        return spk_Suffix;
        //    }
        //}
        /// <summary>
        /// A协议功能的特性
@@ -178,16 +221,12 @@
                        _trait_on_off.curValue = "off";
                    }
                }
                if(_trait_on_off.curValue.ToString() != "on"&& _trait_on_off.curValue.ToString() != "off")
                if(_trait_on_off.curValue.ToString() != "on"&& _trait_on_off.curValue.ToString() != "off" && _trait_on_off.curValue.ToString() != "stop")
                {
                    _trait_on_off.curValue = "off";
                }
                return _trait_on_off;
            }
            //set
            //{
            //    _trait_on_off = value;
            //}
        }
        /// <summary>
@@ -299,7 +338,7 @@
                }
                roomNameList += findRoom.floorName +"-"+ findRoom.roomName;
            }
            if (roomNameList == "" && functionType == FunctionType.Scene)
            if (roomNameList == "" )
            {
                roomNameList = Language.StringByID(StringId.WholeZone);
            }
@@ -350,6 +389,7 @@
        /// </summary>
        public void UpdataFuncitonInfo()
        {
            new System.Threading.Thread(() =>
            {
                var pm = new HttpServerRequest();
                var pack = pm.UpdataDevcieInfo(this);
@@ -609,7 +649,19 @@
        /// 当前值
        /// </summary>
        public object curValue = new object();
        /// <summary>
        /// curValue的翻译值,最坏的结果也只会返回string.Empty
        /// </summary>
        public string realValue
        {
            get
            {
                var myValue = curValue.ToString();
                //沙雕定义的object类型
                if (myValue.Contains("{") == true) { return string.Empty; }
                return myValue;
            }
        }
    }
    /// <summary>
    /// 功能属性键名列表
@@ -797,10 +849,36 @@
        /// 湿度传感器
        /// </summary>
        public const string SensorHumidity = "sensor.humidity";
        /// <summary>
        /// 烟雾传感器
        /// </summary>
        public const string SensorSmoke = "sensor.smoke";
        /// <summary>
        /// 水浸传感器
        /// </summary>
        public const string SensorWater = "sensor.water";
        /// <summary>
        /// 燃气传感器
        /// </summary>
        public const string SensorGas= "sensor.gas";
        /// <summary>
        /// 红外珊栏传感器
        /// </summary>
        public const string SensorShanLan = "sensor.shanlan";
        /// <summary>
        /// 红外对射传感器
        /// </summary>
        public const string SensorDuiShe = "sensor.duishe";
        /// <summary>
        /// 超声波传感器
        /// </summary>
        public const string SensoruUtrasonic = "sensor.ultrasonic";
        /// <summary>
        /// (干接点)
        /// </summary>
        public const string DryContact = "dryContact.standard";
        public const string SensorDryContact = "sensor.dryContact";
        /// <summary>
        /// 家电、插座
        /// </summary>
@@ -812,7 +890,66 @@
        /// <summary>
        /// 家电、风扇
        /// </summary>
        public const string ElectricFan = "electrical.fan";
        public const string ElectricFan = "electrical.fan";
        /// <summary>
        /// 家电、涂鸦空气净化器
        /// </summary>
        public const string ElectricTuyaAirCleaner = "electrical.Q1RsefNf91tIXyyQ";
        /// <summary>
        /// 家电、涂鸦电风扇
        /// </summary>
        public const string ElectricTuyaFan = "electrical.tyqborgovyzytytz";
        /// <summary>
        /// 家电、涂鸦扫地机器人
        /// </summary>
        public const string ElectricTuyaWeepRobot = "electrical.ai6HtccKFIw3dxo3";
    }
    /// <summary>
    /// 功能类别
    /// </summary>
    public static class FunctionCategory
    {
        /// <summary>
        ///(灯)
        /// </summary>
        public const string Light = "light";
        /// <summary>
        /// (窗帘)
        /// </summary>
        public const string Curtain = "curtain";
        /// <summary>
        /// (空调)
        /// </summary>
        public const string AC = "ac";
        /// <summary>
        /// (地热)
        /// </summary>
        public const string FloorHeat = "floorHeat";
        /// <summary>
        /// (新风)
        /// </summary>
        public const string AirFresh = "airFresh";
        /// <summary>
        /// (音乐)
        /// </summary>
        public const string Music = "music";
        /// <summary>
        /// (传感器)
        /// </summary>
        public const string Sensor = "sensor";
        /// <summary>
        /// (干接点)
        /// </summary>
        public const string DryContact = "dryContact";
        /// <summary>
        /// 家电
        /// </summary>
        public const string Electric = "electrical";
        //Music = 0x09,
    }
}