示例#1
0
        public static bool IsTargetNodeLegal(IPfcNode origin, IPfcNode target)
        {
            bool retval = false;
            IProcedureFunctionChart parent = origin.Parent;

            // We only evaluate step-to-step links, or transition-to-transition links,
            // meaning that we must always add a shim node between them.
            if (origin.ElementType.Equals(target.ElementType))
            {
                if (s_diagnostics)
                {
                    Console.WriteLine("Before: " + StringOperations.ToCommasAndAndedListOfNames <IPfcNode>(parent.Nodes));
                }

                IPfcLinkElement link1, link2;
                IPfcNode        shimNode;
                parent.Bind(origin, target, out link1, out shimNode, out link2, false);

                if (s_diagnostics)
                {
                    Console.WriteLine("During: " + StringOperations.ToCommasAndAndedListOfNames <IPfcNode>(parent.Nodes));
                }

                PfcValidator validator = new PfcValidator(parent);
                retval = validator.PfcIsValid();

                if (shimNode != null)
                {
                    parent.Unbind(origin, shimNode, true);
                    parent.Unbind(shimNode, target, true);
                    parent.UpdateStructure();
                }
                else
                {
                    parent.Unbind(origin, target);
                }

                if (s_diagnostics)
                {
                    Console.WriteLine("After: " + StringOperations.ToCommasAndAndedListOfNames <IPfcNode>(parent.Nodes));
                }

                parent.ElementFactory.Retract();
            }
            else
            {
                return(false);
            }

            return(retval);
        }
示例#2
0
 public PfcValidator(IProcedureFunctionChart pfc)
 {
     m_errorList = new List <PfcValidationError>();
     m_pfc       = (IProcedureFunctionChart)pfc.Clone();
     Reduce();
     try
     {
         m_pfc.UpdateStructure();
         Validate();
     }
     catch (PFCValidityException)
     {
         m_pfcIsValid = false;
     }
 }