Exemplo n.º 1
0
        private void ConsoleOut(TrainInfo trainInfo, InfoSendToATP infoSendToATP, bool isComplete)
        {
            if (MainWindow.IsShowLog)
            {
                string content = null;
                if (!isComplete)
                {
                    content = "Receive from ATP:"
                              + "\r\n" + "NID_Train:" + trainInfo.NIDTrain +
                              " NC_Train:" + trainInfo.NcTrain +
                              " HeadPosition:" + (trainInfo.HeadPosition is Section ? trainInfo.HeadPosition.Name : ((trainInfo.HeadPosition as RailSwitch).SectionName + "-" + (trainInfo.HeadPosition as RailSwitch).Name)) + "+" + trainInfo.HeadOffset +
                              " TailPosition:" + (trainInfo.TailPosition is Section ? trainInfo.TailPosition.Name : ((trainInfo.TailPosition as RailSwitch).SectionName + "-" + (trainInfo.TailPosition as RailSwitch).Name)) + "+" + trainInfo.TailOffset +
                              " Speed:" + trainInfo.Speed + " Direction:" + (trainInfo.TrainDirection == TrainDir.Right ? "Up" : "Down") + " PSDoor:" + (trainInfo.PSDoor ? "Open" : "Close") +
                              "\r\n";
                    MainWindow.AllocConsole();
                    if (content != consoleFromATP)
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine(content);
                        consoleFromATP = content;
                        OutPutLogs(consoleFromATP);
                    }
                }
                else
                {
                    content = "Send to ATP:" + "\r\n" +
                              "NC_ZC:" + infoSendToATP.atpPackage.NC_ZC + " MALength:" + infoSendToATP.atpPackage.N_Length +
                              " EndMA:" + (infoSendToATP.MA.MAEndDevice is Section ? infoSendToATP.MA.MAEndDevice.Name :(infoSendToATP.MA.MAEndDevice == null? "null":((infoSendToATP.MA.MAEndDevice as RailSwitch).SectionName) + "-" + infoSendToATP.MA.MAEndDevice.Name)) +
                              " EndMAOffset:" + infoSendToATP.atpPackage.D_MATailOff +
                              " NumOfObstacle:" + infoSendToATP.atpPackage.N_Obstacle + "  {  ";
                    foreach (var item in infoSendToATP.atpPackage.Obstacle)
                    {
                        RailSwitch obsta = MainWindow.stationElements_.Elements.Find((GraphicElement element) =>
                        {
                            if (element is RailSwitch)
                            {
                                return((element as RailSwitch).ID == item.NID_Obstacle);
                            }
                            return(false);
                        }) as RailSwitch;

                        content += obsta.SectionName + "-" + obsta.Name + "(" + item.Q_Obstacle_Now + ")  ";
                    }
                    content = content + "}";
                    MainWindow.AllocConsole();
                    if (content != consoleConcentToATP)
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine(content);
                        consoleConcentToATP = content;
                        OutPutLogs(consoleConcentToATP);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void JudgeDevice(PacketHeader head)
        {
            if (head.SenderID == DeviceID.ATP1 || head.SenderID == DeviceID.ATP2 || head.SenderID == DeviceID.ATP3 || head.SenderID == DeviceID.ATP4)
            {
                HandleVobc VOBC = new HandleVobc(UnPack);
                ConsoleOut(VOBC.trainInfo, null, false);
                if (VOBC.trainInfo.NcTrain == NCTrain.QuitCBTCLogOutZC)
                {
                    ATPPackage InfoSendToATP = new ATPPackage();
                    InfoSendToATP.NC_ZC = 0x03;
                    VOBCQuit Quit = new VOBCQuit(VOBC.trainInfo);
                    UpdateTrainPosition.PreTrainPosition.Remove(VOBC.trainInfo.NIDTrain);
                    UpdateRoute.PreAccess.Remove(VOBC.trainInfo.NIDTrain);
                    InfoSendToATP.PackATP();
                    Send(InfoSendToATP.ATPPack.buf_, IPConfigure.IPList[0].IP, IPConfigure.IPList[0].Port, InfoSendToATP.ATPPack.byteFlag_);

                    InfoToATS infoToATS = new InfoToATS();
                    new ATS.PackToATS(infoToATS, VOBC.trainInfo);
                    Send(MySerialize.serializeObject(infoToATS), GetIPByDataType((int)DeviceID.ATS), GetPortByDataType((int)DeviceID.ATS), MySerialize.serializeObject(infoToATS).Length);
                }
                else if (VOBC.trainInfo.NcTrain == NCTrain.AskMA)
                {
                    new UpdateTrainPosition(VOBC.trainInfo);
                    InfoSendToATP infoSendToATP = new InfoSendToATP(VOBC.trainInfo, head.SenderID);
                    new UpdateRoute(VOBC.trainInfo, infoSendToATP.MA);
                    infoSendToATP.atpPackage.PackATP();
                    Send(infoSendToATP.atpPackage.ATPPack.buf_, GetIPByDataType((int)head.SenderID), GetPortByDataType((int)head.SenderID), infoSendToATP.atpPackage.ATPPack.byteFlag_);

                    InfoToATS infoToATS = new InfoToATS();
                    new ATS.PackToATS(infoToATS, VOBC.trainInfo);
                    Send(MySerialize.serializeObject(infoToATS), GetIPByDataType((int)DeviceID.ATS), GetPortByDataType((int)DeviceID.ATS), MySerialize.serializeObject(infoToATS).Length);
                    ConsoleOut(VOBC.trainInfo, infoSendToATP, true);
                }
            }
            else if (head.SenderID == DeviceID.CI1 || head.SenderID == DeviceID.CI2 || head.SenderID == DeviceID.CI3 || head.SenderID == DeviceID.CI4)
            {
                CI.HandleCIData        CI       = new CI.HandleCIData(UnPack, head.SenderID);
                shenyangZC.CI.PackToCI packToCI = new shenyangZC.CI.PackToCI(head.SenderID, CI);
                Send(packToCI.CIPacket.buf_, GetIPByDataType((int)head.SenderID), GetPortByDataType((int)head.SenderID), packToCI.CIPacket.byteFlag_);
            }
        }