예제 #1
0
        public UCRecord(Recording recording)
        {
            InitializeComponent();

            _recording = recording;

            updateTitle();

            _ts = new EZ_B.EZTaskScheduler(recording.Title, true);
            _ts.OnEventToRun     += _ts_OnEventToRun;
            _ts.OnQueueCompleted += _ts_OnQueueCompleted;

            _sw = new Stopwatch();
        }
예제 #2
0
        private void _ts_OnEventToRun(EZ_B.EZTaskScheduler sender, int taskId, object o)
        {
            try {
                if (sender.IsCancelRequested(taskId))
                {
                    return;
                }

                ARC.Scripting.VariableManager.SetVariable(FormMain._VariableIsRunning, true);

                _state = StateEnum.Playing;

                this.Invoke(new Action(() => {
                    btnDelete.Enabled = false;
                    btnRecord.Enabled = false;
                    btnPlay.BackColor = Color.Red;
                    btnPlay.ForeColor = Color.White;
                    btnPlay.Text      = "Stop";
                }));

                OnLog("{0}: Started", _recording.Title);

                _sw.Restart();

                foreach (var recording in _recording.ServoPositions)
                {
                    if (sender.IsCancelRequested(taskId))
                    {
                        return;
                    }

                    while (_sw.ElapsedTicks < recording.Ticks)
                    {
                        if (sender.IsCancelRequested(taskId))
                        {
                            return;
                        }

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

                    EZBManager.EZBs[0].Servo.SetServoPosition(recording.GetAsEZBServoItems());
                }
            } catch (Exception ex) {
                OnLog("{0}: {1}", _recording.Title, ex.Message);
            } finally {
                ARC.Scripting.VariableManager.SetVariable(FormMain._VariableIsRunning, false);

                OnLog("{0}: Completed", _recording.Title);

                this.Invoke(new Action(() => {
                    btnDelete.Enabled = true;
                    btnRecord.Enabled = true;
                    btnPlay.BackColor = Color.White;
                    btnPlay.ForeColor = Color.Black;
                    btnPlay.Text      = "Play";
                }));

                _state = StateEnum.Stopped;
            }
        }
예제 #3
0
 private void _ts_OnQueueCompleted(EZ_B.EZTaskScheduler sender)
 {
     ARC.Scripting.VariableManager.SetVariable(FormMain._VariableIsRunning, false);
 }