public IPointsRow ParseRow(IList <byte> data) { // tried to optimize var entities = EntitiesDeserializer.Deserialize(data, _descriptors).ToArray(); var points = new double[entities.Length]; for (int i = 0; i < entities.Length; i++) { points[i] = (entities[i] as IPointDataEntity)?.Point ?? double.NaN; } return(new PointsRow(points)); }
public async static Task <FlashStreamReader> CreateAsync(RUSDeviceId device, IDictionary <RUSDeviceId, IEnumerable <IDataEntity> > formats, IFlashDumpDataParserFactory parserFactory, AsyncOperationInfo operationInfo) { var flashDumpPath = Storaging.GetTempFilePath(); var baseStream = new FileStream(flashDumpPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read); var flashDumpWriteStream = new FillNotifiableWriteOnlyStreamDecorator(CHUNK_SIZE, baseStream); var partsProvider = new DumpParserPartsProvider(flashDumpPath); var partsProviderSupplier = new StreamPartsProviderSupplier(flashDumpWriteStream, partsProvider); var scope = new DeviceOperationScope(new FlashDumpStreamParameter(flashDumpWriteStream)); var sections = formats.Select(f => new SectionedDataPacketParser.Section( f.Key, new DataPacketParser(EntitiesDeserializer.ExtractDataPacketDescriptors(f.Value)))) .ToArray(); var dataParser = new SectionedDataPacketParser(sections); var parserFuture = parserFactory.CreateFromRawPartsAsync(partsProvider.RawDumpParts(), dataParser, operationInfo); return(new FlashStreamReader(scope, device, formats, parserFuture, partsProviderSupplier, flashDumpWriteStream, flashDumpPath)); }