Exemplo n.º 1
0
        /// <summary>
        /// Creates the mapped location in the Target Simulation
        /// </summary>
        /// <param name="SQLConnector">The target simulation where the location should be created</param>
        /// <param name="TargetSimulation">A GFSqlConnector object connected to the GroundFrame.SQL database</param>
        /// <param name="Version">The version under which the location node was created</param>
        /// <param name="SimEra">The era for which the location node is valid</param>
        /// <param name="Location">The location against which the location node will be created</param>
        public void CreateLocationNode(ref SimSig.SimulationExtension TargetSimulation, GFSqlConnector SQLConnector, SimSig.Location Location, SimSig.Version Version, SimSig.SimulationEra SimEra)
        {
            //Validate Arguments
            ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo());
            ArgumentValidation.ValidateSimulation(TargetSimulation, Globals.UserSettings.GetCultureInfo());
            ArgumentValidation.ValidateVersion(Version, Globals.UserSettings.GetCultureInfo());
            ArgumentValidation.ValidateLocation(Location, Globals.UserSettings.GetCultureInfo());
            ArgumentValidation.ValidateSimEra(SimEra, Globals.UserSettings.GetCultureInfo());

            //Default Value
            Electrification DefaultElectrification = new Electrification("D");

            //Instantiate Location Node
            SimSig.LocationNode NewLocationNode = new SimSig.LocationNode(TargetSimulation.ID, Location.ID, SimEra.ID, Version, this.Platform, DefaultElectrification, SimSig.SimSigLocationType.Unknown, null, false, this.Line, this.Path, SQLConnector);

            if (TargetSimulation.LocationNodes.Exists(NewLocationNode) == false)
            {
                //Save to GroundFrame.SQL database
                NewLocationNode.SaveToSQLDB();
                //Add location node to MapperLocationNode
                this._LocationNode = NewLocationNode;
                //Add location to the simulation
                TargetSimulation.LocationNodes.Add(NewLocationNode);
            }

            //Dispose
            NewLocationNode.Dispose();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Instantiates a new PathEdge object from the supplied values
 /// </summary>
 /// <param name="FromLocation">The start location node of the path</param>
 /// <param name="ToLocation">The end location node of the path</param>
 /// <param name="SQLConnector">A conector to the GroundFrame.SQL database</param>
 public PathEdge(LocationNode FromLocation, LocationNode ToLocation, GFSqlConnector SQLConnector)
 {
     //Validate Arguments
     ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo());
     this._FromLocation       = FromLocation;
     this._ToLocation         = ToLocation;
     this._SQLConnector       = new GFSqlConnector(SQLConnector);
     this.PathDirection       = SimSigPathDirection.None;
     this.PathElectrification = new Electrification(0);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Parses a SqlDataReader object into a PathEdge object
        /// </summary>
        /// <param name="DataReader">The SqlDataReader DataReader object to parse</param>
        private void ParseDataReader(SqlDataReader DataReader)
        {
            int toLocationNodeID = DataReader.GetInt32("to_locationnode_id");

            //Instantiate the To LocationNode object
            this._ToLocation         = new LocationNode(toLocationNodeID, this._SQLConnector, false); //We don't need to load the Path Edges for a to location node (otherwise we'll end up in an infinite loop
            this.PathLength          = DataReader.GetNullableInt16("length") == 0 ? null : new Length(DataReader.GetNullableInt16("length"));
            this.PathElectrification = DataReader.GetNullableByte("simsig_elec_bitmap") == 0 ? null : new Electrification((ElectrificationBitValue)DataReader.GetNullableByte("simsig_elec_bitmap"));
            this.PathDirection       = (SimSigPathDirection)DataReader.GetNullableByte("path_direction");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Instantiates a PathEdgeCollection for the supplied start location
        /// </summary>
        /// <param name="FromLocation">The LocationNode object to which the path collection starts</param>
        /// <param name="SQLConnector">A GFSqlConnector to the GroundFrame.SQL database</param>
        public PathEdgeCollection(LocationNode FromLocation, GFSqlConnector SQLConnector)
        {
            CultureInfo culture = Globals.UserSettings.GetCultureInfo();

            ArgumentValidation.ValidateSQLConnector(SQLConnector, culture);

            this._FromLocationNode = FromLocation;
            //Set the SQL Connector
            this._SQLConnector = new GFSqlConnector(SQLConnector); //Instantiated as a new copy of the SQLConnector to stop conflict issues with open connections, commands and DataReaders
            //Get the locations
            this.GetAllPathEdgesFromLocation();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Instantiates a new PathEdge object from the supplied SqlDataReader
        /// </summary>
        /// <param name="FromLocation">The start location node of the path</param>
        /// <param name="DataReader">The SqlDataReader object to parse into this path edge object</param>
        /// <param name="SQLConnector">A conector to the GroundFrame.SQL database</param>
        public PathEdge(LocationNode FromLocation, SqlDataReader DataReader, GFSqlConnector SQLConnector)
        {
            //Validate Arguments
            ArgumentValidation.ValidateSqlDataReader(DataReader, Globals.UserSettings.GetCultureInfo());
            ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo());

            this._FromLocation = FromLocation;
            this._SQLConnector = new GFSqlConnector(SQLConnector);

            //Parse the DataReader object
            this.ParseDataReader(DataReader);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Adds a Path Edge to the supplied To Location Node
        /// </summary>
        /// <param name="ToLocationNode">The Location Node at the end of the path</param>
        /// <param name="PathElectrifcation">The available electrification of the path</param>
        /// <param name="PathLength">The path length</param>
        /// <param name="PathDirection">The path direction</param>
        public void AddPathEdge(LocationNode ToLocationNode, Electrification PathElectrifcation, Length PathLength, SimSigPathDirection PathDirection)
        {
            //Validate arguments
            ArgumentValidation.ValidateLocationNode(ToLocationNode, Globals.UserSettings.GetCultureInfo());

            if (this.ID == 0)
            {
                ExceptionHelper.GetStaticException("AddPathEdgeFromLocationNodeError", null, Globals.UserSettings.GetCultureInfo());
            }

            if (ToLocationNode.ID == 0)
            {
                ExceptionHelper.GetStaticException("AddPathEdgeToLocationNodeError", null, Globals.UserSettings.GetCultureInfo());
            }

            PathEdge NewPathEdge = new PathEdge(this, ToLocationNode, PathElectrifcation, PathLength, PathDirection, this._SQLConnector);

            NewPathEdge.SaveToSQLDB();
            this._PathEdges.Add(NewPathEdge);
        }