/// <summary>
        /// Fires given transition in fitting manner based on number of input and output places.
        /// </summary>
        /// <param name="transition">A transition to be fired.</param>
        private void FireTransition(TransitionTokenTraverseOverlay transition)
        {
            {
                List <FootprintAnalysisToken> inputFootprints = GetFootprintsFromPlaces(transition.InputPlaces);
                FootprintAnalysisToken        newFootprint;

                if (transition.OutputPlaces.Count > 1)
                {
                    if (transition.InputPlaces.Count > 1)
                    {
                        newFootprint = TokenManipulationUtils.MergeTokens(inputFootprints, ActiveGlobalIdMonitor);
                    }
                    else
                    {
                        newFootprint = transition.InputPlaces[0].TokenFootprint;
                    }
                    transition.SetFootprint(newFootprint);
                    FireParallel(transition.OutputPlaces, newFootprint);
                    return;
                }

                if (transition.InputPlaces.Count > 1 && transition.OutputPlaces.Count > 0)
                {
                    newFootprint = TokenManipulationUtils.MergeTokens(inputFootprints, ActiveGlobalIdMonitor);
                    foreach (PlaceTokenTraverseOverlay p in transition.OutputPlaces)
                    {
                        p.SetFootprint(newFootprint);
                    }
                    transition.SetFootprint(newFootprint);
                    return;
                }

                if (transition.InputPlaces.Count == 1 && transition.OutputPlaces.Count == 1)
                {
                    newFootprint = transition.InputPlaces[0].TokenFootprint;
                    transition.SetFootprint(newFootprint);
                    transition.OutputPlaces[0].SetFootprint(newFootprint);
                }
            }
        }
        /// <summary>
        /// Finds and sets up start place in the Petri Net overlay (marks it with empty FootprintAnalysisToken).
        /// </summary>
        private void SetUpStartPlace()
        {
            TransitionTokenTraverseOverlay start = TransitionsWithFootprints.Find(a => a.InputPlaces.Exists(b => b.Place.Id == PetriNet.StartPlace.Id));

            start.InputPlaces[0].SetFootprint(new FootprintAnalysisToken());
        }
Exemple #3
0
 /// <summary>
 /// Checks whether given transition overlays are not "falsely parallel" (A does not directly precede B, but A always comes before B).
 /// </summary>
 /// <param name="fromTransition">Transition overlay A.</param>
 /// <param name="toTransition">Transition overlay B.</param>
 /// <returns>True if A is falsely parallel with B, else returns false.</returns>
 private static bool IsFalseParallelism(TransitionTokenTraverseOverlay fromTransition, TransitionTokenTraverseOverlay toTransition)
 {
     return(fromTransition.TokenFootprint.ActiveLevels.Exists(a => toTransition.TokenFootprint.MergedLevels.Contains(a)) ||
            fromTransition.TokenFootprint.ActiveLevels.Exists(a => toTransition.TokenFootprint.ActiveLevels.Contains(a)));
 }