コード例 #1
0
 public void Handle(StartedEvent message)
 {
     if (!startInTray)
     {
         ShowWindow();
     }
 }
コード例 #2
0
 public void Handle(StartedEvent message)
 {
     Environment
     .GetCommandLineArgs()
     .Skip(1)
     .ForEach(CreateScriptViewModel);
 }
コード例 #3
0
        //------------------------------------------------------------------------/
        // Methods
        //------------------------------------------------------------------------/
        /// <summary>
        /// Adds the status onto the target
        /// </summary>
        /// <param name="target"></param>
        /// <param name="timeStep"></param>
        /// <returns>True if the status has ended, false otherwise. </returns>
        public void Apply(CombatController caster, CombatController target)
        {
            var startedEvent = new StartedEvent();

            startedEvent.status = new Instance(this, caster, target);
            target.gameObject.Dispatch <StartedEvent>(startedEvent);
        }
コード例 #4
0
ファイル: RobotControl.cs プロジェクト: pkhanal/k3po.dotnet
        private StartedEvent ReadStartedEvent()
        {
            StartedEvent startedEvent = new StartedEvent();
            string       headerLine;

            do
            {
                headerLine = ReadLine();
                Match headerMatch = Regex.Match(headerLine, HEADER_PATTERN);
                if (headerMatch.Success)
                {
                    string headerName  = headerMatch.Groups[1].Value;
                    string headerValue = headerMatch.Groups[2].Value;

                    if (headerName.Equals("name"))
                    {
                        startedEvent.Name = headerValue;
                    }
                    else
                    {
                        throw new InvalidOperationException(String.Format("Invalid header - '{0}:{1}' while parsing STARTED event", headerName, headerValue));
                    }
                }
            } while (headerLine != String.Empty);

            return(startedEvent);
        }
コード例 #5
0
        public static ChaosEvent FromNativeEvent(NativeTypes.FABRIC_CHAOS_EVENT nativeEvent)
        {
            switch (nativeEvent.Kind)
            {
            case NativeTypes.FABRIC_CHAOS_EVENT_KIND.FABRIC_CHAOS_EVENT_KIND_STARTED:
                return(StartedEvent.FromNative(nativeEvent.Value));

            case NativeTypes.FABRIC_CHAOS_EVENT_KIND.FABRIC_CHAOS_EVENT_KIND_EXECUTING_FAULTS:
                return(ExecutingFaultsEvent.FromNative(nativeEvent.Value));

            case NativeTypes.FABRIC_CHAOS_EVENT_KIND.FABRIC_CHAOS_EVENT_KIND_STOPPED:
                return(StoppedEvent.FromNative(nativeEvent.Value));

            case NativeTypes.FABRIC_CHAOS_EVENT_KIND.FABRIC_CHAOS_EVENT_KIND_TEST_ERROR:
                return(TestErrorEvent.FromNative(nativeEvent.Value));

            case NativeTypes.FABRIC_CHAOS_EVENT_KIND.FABRIC_CHAOS_EVENT_KIND_VALIDATION_FAILED:
                return(ValidationFailedEvent.FromNative(nativeEvent.Value));

            case NativeTypes.FABRIC_CHAOS_EVENT_KIND.FABRIC_CHAOS_EVENT_KIND_WAITING:
                return(WaitingEvent.FromNative(nativeEvent.Value));

            default:
                return(null);
            }
        }
コード例 #6
0
        public static ChaosEvent GetEventFromBytes(byte[] data)
        {
            ChaosEvent     e    = null;
            ChaosEventType type = (ChaosEventType)BitConverter.ToInt32(data, 0);

            switch (type)
            {
            case ChaosEventType.Started:
            {
                e = new StartedEvent();
            }

            break;

            case ChaosEventType.Stopped:
            {
                e = new StoppedEvent();
            }

            break;

            case ChaosEventType.ExecutingFaults:
            {
                e = new ExecutingFaultsEvent();
            }

            break;

            case ChaosEventType.ValidationFailed:
            {
                e = new ValidationFailedEvent();
            }

            break;

            case ChaosEventType.TestError:
            {
                e = new TestErrorEvent();
            }

            break;

            case ChaosEventType.Waiting:
            {
                e = new WaitingEvent();
            }

            break;
            }

            if (e != null)
            {
                byte[] eventData = new byte[data.Length - 4];
                Array.Copy(data, 4, eventData, 0, eventData.Length);
                e.FromBytes(eventData);
            }

            return(e);
        }
コード例 #7
0
        /// <summary>
        /// Starts this trigger.
        /// </summary>
        /// <param name="space"></param>
        public void Start(StratusCombatController caster, Type type, float duration)
        {
            var startedEvent = new StartedEvent();

            // Make a copy of this trigger ??
            startedEvent.Instance = new StratusCombatTrigger.Instance(Copy(this), caster, type, duration);
            StratusScene.Dispatch <StartedEvent>(startedEvent);
        }
コード例 #8
0
        public async void CycleProcess(Rack _rack)
        {
            if (!CmmOnline)
            {
                return;
            }

            Working = true;
            StartedEvent?.Invoke(this, null);
            _cts = new CancellationTokenSource();
            Tray tray = null;
            bool success;

            while (true)
            {
                if (_cts.IsCancellationRequested)
                {
                    break;
                }

                tray = await _traySelector.ExecuteAsync(_rack, _cts);

                if (tray == null)
                {
                    break;
                }

                if (_cts.IsCancellationRequested)
                {
                    tray.Status = TrayStatus.TS_Idle;
                    break;
                }

                SetupTray(tray);

                success = await _rootActivity.ExecuteAsync(CurrentTray, _cts).ConfigureAwait(false);

                if (!success)
                {
                    // 报告错误并跳出循环
                    tray.Status = TrayStatus.TS_Error;
                    break;
                }
                tray.Status = TrayStatus.TS_Measured;
            }
            // 如果运行到这里,设置离线可能会断不开连接
            // 在cmmControl中增加标志位,是否还在连接
            //if (!CmmOnline)
            //{
            //    _cmmControl.Offline();
            //}
            Working = false;
            StoppedEvent?.Invoke(this, null);
            _offlineWaitFlag.Set();
        }
コード例 #9
0
        public void Init()
        {
            if (BlockChanged == null)
            {
                BlockChanged = new PerBlockEvent();
            }
            if (Started == null)
            {
                Started = new StartedEvent();
            }
            if (Stopped == null)
            {
                Stopped = new StoppedEvent();
            }

            StartBlock = 0;
            var musicPlayerInstance = new GameObject {
                name = "AudioSource"
            };

            if (pianoMixerGroup != null)
            {
                pianoPlayer = musicPlayerInstance.AddComponent <AudioSource>();
                pianoPlayer.outputAudioMixerGroup = pianoMixerGroup;
            }

            if (ePianoMixerGroup != null)
            {
                ePianoPlayer = musicPlayerInstance.AddComponent <AudioSource>();
                ePianoPlayer.outputAudioMixerGroup = ePianoMixerGroup;
            }

            if (stringMixerGroup != null)
            {
                stringPlayer = musicPlayerInstance.AddComponent <AudioSource>();
                stringPlayer.outputAudioMixerGroup = stringMixerGroup;
            }

            if (backingTrackMixerGroup != null)
            {
                backingTrackPlayers = new List <AudioSource>();
                foreach (AudioClip clip in data.BackingTracks)
                {
                    var backingTrackPlayer = musicPlayerInstance.AddComponent <AudioSource>();
                    backingTrackPlayer.outputAudioMixerGroup = backingTrackMixerGroup;
                    backingTrackPlayer.clip = clip;
                    backingTrackPlayers.Add(backingTrackPlayer);
                }
            }

            EntryPoint.Instance.Updated.AddListener(Update);

            ResetGrid();
        }
コード例 #10
0
        /// <summary>
        ///
        /// </summary>
        public void Start()
        {
            if (_status != RunningStatus.Stopped)
            {
                return;
            }

            if (_settings.Path == "")
            {
                throw new Exception($"[{_settings.Name}]: 'Path' property not set");
            }
            if (_settings.Server == "")
            {
                throw new Exception($"[{_settings.Name}]: 'Server' property not set");
            }

            _completionEvent.WaitOne();
            try
            {
                _completionEvent.Reset();
                _statistics.Lock();
                _statistics.Reset();
                _statistics.Unlock();
                LoadNativeModule();

                if (_feederInstance == IntPtr.Zero)
                {
                    InitInstance();
                    _failedConnectAttempts = 0;
                    //flag = false;
                }

                lock (_stateLock)
                {
                    _timer.Change(0, Timeout.Infinite);
                }
                _status = RunningStatus.Running;
                StartedEvent?.Invoke(this, null);
            }
            finally
            {
                _completionEvent.Set();
            }
        }
コード例 #11
0
        /// <summary>
        ///
        /// </summary>
        public void Resume()
        {
            if (_status != RunningStatus.Paused)
            {
                return;
            }

            _completionEvent.WaitOne();
            try
            {
                _completionEvent.Reset();
                _status = RunningStatus.Running;
            }
            finally
            {
                _completionEvent.Set();
                StartedEvent?.Invoke(this, null);
            }
        }
コード例 #12
0
 private void OnStartedEvent()
 {
     StartedEvent?.Invoke(this, EventArgs.Empty);
 }
コード例 #13
0
        public void Execute(MacroEntry macro)
        {
            _macro = macro;

            if (Thread != null && Thread.IsAlive)
            {
                Stop();
            }

            _cancellationToken = new CancellationTokenSource();

            if (_importCache == null)
            {
                _importCache = InitializeImports(_engine);
            }

            ScriptSource source = _engine.CreateScriptSourceFromString(_macro.Macro, SourceCodeKind.Statements);

            Dictionary <string, object> importCache = new Dictionary <string, object>(_importCache);

            IsFaulted = false;

            Thread = new Thread(() =>
            {
                Thread = Thread.CurrentThread;

                try
                {
                    StartedEvent?.Invoke();

                    AliasCommands.SetDefaultAliases();

                    ScriptScope macroScope = _engine.CreateScope(importCache);

                    _stopWatch.Reset();
                    _stopWatch.Start();

                    do
                    {
                        _cancellationToken.Token.ThrowIfCancellationRequested();

                        source.Execute(macroScope);

                        _stopWatch.Stop();

                        bool willLoop = _macro.Loop && !IsFaulted && !_cancellationToken.IsCancellationRequested;

                        if (!willLoop)
                        {
                            break;
                        }

                        if (Options.CurrentOptions.Debug)
                        {
                            UO.Commands.SystemMessage(string.Format(Strings.Loop_time___0_, _stopWatch.Elapsed));
                        }

                        int diff = 50 - (int)_stopWatch.ElapsedMilliseconds;

                        if (diff > 0)
                        {
                            Thread.Sleep(diff);
                        }
                    }while (_macro.Loop && !IsFaulted);
                }
                catch (TaskCanceledException)
                {
                    IsFaulted = true;
                }
                catch (ThreadInterruptedException)
                {
                    IsFaulted = true;
                }
                catch (ThreadAbortException)
                {
                    IsFaulted = true;
                }
                catch (Exception e)
                {
                    IsFaulted = true;
                    Exception = e;

                    ExceptionEvent?.Invoke(e);
                }
                finally
                {
                    StoppedEvent?.Invoke();
                }
            })
            {
                IsBackground = true
            };

            try
            {
                Thread.Start();
                Thread.Join();
            }
            catch (ThreadStartException)
            {
                // TODO
            }
        }
コード例 #14
0
 protected virtual void OnStartedEvent()
 {
     StartedEvent?.Invoke(this, EventArgs.Empty);
 }