public void Run()
 {
     Started.Set();
     EventStarted?.Invoke(this);
     Finished.Set();
     ContiniousBlockCompleted.Set();
     EventFinished?.Invoke(this);
 }
Exemplo n.º 2
0
 public void Run()
 {
     Started.Set();
     EventStarted?.Invoke(this);
     if (manager != null)
     {
         manager.SyncCoordinates(globalPosition);
     }
     Finished.Set();
     ContiniousBlockCompleted.Set();
     EventFinished?.Invoke(this);
 }
Exemplo n.º 3
0
 private void OnDroppedHdl(int nid)
 {
     if (nid != CommandId)
     {
         return;
     }
     Logger.Instance.Debug(this, "dropped", nid.ToString());
     ContiniousBlockCompleted.Set();
     Started.Set();
     Finished.Set();
     EventFinished?.Invoke(this);
 }
Exemplo n.º 4
0
 public void Run()
 {
     Started.Set();
     EventStarted?.Invoke(this);
     foreach (var reg in toolCommand.Registers)
     {
         sender.WriteRegister(reg.DeviceId, reg.RegisterId, reg.RegisterValue);
     }
     if (toolCommand.Delay > 0)
     {
         Thread.Sleep(toolCommand.Delay);
     }
     Finished.Set();
     ContiniousBlockCompleted.Set();
     EventFinished?.Invoke(this);
 }
Exemplo n.º 5
0
        private void OnFailedHdl(int nid, String line)
        {
            if (nid != CommandId)
            {
                return;
            }
            Logger.Instance.Debug(this, "failed", nid.ToString());
            var dict = new Dictionary <string, string>
            {
                ["error"] = line
            };

            ActionResult = dict;
            Failed       = true;
            Finished.Set();
            EventFinished?.Invoke(this);
        }
Exemplo n.º 6
0
        private void OnCompletedHdl(int nid, IReadOnlyDictionary <String, String> result)
        {
            if (nid != CommandId)
            {
                return;
            }
            Logger.Instance.Debug(this, "completed", nid.ToString());
            var dict = new Dictionary <string, string>();

            foreach (var pair in result)
            {
                dict.Add(pair.Key, pair.Value);
            }
            ActionResult = dict;
            Finished.Set();
            EventFinished?.Invoke(this);
        }
        public void Schedule(IEvent @event, Time time, Func <int, bool> maySchedule)
        {
            var scheduled = new ScheduledEvent(@event, time);

            Task.Run(async() =>
            {
                EventScheduled?.Invoke(this, scheduled);

                while (maySchedule(scheduled.TimesExecuted))
                {
                    await waiter.Wait(scheduled.TimeUntil.TotalMilliseconds());

                    @event.Execute();
                    scheduled.TimesExecuted++;
                }

                EventFinished?.Invoke(this, scheduled);
            });
        }