Exemplo n.º 1
0
        /// <summary>
        /// Creates a new <see cref="TaskProcessor"/> based on a <see cref="Task"/>
        /// </summary>
        /// <param name="task"> The <see cref="Task"/></param>
        /// <returns></returns>
        public TaskProcessor(AdaptTask task)
        {
            SignalWritter.CleanAppData();
            CreateSourceInstance(task.DataSource);
            List <AdaptSignal> inputSignals = m_Source.GetSignals().Where(s => task.InputSignalIds.Contains(s.ID)).ToList();

            m_sourceQueue       = Channel.CreateUnbounded <IFrame>();
            m_start             = task.Start;
            m_end               = task.End;
            m_sourceSignals     = inputSignals;
            m_cancelationSource = new CancellationTokenSource();
            m_sectionQueue      = task.Sections.Select(sec => Channel.CreateUnbounded <IFrame>()).ToList();
            Dictionary <string, int> framesPerSecond = new Dictionary <string, int>(inputSignals.Select(item => new KeyValuePair <string, int>(item.ID, (int)item.FramesPerSecond)));

            m_processors = task.Sections.Select((sec, i) => {
                if (i == 0)
                {
                    return(new SignalProcessor(m_sourceQueue, m_sectionQueue[0], sec, framesPerSecond));
                }
                return(new SignalProcessor(m_sectionQueue[i - 1], m_sectionQueue[i], sec, framesPerSecond));
            }).ToList();

            task.OutputSignals.ForEach(s => s.FramesPerSecond = framesPerSecond[s.ID]);
            m_writers = new ConcurrentDictionary <string, SignalWritter>(task.OutputSignals.ToDictionary(signal => signal.ID, signal => new SignalWritter(signal, task.VariableReplacements)));

            m_commonFrameRate = TimeAlignment.Combine(m_processors.Select(item => item.FramesPerSecond).Where(fps => fps > 0).ToArray());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Create as new <see cref="TaskProcessor"/> that only grabs the data from the <see cref="IDataSource"/> and saves it.
 /// No Processing is done in between.
 /// </summary>
 /// <param name="Signals"> A list of <see cref="AdaptSignal"/> to grab.</param>
 /// <param name="Source"> The <see cref="DataSource"/> used to get the Data</param>
 public TaskProcessor(List <AdaptSignal> Signals, DataSource Source, DateTime start, DateTime end)
 {
     SignalWritter.CleanAppData();
     CreateSourceInstance(Source);
     m_writers           = new ConcurrentDictionary <string, SignalWritter>(Signals.ToDictionary(signal => signal.ID, signal => new SignalWritter(signal)));
     m_processors        = new List <SignalProcessor>();
     m_sourceQueue       = Channel.CreateUnbounded <IFrame>();
     m_sectionQueue      = new List <Channel <IFrame> >();
     m_start             = start;
     m_end               = end;
     m_sourceSignals     = Signals;
     m_cancelationSource = new CancellationTokenSource();
     m_commonFrameRate   = TimeAlignment.Combine(Signals.Select(item => item.FramesPerSecond).ToArray());
 }