コード例 #1
0
        /// <summary>
        /// Checks the parallelism of two transitions in a petrinet recursively
        /// In some petrinets with a high complexity
        /// </summary>
        /// <param name="transition1">Eventname of y-direction</param>
        /// <param name="transition2">Eventname of x-direction</param>
        /// <param name="petriNet">Petrinet</param>
        /// <returns>Return true if the two transitions are parallel</returns>
        /// <autor>Andrej Albrecht</autor>
        // ReSharper disable once UnusedMember.Local
        private static bool CheckTransitionIsParallel(string transition1, string transition2, PetriNet petriNet)
        {
            Transition transitionY = petriNet.FindTransition(transition1);
            Transition transitionX = petriNet.FindTransition(transition2);

            return(CheckTransitionIsParallel(transitionY, transitionX, petriNet));
        }
コード例 #2
0
        /// <summary>
        /// Returns a list of places between two transitions in a petrinet
        /// </summary>
        /// <param name="t1">Transitionname</param>
        /// <param name="t2">Transitionname</param>
        /// <param name="petriNet">Petrinet</param>
        /// <returns>Returns a list of places</returns>
        /// <autor>Andrej Albrecht</autor>
        private List <Place> GetListOfPlacesBetweenTwoTransitionsFromPetriNet(string t1, string t2, PetriNet petriNet)
        {
            Transition      transition1     = petriNet.FindTransition(t1);
            Transition      transition2     = petriNet.FindTransition(t2);
            HashSet <Place> placesInBetween = new HashSet <Place>();

            foreach (Place outgoingPlace in transition1.OutgoingPlaces)
            {
                if (transition2.IncomingPlaces.Contains(outgoingPlace))
                {
                    placesInBetween.Add(outgoingPlace);
                }
            }

            return(placesInBetween.ToList());
        }
コード例 #3
0
        /// <summary>
        /// Adds a place and the transitions it leads to.
        /// </summary>
        /// <param name="startingTransition">>Contains the starting transition</param>
        /// <param name="followers">node.followers</param>
        /// <param name="petriNet">Contains the current petri net</param>
        /// <returns>The two transitions that are in an XOR-relation.</returns>
        /// <author>Jannik Arndt</author>
        public List <Transition> StartXOR(Transition startingTransition, List <EventNode> followers, PetriNet petriNet)
        {
            if (followers.Count > 1)
            {
                for (var index = 0; index < followers.Count; index++)
                {
                    _openParallelismCount.Push(Parallelism.Xor);
                }
            }

            var newPlace = petriNet.AddPlace();
            var listOfFollowingTransitions = new List <Transition>();

            foreach (var eventNode in followers)
            {
                if (eventNode == null)
                {
                    break;
                }

                /* _____________________          __________         ____________________________
                 * | startingTransition |  --->  ( NewPlace )  --->  |  NewFollowingTransition  |
                 * '''''''''''''''''''''          **********         ''''''''''''''''''''''''''''
                 */
                var newFollowingTransition = petriNet.FindTransition(eventNode.InnerEvent.Name);
                // The following transition already exists => close something
                if (newFollowingTransition != null)
                {
                    if (_openParallelismCount.Count > 0)
                    {
                        switch (_openParallelismCount.Peek())
                        {
                        // Close XOR
                        case Parallelism.Xor:
                            newFollowingTransition.IncomingPlaces.Remove(newPlace);
                            startingTransition.AddOutgoingPlace(newFollowingTransition.IncomingPlaces.First());
                            _openParallelismCount.Pop();
                            break;

                        // Close AND
                        case Parallelism.And:
                            newFollowingTransition.AddIncomingPlace(newPlace);
                            startingTransition.AddOutgoingPlace(newPlace);
                            _openParallelismCount.Pop();
                            break;
                        }
                    }
                }
                // Open XOR
                else
                {
                    newFollowingTransition = petriNet.AddTransition(eventNode.InnerEvent.Name, incomingPlace: newPlace);
                    if (newPlace.IncomingTransitions.Count == 0)
                    {
                        startingTransition.AddOutgoingPlace(newPlace);
                    }
                }

                listOfFollowingTransitions.Add(newFollowingTransition);
            }
            if (newPlace.IncomingTransitions.Count == 0 && newPlace.OutgoingTransitions.Count == 0)
            {
                petriNet.Places.Remove(newPlace);
            }
            return(listOfFollowingTransitions);
        }