예제 #1
0
        public override bool Equals(Condition other)
        {
            AndCondition ot = other as AndCondition;

            if (ot == null)
            {
                return(false);
            }
            return(IteratorEquals(_conditions.GetEnumerator(), ot._conditions.GetEnumerator()));
        }
예제 #2
0
        public void Pattern_Conditions()
        {
            Project p = new Project();
            MathSystem s = p.CurrentSystem;

            // sin(x^2)
            Signal x = Binder.CreateSignal(); x.Label = "x";
            Std.ConstrainAlwaysReal(x);
            Signal x2 = StdBuilder.Power(x, IntegerValue.ConstantTwo); x2.Label = "x2";
            Signal sinx2 = StdBuilder.Sine(x2); sinx2.Label = "sinx2";

            AlwaysTrueCondition ctrue = AlwaysTrueCondition.Instance;
            Assert.AreEqual(true, ctrue.FulfillsCondition(x, x.DrivenByPort), "A01");

            EntityCondition centity = new EntityCondition(new MathIdentifier("Sine", "Std"));
            Assert.AreEqual(true, centity.FulfillsCondition(sinx2, sinx2.DrivenByPort), "A02");
            Assert.AreEqual(false, centity.FulfillsCondition(x2, x2.DrivenByPort), "A03");

            //InputSignalsPropertyCondition cinputconst = new InputSignalsPropertyCondition(new MathIdentifier("Constant", "Std"), CombinationMode.AtLeastOne);
            InputSignalsFlagCondition cinputconst = new InputSignalsFlagCondition(StdAspect.ConstantFlag, FlagState.Enabled, CombinationMode.AtLeastOne);
            Assert.AreEqual(true, cinputconst.FulfillsCondition(x2, x2.DrivenByPort), "A04");
            Assert.AreEqual(false, cinputconst.FulfillsCondition(sinx2, sinx2.DrivenByPort), "A05");

            OrCondition cor = new OrCondition(centity, cinputconst);
            Assert.AreEqual(true, cor.FulfillsCondition(x2, x2.DrivenByPort), "A06");
            Assert.AreEqual(true, cor.FulfillsCondition(sinx2, sinx2.DrivenByPort), "A07");
            Assert.AreEqual(false, cor.FulfillsCondition(x, x.DrivenByPort), "A08");

            AndCondition cand = new AndCondition(ctrue, centity);
            Assert.AreEqual(true, cand.FulfillsCondition(sinx2, sinx2.DrivenByPort), "A09");
            Assert.AreEqual(false, cand.FulfillsCondition(x2, x2.DrivenByPort), "A10");
        }