Beispiel #1
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
        }
Beispiel #2
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());
            }
        }