예제 #1
0
 /// <summary>
 /// Tests equality with a target</summary>
 /// <param name="other">Object compared to</param>
 /// <returns>True iff other object binds to the same leaf node and pin index. Instancing node is not checked.</returns>
 public bool Equals(PinTarget other)
 {
     if (other == null)
     {
         return(false);
     }
     return(LeafDomNode == other.LeafDomNode && LeafPinIndex == other.LeafPinIndex);
 }
예제 #2
0
 /// <summary>
 /// Determines whether the specified pin target is equal to the current pin target, including the instancing node</summary>
 /// <param name="other">Pin target compared to</param>
 /// <returns>True iff other pin target binds to the same leaf node, pin index, and same instancing node</returns>
 public bool FullyEquals(PinTarget other)
 {
     if (other == null)
     {
         return(false);
     }
     return(LeafDomNode == other.LeafDomNode && LeafPinIndex == other.LeafPinIndex &&
            InstancingNode == other.InstancingNode);
 }
예제 #3
0
        /// <summary>
        /// Updates LeafDomNode and LeafPinIndex from the ultimate DomNode this group pin binds to
        /// by recursively going down the nested group hierarchy</summary>
        /// <param name="inputSide">True if this is an input-side group pin, false if output-side</param>
        public void SetPinTarget(bool inputSide)
        {
            m_inputSide = inputSide;

            DomNode instancingNode;
            DomNode leafNode = GetLeafDomNode(inputSide, out instancingNode);

            if (m_pinTarget != null && m_pinTarget.InstancingNode != null)
            {
                instancingNode = m_pinTarget.InstancingNode;// try keep the original instancingNode
            }
            PinTarget = new PinTarget(leafNode, GetLeafPinIndex(inputSide), instancingNode);
        }
예제 #4
0
        /// <summary>
        /// Finds the element and pin that matched the pin target for this circuit container.</summary>
        /// <param name="pinTarget">Contains pin's element and pin index</param>
        /// <param name="inputSide">True for input pin, false for output pin</param>
        /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self,
        /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns>
        public override Pair <Element, ICircuitPin> MatchPinTarget(PinTarget pinTarget, bool inputSide)
        {
            if (pinTarget.InstancingNode != DomNode)
            {
                return(new Pair <Element, ICircuitPin>()); // look no farthur
            }
            var result = Element.MatchPinTarget(pinTarget, inputSide);

            if (result.First != null)
            {
                result.First = this;
            }
            return(result);
        }
예제 #5
0
        /// <summary>
        /// Finds the element and pin that matched the pin target for this circuit container</summary>
        /// <param name="pinTarget">Contains pin's element and pin index</param>
        /// <param name="inputSide">True for input pin, false for output pin</param>
        /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self,
        /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns>
        public virtual Pair <Element, ICircuitPin> MatchPinTarget(PinTarget pinTarget, bool inputSide)
        {
            var result = new Pair <Element, ICircuitPin>();

            if (pinTarget != null && pinTarget.LeafDomNode == DomNode)  // an element must be a leaf node in a circuit hierarchy
            {
                var pin = inputSide ? Type.GetInputPin(pinTarget.LeafPinIndex)
                                        : Type.GetOutputPin(pinTarget.LeafPinIndex);
                if (pin != null)
                {
                    result.First  = this;
                    result.Second = pin;
                }
            }
            return(result);
        }
예제 #6
0
파일: Circuit.cs 프로젝트: zoombapup/ATF
        /// <summary>
        /// Finds the element and pin that fully matched the pin target for this circuit container,
        /// including the template instance node</summary>
        /// <param name="pinTarget">Contains pin's element and pin index</param>
        /// <param name="inputSide">True for input pin, false for output pin</param>
        /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self,
        /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns>
        public Pair <Element, ICircuitPin> FullyMatchPinTarget(PinTarget pinTarget, bool inputSide)
        {
            var result = new Pair <Element, ICircuitPin>();


            foreach (var module in Elements)
            {
                result = module.FullyMatchPinTarget(pinTarget, inputSide);
                if (result.First != null)
                {
                    break;
                }
            }


            return(result);
        }
예제 #7
0
        /// <summary>
        /// Finds the element and pin that matched the pin target for this circuit container</summary>
        /// <param name="pinTarget">Contains pin's element and pin index</param>
        /// <param name="inputSide">True for input pin, false for output pin</param>
        /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self,
        /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns>
        public virtual Pair <Element, ICircuitPin> MatchPinTarget(PinTarget pinTarget, bool inputSide)
        {
            var result = new Pair <Element, ICircuitPin>();

            if (pinTarget != null && pinTarget.LeafDomNode == DomNode)  // an element must be a leaf node in a circuit hierarchy
            {
                bool validPinIndex = inputSide
                                         ? pinTarget.LeafPinIndex < Type.Inputs.Count
                                         : pinTarget.LeafPinIndex < Type.Outputs.Count;

                if (validPinIndex)
                {
                    result.First  = this;
                    result.Second = inputSide
                                        ? Type.Inputs[pinTarget.LeafPinIndex]
                                        : Type.Outputs[pinTarget.LeafPinIndex];
                }
            }

            return(result);
        }
예제 #8
0
 /// <summary>
 /// Finds the element and pin that fully matched the pin target for this circuit container, 
 /// including the template instance node</summary>
 /// <param name="pinTarget">Contains pin's element and pin index</param>
 /// <param name="inputSide">True for input pin, false for output pin</param>
 /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self, 
 /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns>
 public virtual Pair<Element, ICircuitPin> FullyMatchPinTarget(PinTarget pinTarget, bool inputSide)
 {
     return MatchPinTarget(pinTarget, inputSide);
 }
예제 #9
0
        /// <summary>
        /// Finds the element and pin that matched the pin target for this circuit container</summary>
        /// <param name="pinTarget">Contains pin's element and pin index</param>
        /// <param name="inputSide">True for input pin, false for output pin</param>
        /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self, 
        /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns>
        public virtual Pair<Element, ICircuitPin> MatchPinTarget(PinTarget pinTarget, bool inputSide)
        {
            var result = new Pair<Element, ICircuitPin>();
            if (pinTarget != null &&  pinTarget.LeafDomNode == DomNode) // an element must be a leaf node in a circut hiearchy
            {
                bool validPinIndex = inputSide
                                         ? pinTarget.LeafPinIndex < Type.Inputs.Count
                                         : pinTarget.LeafPinIndex < Type.Outputs.Count;

                if (validPinIndex)
                {
                    result.First = this;
                    result.Second = inputSide
                                        ? Type.Inputs[pinTarget.LeafPinIndex]
                                        : Type.Outputs[pinTarget.LeafPinIndex];
                }
            }
 
            return result;
        }
예제 #10
0
 /// <summary>
 /// Tests equality with a target</summary>
 /// <param name="other">Object compared to</param>
 /// <returns>True iff other object binds to the same leaf node and pin index. Instancing node is not checked.</returns>
 public bool Equals(PinTarget other)
 {
     if (other == null)
         return false;
     return (LeafDomNode == other.LeafDomNode && LeafPinIndex == other.LeafPinIndex);
 }
예제 #11
0
 /// <summary>
 /// Determines whether the specified pin target is equal to the current pin target, including the instancing node</summary>
 /// <param name="other">Pin target compared to</param>
 /// <returns>True iff other pin target binds to the same leaf node, pin index, and same instancing node</returns>
 public bool FullyEquals(PinTarget other)
 {
     if (other == null)
         return false;
     return (LeafDomNode == other.LeafDomNode && LeafPinIndex == other.LeafPinIndex &&
         InstancingNode == other.InstancingNode);
 }
예제 #12
0
 /// <summary>
 /// Finds the element and pin that fully matched the pin target for this circuit container,
 /// including the template instance node</summary>
 /// <param name="pinTarget">Contains pin's element and pin index</param>
 /// <param name="inputSide">True for input pin, false for output pin</param>
 /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self,
 /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns>
 public override Pair <Element, ICircuitPin> FullyMatchPinTarget(PinTarget pinTarget, bool inputSide)
 {
     return(MatchPinTarget(pinTarget, inputSide));
 }
예제 #13
0
파일: Element.cs 프로젝트: sbambach/ATF
 /// <summary>
 /// Finds the element and pin that matched the pin target for this circuit container</summary>
 /// <param name="pinTarget">Contains pin's element and pin index</param>
 /// <param name="inputSide">True for input pin, false for output pin</param>
 /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self, 
 /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns>
 public virtual Pair<Element, ICircuitPin> MatchPinTarget(PinTarget pinTarget, bool inputSide)
 {
     var result = new Pair<Element, ICircuitPin>();
     if (pinTarget != null &&  pinTarget.LeafDomNode == DomNode) // an element must be a leaf node in a circuit hierarchy
     {                
         var  pin = inputSide ? Type.GetInputPin(pinTarget.LeafPinIndex)
                                 : Type.GetOutputPin(pinTarget.LeafPinIndex);
         if (pin != null)
         {
             result.First = this;
             result.Second = pin;
         }
     } 
     return result;
 }
예제 #14
0
        /// <summary>
        /// Sets input and output PinTarget for this connection</summary>
        public void SetPinTarget()
        {
            if (InputPin != null)
            {
                bool isInputElementRef = InputElement.DomNode.Is <IReference <DomNode> >();

                if (InputPin.Is <GroupPin>())
                {
                    if (isInputElementRef)
                    {
                        var pinTarget = InputPin.Cast <GroupPin>().PinTarget;
                        InputPinTarget = new PinTarget(pinTarget.LeafDomNode, pinTarget.LeafPinIndex,
                                                       InputElement.DomNode);
                    }
                    else
                    {
                        InputPinTarget = InputPin.Cast <GroupPin>().PinTarget;
                    }
                }
                else
                {
                    if (isInputElementRef)
                    {
                        var reference = InputElement.As <IReference <DomNode> >();
                        InputPinTarget = new PinTarget(reference.Target, InputPin.Index, InputElement.DomNode);
                    }
                    else
                    {
                        InputPinTarget = new PinTarget(InputElement.DomNode, InputPin.Index, null);
                    }
                }
                Debug.Assert(InputPinTarget != null, "sanity check");
            }

            if (OutputPin != null)
            {
                bool isOutputElementRef = OutputElement.DomNode.Is <IReference <DomNode> >();
                if (OutputPin.Is <GroupPin>())
                {
                    if (isOutputElementRef)
                    {
                        var pinTarget = OutputPin.Cast <GroupPin>().PinTarget;
                        OutputPinTarget = new PinTarget(pinTarget.LeafDomNode, pinTarget.LeafPinIndex,
                                                        OutputElement.DomNode);
                    }
                    else
                    {
                        OutputPinTarget = OutputPin.Cast <GroupPin>().PinTarget;
                    }
                }
                else
                {
                    if (isOutputElementRef)
                    {
                        var reference = OutputElement.Cast <IReference <DomNode> >();
                        OutputPinTarget = new PinTarget(reference.Target, OutputPin.Index, OutputElement.DomNode);
                    }
                    else
                    {
                        OutputPinTarget = new PinTarget(OutputElement.DomNode, OutputPin.Index, null);
                    }
                }
                Debug.Assert(OutputPinTarget != null, "sanity check");
            }
        }