예제 #1
0
 void DeactivateJobToolStripButtonClick(object sender, EventArgs e)
 {
     foreach (DataGridViewRow Row in dataGridViewRobotJobsQueue.SelectedRows)
     {
         RobotJob RJ = (RobotJob)Row.DataBoundItem;
         RJ.JobStatus = RobotJob.Status.TerminatedByUser;
     }
 }
예제 #2
0
        private RobotJob.Status GetJobStatus(RobotJob RunRobotJob)
        {
            RobotJob.Status JobStatus = RJQ.GetJobStatus(RunRobotJob.UniqueID);

            string Message = string.Format("{0}({1})>{2}", RunRobotJob.ScriptName, RunRobotJob.UniqueID, JobStatus.ToString());

            this.DisplayData(Message);
            return(JobStatus);
        }
예제 #3
0
        public void execJob(string label, ref ListBox cmds, int timeout, bool update)
        {
            RobotJob job = config.getJob(label);

            var_util.var_robot = job;

            if (job != null)
            {
                job.run(ref hsh_layers, ref hsh_layers_events, ref cmds, timeout, update);
            }
            else
            {
                MessageBox.Show("Unknown Job!", "Error");
            }
        }
예제 #4
0
 public RobotJobStatusChangedEventArgs(RobotJob Job)
 {
     this._Job = Job;
 }
예제 #5
0
        public void RunScript(RobotJob Job)
        {
            int ScriptID;
            Job.WriteParameterFile();

            Logon();

            try
            {
                try
                {
                    ScriptID = Evo.PrepareScript(Job.ScriptFilePath);
                }
                catch (System.Runtime.InteropServices.COMException e)
                {
                    if (e.Message.Contains("Previous script could not be unloaded"))
                    {
                        ScriptID = Evo.PrepareScript(Job.ScriptFilePath);
                    }
                    else
                    {
                        throw e;
                    }

                }
                Evo.StartScript(ScriptID, 0, 0);

                //myLogger.Add("After OctoTip.Manager.RobotWrapper.StartScript");

                Job.JobStatus = RobotJob.Status.Running;
                OnRobotJobStatusChanged( new RobotJobStatusChangedEventArgs(Job));
            }
            catch(Exception e)
            {
                Job.JobStatus = RobotJob.Status.Failed;
                OnRobotJobStatusChanged( new RobotJobStatusChangedEventArgs(Job));
                Logoff();
                throw e;
            }

            //Loop while the robot is preforming the job

            try
            {
                SC_ScriptStatus ScriptStatusEx = Evo.GetScriptStatusEx(ScriptID);
                SC_ScriptStatus ScriptStatus   = Evo.GetScriptStatus(ScriptID);

                string Title = "ScriptStatusEx:" + ScriptStatusEx.ToString() + "ScriptStatus:" + ScriptStatus.ToString();
                Log.LogEntery(new LoggingEntery("OctoTipPlus Appilcation","RobotWrapper",Title,LoggingEntery.EnteryTypes.Debug));

                while(ScriptStatus == SC_ScriptStatus.SS_BUSY && !_ShouldStop)
                {
                    System.Threading.Thread.Sleep(RobotSamplingRate);

                    // Handeling pause request
                    if (_ShouldPause)
                    {
                        Evo.Pause();
                        Job.JobStatus=RobotJob.Status.Paused;
                        OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));

                        while (_ShouldPause)
                        {
                            System.Threading.Thread.Sleep(RobotSamplingRate);
                        }

                        if (!_ShouldStop)
                        {
                            Evo.Resume();
                            Job.JobStatus = RobotJob.Status.Running;
                            OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                        }
                    }

                    //Chack for runtime error and wait
                    if(Evo.GetScriptStatusEx(ScriptID) == SC_ScriptStatus.SS_ERROR)
                    {

                        Job.JobStatus = RobotJob.Status.RuntimeError;
                        OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));

                        while(Evo.GetScriptStatusEx(ScriptID) == SC_ScriptStatus.SS_ERROR &&
                              !_ShouldStop)
                        {
                            System.Threading.Thread.Sleep(RobotSamplingRate);
                        }

                        if (!_ShouldStop)
                        {
                            Job.JobStatus = RobotJob.Status.Running;
                            OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                        }

                    }

                    ScriptStatus = Evo.GetScriptStatus(ScriptID);
                }
                //or ended of _souldStop or

                if (_ShouldStop)
                {
                    Evo.Stop();
                    Job.JobStatus = RobotJob.Status.TerminatedByUser;
                    OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                }
                else
                {
                    ScriptStatusEx = Evo.GetScriptStatusEx(ScriptID);
                    Log.LogEntery(new LoggingEntery("OctoTipPlus Appilcation","RobotWrapper","ScriptStatusEx:" + ScriptStatusEx.ToString(),LoggingEntery.EnteryTypes.Debug));

                    // determain script termination status
                    switch (ScriptStatusEx)
                    {
                        case SC_ScriptStatus.SS_IDLE:
                            Job.JobStatus = RobotJob.Status.Finished;
                            OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                            break;
                        case SC_ScriptStatus.SS_STOPPED:
                            Job.JobStatus = RobotJob.Status.TerminatedByUser;
                            OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                            break;
                        case SC_ScriptStatus.SS_ABORTED:
                            Job.JobStatus = RobotJob.Status.TerminatedByUser;
                            OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                            break;
                        case SC_ScriptStatus.SS_STATUS_ERROR:
                            Job.JobStatus = RobotJob.Status.Failed;
                            OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                            break;
                    }
                }
            }
            catch(Exception e)
            {
                Job.JobStatus = RobotJob.Status.Failed;
                OnRobotJobStatusChanged( new RobotJobStatusChangedEventArgs(Job));
                throw e;
            }
            finally
            {
                Logoff();
            }
        }
예제 #6
0
        private void StartReadingQueue()
        {
            while (!_ShouldStop)
            {
                if (_Status != RobotWorkerStatus.WaitingForQueuedItems)
                {
                    OnStatusChanged(new RobotWorkerStatusChangeEventArgs(RobotWorkerStatus.WaitingForQueuedItems, null, "Waiting..."));
                }

                if (_ShouldPause && !_ShouldStop)
                {
                    OnStatusChanged(new RobotWorkerStatusChangeEventArgs(RobotWorkerStatus.Paused, null, "Paused..."));
                    while (_ShouldPause && !_ShouldStop)
                    {
                        Thread.Sleep(QueueSumplelingRate);
                    }
                }
                //not paused or stoped read job from Q

                RobotJob RJ = WorkerRobotJobsQueue.GetNextRobotJob();
                if (RJ != null)
                {
                    OnStatusChanged(new RobotWorkerStatusChangeEventArgs(RobotWorkerStatus.RunningJob, RJ, "Running...."));


                    Robot.RunScript(RJ);


                    switch (RJ.JobStatus)
                    {
                    case OctoTip.Lib.RobotJob.Status.Finished:
                        OnStatusChanged(new RobotWorkerStatusChangeEventArgs(RobotWorkerStatus.WaitingForQueuedItems, RJ, "Job terminated Successfuly "));
                        break;

                    case OctoTip.Lib.RobotJob.Status.TerminatedByUser:
                        OnStatusChanged(new RobotWorkerStatusChangeEventArgs(RobotWorkerStatus.Paused, RJ, "Job Terminated By the User "));
                        _ShouldPause = true;
                        break;

                    case OctoTip.Lib.RobotJob.Status.Failed:
                        OnStatusChanged(new RobotWorkerStatusChangeEventArgs(RobotWorkerStatus.Paused, RJ, "Job Failed"));
                        _ShouldPause = true;
                        break;
                    }
                }


                if (_ShouldPause)
                {
                    OnStatusChanged(new RobotWorkerStatusChangeEventArgs(RobotWorkerStatus.Paused, null, "Paused..."));
                    while (_ShouldPause)
                    {
                        System.Threading.Thread.Sleep(QueueSumplelingRate);
                    }
                    OnStatusChanged(new RobotWorkerStatusChangeEventArgs(RobotWorkerStatus.WaitingForQueuedItems, null, "Waiting..."));
                }

                Thread.Sleep(QueueSumplelingRate);
            }
            OnStatusChanged(new RobotWorkerStatusChangeEventArgs(RobotWorkerStatus.Stopped, null, "Stopped..."));
        }
예제 #7
0
 public RobotWorkerStatusChangeEventArgs(RobotWorker.RobotWorkerStatus RobotWorkerStatus, RobotJob CurrentJob, string Message)
 {
     _RobotWorkerStatus = RobotWorkerStatus;
     _CurrentJob        = CurrentJob;
     _Message           = Message;
 }
예제 #8
0
 public RobotWorkerStatusChangeEventArgs(RobotWorker.RobotWorkerStatus RobotWorkerStatus,RobotJob CurrentJob,string Message)
 {
     _RobotWorkerStatus = RobotWorkerStatus;
     _CurrentJob=CurrentJob;
     _Message = Message;
 }
예제 #9
0
        void FormRobotWorker_StatusChanged(object sender, RobotWorkerStatusChangeEventArgs e)
        {
            string Message;

            if (e.RobotWorkerStatus == RobotWorker.RobotWorkerStatus.RunningJob && e.CurrentJob != null)
            {
                Message = string.Format("{0}-{1}({2}), parameters:{3}) ,{4}", e.RobotWorkerStatus, e.CurrentJob.ScriptName, e.CurrentJob.UniqueID, e.CurrentJob.RobotJobDisplayParameters, e.Message);
            }
            else
            {
                Message = string.Format("{0} - {1}", e.RobotWorkerStatus, e.Message);
            }
            Notify(new LoggingEntery("OctoTipPlus Appilcation", "RobotWorker", "RunningJob", Message, LoggingEntery.EnteryTypes.Debug));


            if (e.CurrentJob == null)
            {
                RuningJob = null;
                UpdateRunningJob();
            }
            else
            {
                RuningJob = e.CurrentJob;
                UpdateRunningJob();
            }

            bool buttonPauseEnabled;
            bool buttonStartEnabled;
            bool buttonStopEnabled;

            string textBoxRuningJobStatusText = string.Empty;
            string textRobotWorkerStatusText  = string.Empty;

            textRobotWorkerStatusText = RobotWorker.GetRobotWorkerStatusText(e.RobotWorkerStatus);

            switch (e.RobotWorkerStatus)
            {
            case (RobotWorker.RobotWorkerStatus.Stopped):
                buttonPauseEnabled = false;
                buttonStartEnabled = true;
                buttonStopEnabled  = false;
                break;

            case (RobotWorker.RobotWorkerStatus.Paused):
                buttonPauseEnabled = false;
                buttonStartEnabled = true;
                buttonStopEnabled  = true;
                break;

            case (RobotWorker.RobotWorkerStatus.Stopping):
                buttonPauseEnabled = false;
                buttonStartEnabled = false;
                buttonStopEnabled  = false;
                break;

            case (RobotWorker.RobotWorkerStatus.Pausing):
                buttonPauseEnabled = false;
                buttonStartEnabled = false;
                buttonStopEnabled  = false;
                break;

            default:
                buttonPauseEnabled = true;
                buttonStartEnabled = false;
                buttonStopEnabled  = true;
                break;
            }

            if (!this.IsDisposed)
            {
                MethodInvoker buttonPauseInvoker = delegate
                {
                    buttonRobotPause.Enabled = buttonPauseEnabled;
                };
                buttonRobotPause.BeginInvoke(buttonPauseInvoker);

                MethodInvoker buttonStartInvoker = delegate
                {
                    buttonRobotStart.Enabled = buttonStartEnabled;
                };
                buttonRobotStart.BeginInvoke(buttonStartInvoker);

                MethodInvoker buttonStopInvoker = delegate
                {
                    buttonRobotStop.Enabled = buttonStopEnabled;
                };
                buttonRobotStop.BeginInvoke(buttonStopInvoker);

                MethodInvoker textBoxRuningJobStatusInvoker = delegate
                {
                    RunningJobStatus.Text = textBoxRuningJobStatusText;
                };
                RunningJobStatus.BeginInvoke(textBoxRuningJobStatusInvoker);

                MethodInvoker textRobotWorkerStatusInvoker = delegate
                {
                    RobotStatuslabel.Text = textRobotWorkerStatusText;
                };
                RunningJobStatus.BeginInvoke(textRobotWorkerStatusInvoker);
            }
        }
예제 #10
0
        protected override void DoWork()
        {
            //Get the RobotJob from the dirived clases
            RunRobotJob = BeforeRobotRun();
            if (RunRobotJob == null)
            {
                throw new NullReferenceException("GetRobotJob returned a null RobotJob");
            }
            RobotJob.Status JobStatus = RobotJob.Status.Created;

            // Inserting the Job in the queue
            RunRobotJob.TestJobParameters();
            RJQ =  RobotJobsQueue.Instance;

            Guid JobID = RJQ.InsertRobotJob(RunRobotJob);

            RunRobotJob.UniqueID = JobID;

            this.Log(string.Format("Queued {0}, UniqueID: {1} (parameters={2})",RunRobotJob.ScriptName,RunRobotJob.UniqueID,RunRobotJob.RobotJobDisplayParameters));

            do
            {

                // keep monitoring the queue till the job status is changed to
                JobStatus = GetJobStatus(RunRobotJob);

                //pause state
                if (this.ShouldPause)
                {
                    this.SetCurrentStatus(Statuses.Paused,"RobotJob Pausing not implimented yet");
                    while(this.ShouldPause && !this.ShouldStop)
                    {
                        System.Threading.Thread.Sleep(this.StateSamplelingRate);
                    }

                    if (!this.ShouldPause && !this.ShouldStop)
                    {
                        this.SetCurrentStatus(State.Statuses.Started,"Protocol resumed");
                    }
                }

                if (JobStatus == RobotJob.Status.RuntimeError)
                {
                    this.SetCurrentStatus(State.Statuses.RuntimeError, "Runtime Error");

                    while (JobStatus == RobotJob.Status.RuntimeError && !this.ShouldStop)
                    {
                        System.Threading.Thread.Sleep(StateSamplelingRate);
                        JobStatus = GetJobStatus(RunRobotJob);
                    }
                    if(!this.ShouldStop)
                    {
                        this.SetCurrentStatus(State.Statuses.Started, "Runtime Error resumed");
                    }
                    else
                    {
                        break;
                    }

                }
                System.Threading.Thread.Sleep(StateSamplelingRate);

            }
            while(
                JobStatus != RobotJob.Status.TerminatedByUser &&
                JobStatus != RobotJob.Status.Finished &&
                JobStatus != RobotJob.Status.Failed &&
                !this.ShouldStop);

            //Handling termination statuses
            switch (JobStatus)
            {
                case (RobotJob.Status.Failed):
                    this.SetCurrentStatus(State.Statuses.FatalError, "Failed");
                    //this.RequestStop("Robot Job Failed");
                    break;
                case (RobotJob.Status.TerminatedByUser):
                    this.SetCurrentStatus(State.Statuses.FatalError, "Terminated by user");
                    //this.RequestStop("Terminated by user");
                    break;
                case (RobotJob.Status.Finished):
                    this.SetCurrentStatus( State.Statuses.EndedSuccessfully, "Terminated successfully");
                    AfterRobotRun();
                    break;
            }
        }
예제 #11
0
        private RobotJob.Status GetJobStatus(RobotJob RunRobotJob)
        {
            RobotJob.Status JobStatus = RJQ.GetJobStatus(RunRobotJob.UniqueID);

            string Message = string.Format("{0}({1})>{2}",RunRobotJob.ScriptName,RunRobotJob.UniqueID,JobStatus.ToString());
            this.DisplayData(Message);
            return JobStatus;
        }
예제 #12
0
        void FormRobotWorker_StatusChanged(object sender, RobotWorkerStatusChangeEventArgs e)
        {
            string Message;
            if(e.RobotWorkerStatus==RobotWorker.RobotWorkerStatus.RunningJob && e.CurrentJob!=null)
            {
                Message  = string.Format("{0}-{1}({2}), parameters:{3}) ,{4}" , e.RobotWorkerStatus,e.CurrentJob.ScriptName,e.CurrentJob.UniqueID,e.CurrentJob.RobotJobDisplayParameters,e.Message);
            }
            else
            {

                Message  = string.Format("{0} - {1}" , e.RobotWorkerStatus,e.Message);
            }
            Notify(new LoggingEntery("OctoTipPlus Appilcation","RobotWorker","RunningJob",Message,LoggingEntery.EnteryTypes.Debug));

            if (e.CurrentJob == null)
            {
                RuningJob = null;
                UpdateRunningJob();
            }
            else
            {

                RuningJob = e.CurrentJob;
                UpdateRunningJob();
            }

            bool buttonPauseEnabled ;
            bool buttonStartEnabled ;
            bool buttonStopEnabled;

            string textBoxRuningJobStatusText = string.Empty;
            string textRobotWorkerStatusText = string.Empty;

            textRobotWorkerStatusText = RobotWorker.GetRobotWorkerStatusText(e.RobotWorkerStatus);

            switch(e.RobotWorkerStatus)
            {
                case(RobotWorker.RobotWorkerStatus.Stopped):
                    buttonPauseEnabled = false;
                    buttonStartEnabled = true;
                    buttonStopEnabled = false;
                    break;
                case(RobotWorker.RobotWorkerStatus.Paused):
                    buttonPauseEnabled = false;
                    buttonStartEnabled = true;
                    buttonStopEnabled = true;
                    break;
                case(RobotWorker.RobotWorkerStatus.Stopping ):
                    buttonPauseEnabled = false;
                    buttonStartEnabled = false;
                    buttonStopEnabled = false;
                    break;
                case( RobotWorker.RobotWorkerStatus.Pausing):
                    buttonPauseEnabled = false;
                    buttonStartEnabled = false;
                    buttonStopEnabled = false;
                    break;
                default:
                    buttonPauseEnabled = true;
                    buttonStartEnabled = false;
                    buttonStopEnabled = true;
                    break;

            }

            if (!this.IsDisposed)
            {
                MethodInvoker buttonPauseInvoker = delegate
                {
                    buttonRobotPause.Enabled = buttonPauseEnabled ;
                };
                buttonRobotPause.BeginInvoke(buttonPauseInvoker);

                MethodInvoker buttonStartInvoker = delegate
                {
                    buttonRobotStart.Enabled = buttonStartEnabled ;
                };
                buttonRobotStart.BeginInvoke(buttonStartInvoker);

                MethodInvoker buttonStopInvoker = delegate
                {
                    buttonRobotStop.Enabled = buttonStopEnabled ;
                };
                buttonRobotStop.BeginInvoke(buttonStopInvoker);

                MethodInvoker textBoxRuningJobStatusInvoker = delegate
                {
                    RunningJobStatus.Text = textBoxRuningJobStatusText ;
                };
                RunningJobStatus.BeginInvoke(textBoxRuningJobStatusInvoker);

                MethodInvoker textRobotWorkerStatusInvoker = delegate
                {
                    RobotStatuslabel.Text = textRobotWorkerStatusText ;
                };
                RunningJobStatus.BeginInvoke(textRobotWorkerStatusInvoker);
            }
        }
예제 #13
0
        protected override void DoWork()
        {
            //Get the RobotJob from the dirived clases
            RunRobotJob = BeforeRobotRun();
            if (RunRobotJob == null)
            {
                throw new NullReferenceException("GetRobotJob returned a null RobotJob");
            }
            RobotJob.Status JobStatus = RobotJob.Status.Created;

            // Inserting the Job in the queue
            RunRobotJob.TestJobParameters();
            RJQ = RobotJobsQueue.Instance;

            Guid JobID = RJQ.InsertRobotJob(RunRobotJob);

            RunRobotJob.UniqueID = JobID;

            this.Log(string.Format("Queued {0}, UniqueID: {1} (parameters={2})", RunRobotJob.ScriptName, RunRobotJob.UniqueID, RunRobotJob.RobotJobDisplayParameters));

            do
            {
                // keep monitoring the queue till the job status is changed to
                JobStatus = GetJobStatus(RunRobotJob);

                //pause state
                if (this.ShouldPause)
                {
                    this.SetCurrentStatus(Statuses.Paused, "RobotJob Pausing not implimented yet");
                    while (this.ShouldPause && !this.ShouldStop)
                    {
                        System.Threading.Thread.Sleep(this.StateSamplelingRate);
                    }

                    if (!this.ShouldPause && !this.ShouldStop)
                    {
                        this.SetCurrentStatus(State.Statuses.Started, "Protocol resumed");
                    }
                }

                if (JobStatus == RobotJob.Status.RuntimeError)
                {
                    this.SetCurrentStatus(State.Statuses.RuntimeError, "Runtime Error");

                    while (JobStatus == RobotJob.Status.RuntimeError && !this.ShouldStop)
                    {
                        System.Threading.Thread.Sleep(StateSamplelingRate);
                        JobStatus = GetJobStatus(RunRobotJob);
                    }
                    if (!this.ShouldStop)
                    {
                        this.SetCurrentStatus(State.Statuses.Started, "Runtime Error resumed");
                    }
                    else
                    {
                        break;
                    }
                }
                System.Threading.Thread.Sleep(StateSamplelingRate);
            }while(
                JobStatus != RobotJob.Status.TerminatedByUser &&
                JobStatus != RobotJob.Status.Finished &&
                JobStatus != RobotJob.Status.Failed &&
                !this.ShouldStop);

            //Handling termination statuses
            switch (JobStatus)
            {
            case (RobotJob.Status.Failed):
                this.SetCurrentStatus(State.Statuses.FatalError, "Failed");
                //this.RequestStop("Robot Job Failed");
                break;

            case (RobotJob.Status.TerminatedByUser):
                this.SetCurrentStatus(State.Statuses.FatalError, "Terminated by user");
                //this.RequestStop("Terminated by user");
                break;

            case (RobotJob.Status.Finished):
                this.SetCurrentStatus(State.Statuses.EndedSuccessfully, "Terminated successfully");
                AfterRobotRun();
                break;
            }
        }
예제 #14
0
 public RobotJobStatusChangedEventArgs(RobotJob Job)
 {
     this._Job = Job;
 }
예제 #15
0
        public void RunScript(RobotJob Job)
        {
            int ScriptID;

            Job.WriteParameterFile();



            Logon();



            try
            {
                try
                {
                    ScriptID = Evo.PrepareScript(Job.ScriptFilePath);
                }
                catch (System.Runtime.InteropServices.COMException e)
                {
                    if (e.Message.Contains("Previous script could not be unloaded"))
                    {
                        ScriptID = Evo.PrepareScript(Job.ScriptFilePath);
                    }
                    else
                    {
                        throw e;
                    }
                }
                Evo.StartScript(ScriptID, 0, 0);


                //myLogger.Add("After OctoTip.Manager.RobotWrapper.StartScript");

                Job.JobStatus = RobotJob.Status.Running;
                OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
            }
            catch (Exception e)
            {
                Job.JobStatus = RobotJob.Status.Failed;
                OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                Logoff();
                throw e;
            }

            //Loop while the robot is preforming the job

            try
            {
                SC_ScriptStatus ScriptStatusEx = Evo.GetScriptStatusEx(ScriptID);
                SC_ScriptStatus ScriptStatus   = Evo.GetScriptStatus(ScriptID);

                string Title = "ScriptStatusEx:" + ScriptStatusEx.ToString() + "ScriptStatus:" + ScriptStatus.ToString();
                Log.LogEntery(new LoggingEntery("OctoTipPlus Appilcation", "RobotWrapper", Title, LoggingEntery.EnteryTypes.Debug));


                while (ScriptStatus == SC_ScriptStatus.SS_BUSY && !_ShouldStop)
                {
                    System.Threading.Thread.Sleep(RobotSamplingRate);

                    // Handeling pause request
                    if (_ShouldPause)
                    {
                        Evo.Pause();
                        Job.JobStatus = RobotJob.Status.Paused;
                        OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));

                        while (_ShouldPause)
                        {
                            System.Threading.Thread.Sleep(RobotSamplingRate);
                        }

                        if (!_ShouldStop)
                        {
                            Evo.Resume();
                            Job.JobStatus = RobotJob.Status.Running;
                            OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                        }
                    }

                    //Chack for runtime error and wait
                    if (Evo.GetScriptStatusEx(ScriptID) == SC_ScriptStatus.SS_ERROR)
                    {
                        Job.JobStatus = RobotJob.Status.RuntimeError;
                        OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));

                        while (Evo.GetScriptStatusEx(ScriptID) == SC_ScriptStatus.SS_ERROR &&
                               !_ShouldStop)
                        {
                            System.Threading.Thread.Sleep(RobotSamplingRate);
                        }

                        if (!_ShouldStop)
                        {
                            Job.JobStatus = RobotJob.Status.Running;
                            OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                        }
                    }



                    ScriptStatus = Evo.GetScriptStatus(ScriptID);
                }
                //or ended of _souldStop or

                if (_ShouldStop)
                {
                    Evo.Stop();
                    Job.JobStatus = RobotJob.Status.TerminatedByUser;
                    OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                }
                else
                {
                    ScriptStatusEx = Evo.GetScriptStatusEx(ScriptID);
                    Log.LogEntery(new LoggingEntery("OctoTipPlus Appilcation", "RobotWrapper", "ScriptStatusEx:" + ScriptStatusEx.ToString(), LoggingEntery.EnteryTypes.Debug));

                    // determain script termination status
                    switch (ScriptStatusEx)
                    {
                    case SC_ScriptStatus.SS_IDLE:
                        Job.JobStatus = RobotJob.Status.Finished;
                        OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                        break;

                    case SC_ScriptStatus.SS_STOPPED:
                        Job.JobStatus = RobotJob.Status.TerminatedByUser;
                        OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                        break;

                    case SC_ScriptStatus.SS_ABORTED:
                        Job.JobStatus = RobotJob.Status.TerminatedByUser;
                        OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                        break;

                    case SC_ScriptStatus.SS_STATUS_ERROR:
                        Job.JobStatus = RobotJob.Status.Failed;
                        OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Job.JobStatus = RobotJob.Status.Failed;
                OnRobotJobStatusChanged(new RobotJobStatusChangedEventArgs(Job));
                throw e;
            }
            finally
            {
                Logoff();
            }
        }