Пример #1
0
        public async Task <CalibrationExecutionReport> FinishAsync()
        {
            if (_states.CanFire(CalibratorAction.Finish))
            {
                CalibrationExecutionReport report = null;
                if (_pointsLeft <= 0)
                {
                    var result = await _tracker.ComputeCalibrationAsync();

                    var data = _tracker.GetCalibration();
                    var plan = new CalibrationPlan(_calibratedPoints);
                    report = new CalibrationExecutionReport(plan, result, data);

                    _calibrations.Add(result);
                    CalibrationFinished?.Invoke(this, result);
                }

                await _states.FireAsync(CalibratorAction.Finish);

                return(report);
            }
            else
            {
                throw new InvalidOperationException($"Cannot finish calibration in the current state of Calibrator: {State.ToString()}");
            }
        }
Пример #2
0
        public async Task StartAsync(CalibrationPlan plan)
        {
            _pointsLeft = plan.Length;
            _calibratedPoints.Clear();

            await _tracker.StartCalibrationAsync();

            _states.Fire(CalibratorAction.Start);
        }
Пример #3
0
 public bool CanStart(CalibrationPlan plan) => _states.CanFire(CalibratorAction.Start) &&
 plan != null &&
 plan.Length > 0 &&
 plan.All(p => p.X > 0d && p.Y < 1d);
Пример #4
0
 internal CalibrationExecutionReport(CalibrationPlan plan, CalibrationResult result, CalibrationData data)
 {
     Plan   = plan;
     Result = result;
     Data   = data;
 }