コード例 #1
0
        public static async Task <TemperatureCalibrationErrorVM> CreateAsync(CalibratedPoint[] points)
        {
            var vm = new TemperatureCalibrationErrorVM();

            vm.Angle = "Inc={0} Azi={1} GTF={2}".Format(points[0].Angle.X, points[0].Angle.Y, points[0].Angle.Z);
            try
            {
                await calculateParametersAsync();
            }
            catch (Exception ex)
            {
                Logger.LogErrorEverywhere("Ошибка расчета контрольных параметров", ex);

                throw;
            }

            return(vm);

            async Task calculateParametersAsync()
            {
                vm.VectorsSets = new OptionVM <SensorsSetVM>[]
                {
                    new OptionVM <SensorsSetVM>("Углы", await SensorsSetVM.CreateAsync(VectorSet.ANGLES, points)),
                    new OptionVM <SensorsSetVM>("Магнитометр", await SensorsSetVM.CreateAsync(VectorSet.MAGNITOMETR, points)),
                    new OptionVM <SensorsSetVM>("Акселерометр", await SensorsSetVM.CreateAsync(VectorSet.ACCELEROMETR, points)),
                };
                vm.SelectedSet = vm.VectorsSets[0];
            }
        }
コード例 #2
0
        public override async Task ReloadAsync()
        {
            using (new FlagInverseAction(true, v => IsLoading = v))
            {
                var hasOldState = Error != null;
                var oldAngle    = Error?.Angle;
                var oldVSet     = Error?.SelectedSet?.Value?.Set;

                foreach (var useTestAngle in new bool[] { false, true })
                {
                    var baseMeasures  = _calibrator.Results.ToList();
                    var calibratorApp = new CalibratorApplication(baseMeasures, _calibrator.Constants);
                    var points        = await calibratorApp.CalculateErrorsAsync(useTestAngle);

                    var errors = new ErrorsCollection();
                    var tasks  = points.Length.Range()
                                 .Select(i => TemperatureCalibrationErrorVM.CreateAsync(points[i]))
                                 .ToArray();
                    for (int i = 0; i < points.Length; i++)
                    {
                        errors.Add(await tasks[i]);
                        errors[i].PropertyChanged += TemperatureCalibrationErrorsVM_PropertyChanged1;
                    }

                    _errors[useTestAngle] = errors;
                }

                Update();

                if (hasOldState)
                {
                    Error             = _errors[UseTestPoint].First(e => e.Angle == oldAngle);
                    Error.SelectedSet = Error.VectorsSets.First(s => s.Value.Set == oldVSet);
                }
            }
        }