wei
2020-12-04 6ba43603ccd8868a4ee73e9b978b7cb20a5b2c52
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
@@ -73,6 +73,54 @@
            }
            return logicId;
        }
        /// <summary>
        /// 生成逻辑sid方法
        /// </summary>
        //public static string NewSid()
        //{
        //    String sLogicid = "";
        //    try
        //    {
        //        String sOidBeginsWith = "000101";//厂商 + 通讯方式
        //        //生成4个byte时间戳
        //        DateTime dt = DateTime.Now;
        //        long sTimeSp = GateWay.ConvertDateTimeLong(dt);
        //        string sTimeSpan = "";
        //        GateWay.ConvertIntToByteArray(sTimeSp, ref sTimeSpan);
        //        if (sTimeSpan.Length != 8) return sLogicid;
        //        //间隔10毫秒 错开时间戳
        //        HDLUDP.TimeBetwnNext(10);
        //        sLogicid = sOidBeginsWith + sTimeSpan;
        //        //1501 物模型为自动化, 0001 表示 1 号自动化功能
        //        sLogicid += "15";
        //        sLogicid += "1501";
        //        //自动化号自增
        //        int iTopSceneId = 1;
        //        if (myGateway.LogicResponse != null)
        //        {
        //            if (myGateway.LogicResponse.objects != null)
        //            {
        //                for (int i = 0; i < myGateway.LogicResponse.objects.Count; i++)
        //                {
        //                    string ccc = myGateway.LogicResponse.objects[i].sid.Substring(myGateway.LogicResponse.objects[i].sid.Length - 8, 4);
        //                    int iThisSceneId = Convert.ToInt16(myGateway.LogicResponse.objects[i].sid.Substring(myGateway.LogicResponse.objects[i].sid.Length - 8, 4), 16);
        //                    if (iThisSceneId >= iTopSceneId)
        //                        iTopSceneId = iThisSceneId + 1;
        //                }
        //            }
        //        }
        //        sLogicid += iTopSceneId.ToString("X4");//场景号 两个byte
        //                                               //大类小类没有用到 固定为0
        //        sLogicid += "0000";
        //        return sLogicid;
        //    }
        //    catch
        //    {
        //        return sLogicid;
        //    }
        //}
        /// <summary>
        /// 封装Dictionary对象
        /// </summary>
@@ -123,8 +171,81 @@
        /// <returns></returns>
        public static List<HDL_ON.Entity.Function> GetGatewayDeviceList()
        {
            List<HDL_ON.Entity.Function> list = new List<Entity.Function>();
            for (int i=0;i<10;i++) {
                HDL_ON.Entity.Function function = new Entity.Function();
                switch (i) {
                    case 0: {
                            function.sid = "1234560001212121020182";
                            function.name ="灯光";
                            list.Add(function);
                        }
                        break;
                    case 1: {
                            function.sid = "1234560001212121030182";
                            function.name = "窗帘";
                            list.Add(function);
                        } break;
                    case 2: {
                            function.sid = "1234560001212121040182";
                            function.name = "空调";
                            list.Add(function);
                        } break;
                    case 3:
                        {
                            function.sid = "1234560001212121010282";
                            function.name = "RGBW";
                            list.Add(function);
                        }
                        break;
                    case 4:
                        {
            return HDL_ON.Entity.DB_ResidenceData.functionList.GetAllFunction();
                            function.sid = "1234560001212121010382";
                            function.name = "CCT灯";
                            list.Add(function);
                        }
                        break;
                    case 5:
                        {
                            function.sid = "1234560001212121010482";
                            function.name = "开合帘";
                            list.Add(function);
                        }
                        break;
                    case 6:
                        {
                            function.sid = "1234560001212121010582";
                            function.name = "卷帘";
                            list.Add(function);
                        }
                        break;
                    case 7:
                        {
                            function.sid = "1234560001212121040282";
                            function.name = "地热";
                            list.Add(function);
                        }
                        break;
                    case 8:
                        {
                            function.sid = "1234560001212121020282";
                            function.name = "调关";
                            list.Add(function);
                        }
                        break;
                    case 9:
                        {
                            function.sid = "1234560001212121020482";
                            function.name = "RGB";
                            list.Add(function);
                        }
                        break;
                }
            }
            return list;
            //return HDL_ON.Entity.DB_ResidenceData.functionList.GetAllFunction();
        }
        /// <summary>
        /// 获取网关场景列表
@@ -229,8 +350,29 @@
            switch (functionType)
            {
                case FunctionType.Relay:
                case FunctionType.RGB:
                case FunctionType.RGBW:
                case FunctionType.CCT:
                case FunctionType.Dimmer:
                    {
                        strPath = "LogicIcon/lightloguc.png";
                    }
                    break;
                case FunctionType.Curtain:
                case FunctionType.RollerCurtain:
                case FunctionType.TrietexCurtain:
                    {
                        strPath = "LogicIcon/curtainlogic.png";
                    }
                    break;
                case FunctionType.AC:
                    {
                        strPath = "LogicIcon/airconditionerlogic.png";
                    }
                    break;
                case FunctionType.FloorHeating:
                    {
                        strPath = "LogicIcon/heatlogic.png";
                    }
                    break;
@@ -246,13 +388,13 @@
        {
            List<string> deviceStrTypeList = new List<string>(); 
            deviceStrTypeList.Clear();
            var lightjosn = deviceList.Find((device) => device.functionType == FunctionType.Relay || device.functionType == FunctionType.Dimmer);
            var lightjosn = deviceList.Find((device) => device.functionType == FunctionType.Relay || device.functionType == FunctionType.Dimmer|| device.functionType == FunctionType.CCT || device.functionType == FunctionType.RGB|| device.functionType == FunctionType.RGBW);
            if (lightjosn != null)
            {
                deviceStrTypeList.Add(Language.StringByID(StringId.Lights));
            }
            var curtainjosn = deviceList.Find((device) => device.functionType ==FunctionType.Curtain);
            var curtainjosn = deviceList.Find((device) => device.functionType ==FunctionType.Curtain|| device.functionType == FunctionType.TrietexCurtain|| device.functionType == FunctionType.RollerCurtain);
            if (curtainjosn != null)
            {
                deviceStrTypeList.Add(Language.StringByID(StringId.Curtain));
@@ -262,6 +404,11 @@
            if (ac != null)
            {
                deviceStrTypeList.Add(Language.StringByID(StringId.AC));
            }
            var floorHeating = deviceList.Find((device) => device.functionType == FunctionType.FloorHeating);
            if (ac != null)
            {
                deviceStrTypeList.Add(Language.StringByID(StringId.FloorHeating));
            }
            return deviceStrTypeList;
@@ -278,10 +425,23 @@
            {
                functionTypeList.Add(FunctionType.Relay);
                functionTypeList.Add(FunctionType.Dimmer);
                functionTypeList.Add(FunctionType.RGB);
                functionTypeList.Add(FunctionType.RGBW);
                functionTypeList.Add(FunctionType.CCT);
            }
            else if (deviceType == Language.StringByID(StringId.Curtain))
            {
                functionTypeList.Add(FunctionType.Curtain);
                functionTypeList.Add(FunctionType.RollerCurtain);
                functionTypeList.Add(FunctionType.TrietexCurtain);
            }
            else if (deviceType == Language.StringByID(StringId.AC))
            {
                functionTypeList.Add(FunctionType.AC);
            }
            else if (deviceType == Language.StringByID(StringId.FloorHeating))
            {
                functionTypeList.Add(FunctionType.FloorHeating);
            }
            return functionTypeList;
@@ -296,11 +456,29 @@
            switch (if_type) {
                case condition_if: {
                        deviceTypeList.Add(FunctionType.Relay);
                        deviceTypeList.Add(FunctionType.RGB);
                        deviceTypeList.Add(FunctionType.RGBW);
                        deviceTypeList.Add(FunctionType.Dimmer);
                        deviceTypeList.Add(FunctionType.CCT);
                        deviceTypeList.Add(FunctionType.Curtain);
                        deviceTypeList.Add(FunctionType.RollerCurtain);
                        deviceTypeList.Add(FunctionType.TrietexCurtain);
                        deviceTypeList.Add(FunctionType.AC);
                        deviceTypeList.Add(FunctionType.FloorHeating);
                    }
                    break;
                case target_if:
                    {
                        deviceTypeList.Add(FunctionType.Relay);
                        deviceTypeList.Add(FunctionType.RGB);
                        deviceTypeList.Add(FunctionType.RGBW);
                        deviceTypeList.Add(FunctionType.Dimmer);
                        deviceTypeList.Add(FunctionType.CCT);
                        deviceTypeList.Add(FunctionType.Curtain);
                        deviceTypeList.Add(FunctionType.RollerCurtain);
                        deviceTypeList.Add(FunctionType.TrietexCurtain);
                        deviceTypeList.Add(FunctionType.AC);
                        deviceTypeList.Add(FunctionType.FloorHeating);
                    }
                    break;
            }