public void HandleVOBC(int SenderID, byte[] DATA) { int num = VOBCNonCom.IndexOf(DATA[8]); if (num == -1) { VOBCNonCom.Add(DATA[8]); } HandleVOBCData HandleVOBCData = new HandleVOBCData(DATA); if (HandleVOBCData.NC_Train == 0x03) { ATPPackage InfoSendToATP = new ATPPackage(); InfoSendToATP.NC_ZC = 0x03; VOBCQuit Quit = new VOBCQuit(VOBCData.PreAccess, HandleVOBCData.NID_Train, HandleVOBCData.TrainPosition); HandleVOBCData.TrainPosition.Remove(HandleVOBCData.NID_Train); HandleVOBCData.TrainDirection.Remove(HandleVOBCData.NID_Train); VOBCData.PreAccess.Remove(HandleVOBCData.NID_Train); Send(InfoSendToATP.ATPPack.buf_, GetIPByDataType(SenderID), GetPortByDataType(SenderID), InfoSendToATP.ATPPack.byteFlag_); } else { UpdateInfo UpdateInfo = new UpdateInfo(HandleVOBCData, DATA); VOBCData VOBCData = new VOBCData(DATA, HandleVOBCData); Send(VOBCData.InfoSendToATP.ATPPack.buf_, GetIPByDataType(SenderID), GetPortByDataType(SenderID), VOBCData.InfoSendToATP.ATPPack.byteFlag_); } }
public VOBCData(byte[] data, HandleVOBCData handle) { this.Data = data; this.Handle = handle; SetInfoToVOBC(); InfoSendToATP.PackATP(); CancelPreAccess(); UpdateAccess(); UpdatePreAccess(); }
public UpdateInfo(HandleVOBCData Handle, byte[] Data) { this.Data = Data; this.VOBCInfo = Handle; CancelPreTrainPosition(); UpDataTrainOccupy(); UpdataLine(); UpdatePrePosition(); }
public byte[] DetermineMA(HandleVOBCData Handle) { this.Handle = Handle; int TrainSectionInt = Convert.ToInt16(HandleVOBCData.TrainPosition[Handle.NID_Train][1]) * 256 + Convert.ToInt16(HandleVOBCData.TrainPosition[Handle.NID_Train][0]);//纯数字 int RailSwitchInt = Convert.ToInt16(HandleVOBCData.TrainPosition[Handle.NID_Train][2]); string RailSwitchString; string TrainSectionString; if (TrainSectionInt == 501) { TrainSectionString = "XJ1G"; } else if (TrainSectionInt == 502) { TrainSectionString = "XJ2G"; } else { TrainSectionString = TrainSectionInt.ToString(); } if (TrainSectionString == "118") { } RailSwitchString = RailSwitchInt.ToString(); int TrainDir = Handle.Q_TrainRealDirection; foreach (var item in MainWindow.stationElements_.Elements) { if (item is Section) { if (item.Name.Length > 2) { if (item.Name.Substring(0, 3) == TrainSectionString) { FindCurTrainIn(TrainSectionString + "-0", TrainDir); } } } if (item is RailSwitch) { if ((item as RailSwitch).SectionName.Length > 2) { if ((item as RailSwitch).SectionName.Substring(0, 3) == TrainSectionString) { FindCurTrainIn(TrainSectionString + "-" + RailSwitchString, TrainDir); } } } } foreach (var item in MainWindow.stationElements_1_.Elements) { if (item is Section) { if (item.Name.Length > 2) { if (item.Name.Substring(0, 3) == TrainSectionString) { FindCurTrainIn(TrainSectionString + "-0", TrainDir); } } } if (item is RailSwitch) { if ((item as RailSwitch).SectionName.Length > 2) { if ((item as RailSwitch).SectionName.Substring(0, 3) == TrainSectionString) { FindCurTrainIn(TrainSectionString + "-" + RailSwitchString, TrainDir); } } } } CItable NextAccess = null; if (CurTrainIn.Count != 0) { foreach (var item in CurTrainIn) { if ((TrainSectionString + "-" + RailSwitchString) == item.StartSection) { Signal startSignal = TraverseSignal(item.StartSignal) as Signal; if (!startSignal.IsSignalOpen) { return(ConvertToByte(TrainSectionString, 130, TrainDir)); } } int num = item.Section.IndexOf(TrainSectionString + "-" + RailSwitchString); if (item.IsReturn) { MAEndType = 0x02; for (int i = num; i < item.Section.Count; i++) { if (!Route.Contains(item.Section[i])) { Route.Add(item.Section[i]); } } if (Route.Count > 1) { for (int i = 1; i < Route.Count; i++) { if (Route[i].Substring(0, 3) != item.Section[num].Substring(0, 3)) { byte[] a = SectionAxleOccpy(Route[i], TrainDir); if (a != null) { for (int x = i; x < Route.Count; x++) { Route.Remove(Route[i]); } return(a); } } byte[] b = SectionOccpy(Route[i], TrainDir); if (b != null) { for (int x = i; x < Route.Count; x++) { Route.Remove(Route[i]); } return(b); } } return(SetAccessEndMA(Route[Route.Count - 1], TrainDir)); } else if (Route.Count == 1) { return(SetAccessEndMA(Route[Route.Count - 1], TrainDir)); } } else { for (int i = num; i < item.Section.Count; i++) { if (!Route.Contains(item.Section[i])) { Route.Add(item.Section[i]); } if (item.Section[i].Substring(0, 3) != item.Section[num].Substring(0, 3)) { byte[] a = SectionAxleOccpy(item.Section[i], TrainDir); if (a != null) { return(a); } } byte[] b = SectionOccpy(item.Section[i], TrainDir); if (b != null) { return(b); } CItable Access = IsApproachSection(item.Section[i], TrainDir); if (Access != null) { NextAccess = Access; } } } } } if (NextAccess != null) { bool HasNextAccessOpen = true; while (HasNextAccessOpen) { if (NextAccess.IsReturn) { for (int i = 0; i < NextAccess.Section.Count; i++) { if (!Route.Contains(NextAccess.Section[i])) { Route.Add(NextAccess.Section[i]); } } MAEndType = 0x02; return(SetReturnAccess(Route, TrainDir)); } else { CItable Next = null; for (int i = 0; i < NextAccess.Section.Count; i++) { if (NextAccess.Section[i] == TrainSectionString + "-" + RailSwitchString) { } else { if (!Route.Contains(NextAccess.Section[i])) { Route.Add(NextAccess.Section[i]); } byte[] a = SectionOccpy(NextAccess.Section[i], TrainDir); if (a != null) { return(a); } Next = IsApproachSection(NextAccess.Section[i], TrainDir); } } if (Next != null) { NextAccess = Next; } else { HasNextAccessOpen = false; } } } } else { if (CurTrainIn.Count > 0) { NextAccess = CurTrainIn[CurTrainIn.Count - 1]; } else { return(null); } } MASection = NextAccess.EndSection; return(SetAccessEndMA(MASection, TrainDir));; }