예제 #1
0
        /// <summary>
        /// The initialize persistent data.
        /// </summary>
        /// <param name="buffer">
        /// The buffer.
        /// </param>
        public void InitializePersistentData(byte[] buffer, EventParser eventParser)
        {
            eventParser.Parse(buffer);

            // if message using binding,need parse all
            this.HalfSubFrameNo = Convert.ToInt32(eventParser.GetEventTreeHeadNode("Time").Value);

            this.EventIdentifier = Convert.ToInt32(eventParser.GetEventTreeHeadNode("EventType").Value);

            string messageSource;
            string messageDestination;
            string evtname;

            eventParser.GetMessageDirection(this, out messageSource, out messageDestination, out evtname);

            this.MessageSource      = messageSource;
            this.MessageDestination = messageDestination;
            this.EventName          = evtname;

            this.Protocol = OffLineProtocolInfoManager.GetSingleton().GetProtocolName(Convert.ToUInt32(eventParser.GetEventTreeHeadNode("InterfaceType").Value));

            this.LocalCellId = Convert.ToUInt16(eventParser.GetEventTreeHeadNode("LocalCellID").Value);

            this.CellUeId = Convert.ToUInt16(eventParser.GetEventTreeHeadNode("CellUEIndex").Value);

            this.CellId = Convert.ToUInt16(eventParser.GetEventTreeHeadNode("CellID").Value);

            this.EventIdentifier = Convert.ToInt32(eventParser.GetEventTreeHeadNode("EventType").Value);

            //this.EventName = eventParser.eventConfigurationMgr.GetEventConfiguration(this.Version).GetEventBodyNodeById(this.EventIdentifier).GetAttribute("Describe");

            this.RawData = buffer;
        }
예제 #2
0
        /// <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);
            }
        }