// step ready to be parsed collection public void parseAllReadyData(DBWriter myDBWriter) { if (!closing) { DateTime start = DateTime.Now; var parseDurations = new List <double>(); lock (currentlyParsingLock) { lock (failedParsing) { currentlyParsingIndex = 0; // Parse all data currentlyParsing.ForEach(delegate(RawData obj) { try { Logger.GetInstance().WritePayloadToLogFile(obj.rawData, obj.rawDataLength, LogType.RawData); Logger.GetInstance().WritePayloadBinaryToLogFile(obj.rawData, obj.rawDataLength, LogType.RawBinary); } catch (Exception ex) { Logger.GetInstance().Exception("Failed to write the log file", ex, EventLogPostfix); } bool moreDataExpected = false; // currently ignored bool packetParsedOK = false; IPacketParser packetParser = PacketParserCommon.selectPacketParser(obj.rawData, obj.rawDataLength); currentlyParsingIndex++; var parseStart = DateTime.Now; if (packetParser != null) { packetParser.TrackerID = obj.trackerID; packetParsedOK = packetParser.Parse(myDBWriter, obj.rawData, obj.rawDataLength, ref moreDataExpected); obj.parsedOK = packetParsedOK; if (!packetParsedOK) { obj.parseRetryCount++; } } parseDurations.Add((DateTime.Now - parseStart).TotalMilliseconds); }); currentlyParsing.Clear(); } } previousParseDurationAverage = Average(parseDurations); previousParseDuration = DateTime.Now - start; } }
private void ParseData(DBWriter myDBWriter, RawData obj, List <double> parseDurations) { bool moreDataExpected = false; // currently ignored bool packetParsedOK = false; IPacketParser packetParser = PacketParserCommon.selectPacketParser(obj.rawData, obj.rawDataLength); currentlyParsingIndex++; var parseStart = DateTime.Now; if (packetParser != null) { packetParser.TrackerID = obj.trackerID; packetParsedOK = packetParser.Parse(myDBWriter, obj.rawData, obj.rawDataLength, ref moreDataExpected); obj.parsedOK = packetParsedOK; if (!packetParsedOK) { obj.parseRetryCount++; } } parseDurations.Add((DateTime.Now - parseStart).TotalMilliseconds); }