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()}"); } }
public async Task StartAsync(CalibrationPlan plan) { _pointsLeft = plan.Length; _calibratedPoints.Clear(); await _tracker.StartCalibrationAsync(); _states.Fire(CalibratorAction.Start); }
public bool CanStart(CalibrationPlan plan) => _states.CanFire(CalibratorAction.Start) && plan != null && plan.Length > 0 && plan.All(p => p.X > 0d && p.Y < 1d);
internal CalibrationExecutionReport(CalibrationPlan plan, CalibrationResult result, CalibrationData data) { Plan = plan; Result = result; Data = data; }