Exemple #1
0
 /// <summary>
 /// Returns all nodes in this collection that are of the specified type.
 /// </summary>
 /// <param name="elementType">Type of the element.</param>
 /// <returns>
 /// A collection of all nodes in this collection that are of the specified type.
 /// </returns>
 public PfcNodeList GetBy(PfcElementType elementType)
 {
     if (elementType.Equals(PfcElementType.Link))
     {
         return(new PfcNodeList());
     }
     return((PfcNodeList)FindAll(delegate(IPfcNode node) { return node.ElementType.Equals(elementType); }));
 }
Exemple #2
0
        private IPfcNode CreateNode(ProcedureFunctionChart pfc, string name, PfcElementType inType)
        {
            switch (inType)
            {
            case PfcElementType.Link:
                break;

            case PfcElementType.Transition:
                return(pfc.CreateTransition("T_" + name, "", Guid.NewGuid()));

            //break;
            case PfcElementType.Step:
                return(pfc.CreateStep("S_" + name, "", Guid.NewGuid()));

            //break;
            default:
                break;
            }
            return(null);
        }
Exemple #3
0
        private void _TestSimpleLink(PfcElementType inType, PfcElementType outType, string shouldBe)
        {
            string testName = "Simple link from " + inType.ToString() + " to " + outType.ToString();
            Model  model    = new Model(testName);

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

            IPfcNode n0, n1;

            n0 = CreateNode(pfc, "Alice", inType);
            n1 = CreateNode(pfc, "Bob", outType);
            pfc.Bind(n0, n1);

            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);
            }
        }
Exemple #4
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);
            }
        }