当前位置: 首页>>代码示例>>C#>>正文


C# Tracker.Parse方法代码示例

本文整理汇总了C#中Tracker.Parse方法的典型用法代码示例。如果您正苦于以下问题:C# Tracker.Parse方法的具体用法?C# Tracker.Parse怎么用?C# Tracker.Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tracker的用法示例。


在下文中一共展示了Tracker.Parse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Process

        public static DeviceInfo Process(Tracker.Parser.Protocol protocolParser, DeviceInfo deviceInfo)
        {
            log.InfoFormat("{0}/Process:", _fileNm);

            bool IsSequenceFirst = true;

            log.DebugFormat("{0}/Process: IsSequenceFirst: {1}", _fileNm, IsSequenceFirst);

            Console.WriteLine("{0} >> {1}", deviceInfo.TrackerIp, BitConverter.ToString(deviceInfo.RawData));

            while ((IsSequenceFirst == true) ||
                (deviceInfo.Payload != null && deviceInfo.Payload.Length >= protocolParser.REQ_MIN_Length()))
            {
                log.DebugFormat("{0}/Process: IsSequenceFirst: {1}, deviceInfo.Payload: {2}, REQ_MIN_Length: {3}",
                    _fileNm, IsSequenceFirst, deviceInfo.Payload, protocolParser.REQ_MIN_Length());

                IsSequenceFirst = false;

                deviceInfo.ParserStatus = ProtocolParserStatus.Initialized;

                bool IsDeviceNeedToIdentify = false;
                if (string.IsNullOrWhiteSpace(deviceInfo.DeviceId))
                {
                    // new connection, first request
                    IsDeviceNeedToIdentify = true;
                }

                deviceInfo = protocolParser.Parse(deviceInfo);

                if (IsDeviceNeedToIdentify)
                {
                    deviceInfo = DeviceData.CopyLastDataOfDevice(deviceInfo);
                }

                log.DebugFormat("{0}/Process: deviceInfo.ParserStatus: {1}", _fileNm, deviceInfo.ParserStatus);

                if (deviceInfo.ParserStatus == ProtocolParserStatus.Parsed)
                {
                    if (DeviceData.IsActiveDevice(deviceInfo.DeviceId))
                    {
                        DeviceData.AddActiveDevice(deviceInfo.DeviceId);
                        DeviceData.SaveData(deviceInfo);
                    }
                    else
                    {
                        DeviceData.AddUnknownDevice(deviceInfo.DeviceId);
                    }

                    deviceInfo.ParserStatus = ProtocolParserStatus.Saved;

                    log.DebugFormat("{0}/Process: deviceInfo.ParserStatus: {1}", _fileNm, deviceInfo.ParserStatus);

                    deviceInfo = DeviceData.ClearProcessedData(deviceInfo);
                    deviceInfo.ParserStatus = ProtocolParserStatus.Finished;

                    log.DebugFormat("{0}/Process: deviceInfo.ParserStatus: {1}", _fileNm, deviceInfo.ParserStatus);
                }
                else
                {
                    break;
                }
            }
            log.InfoFormat("{0}/Process: Finished", _fileNm);
            return deviceInfo;
        }
开发者ID:madankumar6,项目名称:CSharp,代码行数:65,代码来源:Parser.cs


注:本文中的Tracker.Parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。