コード例 #1
0
ファイル: WTTTrip.cs プロジェクト: RailByte/Groundframe
        /// <summary>
        /// Parses a WTTTrip SimSig XML Xlement into the WTTTrip object
        /// </summary>
        /// <param name="WTTTripXML"></param>
        private void ParseWTTTripXML(XElement WTTTripXML)
        {
            try
            {
                this.Location                 = XMLMethods.GetValueFromXElement <string>(WTTTripXML, @"Location", string.Empty);
                this.DepPassTime              = XMLMethods.GetValueFromXElement <WTTTime>(WTTTripXML, @"DepPassTime", null, new object[] { this.StartDate });
                this.ArrTime                  = XMLMethods.GetValueFromXElement <WTTTime>(WTTTripXML, @"ArrTime", null, new object[] { this.StartDate });
                this.IsPassTime               = XMLMethods.GetValueFromXElement <bool>(WTTTripXML, @"IsPassTime", false);
                this.Platform                 = XMLMethods.GetValueFromXElement <string>(WTTTripXML, @"Platform", null);
                this.Line                     = XMLMethods.GetValueFromXElement <string>(WTTTripXML, @"Line", null);
                this.Path                     = XMLMethods.GetValueFromXElement <string>(WTTTripXML, @"Path", null);
                this.AutoPath                 = XMLMethods.GetValueFromXElement <bool>(WTTTripXML, @"AutoPath", false);
                this.AutoLine                 = XMLMethods.GetValueFromXElement <bool>(WTTTripXML, @"AutoLine", false);
                this.DownDirection            = XMLMethods.GetValueFromXElement <bool>(WTTTripXML, @"DownDirection", false);
                this.PrevPathEndDown          = XMLMethods.GetValueFromXElement <bool>(WTTTripXML, @"PrevPathEndDown", false);
                this.NextPathStartDown        = XMLMethods.GetValueFromXElement <bool>(WTTTripXML, @"NextPathStartown", false);
                this.StopLocation             = XMLMethods.GetValueFromXElement <WTTStopLocation>(WTTTripXML, @"StopLocation", WTTStopLocation.Default);
                this.DwellTime                = XMLMethods.GetValueFromXElement <WTTDuration>(WTTTripXML, @"DwellTime", null);
                this.BerthsHere               = XMLMethods.GetValueFromXElement <bool>(WTTTripXML, @"BerthsHere", false);
                this.AllowStopsOnThroughLines = XMLMethods.GetValueFromXElement <bool>(WTTTripXML, @"AllowStopsOnThroughLines", false);
                this.WaitForBookedTime        = XMLMethods.GetValueFromXElement <bool>(WTTTripXML, @"WaitForBookedTime", false);
                this.SetDownOnly              = XMLMethods.GetValueFromXElement <bool>(WTTTripXML, @"SetDownOnly", false);

                //Parse Activties

                if (WTTTripXML.Element("Activities") != null)
                {
                    this.Activities = new WTTActivityCollection(WTTTripXML.Element("Activities"));
                }
            }
            catch (Exception Ex)
            {
                throw new Exception(ExceptionHelper.GetStaticException("ParseFromXElementWTTTripException", null, Globals.UserSettings.GetCultureInfo()), Ex);
            }
        }
コード例 #2
0
        /// <summary>
        /// Parses a WTTCautionSpeedSetXML XElement into this object
        /// </summary>
        /// <param name="WTTCautionSpeedSetXML">The SimSig XML Snippet (as an XElement) representing a single WTT Caution Speed set</param>
        private void ParseWTTCautionSpeedSetXML(XElement WTTCautionSpeedSetXML)
        {
            try
            {
                if (WTTCautionSpeedSetXML.Attribute("ID") == null)
                {
                    this.GenerateSimSigID();
                }
                else
                {
                    this._SimSigID = WTTCautionSpeedSetXML.Attribute("ID").Value;
                }

                this.Name = XMLMethods.GetValueFromXElement <string>(WTTCautionSpeedSetXML, @"Name", string.Empty);

                if (WTTCautionSpeedSetXML.Element("CautionSpeeds") != null)
                {
                    this._CautionSpeeds = new List <WTTCautionSpeed>();

                    foreach (XElement WTTCautionSpeedXML in WTTCautionSpeedSetXML.Element("CautionSpeeds").Elements("CautionSpeed"))
                    {
                        this._CautionSpeeds.Add(new WTTCautionSpeed(WTTCautionSpeedXML));
                    }
                    ;
                }
            }
            catch (Exception Ex)
            {
                throw new Exception(ExceptionHelper.GetStaticException("ParseFromXElementWTTCautionSpeedSetException", null, Globals.UserSettings.GetCultureInfo()), Ex);
            }
        }
コード例 #3
0
        private void ParseHeaderXML(XElement TrainCategoryXML)
        {
            try
            {
                this._SimSigID             = TrainCategoryXML.Attribute("ID")?.Value.ToString();
                this.Description           = XMLMethods.GetValueFromXElement <string>(TrainCategoryXML, @"Description", string.Empty);
                this.AccelBrakeIndex       = XMLMethods.GetValueFromXElement <WTTAccelBrakeIndex>(TrainCategoryXML, @"AccelBrakeIndex", WTTAccelBrakeIndex.MediumInterCity);
                this.IsFreight             = XMLMethods.GetValueFromXElement <bool>(TrainCategoryXML, @"IsFreight", false);
                this.CanUseGoodsLines      = XMLMethods.GetValueFromXElement <bool>(TrainCategoryXML, @"CanUseGoodsLines", false);
                this.MaxSpeed              = XMLMethods.GetValueFromXElement <WTTSpeed>(TrainCategoryXML, @"MaxSpeed", null);
                this.TrainLength           = XMLMethods.GetValueFromXElement <Length>(TrainCategoryXML, @"TrainLength", null);
                this.SpeedClass            = XMLMethods.GetValueFromXElement <WTTSpeedClass>(TrainCategoryXML, @"SpeedClass", null);
                this.PowerToWeightCategory = XMLMethods.GetValueFromXElement <WTTPowerToWeightCategory>(TrainCategoryXML, @"PowerToWeightCategory", WTTPowerToWeightCategory.Normal);
                this.Electrification       = XMLMethods.GetValueFromXElement <Electrification>(TrainCategoryXML, @"Electrification", null);
                this.CautionSpeedSet       = XMLMethods.GetValueFromXElement <string>(TrainCategoryXML, @"CautionSpeedSet", null);

                //Load any dwell times
                XElement DwellXML = TrainCategoryXML.Element("DwellTimes");

                //If the Dwell times XML is <NULL> then just make the DwellTimes property null
                if (!DwellXML.HasElements)
                {
                    this.DwellTimes = null;
                }
                else
                {
                    this.DwellTimes = new WTTDwell(DwellXML);
                }
            }
            catch (Exception Ex)
            {
                throw new Exception(ExceptionHelper.GetStaticException("ParseFromXElementWTTTrainCategoryException", null, Globals.UserSettings.GetCultureInfo()), Ex);
            }
        }
コード例 #4
0
        private void ParseHeaderXML(XElement DwellXML)
        {
            try
            {
                //If there are no dwell times records then return empty dwell object

                if (!DwellXML.HasElements)
                {
                    return;
                }

                this.RedSignalMoveOff = XMLMethods.GetValueFromXElement <WTTDuration>(DwellXML, @"RedSignalMoveOff", null);
                this.StationForward   = XMLMethods.GetValueFromXElement <WTTDuration>(DwellXML, @"StationForward", null);
                this.StationReverse   = XMLMethods.GetValueFromXElement <WTTDuration>(DwellXML, @"StationReverse", null);
                this.TerminateForward = XMLMethods.GetValueFromXElement <WTTDuration>(DwellXML, @"TerminateForward", null);
                this.TerminateReverse = XMLMethods.GetValueFromXElement <WTTDuration>(DwellXML, @"TerminateReverse", null);
                this.Join             = XMLMethods.GetValueFromXElement <WTTDuration>(DwellXML, @"Join", null);
                this.Divide           = XMLMethods.GetValueFromXElement <WTTDuration>(DwellXML, @"Divide", null);
                this.CrewChange       = XMLMethods.GetValueFromXElement <WTTDuration>(DwellXML, @"CrewChange", null);
            }
            catch (Exception Ex)
            {
                throw new Exception(ExceptionHelper.GetStaticException("ParseFromXElementWTTTrainCategoryException", null, Globals.UserSettings.GetCultureInfo()), Ex);
            }
        }
コード例 #5
0
ファイル: WTTTimeTable.cs プロジェクト: RailByte/Groundframe
        private void ParseWTTTimeTable(XElement TimeTableXML)
        {
            try
            {
                //Parse XML
                this.Headcode                = XMLMethods.GetValueFromXElement <string>(TimeTableXML, @"ID", null);
                this.UID                     = XMLMethods.GetValueFromXElement <string>(TimeTableXML, @"UID", null);
                this.AccelBrakeIndex         = XMLMethods.GetValueFromXElement <WTTAccelBrakeIndex>(TimeTableXML, @"AccelBrakeIndex", WTTAccelBrakeIndex.MediumInterCity);
                this.RunAsRequired           = XMLMethods.GetValueFromXElement <bool>(TimeTableXML, @"AsRequired", false);
                this.RunAsRequiredPercentage = XMLMethods.GetValueFromXElement <int>(TimeTableXML, @"AsRequiredPercent", 50);
                this.Delay                   = XMLMethods.GetValueFromXElement <WTTDuration>(TimeTableXML, @"Delay", null);
                this.DepartTime              = XMLMethods.GetValueFromXElement <WTTTime>(TimeTableXML, @"DepartTime", null, new object[] { this._StartDate });
                this.Description             = XMLMethods.GetValueFromXElement <string>(TimeTableXML, @"Description", string.Empty);
                this.SeedingGap              = XMLMethods.GetValueFromXElement <Length>(TimeTableXML, @"SeedingGap", new Length(15));
                this.EntryPoint              = XMLMethods.GetValueFromXElement <string>(TimeTableXML, @"EntryPoint", null);
                this.EntryDecision           = XMLMethods.GetValueFromXElement <string>(TimeTableXML, @"EntryDecision", null);
                this.EntryChoice             = XMLMethods.GetValueFromXElement <string>(TimeTableXML, @"EntryChoice", null);
                this.ActualEntryPoint        = XMLMethods.GetValueFromXElement <string>(TimeTableXML, @"ActualEntryPoint", string.Empty);
                this.MaxSpeed                = XMLMethods.GetValueFromXElement <WTTSpeed>(TimeTableXML, @"MaxSpeed", null);
                this.SpeedClass              = XMLMethods.GetValueFromXElement <WTTSpeedClass>(TimeTableXML, @"SpeedClass", null);
                this.Started                 = XMLMethods.GetValueFromXElement <bool>(TimeTableXML, @"Started", false);
                this.TrainLength             = XMLMethods.GetValueFromXElement <Length>(TimeTableXML, @"TrainLength", 20);
                this.Electrification         = XMLMethods.GetValueFromXElement <Electrification>(TimeTableXML, @"Electrification", new Electrification("D"));
                this.OriginName              = XMLMethods.GetValueFromXElement <string>(TimeTableXML, @"DestinationName", null);
                this.DestinationName         = XMLMethods.GetValueFromXElement <string>(TimeTableXML, @"DestinationTime", null);
                this.OriginTime              = XMLMethods.GetValueFromXElement <WTTTime>(TimeTableXML, @"OriginTime", null, new object[] { this._StartDate });
                this.DestinationTime         = XMLMethods.GetValueFromXElement <WTTTime>(TimeTableXML, @"DestinationTime", null, new object[] { this._StartDate });
                this.OperatorCode            = XMLMethods.GetValueFromXElement <string>(TimeTableXML, @"OperatorCode", null);
                this.NonARSOnEntry           = XMLMethods.GetValueFromXElement <bool>(TimeTableXML, @"NonARSOnEntry", false);
                this.RunAsRequiredTested     = XMLMethods.GetValueFromXElement <bool>(TimeTableXML, @"AsRequiredTested", false);
                //TODO: Entry Warned
                this.StartTraction         = XMLMethods.GetValueFromXElement <Electrification>(TimeTableXML, @"StartTraction", new Electrification("D"));
                this.SimSigTrainCategoryID = XMLMethods.GetValueFromXElement <string>(TimeTableXML, @"Category", string.Empty);
                this.RedSignalMoveOff      = XMLMethods.GetValueFromXElement <WTTDuration>(TimeTableXML, @"RedSignalMoveOff", null);
                this.StationForward        = XMLMethods.GetValueFromXElement <WTTDuration>(TimeTableXML, @"StationForward", null);
                this.StationReverse        = XMLMethods.GetValueFromXElement <WTTDuration>(TimeTableXML, @"StationReverse", null);
                this.TerminateForward      = XMLMethods.GetValueFromXElement <WTTDuration>(TimeTableXML, @"TerminateForward", null);
                this.TerminateReverse      = XMLMethods.GetValueFromXElement <WTTDuration>(TimeTableXML, @"TerminateReverse", null);
                this.Join       = XMLMethods.GetValueFromXElement <WTTDuration>(TimeTableXML, @"Join", null);
                this.Divide     = XMLMethods.GetValueFromXElement <WTTDuration>(TimeTableXML, @"Divide", null);
                this.CrewChange = XMLMethods.GetValueFromXElement <WTTDuration>(TimeTableXML, @"CrewChange", null);

                //Parse Trips
                this.ParseTripsXML(TimeTableXML.Element("Trips"));
            }
            catch (Exception Ex)
            {
                throw new Exception(ExceptionHelper.GetStaticException("ParseFromXElementWTTTimeTableException", null, Globals.UserSettings.GetCultureInfo()), Ex);
            }
        }
コード例 #6
0
 /// <summary>
 /// Parses a CautionSpeedXML XElement into this object
 /// </summary>
 /// <param name="WTTCautionSpeedXML">The SimSig XML Snippet (as an XElement) representing a single WTT Caution Speed</param>
 private void ParseWTTCautionSpeedXML(XElement WTTCautionSpeedXML)
 {
     try
     {
         //Parse XML
         this.AspectPassed         = XMLMethods.GetValueFromXElement <WTTSignalAspect>(WTTCautionSpeedXML, @"AspectPassed", WTTSignalAspect.Red);
         this.FromLineSpeed        = XMLMethods.GetValueFromXElement <WTTSpeed>(WTTCautionSpeedXML, @"FromLineSpeed", null);
         this.ReduceNowValue       = XMLMethods.GetValueFromXElement <int>(WTTCautionSpeedXML, @"ReduceNowValue", 0);
         this.ApproachNextValue    = XMLMethods.GetValueFromXElement <int>(WTTCautionSpeedXML, @"ApproachNextValue", 0);
         this.ApproachNextDistance = XMLMethods.GetValueFromXElement <Length>(WTTCautionSpeedXML, @"ApproachNextDistance", null);
         this.NowValueType         = XMLMethods.GetValueFromXElement <WTTNumberType>(WTTCautionSpeedXML, @"NowValueType", WTTNumberType.NotApplicable);
         this.NextValueType        = XMLMethods.GetValueFromXElement <WTTNumberType>(WTTCautionSpeedXML, @"NextValueType", WTTNumberType.NotApplicable);
     }
     catch (Exception Ex)
     {
         throw new Exception(ExceptionHelper.GetStaticException("ParseFromXElementWTTCautionSpeedException", null, Globals.UserSettings.GetCultureInfo()), Ex);
     }
 }
コード例 #7
0
ファイル: WTTHeader.cs プロジェクト: RailByte/Groundframe
 /// <summary>
 /// Parses the WTTHeader from the SimSigTimeable element from a SimSig SavedTimetable.xml document
 /// </summary>
 /// <param name="Header"></param>
 private void ParseHeaderXML(XElement Header)
 {
     try
     {
         //Parse XML
         this.Name                     = XMLMethods.GetValueFromXElement <string>(Header, @"Name", string.Empty, null);
         this.Description              = XMLMethods.GetValueFromXElement <string>(Header, @"Description", string.Empty, null);
         this.StartTime                = XMLMethods.GetValueFromXElement <WTTTime>(Header, @"StartTime", null, new object[] { this._StartDate });
         this.FinishTime               = XMLMethods.GetValueFromXElement <WTTTime>(Header, @"FinishTime", null, new object[] { this._StartDate });
         this.VersionMajor             = XMLMethods.GetValueFromXElement <int>(Header, @"VMajor", 1);
         this.VersionMinor             = XMLMethods.GetValueFromXElement <int>(Header, @"VMinor", 0);
         this._VersionBuild            = XMLMethods.GetValueFromXElement <int>(Header, @"VBuild", 0);
         this.TrainDescriptionTemplate = XMLMethods.GetValueFromXElement <string>(Header, @"TrainDescriptionTemplate", @"$originTime $originName-$destName $operator ($stock)");
         this.SeedGroupSummary         = XMLMethods.GetValueFromXElement <string>(Header, @"SeedGroupSummary", string.Empty);
     }
     catch (Exception Ex)
     {
         throw new Exception(ExceptionHelper.GetStaticException("ParseWTTHeaderException", null, Globals.UserSettings.GetCultureInfo()), Ex);
     }
 }
コード例 #8
0
 /// <summary>
 /// Parses a SimSig XML snippet (as an XElement) which represents a single activity
 /// </summary>
 /// <param name="WTTActivityXML">The SimSig XML snippet (as an XElement) to parse</param>
 private void ParseWTTActivityXML(XElement WTTActivityXML)
 {
     this.ActivityType            = (WTTActivityType)XMLMethods.GetValueFromXElement <int>(WTTActivityXML, @"Activity", 0);
     this.AssociatedTrainHeadCode = XMLMethods.GetValueFromXElement <string>(WTTActivityXML, @"AssociatedTrain", null);
     this.AssociatedUID           = XMLMethods.GetValueFromXElement <string>(WTTActivityXML, @"AssociatedUID", null);
 }