public void InitOtherParams() { try { if (RawData == null) { return; } if (MsgBody != null) { string strUeId = GetNodeFromMsgBody(MsgBody, "eNBUEID"); if (strUeId != null) { EnbUeId = Convert.ToUInt32(strUeId); } string strCrnti = GetNodeFromMsgBody(MsgBody, "Crnti"); uint crntixx; if (BTSVersionsManager.HasVersion(Version) == true) { CRNTI = this.padarry; } else if (strCrnti != null && uint.TryParse(strCrnti, out crntixx)) { CRNTI = Convert.ToUInt32(strCrnti); } mmeues1apid = GetMMEUES1APID(MsgBody, "MME-UE-S1AP-ID"); string tmp_x2apId = GetNodeFromMsgBody(MsgBody, "UE-X2AP-ID"); if (tmp_x2apId != null) { UEX2APID = tmp_x2apId; } string tmp = FindValueFromTarget(MsgBody, " |----Imsi :"); if (tmp != null) { IMSI = tmp; } } } catch (Exception exp) { System.Diagnostics.Debug.WriteLine("InitOtherParams:" + exp.Message); } }
/// <summary> /// 时间转换 /// </summary> /// <param name="time2">1970年1月1日1时0秒 后秒部分</param> /// <param name="time3">ns部分</param> /// <param name="myTime">输出时间</param> /// <param name="ticks">ticks</param> /// <returns></returns> bool changeTime(int time2, uint time3, out string strTimeStamp, out ulong ticks) { strTimeStamp = ""; ticks = 0; if (0 == time2 || 0 == time3 || this.EventName == "UNKNOWN TYPE") { return(false); } else { DateTime tStart = new DateTime(1970, 1, 1, 0, 0, 0); DateTime currTime = tStart + TimeSpan.FromSeconds(time2); //time3 表示时间的ns部分,对超出1s的部分进行截断 time3 = time3 % 1000000000; // convert to ticks long nsticks = (long)time3 / 100; currTime = currTime + TimeSpan.FromTicks(nsticks); //对小基站版本不进行时区转换 if (BTSVersionsManager.HasVersion(Version) == false) { //yanjiewa 2015-6-13 转换为本地时间 currTime = currTime.ToLocalTime(); } // yanjiewa 2015-6-15 修改时间格式化为24小时制-DTMUC00269445 strTimeStamp = (currTime.ToString("yyyy-MM-dd HH:mm:ss.fff")); // end yanjiewa 2015-6-15 修改时间格式化为24小时制-DTMUC00269445 ticks = Convert.ToUInt64(currTime.Ticks); return(true); } }
/// <summary> /// The initialize persistent data. /// </summary> /// <param name="stream"> /// The stream. /// </param> public bool InitializePersistentData(MemoryStream stream, string fileVersion) { lock (parseLock) { long startPosition = stream.Position; this.Version = fileVersion; EventParser eventParser = EventParserManager.Instance.GetParser(fileVersion); eventParser.Parse(stream); IConfigNodeWrapper boardTypeNode = eventParser.GetEventTreeHeadNode("Rsv"); if (boardTypeNode != null) { string strBoardType = boardTypeNode.Value.ToString(); int boardType = 0; if (Int32.TryParse(strBoardType, out boardType)) { // sctd/scte板卡都按scte处理 if (boardType == 0x8d || boardType == 0xb2) { boardType = 0x8d; } string finalVersion = string.Format("{0}.{1}", fileVersion, boardType); if (boardType > 0 && System.IO.File.Exists(GetEventConfigFilePath(finalVersion))) { if (EventParserManager.Instance.GetParser(finalVersion) == null) { EventParser parser = new EventParser(); parser.Version = finalVersion; EventParserManager.Instance.AddEventParser(parser.Version, parser); } //覆盖Version 否则解析消息体会出问题 this.Version = finalVersion; } } } string strdtlength = eventParser.GetEventTreeHeadNode("DataLength").Value.ToString(); int dtlength; if (Int32.TryParse(strdtlength, out dtlength) == false) { System.Diagnostics.Debug.WriteLine("datalength is error."); } if (dtlength == 0) { long tmplength = stream.Position; stream.Position = startPosition; dtlength = (int)(tmplength - startPosition); var raws = new byte[dtlength]; stream.Read(raws, 0, dtlength); this.RawData = raws; return(false); } // finally read row data........in case exception stream may never goto end. stream.Position = startPosition; dtlength = (int)(dtlength < stream.Length - startPosition ? dtlength : stream.Length - startPosition); var rowdata = new byte[dtlength]; stream.Read(rowdata, 0, dtlength); this.RawData = rowdata; // if message using binding,need parse all string strtime = (string)eventParser.GetEventTreeHeadNode("Time").Value.ToString(); int tmval; if (Int32.TryParse(strtime, out tmval) == false) { System.Diagnostics.Debug.WriteLine("time is invalid."); this.HalfSubFrameNo = 0; } this.HalfSubFrameNo = tmval; //added by zhuwentian begin if (BTSVersionsManager.HasVersion(Version) == true) { if (eventParser.GetEventTreeHeadNode("Pad[2]") != null && eventParser.GetEventTreeHeadNode("Pad[2]").Value != null) { string strpad = eventParser.GetEventTreeHeadNode("Pad[2]").Value.ToString(); uint pad = 0; if (UInt32.TryParse(strpad, out pad) == false) { System.Diagnostics.Debug.WriteLine("pad[2] is invalid."); } this.padarry = pad; } } //added by zhuwentian end string strtype = eventParser.GetEventTreeHeadNode("EventType").Value.ToString(); int evtype; if (Int32.TryParse(strtype, out evtype) == false) { System.Diagnostics.Debug.WriteLine("EventType is invalid."); } this.EventIdentifier = evtype; string messageSource; string messageDestination; string evtname; eventParser.GetMessageDirection(this, out messageSource, out messageDestination, out evtname); this.MessageSource = messageSource; this.MessageDestination = messageDestination; if (!string.IsNullOrEmpty(evtname)) { this.EventName = evtname; } // 2015-05-07 lixiang start if (null != eventParser.GetEventTreeHeadNode("Time2") && null != eventParser.GetEventTreeHeadNode("Time3")) { string strTime2 = eventParser.GetEventTreeHeadNode("Time2").Value.ToString(); int evTime2 = 0; if (Int32.TryParse(strTime2, out evTime2) == false) { System.Diagnostics.Debug.WriteLine("Time2 is invalid."); } string strTime3 = eventParser.GetEventTreeHeadNode("Time3").Value.ToString(); uint evTime3 = 0; if (UInt32.TryParse(strTime3, out evTime3) == false) { System.Diagnostics.Debug.WriteLine("Time3 is invalid."); } string tempTimeStamp; ulong ticks; if (changeTime(evTime2, evTime3, out tempTimeStamp, out ticks)) { this.TimeStamp = tempTimeStamp; //不设置会导致统计有问题 this.TickTime = ticks; } } string strprot = eventParser.GetEventTreeHeadNode("InterfaceType").Value.ToString(); uint uiprot; if (UInt32.TryParse(strprot, out uiprot) == false) { System.Diagnostics.Debug.WriteLine("interfacetype is invalid."); } this.Protocol = OffLineProtocolInfoManager.GetSingleton().GetProtocolName(uiprot); ushort ilcellid; if (UInt16.TryParse(eventParser.GetEventTreeHeadNode("LocalCellID").Value.ToString(), out ilcellid) == false) { System.Diagnostics.Debug.WriteLine("localcellid is invalid."); this.LocalCellId = 0; } this.LocalCellId = ilcellid; ushort icellueind; if (UInt16.TryParse(eventParser.GetEventTreeHeadNode("CellUEIndex").Value.ToString(), out icellueind) == false) { System.Diagnostics.Debug.WriteLine("cellueindex is invalid."); this.CellUeId = 255; } this.CellUeId = icellueind; ushort cellid; if (UInt16.TryParse(eventParser.GetEventTreeHeadNode("CellID").Value.ToString(), out cellid) == false) { System.Diagnostics.Debug.WriteLine("cellid is invalid."); this.CellId = 255; } this.CellId = cellid; return(true); } }
/// <summary> /// The initialize value. /// </summary> /// <param name="memoryStream"> /// The memory Stream. /// </param> // public virtual void InitializeValue(Stream memoryStream) // { // try // { // //Debug.Assert(null != this.ConfigurationNode || this.Children.Count > 0, "event tree node ,must have a configuration node"); // if (this.ConfigurationNode == null || ConfigurationNode.Children.Count == 0) // { // Log.Error("node id = " + this.Id + ", ConfigurationNode == null."); // } // // not a leaf node // if (this.children.Count > 0) // { // foreach (var child in this.Children) // { // if (null != child) // { // child.InitializeValue(memoryStream); // } // } // } // else // { // if (this.Id == "CellInfo") // { // IConfigNodeWrapper FileVer = this.Parent.GetChildNodeById("FileVer"); // if (FileVer != null) // { // string strfileVer = FileVer.Value.ToString(); // // if (strfileVer != "2") // { // Log.Info("This is used for special version!"); // return; // } // // } // // } // // if (this.isDataLengthUsingBinding) // { // // this.dataLength = new DataLengthParser().GetDataLength(this, ref this.isDataLengthUsingBinding); // if (this.dataLength < 1) // { // Log.Error("InitializeValue data length get error!"); // return; // } // } // // var dataBuffer = new byte[this.dataLength]; // memoryStream.Read(dataBuffer, 0, this.dataLength); // var configurationNode = this.ConfigurationNode; // if (configurationNode != null) // { // // this.Value = ConvertUtil.Singleton.ConvertByteArrayToDataTypeObject( // configurationNode.GetAttribute("DataType"), dataBuffer); // // } // } // } // catch (Exception ex) // { // Log.Error(string.Format("InitializeValue erro msg ={0}", ex.Message)); // } // } // public virtual void InitializeValue(FileStream stream) // { // InitializeValue(stream, ""); // } // public virtual void InitializeValue(FileStream stream, string btsVersion) // { // Debug.Assert(null != this.ConfigurationNode, "event tree node ,must have a configuration node"); // if (this.ConfigurationNode == null) // { // Log.Error("event tree node ,must have a configuration node"); // return; // } // // // not a leaf node // if (this.children.Count > 0) // { // foreach (var child in this.Children) // { // if (null != child) // { // child.InitializeValue(stream, btsVersion); // } // } // } // else // { // // if (this.Id == "CellInfo") // { // IConfigNodeWrapper FileVer = this.Parent.GetChildNodeById("FileVer"); // if (FileVer != null) // { // string strfileVer = FileVer.Value.ToString(); // //如果等于2,表示电信专项版本,需要截取 // if (strfileVer != "2") // { // Log.Info("This is used for special version!"); // return; // } // } // } // if (this.isDataLengthUsingBinding) // { // this.dataLength = new DataLengthParser().GetDataLength(this, ref this.isDataLengthUsingBinding); // if (this.dataLength < 1) // { // Log.Error("InitializeValue data length get error!"); // return; // } // } // // var dataBuffer = new byte[this.dataLength]; // stream.Read(dataBuffer, 0, this.dataLength); // //this.Value = ConvertUtil.Singleton.ConvertByteArrayToDataTypeObject( // // this.ConfigurationNode.GetAttribute("DataType"), dataBuffer); // // var configurationNode = this.ConfigurationNode; // if (configurationNode != null) // { // if (BTSVersionsManager.HasVersion(btsVersion)) // { // this.Value = ConvertUtilLittleEnd.Singleton.ConvertByteArrayToDataTypeObject( // configurationNode.GetAttribute("DataType"), dataBuffer); // } // else // { // this.Value = ConvertUtil.Singleton.ConvertByteArrayToDataTypeObject( // configurationNode.GetAttribute("DataType"), dataBuffer); // } // } // } // } /// <summary> /// The initialize value. /// </summary> /// <param name="memoryStream"> /// The memory Stream. /// </param> public virtual void InitializeValue(Stream memoryStream, string btsVersion) { try { Debug.Assert(null != this.ConfigurationNode || this.Children.Count > 0, "event tree node ,must have a configuration node"); // not a leaf node if (this.children.Count > 0) { foreach (var child in this.Children) { if (null != child) { child.InitializeValue(memoryStream, btsVersion); } } } else { if (this.Id == "CellInfo") { IConfigNodeWrapper FileVer = this.Parent.GetChildNodeById("FileVer"); if (FileVer != null) { string strfileVer = FileVer.Value.ToString(); if (strfileVer != "2") { Log.Info("This is used for special version!"); return; } } } if (this.isDataLengthUsingBinding) { this.dataLength = new DataLengthParser().GetDataLength(this, ref this.isDataLengthUsingBinding); if (this.dataLength < 1) { Log.Error("InitializeValue data length get error!"); return; } } var dataBuffer = new byte[this.dataLength]; memoryStream.Read(dataBuffer, 0, this.dataLength); var configurationNode = this.ConfigurationNode; if (configurationNode != null) { if (BTSVersionsManager.HasVersion(btsVersion)) { this.Value = ConvertUtilLittleEnd.Singleton.ConvertByteArrayToDataTypeObject( configurationNode.GetAttribute("DataType"), dataBuffer); } else { this.Value = ConvertUtil.Singleton.ConvertByteArrayToDataTypeObject( configurationNode.GetAttribute("DataType"), dataBuffer); } } } } catch (Exception ex) { Log.Error(string.Format("InitializeValue erro msg ={0}", ex.Message)); } }