Example #1
0
 public ClangAnalyzer(DTE2 dte2)
 {
     State   = AnalyzeState.IDLE;
     _report = new Reporting.Report();
     _dte2   = dte2;
     SetOutputPaneWindows();
 }
Example #2
0
        public void Stop()
        {
            OutputPaneWriteln("Stopping analysis ...");
            switch (State)
            {
            case AnalyzeState.IDLE:
                ts.TraceInformation("Stop not running anyway");
                break;

            case AnalyzeState.RUNNING:
                if (_process != null)
                {
                    ts.TraceInformation("Stop killing process");
                    _process.Kill();
                    State = AnalyzeState.IDLE;
                }
                else
                {
                    ts.TraceInformation("Stop running but no process to kill");
                    OnStopAnalyze(true);
                }
                break;

            default:
                ts.TraceData(TraceEventType.Error, 1, "Stop not in a know state");
                break;
            }
        }
Example #3
0
 private void OnStartAnalyze()
 {
     ts.TraceInformation("OnStartAnalyze");
     State = AnalyzeState.RUNNING;
     OutputPaneClear();
     OutputPaneShow();
     ReportingStart();
     DelegateStartAnalyze(true);
 }
Example #4
0
 private void SeekPrev_Click(object sender, RoutedEventArgs e)
 {
     if (analyzeState == AnalyzeState.SelectTL)
     {
         System.Windows.MessageBox.Show("Click on the top-left corner, then on the bottom-right corner of the game area.");
     }
     else
     {
         analyzeState = AnalyzeState.FindEnd;
     }
 }
Example #5
0
        public void Init()
        {
            _screenshot = new EmguScreenshot("Screenshots/tetris_play_1.png", TimeSpan.Zero);
            _screenshot.OriginalImage = _screenshot.Image;

            var currentPiece = Tetrimino.S;
            var nextPiece    = Tetrimino.L;
            var moves        = new List <Move> {
                Move.Left, Move.Rotate, Move.Drop
            };

            _agent           = new TetrisAgent(_configMock.Object, _clockMock.Object, _quantizer, _executorMock.Object, _extractor, _boardExtractor, _screenExtractor, _search);
            _agent.GameState = new GameState(currentPiece, nextPiece);

            _analyzeState = new AnalyzeState(_agent, TimeSpan.Zero, currentPiece);
            _executeState = new ExecuteState(_agent, moves, new Piece(currentPiece));
        }
Example #6
0
        private void OnStopAnalyze(bool error)
        {
            ts.TraceInformation("OnStopAnalyze");
            State = AnalyzeState.IDLE;

            ReportingStop();

            if (error)
            {
                OutputPaneWriteln("************* Analyzing errors, see log for more info ");
            }
            else
            {
                ReportDisplay();
                OutputPaneWriteln("Analyzing done");
            }

            OutputPaneShow();

            DelegateStopAnalyze(true);
        }
Example #7
0
        private async void Analyzer_Tick(object sender, object e)
        {
            if (analyzeState == AnalyzeState.Idle || analyzeState == AnalyzeState.SelectBR || analyzeState == AnalyzeState.SelectTL)
            {
                return;
            }
            if (Video.IsSeeking)
            {
                return;
            }
            var bmp = await Video.CaptureBitmapAsync();

            bool isBlack = IsBlack(bmp);

            if (analyzeState == AnalyzeState.FindStart)
            {
                if (isBlack)
                {
                    analyzeState = AnalyzeState.Idle;
                }
                else
                {
                    await Video.StepForward();
                }
            }
            else if (analyzeState == AnalyzeState.FindEnd)
            {
                if (isBlack)
                {
                    analyzeState = AnalyzeState.Idle;
                }
                else
                {
                    await Video.StepBackward();
                }
            }
        }