/// <summary>Initializes a new instance of the <see cref="T:System.Object" /> class.</summary> public SpectrumWriterV2([NotNull] string directory, [NotNull] string prefix, SaveType saveType) { _writerV2Implementation = new SerialWriterV2 <TracedSpectrum>(); var dateTime = DateTime.Now; var timeStamp = dateTime.ToString("HHmmssfff"); var timeStr = timeStamp.Enclose("TS"); var path = Path.Combine(directory, timeStr + prefix); if (saveType == SaveType.UnwrappedPhase) { _writerV2Implementation.ElementDequeued += spectrum => { var phase = new double[spectrum.Length()]; for (var i = 0; i < spectrum.Length(); i++) { phase[i] = spectrum.Array[i].Phase; } var unwrap = Functions.Unwrap(phase); Toolbox.WriteStringArray(path + saveType.ToString().Enclose() + spectrum.Tag.Enclose("No") + spectrum.PulseCount.Enclose("Cnt") + Suffix, unwrap.Select(p => p.ToString()).ToArray()); }; } else { var toStringFunc = GetToStringFunc(saveType); _writerV2Implementation.ElementDequeued += spectrum => { Toolbox.WriteStringArray( path + saveType.ToString().Enclose() + spectrum.Tag.Enclose() + spectrum.PulseCount.Enclose("Cnt") + Suffix, spectrum.ToStringArray(toStringFunc)); }; } }
public PhaseVisualizer(BlockingCollection <SampleRecord> queue, IPhaseReader worker, PhaseDisplayAdapter adapter, [CanBeNull] IWriterV2 <TracedSpectrum> writer, int waitEmptyProducerMsTimeout, int?targetCnt) { _worker = worker; _consumer = new SerialConsumerV2 <SampleRecord>(ProcessElement, queue, targetCnt, waitEmptyProducerMsTimeout); Adapter = adapter; Writer = writer; }
/// <summary>Initializes a new instance of the <see cref="T:System.Object" /> class.</summary> public SampleWriterV2([NotNull] string directory, [NotNull] string prefix) { _writer = new SerialWriterV2 <SampleRecord>(); var path = Path.Combine(directory, prefix); _writer.ElementDequeued += record => { try { Toolbox.SerializeData(path + record.Id.Enclose("No") + Suffix, record.PulseSequence); } catch (Exception) { } }; }
/// <summary>Initializes a new instance of the <see cref="T:System.Object" /> class.</summary> /// <param name="queue"></param> /// <param name="workers"></param> /// <param name="adapter"></param> /// <param name="writer"></param> /// <param name="targetCnt"></param> public ParralelSpectroscopyVisualizerV2(BlockingCollection <SampleRecord> queue, IEnumerable <IAccumulator> workers, SpectrumDisplayAdapter adapter, [CanBeNull] IWriterV2 <TracedSpectrum> writer, int waitEmptyProducerMsTimeOut, int?targetCnt, bool saveSpec, bool saveAcc) { _saveSpec = saveSpec; _saveAcc = saveAcc; _consumer = new ParallelConsumerV2 <SampleRecord, IAccumulator, TaggedProcessResult>( queue, workers, ProcessElement, HandleResultSync, waitEmptyProducerMsTimeOut, targetCnt); Adapter = adapter; Writer = writer; TargetAmountReached += OnTargetAmountReached; }