Beispiel #1
0
        public void Create_ShouldCreateProperExecutor()
        {
            var programMock           = new Mock <IProgram>();
            var robotMock             = new Mock <IRobot>();
            IProgramExecutor executor = factory.Create(programMock.Object, robotMock.Object);

            Assert.Equal(programMock.Object, executor.Program);
            Assert.Equal(robotMock.Object, executor.Robot);
            Assert.False(executor.IsCompleted);
        }
Beispiel #2
0
        /// <summary>
        /// Starts the execution of instructions that resides in the memory.
        /// The execution is done in a separate thread.
        /// </summary>
        /// <param name="executor">Who is handling the program execution.</param>
        public void BeginExecution(IProgramExecutor executor)
        {
            if (executor == null)
            {
                throw new ArgumentNullException(nameof(executor));
            }

            _executor = executor;

            if (_knownInstructionTypes == null)
            {
                InitializeTypes();
            }

            //Run all the processing in another thread, so we do not block the UI.
            Task.Factory.StartNew(Execute);
        }
        public IProgramExecutor Execute(IProgram program, IRobot robot)
        {
            if (CanExecute(program, robot) == false)
            {
                throw new RobotsException("Robot is already running a program!");
            }

            IProgramExecutor executor = ExecutorFactory.Create(program, robot);

            lock (runningExecutorsMutex)
            {
                RunningExecutors.Add(executor);
            }

            executor.ProgramExecutionEnd += onExecutionEnd;

            executor.Start();
            ProgramExecutionStarted?.Invoke(this, new ProgramExecutionServiceProgramEventArgs(program));
            return(executor);
        }
Beispiel #4
0
 private void _DisposeProgramExecutor()
 {
     _RemoveEventHandlers();
     _programExecutor.Dispose();
     _programExecutor = null;
 }
Beispiel #5
0
 private void _DisposeProgramExecutor()
 {
     _RemoveEventHandlers();
     _programExecutor.Dispose();
     _programExecutor = null;
 }
Beispiel #6
0
 public RunController(IProgramExecutor executorService)
 {
     this.executorService = executorService;
 }