Exemple #1
0
 FlashStreamReader(
     DeviceOperationScope flashReadOperationScope,
     RUSDeviceId device,
     IDictionary <RUSDeviceId, IEnumerable <IDataEntity> > rowDescriptors,
     Task <IFlashDumpDataParser> parserFuture,
     StreamPartsProviderSupplier partsProviderSupplier,
     Stream rawDumpStream,
     string rawDumpPath)
 {
     FlashReadOperationScope = flashReadOperationScope ?? throw new ArgumentNullException(nameof(flashReadOperationScope));
     _device                = device;
     _rowDescriptors        = rowDescriptors ?? throw new ArgumentNullException(nameof(rowDescriptors));
     _parserFuture          = parserFuture ?? throw new ArgumentNullException(nameof(parserFuture));
     _partsProviderSupplier = partsProviderSupplier ?? throw new ArgumentNullException(nameof(partsProviderSupplier));
     _rawDumpStream         = rawDumpStream;
     _rawDumpPath           = rawDumpPath ?? throw new ArgumentNullException(nameof(rawDumpPath));
 }
Exemple #2
0
        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));
        }