/// <summary>
        /// Splits given token and passes the new tokens to given output places.
        /// </summary>
        /// <param name="outputPlaces">Output places to be fired into.</param>
        /// <param name="footprint">A token to be split into output places.</param>
        private void FireParallel(List <PlaceTokenTraverseOverlay> outputPlaces, FootprintAnalysisToken footprint)
        {
            List <FootprintAnalysisToken> newFootprints = TokenManipulationUtils.SplitToken(footprint, (uint)outputPlaces.Count, GetNewGlobalId(), ActiveGlobalIdMonitor);

            for (int i = 0; i < newFootprints.Count; i++)
            {
                outputPlaces[i].SetFootprint(newFootprints[i]);
            }
        }
        /// <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);
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Finds parallelism in Petri Net overlay and updates given Relation Matrix accordingly.
 /// </summary>
 /// <param name="matrix">A relation matrix of analyzed Petri Net.</param>
 /// <param name="net">Petri Net overlay.</param>
 private static void FindParallelism(ref RelationMatrix matrix, PetriNetTokenTraverseOverlay net)
 {
     foreach (var fromTransition in net.TransitionsWithFootprints)
     {
         foreach (var toTransition in net.TransitionsWithFootprints)
         {
             if (fromTransition.Id != toTransition.Id)
             {
                 HashSet <string> fromTransitionGlobalIds = new HashSet <string>(
                     TokenManipulationUtils.GetActiveGlobalIds(fromTransition.TokenFootprint));
                 HashSet <string> toTransitionGlobalIds = new HashSet <string>(
                     TokenManipulationUtils.GetActiveGlobalIds(toTransition.TokenFootprint));
                 if (fromTransitionGlobalIds.Overlaps(toTransitionGlobalIds) && !IsFalseParallelism(fromTransition, toTransition))
                 {
                     int fromIndex = matrix.ActivityIndices[fromTransition.Activity];
                     int toIndex   = matrix.ActivityIndices[toTransition.Activity];
                     matrix.Footprint[fromIndex, toIndex] = Relation.Parallelism;
                     matrix.Footprint[toIndex, fromIndex] = Relation.Parallelism;
                 }
             }
         }
     }
 }