Exemple #1
0
        public async void RunTrial()
        {
            TrialStart?.Invoke(this, _TrialLoop.CurrentIteration);
            _Status = StatusType.TrialDelay;
            try
            {
                await TrialDelay.RunAsync(CancelToken);

                if (!CancelToken.IsCancellationRequested)
                {
                    CurrentState = StartState;
                    ScriptMachineEventArgs e = new ScriptMachineEventArgs(StartState);
                    ScriptStart?.Invoke(this, e);
                    _MazeDataPoint         = new MazeDataPoint(CurrentState.Name);
                    _MazeDataPoint.Session = _SessionLoop.CurrentIteration;
                    _MazeDataPoint.Trial   = _TrialLoop.CurrentIteration;
                    DataPointReady?.Invoke(this, _MazeDataPoint);
                    CurrentState.Activate();
                    _Status    = StatusType.Running;
                    _StartTime = DateTime.Now;
                }
                else
                {
                    TrialAborted?.Invoke(this, new EventArgs());
                }
            }
            catch (Exception ex)
            {
                TrialAborted?.Invoke(this, new EventArgs());
            }
        }
Exemple #2
0
        private void State_StateCompleted(object sender, ScriptStateEventArgs e)
        {
            CurrentState = null;
            States.TryGetValue(e.NextState, out _CurrentState);
            if (CurrentState.Type == ScriptState.StateType.Complete)
            {
                Status   = StatusType.Completed;
                _EndTime = DateTime.Now;
                //_MazeDataPoint.Stop();
                //DataPointReady?.Invoke(this, _MazeDataPoint);
                //ScriptEnd?.Invoke(this, new ScriptEndEventArgs(true, RunTime));
                //CurrentState = StartState;
            }
            StateChanged?.Invoke(this, new ScriptMachineEventArgs(CurrentState));
            _MazeDataPoint.Stop();
            _MazeDataPoint.ExitAction = e.Condition.Label;
            //DataPointReady?.Invoke(this, _MazeDataPoint);
            _MazeDataPoint         = new MazeDataPoint(CurrentState.Name);
            _MazeDataPoint.Session = _SessionLoop.CurrentIteration;
            _MazeDataPoint.Trial   = _TrialLoop.CurrentIteration;
            DataPointReady?.Invoke(this, _MazeDataPoint);

            if (CurrentState.Type == ScriptState.StateType.Complete)
            {
                ScriptEnd?.Invoke(this, new ScriptEndEventArgs(true, RunTime));
                //CurrentState = StartState;

                if (_TrialLoop.Next() > 0)
                {
                    RunTrial();
                }
                else
                {
                    _TrialLoop.Reset();
                    if (_SessionLoop.Next() > 0)
                    {
                        RunSession();
                    }
                    else
                    {
                        SessionSetComplete?.Invoke(this, new EventArgs());
                    }
                }
            }
        }
Exemple #3
0
 private void ScriptFSM_DataPointReady(object sender, MazeDataPoint e)
 {
     e.Trial = CurrentTrial;
     DataPointReady?.Invoke(this, e);
 }
Exemple #4
0
 private void ScriptFSM_DataPointReady(object sender, MazeDataPoint e)
 {
     e.Session = CurrentSession;
     DataPointReady?.Invoke(this, e);
 }