Ejemplo n.º 1
0
        /// <summary>
        /// Performs the processing procedure against an input
        /// </summary>
        /// <param name="pipeline">The processing pipeline</param>
        /// <param name="input">The input to be processed</param>
        /// <returns>The output from the pipeline, or null if the process
        /// is cancelled</returns>
        private Image _processInput(Pipeline.Pipeline pipeline, JobInput input)
        {
            Image theInput = input.Input;

            foreach (PipelineEntry entry in pipeline)
            {
                lock ( _cancelPadlock )
                {
                    if (_cancel)
                    {
                        return(null);
                    }
                }

                AlgorithmPlugin plugin = entry.Process;
                plugin.Input = theInput;
                plugin.Run(entry.ProcessInput);
                theInput = plugin.Output ?? plugin.Input;
            }

            InputProcessedArgs e = new InputProcessedArgs(input.Identifier, (Image)theInput.Clone());

            _ticket.OnInputProcessed(e);
            return(theInput);
        }
Ejemplo n.º 2
0
        public void TestWork_InputProcessedFired()
        {
            ObjectJobDefinition d = new ObjectJobDefinition(
                new PipelineDefinition(
                    new[] { new AlgorithmDefinition("Test", new Property[] { }) }),
                new[] { new JobInput(Image.FromFile("img.bmp"))
                        {
                            Identifier = "Test"
                        } });
            JobRequest   r      = new JobRequest(d);
            JobTicket    ticket = new JobTicket(r, new DudCancellationHandler());
            TicketWorker w      = new TicketWorker();
            WorkerArgs   args   = new WorkerArgs(new DudPersister(), new DudPipelineFactory());

            args.Ticket = ticket;

            bool didProcess       = false;
            InputProcessedArgs ie = null;
            TicketSink         s  = new TicketSink();

            ticket.Sinks.Add(s);
            s.InputProcessed += (se, e) => { didProcess = true; ie = e; };

            w.Work(args);

            Thread.Sleep(5);

            Assert.IsTrue(didProcess);
            Assert.IsNotNull(ie);
            Assert.AreEqual("Test", ie.Identifier);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Occurs when an input is fully processed
 /// </summary>
 /// <param name="sender">N/A</param>
 /// <param name="e">Event information</param>
 private void _inputProcessed(object sender, InputProcessedArgs e)
 {
     if (_currentStart != null)
     {
         TimeSpan duration = DateTime.Now - (DateTime)_currentStart;
         _currentStart = null;
         _previousDurations.Add(duration);
         _recalculateAverage();
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Occurs when an input has been processed
        /// </summary>
        /// <param name="sender">N/A</param>
        /// <param name="e">Event information</param>
        private void _inputProcessed(object sender, InputProcessedArgs e)
        {
            // Provide the info to the relevant input
            InputsProcessed++;
            var inputWithID = (from input in Inputs
                               where input.Identifier == e.Identifier
                               select input).FirstOrDefault();

            if (inputWithID != null)
            {
                inputWithID.Output      = e.Image;
                inputWithID.IsProcessed = true;
            }
        }
Ejemplo n.º 5
0
 internal void OnInputProcessed(InputProcessedArgs e)
 {
     _sink.FireAsync("InputProcessed", this, e);
 }