Пример #1
0
        public override object Clone()
        {
            var p = new AnalyseProject()
            {
                AnalyseEndTime      = AnalyseEndTime,
                AnalyseStartTime    = AnalyseStartTime,
                ProjectStartTime    = ProjectStartTime,
                CurrentDataSource   = CurrentDataSource.Clone() as IDataSource,
                DefaultFilterNumber = DefaultFilterNumber,
                Fine            = Fine,
                Grade           = Grade,
                Memo            = Memo,
                Name            = Name,
                TestStepDelayMS = TestStepDelayMS,
                Status          = Status
            };

            InstrumentList.ForEach(v => p.InstrumentList.Add(v.Clone() as IInstrument));
            ResultList.ForEach(v => p.ResultList.Add(v.Clone() as IInstrument));
            BlockList.ForEach(v => p.BlockList.Add(v.Clone() as IInstrument));
            ConditionList.ForEach(v => p.ConditionList.Add(v.Clone() as ICondition));
            PredicateList.ForEach(v => p.PredicateList.Add(v.Clone() as ICondition));

            return(p);
        }
Пример #2
0
        private async void FindPathButton_Click(object sender, RoutedEventArgs e)
        {
            Point        startPosition  = new Point(-1, -1);
            Point        targetPosition = new Point(-1, -1);
            var          field          = new int[MATRIX_SIZE, MATRIX_SIZE * 2];
            List <Point> wallList       = new List <Point>();

            targetPosition = BlockList.Where(x => x.NType == NodeType.Target).Select(x => x.Position).FirstOrDefault();

            if (targetPosition == null)
            {
                return;
            }

            var searchWall = BlockList.Where(x => x.NType == NodeType.Wall).Select(x => x.Position);

            foreach (var item in searchWall)
            {
                wallList.Add(item);
            }

            int countPaths = CurrentBlockList.Count;

            List <Point>[] PathsList = new List <Point> [countPaths];

            ASpeedModifier speedModifier = new ASpeedModifier()
            {
                SearchDelayInMilliseconds = 10,
                ViewDelayInMilliseconds   = 20
            };

            List <List <Point> > pathListArray = new List <List <Point> >();

            long timeElapseWithDisplay    = 0;
            long timeElapseWithoutDisplay = 0;

            var tasks = CurrentBlockList.Select(async(x) =>
            {
                var watchWithDisplay    = Stopwatch.StartNew();
                var watchWithoutDisplay = Stopwatch.StartNew();

                await aSCore.FindPathWithoutDisplayAsync(field, startPosition, targetPosition, wallList)
                .ContinueWith(t => watchWithoutDisplay.Stop());

                pathListArray.Add(await aSCore.FindPathAsync(field, x.Position, targetPosition, wallList, BlockList, speedModifier));

                watchWithDisplay.Stop();

                timeElapseWithDisplay    += watchWithDisplay.ElapsedMilliseconds;
                timeElapseWithoutDisplay += watchWithoutDisplay.ElapsedMilliseconds;
            });

            await Task.WhenAll(tasks);

            //Тест
            BlockList.ForEach((x) =>
            {
                if (x.NType == NodeType.SearchPath)
                {
                    x.NType = NodeType.Passable;
                }
            });

            pathListArray.ForEach(async x => await ViewPass(x, speedModifier));

            elapsedTimeLabel.Content = " Скорость: " + Math.Round((double)timeElapseWithoutDisplay / timeElapseWithDisplay, 4)
                                       + " Всего: " + timeElapseWithDisplay
                                       + " мс. | Всего за поиск: " + timeElapseWithoutDisplay
                                       + " мс.";
        }