Exemple #1
0
 private void SetDirection(TopolotyNode incommingnode, TopolotyNode inSectionFirst)
 {
     foreach (var node in incommingnode.RightNodes)
     {
         this.RouteDirection_ = node.ConnectableDevice == inSectionFirst.ConnectableDevice ? TrainDir.Right : TrainDir.Left;
     }
 }
Exemple #2
0
        private List <TopolotyNode> FindNextNode()
        {
            Device       curPos  = trainInfo.HeadPosition;
            TopolotyNode curNode = MainWindow.stationTopoloty_.Nodes.Find((TopolotyNode node) =>
            {
                return(curPos == node.NodeDevice);
            });
            List <TopolotyNode> NextNodes = null;

            NextNodes = trainInfo.TrainDirection == TrainDir.Right ? curNode.RightNodes : curNode.LeftNodes;
            TopolotyNode relayNode = null;

            foreach (var node in NextNodes)
            {
                if (node != null)
                {
                    if (node.NodeDevice is RailSwitch)
                    {
                        relayNode = MainWindow.stationTopoloty_.Nodes.Find((TopolotyNode reNode) => { return(reNode.NodeDevice == node.NodeDevice); });
                    }
                }
            }
            if (relayNode != null)
            {
                NextNodes.Add(relayNode);
            }
            return(NextNodes);
        }
Exemple #3
0
        public void InitializeDirection()
        {
            TopolotyNode inCommingNode  = FindNode(this.IncomingSections[0]);
            TopolotyNode inSectionFirst = FindNode(this.InSections[0]);

            if (inCommingNode.ConnectableDevice is Section)
            {
                this.RouteDirection_ = inCommingNode.RightNodes.Contains(inSectionFirst) ? TrainDir.Right : TrainDir.Left;
            }
            else if (inCommingNode.ConnectableDevice is RailSwitch)
            {
                List <TopolotyNode> CommingRightNode = inCommingNode.RightNodes;
                foreach (var item in CommingRightNode)
                {
                    if (item.ConnectableDevice is RailSwitch)
                    {
                        if ((item.ConnectableDevice as RailSwitch).SectionName == (inCommingNode.ConnectableDevice as RailSwitch).SectionName)
                        {
                            inCommingNode = item;
                        }
                    }
                }
                this.RouteDirection_ = inCommingNode.RightNodes.Contains(inSectionFirst) ? TrainDir.Right : TrainDir.Left;
            }
        }
Exemple #4
0
        private void curBaliseEB(string curBalise, byte tailID, byte tailSectionOrSwitch)
        {
            int          curID           = searchLater.BaliseToID(curBalise);
            TopolotyNode curTopolotyNode = trainMessage.BaliseToIteam(curBalise, curID);

            LeftOrRightEB(curTopolotyNode);
        }
Exemple #5
0
        private void LeftOrRightEB(TopolotyNode curTopolotyNode)
        {
            int curleftType;
            int curleftID;
            List <TopolotyNode> curNextTopolotyNode;

            if (!isLeftSearch)
            {
                curNextTopolotyNode = curTopolotyNode.Left;
            }
            else
            {
                curNextTopolotyNode = curTopolotyNode.Right;
            }
            foreach (var p in curNextTopolotyNode)
            {
                if (socketSearchInfo.IsCurStartWith(p.device.Name, "T") || socketSearchInfo.IsCurStartWith(p.device.Name, "Z"))
                {
                    curleftType = 1;
                    curleftID   = searchLater.BaliseToID(p.device.Name);
                }
                else
                {
                    curleftType = 2;
                    curleftID   = searchLater.BaliseToID((p.device as RailSwitch).section.Name);
                }

                if (curleftID == tailID && curleftType == tailSectionOrSwitch)
                {
                    Socket_EB.Set_EB("超过MA终点");
                    break;
                }
            }
        }
Exemple #6
0
        public TopolotyNode CurBaliseToIteam(string balise) //根据当前的应答器找到节点,道岔根据sectionName即可
        {
            if (balise.Substring(0, 1) == "T")
            {
                foreach (var item in getxml.data.Topo)
                {
                    if (item.device.Name == balise.Substring(0, 5)) //区段时只需要根据Name判断就可以,nameT0103
                    {
                        return(item);
                    }
                }
            }

            else
            {
                TopolotyNode node = getxml.data.Topo.Find((TopolotyNode toponode) =>   //node是寻找到的节点,返回符合条件的
                {
                    if (toponode.device is RailSwitch)
                    {
                        RailSwitch railSwitch = toponode.device as RailSwitch;
                        return(railSwitch.section.Name == balise.Substring(0, 5));
                    }
                    return(false);
                });
                if (node != null)
                {
                    return(node);
                }
            }
            return(null);
        }
Exemple #7
0
        private TopolotyNode FindNode(Device device)
        {
            TopolotyNode Node = MainWindow.stationTopoloty_.Nodes.Find((TopolotyNode node) =>
            {
                if (node.ConnectableDevice == device)
                {
                    return(true);
                }
                return(false);
            });

            return(Node);
        }
Exemple #8
0
        public string NextCurBaliseList(TopolotyNode Node) //根据节点得到Name,有可能是道岔是sectionName,有可能是直轨是Name
        {
            string NextName = "";

            if (Node.device is Section)
            {
                NextName = (Node.device as Section).Name;
            }
            else if (Node.device is RailSwitch)
            {
                NextName = (Node.device as RailSwitch).section.Name; //section的name是原来的section那么
            }
            return(NextName);
        }
Exemple #9
0
        private void DeletePreSection(Device currentDevice)
        {
            List <TopolotyNode> preNodes;
            TopolotyNode        currentNode = FindNode(currentDevice);

            switch (trainInfo.TrainDirection)
            {
            case TrainDir.Right:
                preNodes = currentNode.LeftNodes;
                break;

            case TrainDir.Left:
                preNodes = currentNode.RightNodes;
                break;

            default:
                preNodes = null;
                break;
            }
            if (AdvanceRoute.Count != 0)
            {
                TopolotyNode lastNode = FindNode(AdvanceRoute.Last());
                if (preNodes.Contains(lastNode))
                {
                    if (AdvanceRoute.Last() is Section)
                    {
                        AdvanceRoute.Remove(AdvanceRoute.Last());
                    }
                    else if (AdvanceRoute.Last() is RailSwitch)
                    {
                        if (AdvanceRoute.Count > 1)
                        {
                            if (AdvanceRoute[AdvanceRoute.Count - 2] is RailSwitch)
                            {
                                if ((AdvanceRoute[AdvanceRoute.Count - 2] as RailSwitch).SectionName == (AdvanceRoute.Last() as RailSwitch).SectionName)
                                {
                                    AdvanceRoute.Remove(AdvanceRoute[AdvanceRoute.Count - 2]);
                                }
                            }
                        }
                        AdvanceRoute.Remove(AdvanceRoute.Last());
                    }
                }
            }
        }
Exemple #10
0
        public TopolotyNode IDTypeConvertTopo(byte type, byte ID) //用type和id得到名字。当ZC发送MA的type和ID时可以用到。OK
        {
            if (type == 1)                                        //区段
            {
                TopolotyNode topo = getxml.data.Topo.Find((TopolotyNode toponode) =>
                {
                    if (toponode.device is Section)
                    {
                        if ((toponode.device as Section).Id == ID) //区段ID唯一
                        {
                            return(true);
                        }
                    }
                    return(false);
                });
                return(topo);
            }

            else if (type == 2)  //道岔
            {
                TopolotyNode topo = getxml.data.Topo.Find((TopolotyNode toponode) =>
                {
                    if (toponode.device is RailSwitch)
                    {
                        if ((toponode.device as RailSwitch).Id == ID) //type和id可以唯一确定道岔
                        {
                            return(true);
                        }
                    }
                    return(false);
                });

                return(topo);
            }
            return(null);
        }