コード例 #1
0
ファイル: TokenViewer.xaml.cs プロジェクト: Alleshka/Gidra
        public TokenViewer(TokensCollector collector)
        {
            // Создаём форму
            InitializeComponent();
            _collector = collector; // Сохраняем коллектор

            StartView();            // Запускаем работу
        }
コード例 #2
0
ファイル: TokenViewer.xaml.cs プロジェクト: Alleshka/Gidra
        public TokenViewer()
        {
            // Создаём форму
            InitializeComponent();

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog
            {
                FileName   = "TokenCollectorlog",
                DefaultExt = ".xml",
                Filter     = "(XML documents .xml)|*.xml",
            };

            if (dlg.ShowDialog() == true)
            {
                using (System.IO.FileStream stream = new System.IO.FileStream(dlg.FileName, System.IO.FileMode.Open))
                {
                    Type[] types = new Type[] {
                        typeof(AndBlock),
                        typeof(DuplicateOutputsBlock),
                        typeof(CadResource),
                        typeof(WorkerResource),
                        typeof(TechincalSupportResource),
                        typeof(MethodolgicalSupportResource),
                        typeof(TokensCollector),
                        typeof(ConnectionManager),
                        typeof(ArrangementProcedure),
                        typeof(Assembling),
                        typeof(ClientCoordinationPrrocedure),
                        typeof(DocumentationCoordinationProcedure),
                        typeof(ElectricalSchemeSimulation),
                        typeof(FixedTimeBlock),
                        typeof(FormingDocumentationProcedure),
                        typeof(Geometry2D),
                        typeof(KDT),
                        typeof(KinematicСalculations),
                        typeof(PaperworkProcedure),
                        typeof(QualityCheckProcedure),
                        typeof(SampleTestingProcedure),
                        typeof(SchemaCreationProcedure),
                        typeof(StrengthСalculations),
                        typeof(TracingProcedure),
                        typeof(Process)
                    };

                    System.Runtime.Serialization.DataContractSerializer ser = new System.Runtime.Serialization.DataContractSerializer(typeof(TokensCollector), types);
                    _collector = (TokensCollector)ser.ReadObject(stream);
                    StartView();
                }
            }
            else
            {
                throw new ArgumentNullException("Файл не выбран");
            }
        }
コード例 #3
0
        public void AddTokenTest()
        {
            #region Тест одновходного блока и
            AndBlock andBlock = new AndBlock(1);


            andBlock.AddToken(new Token(0, 0), 0);
            //првоеряем, родил ли блок токен
            Assert.IsNotNull(andBlock.GetOutputToken(0));
            #endregion

            #region Тест двувходного блока
            andBlock = new AndBlock(2);
            andBlock.AddToken(new Token(1, 2), 0);
            //не должен был родить
            Assert.IsNull(andBlock.GetOutputToken(0));


            andBlock.AddToken(new Token(2, 5), 1);
            var token = andBlock.GetOutputToken(0);
            //должен был родить
            Assert.IsNotNull(token);

            //времмя рождения должно быть как последнее из всех входных, т.е. 2
            Assert.AreEqual(2, token.BornTime, 0.1);
            //сложность должна быть средним арифмектическим
            Assert.AreEqual((2 + 5) / 2.0, token.Complexity, 0.1);

            TokensCollector tokensCollector = TokensCollector.GetInstance();
            var             collectorToken1 = tokensCollector.GetHistory()[1];
            var             collectorToken2 = tokensCollector.GetHistory()[2];
            //в коллектор должны были прийти входные
            Assert.IsNotNull(collectorToken1);
            Assert.IsNotNull(collectorToken2);

            //время обработки должно быть как последнее время рождения
            Assert.AreEqual(token.BornTime, collectorToken1.ProcessEndTime, 0.1);
            Assert.AreEqual(token.BornTime, collectorToken2.ProcessEndTime, 0.1);
            #endregion
        }
コード例 #4
0
        private void Statictics()
        {
            using (FileStream stream = new FileStream($"tokens-log-{System.DateTime.Now.ToString("dd.MM.yyyy hh-mm-ss")}.xml", FileMode.Create))
            {
                Type[] types = new Type[]
                {
                    typeof(AndBlock),
                    typeof(DuplicateOutputsBlock),
                    typeof(CadResource),
                    typeof(WorkerResource),
                    typeof(TechincalSupportResource),
                    typeof(MethodolgicalSupportResource),
                    typeof(TokensCollector),
                    typeof(ConnectionManager),
                    typeof(ArrangementProcedure),
                    typeof(Assembling),
                    typeof(ClientCoordinationPrrocedure),
                    typeof(DocumentationCoordinationProcedure),
                    typeof(ElectricalSchemeSimulation),
                    typeof(FixedTimeBlock),
                    typeof(FormingDocumentationProcedure),
                    typeof(Geometry2D),
                    typeof(KDT),
                    typeof(KinematicСalculations),
                    typeof(PaperworkProcedure),
                    typeof(QualityCheckProcedure),
                    typeof(SampleTestingProcedure),
                    typeof(SchemaCreationProcedure),
                    typeof(StrengthСalculations),
                    typeof(TracingProcedure),
                    typeof(Process)
                };

                System.Runtime.Serialization.DataContractSerializer ser = new System.Runtime.Serialization.DataContractSerializer(typeof(TokensCollector), types);
                ser.WriteObject(stream, TokensCollector.GetInstance());
            }
        }