示例#1
0
        private void FillAndPopulateTc()
        {
            float inaccuracyScales   = Settings.Default.InaccuracyScales;
            float inaccuracyRoulette = Settings.Default.InaccuracyRoulette;

            _currentAuto.Foto                 = videoPictuce1.GetImage();
            _currentAuto.MestoKontrolya       = Program.ControlPlace;
            _currentAuto.Ppvk                 = Program.PpvkName;
            _currentAuto.CarId                = SpravochnikUtil.IdentificationNumber;
            _currentAuto.SpecIndex            = Settings.Default.YearIndex;
            _currentAuto.InaccuracyRoulette   = inaccuracyRoulette;
            _currentAuto.Scales.Number        = Program.ScaleNumber;
            _currentAuto.Scales.CheckDateFrom = SpravochnikUtil.GetVesiDate(Program.ScaleNumber, "DateOT");
            _currentAuto.Scales.CheckDateTo   = SpravochnikUtil.GetVesiDate(Program.ScaleNumber, "DateDO");
            _currentAuto.Scales.Inaccuracy    = inaccuracyScales;
            _currentAuto.Road.RoadType        = Program.CurrentRoadType;
            _currentAuto.Road.IsFederalRoad   = Program.IsFederalRoad;
            _currentAuto.AutoType             = (AutoType)cb_vid_TC.SelectedIndex + 1;
            _currentAuto.Road.Distance        = float.Parse(tb_Rastoyan.Text);

            _currentAuto.AxisList.Clear();
            foreach (WheelControl wheel in WheelList.GetRange(0, GetWheelCount()))
            {
                AxisType axisType = ConvertToAxisType(wheel.WheelState);
                _currentAuto.AddNewAxis(axisType: axisType,
                                        distanceToNext: wheel.DistanceToNext,
                                        weightValue: wheel.ScalesValue);
            }

            Calculator.Populate(_currentAuto);
        }
示例#2
0
        public void PopulateAutoTest(string distancesString,
                                     string loadsString,
                                     string fullDamage,
                                     AutoType autoType,
                                     RoadType roadType,
                                     bool isFederal,
                                     bool isKlimat,
                                     float inaccuracyScales,
                                     float inaccuracyRoulette)
        {
            Settings.Default.Klimat_usloviya       = isKlimat;
            Settings.Default.YearIndex             = 1.9749f;
            Settings.Default.DopustimiyProcentAxis = 5;
            Settings.Default.DopustimiyProcentAxis = 5;
            var auto = new Auto {
                InaccuracyRoulette = inaccuracyRoulette,
                AutoType           = autoType,
                Road =
                {
                    RoadType      = roadType,
                    Distance      =       100,
                    IsFederalRoad = isFederal,
                    IsSoftClothes = false
                },
                Scales =
                {
                    Inaccuracy = inaccuracyScales
                }
            };

            string[] distances = distancesString.Split(' ');
            string[] loads     = loadsString.Split(' ');

            for (int i = 0; i < loads.Length; i++)
            {
                var   state       = AxisType.Single;
                float distance    = i < distances.Length ? float.Parse(distances[i]) : 0;
                float weightValue = float.Parse(string.Concat(loads[i].Where(c => !char.IsLetter(c))));

                if (loads[i].Contains("D"))
                {
                    state = AxisType.Double;
                }
                if (loads[i].Contains("P"))
                {
                    state = state == AxisType.Double ? AxisType.DoubleAndPnevmo : AxisType.SingleAndPnevmo;
                }
                auto.AddNewAxis(state, distance, weightValue);
            }
            Calculator.Populate(auto);

            float damage = float.Parse(fullDamage);

            Assert.AreEqual(Math.Round(auto.FullAutoDamage), Math.Round(damage), $"Масса:{Environment.NewLine}{auto.FullWeightData}{Environment.NewLine}" +
                            $"Нагрузки:{Environment.NewLine}{string.Join(Environment.NewLine, auto.AxisList.Select(a => a.ToString()))}");
        }