Ejemplo n.º 1
0
        public static int AssignWeightsForBroadestNonLoopingPath(ProcedureFunctionChart pfc)
        {
            pfc.Nodes.ForEach(n => n.NodeColor = NodeColor.White);
            pfc.Links.ForEach(n => n.Priority  = null);

            PfcStep start  = (PfcStep)pfc.GetStartSteps()[0];
            int     retval = WeightAssignmentPropagationForBroadestNonLoopingPath(start);

            pfc.Links.ForEach(n => { if (n.Priority < 0)
                                     {
                                         n.Priority = int.MinValue - n.Priority;
                                     }
                              });
            return(retval);
        }
Ejemplo n.º 2
0
        private void _TestStepToStepBinding()
        {
            string testName = "Step-to-Step binding, maintaining SFC Compliance";

            Model model = new Model("SFC Test 1");
            ProcedureFunctionChart pfc = new ProcedureFunctionChart(model, "SFC 1", "", Guid.NewGuid());

            PfcStep s1 = (PfcStep)pfc.CreateStep("Alice", "", Guid.Empty);
            PfcStep s2 = (PfcStep)pfc.CreateStep("Bob", "", Guid.Empty);

            //SfcStep s3 = (SfcStep)pfc.CreateStep("Charlie", "", Guid.Empty);

            pfc.Bind(s1, s2);

            string structureString = PfcDiagnostics.GetStructure(pfc);

            Console.WriteLine("After a " + testName + ", structure is \r\n" + structureString);
        }
Ejemplo n.º 3
0
        private static int WeightAssignmentPropagationForBroadestNonLoopingPath(PfcStep step)
        {
            if (step.NodeColor == NodeColor.Black)
            {
                return(int.MinValue);
            }

            if (!step.Successors.Any())
            {
                return(1);                        // We've reached a terminal step. (strictly, should be a transition.)
            }
            step.NodeColor = NodeColor.Black;
            foreach (PfcLink link in step.Successors)
            {
                if (link.Priority == null)
                {
                    link.Priority = WeightAssignmentPropagationForBroadestNonLoopingPath(((PfcTransition)link.Successor));
                }
            }
            step.NodeColor = NodeColor.White;

            return(step.Successors.Max(n => n.Priority.Value) + 1);
        }