| | |
| | | |
| | | logicId = sOidBeginsWith + sTimeSpan; |
| | | |
| | | logicId += "0A"; |
| | | logicId += "0A01"; |
| | | //0A01 物模型为逻辑, 0001 表示 1 号逻辑功能 |
| | | int iTopLogicId = 1; |
| | | logicId += "15"; |
| | | logicId += "1501"; |
| | | //1501 物模型为逻辑, 0001 表示 1 号逻辑功能 |
| | | int maxId = 1; |
| | | |
| | | Random random = new Random(); |
| | | iTopLogicId = random.Next(0, 255); |
| | | iTopLogicId += random.Next(0, 255); |
| | | |
| | | logicId += iTopLogicId.ToString("X4");//逻辑号 两个byte |
| | | logicId += "1100"; |
| | | for (int i = 0; i < Logic.LogicList.Count; i++) |
| | | { |
| | | string s = Logic.LogicList[i].sid.Substring(20, 4); |
| | | int iThisSceneId = Convert.ToInt16(s, 16); |
| | | if (iThisSceneId > maxId) |
| | | maxId = iThisSceneId ; |
| | | } |
| | | |
| | | logicId += (maxId+1).ToString("X4");//逻辑号 两个byte |
| | | logicId += "0000"; |
| | | } |
| | | catch |
| | | { |
| | |
| | | } |
| | | 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对象 |