internal VehicleConfig(XmlDocument doc) { m_nVersion = (byte)BaseN.S64ToInt(doc.DocumentElement.GetAttribute("V", string.Empty)); string strUTMZone = doc.DocumentElement.GetAttribute("U", string.Empty); m_nUTMZoneNo = int.Parse(strUTMZone.Substring(0, strUTMZone.Length - 1)); m_chUTMZoneLetter = strUTMZone[strUTMZone.Length - 1]; StringReader sr = new StringReader(doc.DocumentElement.FirstChild.Value); string str = sr.ReadLine(); int nRow = -1; while (str != null) { switch (++nRow) { case 0: if (str.Length > 0) { m_strHeadSignDefault = str; } break; case 1: byte.TryParse(str, out m_nRouteNoFmt); break; case 2: m_strNSAPrefix = str.Split('~')[0]; break; case 3: m_strConnPrefix = str.Split('~')[0]; break; case 4: { string[] stra = str.Split('~'); m_strNSDStopping = stra[0]; m_strNSDStoppingConcat = stra[1]; break; } case 5: m_strSAPrefixFmt = str.Split('~')[0]; break; } str = sr.ReadLine(); } sr.Close(); }
internal ServiceAlertConfig(XmlDocument doc) { m_Doc = doc; m_nVersion = (byte)BaseN.S64ToInt(m_Doc.DocumentElement.GetAttribute("V", string.Empty)); byte n = 0; string str = m_Doc.DocumentElement.GetAttribute("E", string.Empty); if (str.Length == 0 || !byte.TryParse(str, out n)) { m_SAMode = AVMode.None; } else { m_SAMode = (AVMode)n; } }
internal RoutePatternConfig(XmlDocument doc) { m_Doc = doc; m_nVersion = (byte)BaseN.S64ToInt(m_Doc.DocumentElement.GetAttribute("V", string.Empty)); { byte n = 0; string str = m_Doc.DocumentElement.GetAttribute("F", string.Empty); if (str.Length == 0 || !byte.TryParse(str, out n)) { m_FareboxFields = FareboxFields.None; } else { m_FareboxFields = (FareboxFields)n; } } { byte n = 0; string str = m_Doc.DocumentElement.GetAttribute("C", string.Empty); if (str.Length == 0 || !byte.TryParse(str, out n)) { m_ConnMode = AVMode.None; } else { m_ConnMode = (AVMode)n; } } { string str = m_Doc.DocumentElement.GetAttribute("R", string.Empty); if (str.Length == 0) { m_nNSAReminderSec = 0; } else { m_nNSAReminderSec = (ushort)(60 * BaseN.S64ToInt(str)); } } }
internal bool GetContent(string strRouteTag64, out string strProjectTag, out string strRouteNo, out double nRouteLength, out string strRPcsv) { bool bOK = false; strProjectTag = strRouteNo = strRPcsv = null; nRouteLength = 0.0; XPathNodeIterator it = (XPathNodeIterator)m_Doc.CreateNavigator().Evaluate("//P[@T='" + strRouteTag64 + "']"); if (it.MoveNext()) { bOK = true; strProjectTag = it.Current.GetAttribute("p", string.Empty); if (strProjectTag.Length == 0) { strProjectTag = "1"; } strRouteNo = it.Current.GetAttribute("N", string.Empty); nRouteLength = BaseN.S64ToInt(it.Current.GetAttribute("L", string.Empty)); strRPcsv = it.Current.Value; } return(bOK); }
public static Trip Create(Vehicle vehicle, short nRouteTag, int nRP, int?nTripNo, ushort?nServiceStart, Vehicle.RoutePatternConfig configRP, Vehicle.ServiceAlertConfig configSA, Vehicle.VehicleConfig configV, bool fFerry) { Trip trip = null; try { double nRouteLength; string strProjectTag, strRouteNo, strRPcsv; if (!configRP.GetContent(BaseN.IntToS64(nRouteTag), out strProjectTag, out strRouteNo, out nRouteLength, out strRPcsv)) { return(null); } StringReader sr = new StringReader(strRPcsv); Queue <Platform> queue = new Queue <Platform>(0x80); Collection <string> colNextStop = new Collection <string>(); double nLastEasting = 0.0, nLastNorthing = 0.0, nLastRadius = 0.0; int nLastRP = 0, nNextStopIndex = 0; string str = sr.ReadLine(), strLastDestination = null, strLastHeadSign = null; byte? nLastFareSet = null; byte nServiceDay = 0; ushort nScheduledMin = 0; if (nServiceStart.HasValue) { nServiceDay = (byte)(nServiceStart.Value & 0x07); nScheduledMin = (ushort)(nServiceStart.Value >> 3); } while (str != null) { string[] stra = str.Split('~'); Platform platform = new Platform(); platform.MinDistanceFromPlatform = double.MaxValue; platform.Arrived = platform.ExternalAudioActivated = false; platform.Name = stra[0]; //platform.Position.X = BaseN.S32ToInt( stra[1] ) + nLastEasting; //platform.Position.Y = BaseN.S32ToInt( stra[2] ) + nLastNorthing; platform.Radius = BaseN.S32ToInt(stra[3]) + nLastRadius; platform.RPEnd = BaseN.S64ToInt(stra[4]) + nLastRP; platform.DistanceToEnd = nRouteLength * (platform.RPEnd - nLastRP) / UTM.cRPScalar; if (stra.Length > 5 && stra[5].Length > 0) { switch (stra[5][0]) { case '1': platform.InternalAudio = true; platform.Timepoint = false; break; case '2': platform.InternalAudio = false; platform.Timepoint = true; break; case '3': platform.InternalAudio = platform.Timepoint = true; break; default: //legacy @ platform.InternalAudio = true; platform.Timepoint = false; break; } } else { platform.InternalAudio = platform.Timepoint = false; } platform.Destination = stra.Length > 6 && stra[6].Length > 0 ? stra[6] : strLastDestination; platform.HeadSign = stra.Length > 7 && stra[7].Length > 0 ? stra[7] : strLastHeadSign; platform.FareSet = stra.Length > 8 && stra[8].Length > 0 ? byte.Parse(stra[8]) : nLastFareSet; platform.NSAReminderSec = platform.InternalAudio ? configRP.NSAReminderSec : (ushort)0; platform.NSAReminderDistanceMin = platform.InternalAudio ? (platform.Radius * 2.0 + 50.0) : 0.0; platform.NSAReminderDistanceMax = platform.InternalAudio ? (platform.Radius * 2.0 + 200.0) : 0.0; platform.DepartureEnabled = false; platform.IgnoreServerRP = false; colNextStop.Add(platform.Name); if (nRP <= platform.RPEnd) { if (nServiceDay > 0 && stra.Length > 9) { string strNSAConn = string.Empty, strNSDConn = string.Empty; for (int n = 9; n < stra.Length; ++n) { bool bMatch = false; string[] straDest = stra[n].Split('§'); for (int m = 2; !bMatch && m < straDest.Length;) { byte nServiceMask = (byte)BaseN.S64ToInt(straDest[m]); if ((nServiceDay & nServiceMask) > 0) { ushort nScheduledMinStart = (ushort)BaseN.S64ToInt(straDest[m + 1]); ushort nScheduledMinEnd = (ushort)BaseN.S64ToInt(straDest[m + 2]); if (nScheduledMinStart <= nScheduledMin && nScheduledMin <= nScheduledMinEnd) { bMatch = true; strNSAConn += vehicle.GetRouteNoForAudio(straDest[0]) + " " + straDest[1] + ". "; strNSDConn += straDest[0] + " " + straDest[1] + ", "; } } m += 3; } } if (strNSAConn.Length > 0) { platform.NSAConn = strNSAConn; platform.NSDConn = strNSDConn.Substring(0, strNSDConn.Length - 2) + ". "; } } queue.Enqueue(platform); } else { ++nNextStopIndex; } //nLastEasting = platform.Position.X; //nLastNorthing = platform.Position.Y; nLastRadius = platform.Radius; nLastRP = platform.RPEnd; strLastDestination = platform.Destination; strLastHeadSign = platform.HeadSign; nLastFareSet = platform.FareSet; str = sr.ReadLine(); } sr.Close(); trip = new Trip(); trip.m_Vehicle = vehicle; trip.m_nRouteTag = nRouteTag; trip.m_nRP = nRP; trip.m_nTripNo = nTripNo; trip.m_nServiceStart = nServiceStart; trip.m_strRouteNo = strRouteNo; trip.m_strRouteNoForAudio = vehicle.GetRouteNoForAudio(strRouteNo); trip.m_ConnMode = configRP.ConnMode; trip.m_SAMode = configSA.SAMode; if (trip.m_SAMode != Vehicle.AVMode.None) { trip.m_strSAPrefix = string.Format(configV.SAPrefixFmt, strRouteNo); trip.m_strSAPrefixForAudio = string.Format(configV.SAPrefixFmt, trip.m_strRouteNoForAudio); trip.m_strServiceAlert = configSA.GetContent(strProjectTag, strRouteNo); if (trip.m_strServiceAlert != null) { trip.m_strServiceAlert2 = trip.m_strServiceAlert.Replace("\r\n", " ").Replace('\n', ' '); } } trip.m_configV = configV; trip.m_fFerry = fFerry; trip.m_nRouteLength = nRouteLength; trip.m_Queue = queue; trip.m_colNextStop = new ReadOnlyCollection <string>(colNextStop); trip.m_nNextStopIndex = nNextStopIndex; trip.m_Platform = trip.m_Queue.Dequeue(); trip.UpdateDistanceToEnd(); // trip.OnNewPlatform(false, true); switch (configRP.FareboxFields) { case Vehicle.FareboxFields.RouteNo: vehicle.QueueRequest(new RequestEventArgs(RequestType.Farebox, new Farebox(strRouteNo, null))); break; case Vehicle.FareboxFields.RouteNoTripNo: vehicle.QueueRequest(new RequestEventArgs(RequestType.Farebox, new Farebox(strRouteNo, nTripNo))); break; case Vehicle.FareboxFields.TripNo: if (nTripNo.HasValue) { vehicle.QueueRequest(new RequestEventArgs(RequestType.Farebox, new Farebox(null, nTripNo))); } break; } } catch (Exception) {} return(trip); }
internal DriverConfig(XmlDocument doc) { m_Doc = doc; m_nVersion = (byte)BaseN.S64ToInt(m_Doc.DocumentElement.GetAttribute("V", string.Empty)); }