Ejemplo n.º 1
0
        public void TrackBlockConstructorTest()
        {
            TrackOrientation orientation  = TrackOrientation.EastWest;
            string           name         = "TestBlock";
            double           length       = 3.5;
            double           endElevation = 1.5;
            double           grade        = 1;
            int   staticSpeed             = 75;
            bool  tunnel           = false;
            bool  railroadCrossing = false;
            Point startPoint       = new Point(0, 0);

            TrackBlock target = new TrackBlock(name, orientation, startPoint, length, endElevation, grade, false, true, staticSpeed, TrackAllowedDirection.Both, false, "controller", "controller2", "prevBlock", "nextBlock");

            target.Transponder = new Transponder("Station1", 2);
            Assert.AreEqual(orientation, target.Orientation);
            Assert.AreEqual(length, target.LengthMeters);
            Assert.IsFalse(target.HasTunnel);
            Assert.IsNotNull(target.Transponder);
            Assert.AreEqual("Station1", target.Transponder.StationName);
            Assert.AreEqual(name, target.Name);
            Assert.AreEqual(2, target.Transponder.DistanceToStation);
            Assert.AreEqual(startPoint.X, target.StartPoint.X);
            Assert.AreEqual(startPoint.Y, startPoint.Y);
            Assert.AreEqual(grade, target.Grade);
            Assert.AreEqual(endElevation, target.EndElevationMeters);
        }
Ejemplo n.º 2
0
 // METHOD: TrackBlock
 //--------------------------------------------------------------------------------------
 /// <summary>
 /// Primary constructor with initial state
 /// </summary>
 ///
 /// <param name="name">Track block name</param>
 /// <param name="orientation">Track block orientation</param>
 /// <param name="length">Track block length</param>
 /// <param name="grade">Grade of the block expressed as a percent</param>
 /// <param name="tunnel">Flag indicating the presence of a tunnel</param>
 /// <param name="railroadCrossing">Flag indicating the presence of a railroad crossing</param>
 /// <param name="signal">Track signal state</param>
 /// <param name="train">Flag indicating the presence of a train</param>
 /// <param name="authority">Authority of the block</param>
 /// <param name="startPoint">Starting coordinates</param>
 /// <param name="endElevation">Elevation at the end point</param>
 /// <param name="direction">Direction of the block</param>
 /// <param name="switchID">Switch ID</param>
 /// <param name="controllerID">Primary Controller ID</param>
 /// <param name="secondaryControllerID">Secondary Controller ID</param>
 //--------------------------------------------------------------------------------------
 public TrackBlock(string name, TrackOrientation orientation, Point startPoint, double length, double endElevation,
                   double grade, bool tunnel, bool railroadCrossing, int staticSpeedLimit,
                   TrackAllowedDirection direction, bool hasSwitch, string controllerID,
                   string secondaryControllerID, string prevBlockID, string nextBlockID)
 {
     Name         = name;
     Orientation  = orientation;
     LengthMeters = length;
     // Use arctangent to express the grade as an angle of inclination to the horizontal
     Grade            = grade;
     HasTunnel        = tunnel;
     RailroadCrossing = railroadCrossing;
     m_status.IsOpen  = true;
     StartPoint       = startPoint;
     CalculateEndPoint();
     EndElevationMeters    = endElevation;
     AllowedDirection      = direction;
     HasSwitch             = hasSwitch;
     ControllerId          = controllerID;
     SecondaryControllerId = secondaryControllerID;
     // Set default static max speed to physical limit
     StaticSpeedLimit = staticSpeedLimit;
     if (LengthMeters > 0)
     {
         StartElevationMeters = EndElevationMeters - ((LengthMeters * grade) / 100);
     }
     PreviousBlockId = prevBlockID;
     NextBlockId     = nextBlockID;
 }
Ejemplo n.º 3
0
        public void OrientationTest()
        {
            TrackBlock       target   = new TrackBlock();             // TODO: Initialize to an appropriate value
            TrackOrientation expected = TrackOrientation.NorthSouth;; // TODO: Initialize to an appropriate value

            target.Orientation = expected;
            TrackOrientation actual;

            target.Orientation = expected;
            actual             = target.Orientation;
            Assert.AreEqual(expected, actual);
            expected           = TrackOrientation.NorthWestSouthEast;; // TODO: Initialize to an appropriate value
            target.Orientation = expected;
            Assert.AreEqual(expected, target.Orientation);
        }