CrabtreeOn,印度客户定制APP,迁移2.0平台版本
JLChen
2021-01-20 4c993fcb71b92f8e9837ca8f50f3b5e8f9c59cfe
Crabtree/SmartHome/HDL/Common/HDLLinkUtlis.cs
@@ -27,6 +27,9 @@
//        }
//        #endregion
//        /// <summary>
//        /// 将在线设备转换成sid + 属性列表
//        /// </summary>
@@ -51,13 +54,13 @@
//                }
//                if (onlineDevice.bytSimpleParam != null && onlineDevice.bytSimpleParam.Length > 0) {
//                    for (int intI = 0; intI < onlineDevice.bytSimpleParam.Length / 3; intI++) {
//                        Byte BigType = onlineDevice.bytSimpleParam [0 + intI * 3];
//                        Byte SmallType = onlineDevice.bytSimpleParam [1 + intI * 3];
//                        byte BigType = onlineDevice.bytSimpleParam [0 + intI * 3];
//                        byte SmallType = onlineDevice.bytSimpleParam [1 + intI * 3];
//                        int Count = onlineDevice.bytSimpleParam [2 + intI * 3];
//                        if (Count > 0) {
//                            for (int j = 1; j <= Count; j++) {
//                                Sid tmpSid = new Sid ();
//                                tmpSid.sid = HDLSysPF.FormingNewSid (onlineDevice.DeviceType, sOid, j, false, BigType, SmallType);
//                                tmpSid.sid = HDLSysPF.FormingNewSid (onlineDevice.Type, sOid, j, false, BigType, SmallType);
//                                tmpSid.oid = sOid;
//                                try {
@@ -181,50 +184,116 @@
//        /// </summary>
//        /// <param name="iDeviceType"></param>
//        /// <returns></returns>
//        public string FormingNewOid (int iDeviceType)
//        public string FormingNewOid (DeviceType deviceType)
//        {
//            string sOid = "";
//            try {
//                //1.生成 厂商 + 通讯方式
//                string sOidBeginsWith = "000101";//厂商 + 通讯方式
//                long sTimeSp = HDLSysPF.ConvertDateTimeLong ();
//                //2.生成产品时间戳
//                long sTimeSp = ConvertDateTimeLong (); //以2020年1月1日算出的时间戳0.1s为单位
//                string sTimeSpan = "";
//                GateWay.ConvertIntToByteArray (sTimeSp, ref sTimeSpan);
//                ConvertIntToByteArray (sTimeSp, ref sTimeSpan);
//                if (sTimeSpan.Length != 8) return sOid;
//                HDLUDP.TimeBetwnNext (10);
//                sOid = sOidBeginsWith + sTimeSpan;
//                if (iDeviceType == 00
//                    || DimmerDeviceTypeList.HDLDimmerDeviceTypeList.Contains (iDeviceType)
//                 || DMXDeviceTypeList.HDLDMXDeviceTypeList.Contains (iDeviceType))//调光器 20200730类
//                {
//                    sOid += "01";
//                } else if (RelayDeviceTypeList.HDLRelayDeviceTypeList.Contains (iDeviceType))//继电器类
//                  {
//                    sOid += "02";
//                } else if (CurtainDeviceType.HDLCurtainModuleDeviceType.Contains (iDeviceType))//遮阳类(窗帘)
//                  {
//                    sOid += "03";
//                } else if (HVACModuleDeviceTypeList.HDLHVACModuleDeviceTypeLists.Contains (iDeviceType) || FloorheatingDeviceTypeList.HDLFloorHeatingDeviceType.Contains (iDeviceType))//恒温器(空调)
//                  {
//                    sOid += "12";
//                } else if (AudioDeviceTypeList.AudioBoxDeviceTypeList.Contains (iDeviceType)) {
//                    sOid += "10";
//                } else if (Eightin1DeviceTypeList.HDL8in1DeviceType.Contains (iDeviceType)
//                      || Sevenin1DeviceTypeList.HDL7in1DeviceType.Contains (iDeviceType)
//                      || Twelvein1DeviceTypeList.HDL12in1DeviceType.Contains (iDeviceType))//传感器类
//                  {
//                    sOid += "04";
//                } else {
//                    sOid += "07"; //网关产品
//                }
//                //延迟10ms
//                //3.生成产品类别
//                var productType = GetProductType (deviceType);
//                sOid = sOidBeginsWith + sTimeSpan + productType;
//                return sOid;
//            } catch {
//                return sOid;
//            }
//        }
//        /// <summary>
//        /// 获取产品类别
//        //产品类别 1byte
//        //编号   描述
//      //01   调光器
//      //02   继电器
//      //03   干接点模块
//      //04   传感器
//      //05   面板
//      //06   RCU
//      //07   网关
//      //08   红外发射
//      //09   Android屏
//      //10   场景
//      //11   音乐播放器
//      //12   232/485转换器
//      //21   自动化
//        //22   安防防区
//        //14   窗帘模块
//        //15   HVAC
//        //16   地热模块
//        /// </summary>
//        /// <param name="deviceType"></param>
//        /// <returns></returns>
//        public string GetProductType (DeviceType deviceType)
//        {
//            string productType = "";
//            switch (deviceType) {
//            case DeviceType.LightDimming:
//                productType = "01";//01   调光器
//                break;
//            case DeviceType.LightSwitch:
//                productType = "02";//02 继电器类
//                break;
//            case DeviceType.CurtainModel:
//            case DeviceType.CurtainRoller:
//            case DeviceType.CurtainTrietex:
//                productType = "03";//03   遮阳类(窗帘)
//                break;
//            case DeviceType.SensorWindSpeed:
//                productType = "04";//04   传感器)
//                break;
//            case DeviceType.OnePortWirelessFR:
//            case DeviceType.OnePortBus:
//            case DeviceType.RCU:
//            case DeviceType.SuperWireless:
//            case DeviceType.OnePortMqttFR:
//                productType = "07";//07   网关类
//                break;
//            case DeviceType.ACPanel:
//            case DeviceType.ACDevice:
//            case DeviceType.ACInfrared:
//            case DeviceType.ACCoolmaster:
//            case DeviceType.CustomAC:
//            case DeviceType.HVAC:
//            case DeviceType.FoolHeat:
//            case DeviceType.FoolHeatPanel:
//                productType = "12";//12 恒温器(空调、地热)
//                break;
//            }
//            return productType;
//        }
//        /// <summary>
//        /// 获取生成物理模型参数
//        /// </summary>
//        /// <param name="deviceType"></param>
//        /// <returns></returns>
//        public string GetPhysicalModelType (DeviceType deviceType)
//        {
//            string productType = "";
//            switch (deviceType) {
//            case DeviceType.LightDimming:
//                productType = "0101";
//                break;
//            }
//            return productType;
//        }
//        /// <summary>
//        /// 生成功能设备Sid
@@ -300,6 +369,33 @@
//            }
//        }
//        private long LastTime = 0;
//        /// <summary>
//        /// DateTime时间格式转换为13位带毫秒的Unix时间戳
//        /// </summary>
//        /// <param name="time"> DateTime时间格式</param>
//        /// <returns>Unix时间戳格式</returns>
//        public long ConvertDateTimeLong ()
//        {
//            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime (new System.DateTime (2020, 1, 1));
//            long l = (long)(Math.Round ((DateTime.Now - startTime).TotalSeconds, 1) * 10);
//            if (l <= LastTime) l = LastTime + 1;
//            LastTime = l;
//            return l;
//        }
//        public bool ConvertIntToByteArray (long m, ref string strTmp)
//        {
//            strTmp = "00000000";
//            byte [] arry = new byte [4];
//            arry [0] = (byte)(m & 0xFF);
//            arry [1] = (byte)((m & 0xFF00) >> 8);
//            arry [2] = (byte)((m & 0xFF0000) >> 16);
//            arry [3] = (byte)((m & 0xFF000000) >> 24);
//            strTmp = arry [0].ToString ("X2") + arry [1].ToString ("X2") + arry [2].ToString ("X2") + arry [3].ToString ("X2");
//            return true;
//        }
//    }
@@ -349,7 +445,7 @@
//    {
//        public string sid { get; set; }
//        public string name { get; set; }
//        public string[] uids { get; set; }
//        public string [] uids { get; set; }
//        public string spk { get; set; }
//        public string oid { get; set; }  //设备模块地址
@@ -370,3 +466,97 @@
//    }
//}
////sid组成部分:
////sid
////来源   厂商代码   通讯方式   产品时间戳   产品类别   物模型类   通道号   大小类别
////1byte   1byte   1byte   4byte   1byte   2byte   2byte   2byte
////oid组成部分:
////来源   厂商代码   通讯方式   产品时间戳   产品类别
////1byte   1 byte   1 byte   4 byte   1byte
////其中各部分代码列表:
////来源   1byte   编号   描述
////      00   默认原生态系统数据
////      01   网关或者其他A设备
////      02   调试软件
////      03   APP应用程序
////      04   第三方网关或者平台
////厂商代码   1byte   编号   描述
////      01   HDL
////      02
////通讯方式   1byte   编号   描述
////      01   HDL Bus
////      02   Zigbee
////      03   KNX
////      04   Z-Wave
////产品时间戳   4bytes   以2020年1月1日算出的时间戳0.1s为单位
////产品类别   1byte   编号   描述
////      01   调光器
////      02   继电器
////      03   干接点模块
////      04   传感器
////      05   面板
////      06   RCU
////      07   网关
////      08   红外发射
////      09   Android屏
////      10   场景
////      11   音乐播放器
////      12   232/485转换器
////      21   自动化
////      22   安防防区
////      14   窗帘模块
////      15   HVAC
////      16   地热模块
////物模型类型   2bytes   编号   描述
////      01   开关类   01   开关
////            02   插座
////            03
////      02   照明   01   开关
////            02   调光
////            03   色温(CCT)
////            04   RGB
////      03   遮阳   01   窗帘控制器
////            02   百叶窗
////            03   开合帘
////            04   卷帘
////            05    推窗器
////            06    投影幕
////      04   面板   01   按键面板
////      05   传感器   01   移动探测
////            02   温度传感器
////            03   湿度传感器
////            04   照度传感器
////            05   TVOC
////            06   PM2.5
////            07   CO2
////            08   毫米波传感器
////            09
////            10
////            11   烟雾传感器
////            25   干接点
////      07   恒温器   01   空调
////            02   风扇
////            03   毛细空调
////      08   地热   01   地热模块
////      09   背景音乐   01   音乐播放器
////            02   Sonos
////      10   场景   01   场景
////            02   电影场景
////      19   新风   01   新风
////13   能源   01   电表
////            02   水表
////            03   燃气
////      16   电器   01   风扇
////            02   TV
////      20   安防   01   安防
////      21   自动化   01   自动化
////大类别   1bytes   (预留)
////小类别   1byte   (预留)