示例#1
0
        public static ProcedureFunctionChart CreateTestPfc2()
        {
            ProcedureFunctionChart pfc = new ProcedureFunctionChart(new Highpoint.Sage.SimCore.Model("Test model", Guid.NewGuid()), "SFC 1");

            #region Create Nodes

            char name = 'A';
            A = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            B = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            C = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            D = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            E = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            F = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            G = pfc.CreateStep("Step_" + (name++), "", NextGuid());

            nA = (IPfcNode)A;
            nB = (IPfcNode)B;
            nC = (IPfcNode)C;
            nD = (IPfcNode)D;
            nE = (IPfcNode)E;
            nF = (IPfcNode)F;
            nG = (IPfcNode)G;

            #endregion Create Nodes

            #region Create Structure

            pfc.BindParallelDivergent(nA, new IPfcNode[] { nB, nC });
            pfc.BindParallelDivergent(nB, new IPfcNode[] { nD, nE });
            pfc.BindParallelConvergent(new IPfcNode[] { nD, nE }, nF);
            pfc.BindParallelConvergent(new IPfcNode[] { nF, nC }, nG);

            PfcLinkElementList links = new PfcLinkElementList(pfc.Links);
            links.Sort(new Comparison <IPfcLinkElement>(delegate(IPfcLinkElement a, IPfcLinkElement b) {
                return(Comparer.Default.Compare(a.Name, b.Name));
            }));


            System.Reflection.BindingFlags bf = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance;
            foreach (IPfcLinkElement link in links)
            {
                typeof(PfcElement).GetFields(bf);
                typeof(PfcElement).GetField("m_guid", bf).SetValue((PfcElement)link, NextGuid()); // Totally cheating.
            }

            #endregion Create Structure

            return(pfc);
        }
示例#2
0
        private void _TestComplexLink(LinkSuperType superType, PfcElementType inType, PfcElementType outType, string shouldBe)
        {
            string testName = superType.ToString() + " from " + inType.ToString() + " to " + outType.ToString();
            Model  model    = new Model(testName);

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

            IPfcNode n0, n1, n2, n3, n4;

            switch (superType)
            {
            case LinkSuperType.ParallelConvergent:
                n0 = CreateNode(pfc, "Alice", inType);
                n1 = CreateNode(pfc, "Bob", inType);
                n2 = CreateNode(pfc, "Charley", inType);
                n3 = CreateNode(pfc, "David", inType);
                n4 = CreateNode(pfc, "Edna", outType);
                pfc.BindParallelConvergent(new IPfcNode[] { n0, n1, n2, n3 }, n4);
                break;

            case LinkSuperType.SeriesConvergent:
                n0 = CreateNode(pfc, "Alice", inType);
                n1 = CreateNode(pfc, "Bob", inType);
                n2 = CreateNode(pfc, "Charley", inType);
                n3 = CreateNode(pfc, "David", inType);
                n4 = CreateNode(pfc, "Edna", outType);
                pfc.BindSeriesConvergent(new IPfcNode[] { n0, n1, n2, n3 }, n4);
                break;

            case LinkSuperType.ParallelDivergent:
                n0 = CreateNode(pfc, "Alice", inType);
                n1 = CreateNode(pfc, "Bob", outType);
                n2 = CreateNode(pfc, "Charley", outType);
                n3 = CreateNode(pfc, "David", outType);
                n4 = CreateNode(pfc, "Edna", outType);
                pfc.BindParallelDivergent(n0, new IPfcNode[] { n1, n2, n3, n4 });
                break;

            case LinkSuperType.SeriesDivergent:
                n0 = CreateNode(pfc, "Alice", inType);
                n1 = CreateNode(pfc, "Bob", outType);
                n2 = CreateNode(pfc, "Charley", outType);
                n3 = CreateNode(pfc, "David", outType);
                n4 = CreateNode(pfc, "Edna", outType);
                pfc.BindSeriesDivergent(n0, new IPfcNode[] { n1, n2, n3, n4 });
                break;

            default:
                break;
            }


            string structureString = PfcDiagnostics.GetStructure(pfc);

            Console.WriteLine("After a " + testName + ", structure is \r\n" + structureString);
            Assert.AreEqual(StripCRLF(structureString), StripCRLF(shouldBe), "Structure should have been\r\n" + shouldBe + "\r\nbut it was\r\n" + structureString + "\r\ninstead.");

            if (m_testSerializationToo)
            {
                _TestSerialization(pfc, shouldBe, testName);
            }
        }
示例#3
0
        public static ProcedureFunctionChart CreateTestPfc()
        {
            ProcedureFunctionChart pfc = new ProcedureFunctionChart(new Highpoint.Sage.SimCore.Model("Test model", Guid.NewGuid()), "SFC 1");

            ((PfcElementFactory)pfc.ElementFactory).SetRepeatable(Guid.Empty); // Ensures Guids are repeatable.

            #region Create Nodes

            char name = 'A';
            A = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            B = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            C = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            D = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            E = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            F = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            G = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            H = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            I = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            J = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            K = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            L = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            M = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            N = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            O = pfc.CreateStep("Step_" + (name++), "", NextGuid());
            P = pfc.CreateStep("Step_" + (name), "", NextGuid());

            nA = (IPfcNode)A;
            nB = (IPfcNode)B;
            nC = (IPfcNode)C;
            nD = (IPfcNode)D;
            nE = (IPfcNode)E;
            nF = (IPfcNode)F;
            nG = (IPfcNode)G;
            nH = (IPfcNode)H;
            nI = (IPfcNode)I;
            nJ = (IPfcNode)J;
            nK = (IPfcNode)K;
            nL = (IPfcNode)L;
            nM = (IPfcNode)M;
            nN = (IPfcNode)N;
            nO = (IPfcNode)O;
            nP = (IPfcNode)P;

            #endregion Create Nodes

            #region Create Structure

            pfc.Bind(nA, nB);
            pfc.BindSeriesDivergent(nB, new IPfcNode[] { nC, nF });
            pfc.Bind(nC, nD);
            pfc.Bind(nD, nE);
            pfc.Bind(nF, nG);
            pfc.BindParallelDivergent(nG, new IPfcNode[] { nH, nI, nP });
            pfc.Bind(nH, nJ);
            pfc.Bind(nI, nK);
            pfc.BindParallelConvergent(new IPfcNode[] { nJ, nK, nP }, nL);
            pfc.Bind(nL, nM);
            pfc.BindSeriesConvergent(new IPfcNode[] { nE, nM }, nN);
            pfc.Bind(nN, nO);
            pfc.Bind(nB, nN);

            #endregion Create Structure

            pfc.UpdateStructure();

            return(pfc);
        }