Example #1
0
        public ConnectivityInfo GetParent(double x, double y)
        {
            ConnectivityInfo conInfo = null;
            List<Node> snappedNodes = GetSnappedNodes(x, y);
            Node snappedNode = null;
            if (snappedNodes != null && snappedNodes.Count > 0)
            {
                if (snappedNodes.Count > 1)
                    return null;//snappedNode = snappedNodes.First(nd => StatusExtensions.IsNetJunction(nd.status));
                else
                    snappedNode = snappedNodes[0];
                int phaseCode = 128;
                int constrPhaseCode = 128;
                Section parentSection = null;
                if (snappedNode.parentList.Count > 0)
                {
                    phaseCode = GetPhaseCodeFromParentSections(snappedNode);
                    constrPhaseCode = GetConstructedPhaseCodeFromParentSections(snappedNode);
                    parentSection = SelectParentFromParentSections(snappedNode);
                }
                else
                {
                    phaseCode = GetPhaseCodeFromChildSections(snappedNode);
                    constrPhaseCode = GetConstructedPhaseCodeFromChildSections(snappedNode);
                    parentSection = SelectParentFromChildSections(snappedNode);
                }

                if (parentSection != null)
                {
                    conInfo = new ConnectivityInfo();
                    conInfo.connectedEdges = GetConnectedSections(snappedNode);
                    conInfo.parentFeature = parentSection;
                    conInfo.phaseCode = phaseCode;
                    conInfo.snappedNodes = snappedNodes;
                    conInfo.constructedPhaseCode = constrPhaseCode;
                    if(StatusExtensions.IsEnergized(parentSection.status))
                        conInfo.status = Constants.Energized;
                    if (StatusExtensions.IsUnenergized(parentSection.status))
                        conInfo.status = Constants.Unenergized;
                    if (StatusExtensions.IsLoop(parentSection.status))
                        conInfo.status = Constants.Loop;
                }
            }
            return conInfo;
        }
Example #2
0
        //public void GetNodeStatusToSection(Node nd, Section sec)
        //{
        //    if (StatusExtensions.IsUnenergized(nd.status))
        //    {
        //        netJn.status = Constants.Unenergized + Constants.NetJunction;
        //    }
        //    else if (StatusExtensions.IsEnergized(nd.status))
        //    {
        //        netJn.status = Constants.Energized + Constants.NetJunction;
        //    }
        //    else if (StatusExtensions.IsLoop(nd.status))
        //    {
        //        netJn.status = Constants.Loop + Constants.NetJunction;
        //    }
        //    if (StatusExtensions.IsDisconnected(nd.status))
        //    {
        //        netJn.status = Constants.Disconnected + Constants.NetJunction;
        //    }
        //}
        public ConnectivityInfo GetParent(double x, double y, double tox, double toy)
        {
            ConnectivityInfo conInfo = new ConnectivityInfo();
            List<Node> fromNodeList = GetSnappedNodes(x, y);
            List<Node> toNodeList = GetSnappedNodes(tox, toy);
            Node fromNode = null;
            Node toNode = null;
            if (fromNodeList.Count > 1)
                fromNode = fromNodeList.First(nd => StatusExtensions.IsNetJunction(nd.status));
            else if (fromNodeList != null && fromNodeList.Count!=0)
                fromNode = fromNodeList[0];
            if (toNodeList.Count > 1)
                toNode = toNodeList.First(nd => StatusExtensions.IsNetJunction(nd.status));
            else if(toNodeList!=null && toNodeList.Count!=0)
                toNode = toNodeList[0];
            conInfo.phaseCode = 128;
            conInfo.parentNode = fromNode;
            conInfo.childNode = toNode;
            conInfo.setFlow = false;
            conInfo.status = Constants.Disconnected;

            if (fromNode != null && toNode == null)
            {
                conInfo.status = Constants.WithFlow;
                if(UnenergizedLocal(fromNode)) conInfo.status+= Constants.Unenergized;
                if (!UnenergizedLocal(fromNode)) conInfo.status += Constants.Energized;
                if (StatusExtensions.IsLoop(fromNode.status)) conInfo.status += Constants.Loop;
                if (StatusExtensions.IsDisconnected(fromNode.status)) conInfo.status += Constants.Disconnected;
            }
            if (fromNode == null && toNode != null)
            {
                conInfo.parentNode = toNode;
                conInfo.childNode = fromNode;
                conInfo.status = Constants.AgainstFlow;
                if (UnenergizedLocal(toNode)) conInfo.status += Constants.Unenergized;
                if (!UnenergizedLocal(toNode)) conInfo.status += Constants.Energized;
                if (StatusExtensions.IsLoop(toNode.status)) conInfo.status += Constants.Loop;
                if (StatusExtensions.IsDisconnected(toNode.status)) conInfo.status += Constants.Disconnected;
            }
            if (fromNode != null && toNode != null)
            {
                if (UnenergizedLocal(fromNode) && UnenergizedLocal(toNode))
                {
                    if (StatusExtensions.IsDisconnected(fromNode.status) && StatusExtensions.IsDisconnected(toNode.status))
                    {
                        conInfo.status = Constants.Unenergized + Constants.Disconnected;
                    }
                    else if (!StatusExtensions.IsDisconnected(fromNode.status) && StatusExtensions.IsDisconnected(toNode.status))
                    {
                        conInfo.status = Constants.Unenergized  +Constants.WithFlow;
                        conInfo.setFlow = true;
                        conInfo.phaseCode = -1;
                    }
                    else if (StatusExtensions.IsDisconnected(fromNode.status) && !StatusExtensions.IsDisconnected(toNode.status))
                    {
                        conInfo.parentNode = toNode;
                        conInfo.childNode = fromNode;
                        conInfo.status = Constants.Unenergized + Constants.AgainstFlow;
                        conInfo.setFlow = true;
                        conInfo.phaseCode = -1;
                    }
                    else if (!StatusExtensions.IsDisconnected(fromNode.status) && !StatusExtensions.IsDisconnected(toNode.status))
                    {
                        conInfo.parentNode = fromNode ;
                        conInfo.childNode = toNode;
                        conInfo.status = Constants.Unenergized + Constants.WithFlow;
                        conInfo.phaseCode = -1;
                    }
                }
                if (!UnenergizedLocal(fromNode) && UnenergizedLocal(toNode))
                {
                    conInfo.status = Constants.WithFlow;
                    conInfo.setFlow = true;
                }
                if (UnenergizedLocal(fromNode) && !UnenergizedLocal(toNode))
                {
                    conInfo.parentNode = toNode;
                    conInfo.childNode = fromNode;
                    conInfo.status = Constants.AgainstFlow;
                    conInfo.setFlow = true;
                }
                if (StatusExtensions.IsLoop(fromNode.status) && StatusExtensions.IsLoop(toNode.status))
                {
                    conInfo.status = Constants.Loop;
                }
                else if (!UnenergizedLocal(fromNode) && !UnenergizedLocal(toNode))
                {
                    FillConnectivityInfoForEnergizedSections(conInfo, fromNode, toNode);
                }
            }
            //set phase code
            if (conInfo.parentNode!=null && StatusExtensions.IsNetJunction(conInfo.parentNode.status))
            {
                if (conInfo.phaseCode == -1) conInfo.phaseCode = 128;
                else
                    conInfo.phaseCode = GetPhaseCodeFromParentSections(conInfo.parentNode);
            }
            else
                conInfo.phaseCode = conInfo.parentNode.phaseCode;
            if (conInfo.parentNode != null && StatusExtensions.IsNetJunction(conInfo.parentNode.status))
            {
                conInfo.constructedPhaseCode = GetConstructedPhaseCodeFromParentSections(conInfo.parentNode);
            }
            else
                conInfo.constructedPhaseCode = conInfo.parentNode.constructedPhaseCode;
            return conInfo;
        }
Example #3
0
 public void FillConnectivityInfoForEnergizedSections(ConnectivityInfo conInfo, Node fromNode, Node toNode)
 {
     conInfo = new ConnectivityInfo();
     conInfo.phaseCode = 128;
     conInfo.parentNode = fromNode;
     conInfo.childNode = toNode;
     conInfo.setFlow = false;
     if (StatusExtensions.IsSource(fromNode.status) || StatusExtensions.IsSource(toNode.status))
     {
         if(StatusExtensions.IsSource(fromNode.status))
         {
             conInfo.parentNode = fromNode;
             conInfo.childNode = toNode;
             conInfo.status = Constants.WithFlow + Constants.Unenergized;
             conInfo.setFlow = false;
             conInfo.phaseCode = -1;
         }
         if (StatusExtensions.IsSource(toNode.status))
         {
             conInfo.parentNode = toNode ;
             conInfo.childNode = fromNode;
             conInfo.status = Constants.AgainstFlow + Constants.Unenergized;
             conInfo.setFlow = false;
             conInfo.phaseCode = -1;
         }
     }
     else if ((HasParent(fromNode) && !HasChild(fromNode) && HasChild(toNode) && !HasParent(toNode)))
     {
             conInfo.parentNode = fromNode ;
             conInfo.childNode = toNode;
             conInfo.status = Constants.WithFlow ;
             conInfo.setFlow = false;
     }
     else if ((HasParent(toNode) && !HasChild(toNode) && HasChild(fromNode) && !HasParent(fromNode)))
     {
             conInfo.parentNode = toNode ;
             conInfo.childNode = fromNode;
             conInfo.status = Constants.AgainstFlow;
             conInfo.setFlow = false;
     }
         else
         {
             //int fromNodePC = GetPhaseCodeFromParentSections(fromNode);
             //int toNodePC = GetPhaseCodeFromParentSections(toNode);
             conInfo.parentNode = fromNode;
             conInfo.childNode = toNode;
             conInfo.status = Constants.WithFlow + Constants.Unenergized;
             conInfo.setFlow = false;
             conInfo.phaseCode = -1;
         }
 }