Ejemplo n.º 1
0
        private void AssertOneWayUpdatesPetriNetToFsm(Pn.Place p1, Fsm.State p1State)
        {
            if (p1 == null)
            {
                return;
            }

            p1.Id = "foo2";

            Assert.AreEqual("foo2", p1State.Name);
            Assert.IsFalse(p1State.IsEndState);

            var t = new Pn.Transition();

            t.From.Add(p1);
            pn.Transitions.Add(t);

            Assert.IsTrue(p1State.IsEndState);
        }
Ejemplo n.º 2
0
        private void FillPetriNet()
        {
            var p1 = new Pn.Place()
            {
                Id = "s1"
            };

            var p2 = new Pn.Place()
            {
                Id = "s2"
            };

            var p3 = new Pn.Place()
            {
                Id = "s4"
            };

            var t1 = new Pn.Transition()
            {
                Input = "a"
            };

            var t2 = new Pn.Transition()
            {
                Input = "c"
            };

            t1.From.Add(p1);
            t1.To.Add(p2);

            t2.From.Add(p1);
            t2.To.Add(p3);
            t2.To.Add(p2);

            pn.Places.Add(p1);
            pn.Places.Add(p2);
            pn.Places.Add(p3);
            pn.Transitions.Add(t1);
            pn.Transitions.Add(t2);
        }
Ejemplo n.º 3
0
        private void FillPetriNet()
        {
            var p1 = new Pn.Place()
            {
                Id = "s1"
            };

            var p2 = new Pn.Place()
            {
                Id = "s2"
            };

            var p3 = new Pn.Place()
            {
                Id = "s4"
            };

            var t1 = new Pn.Transition()
            {
                Input = "a"
            };

            var t2 = new Pn.Transition()
            {
                Input = "c"
            };

            t1.From.Add(p1);
            t1.To.Add(p2);

            t2.From.Add(p1);
            t2.To.Add(p3);
            t2.To.Add(p2);

            pn.Places.Add(p1);
            pn.Places.Add(p2);
            pn.Places.Add(p3);
            pn.Transitions.Add(t1);
            pn.Transitions.Add(t2);
        }
Ejemplo n.º 4
0
        private void AssertOneWayUpdatesFsmToPetriNet(Fsm.State s1, Pn.Place s1Place)
        {
            if (s1 == null)
            {
                return;
            }

            s1.Name = "foo1";

            Assert.AreEqual("foo1", s1Place.Id);

            var oldTransitions = pn.Transitions.Count;

            s1.IsEndState = true;

            Assert.AreEqual(oldTransitions + 1, pn.Transitions.Count);
            Assert.IsTrue(s1Place.Outgoing.Any(t => t.To.Count == 0));

            s1.IsEndState = false;

            Assert.AreEqual(oldTransitions, pn.Transitions.Count);
            Assert.IsFalse(s1Place.Outgoing.Any(t => t.To.Count == 0));
        }