private const int _maxCapacity = 222;                      // 74 seated, 148 standing

        #endregion

        #region Constructors

        /// <summary>
        /// This constructor is used when passenger, crew, and temperature information is not given.
        /// It adds no passengers or crew and sets the temperature equal to 32 degrees Celcius.
        /// </summary>
        /// <param name="trainID">The ID to give to the train.</param>
        /// <param name="startingBlock">The starting block of the train.</param>
        /// <param name="environment">The environment being used by the entire simulation.</param>
        public Train(int trainID, IBlock startingBlock, ISimulationEnvironment environment)
        {
            _environment       = environment;
            _environment.Tick += _environment_Tick;

            _trainID          = trainID;
            _totalMass        = calculateMass();
            _informationLog   = "";
            _informationCount = 0;
            _lightsOn         = false;
            _doorsOpen        = false;
            _temperature      = 32;

            _currentAcceleration = 0;
            _currentVelocity     = 0;
            _currentPosition     = 0;

            _numPassengers = 0;
            _numCrew       = 0;

            _brakeFailure        = false;
            _engineFailure       = false;
            _signalPickupFailure = false;

            _emergencyBrakePulled = false;

            _positionWarningGiven     = false;
            _velocityWarningGiven     = false;
            _accelerationWarningGiven = false;
            _decelerationWarningGiven = false;

            _currentBlock    = startingBlock;
            _previousBlockID = 0;
            _currentBlockID  = _currentBlock.BlockID;
            _blockLength     = _currentBlock.BlockSize;
            _trackCircuitID  = _currentBlock.TrackCirID;

            _trackModel      = environment.TrackModel;
            _trainController = new TrainController.TrainController(_environment, this);

            // set allTrains equal to list contained in environment
            allTrains = environment.AllTrains;

            _timeInterval = (environment.GetInterval() / 1000.0);

            appendInformationLog("Created on block " + _currentBlockID + ".");
        }
示例#2
0
        /// <summary>
        ///  Requests Data from each Track Controller
        /// </summary>
        private void AddAutomaticUpdate()
        {
            ITrackModel tm = _env.TrackModel;

            if (tm != null)
            {
                IRouteInfo redInfo = tm.requestRouteInfo(0);
                foreach (IBlock b in redInfo.BlockList)
                {
                    trackControllerDataRequest(b.TrackCirID);
                }

                IRouteInfo greenInfo = tm.requestRouteInfo(1);
                foreach (IBlock b in greenInfo.BlockList)
                {
                    trackControllerDataRequest(b.TrackCirID);
                }
            }
        }//End AddAutomaticUpdate
示例#3
0
        /// <summary>
        /// This constructor is used when passenger, crew, and temperature information is not given.
        /// It adds no passengers or crew and sets the temperature equal to 32 degrees Celcius.
        /// </summary>
        /// <param name="trainID">The ID to give to the train.</param>
        /// <param name="startingBlock">The starting block of the train.</param>
        /// <param name="environment">The environment being used by the entire simulation.</param>
        public Train(int trainID, IBlock startingBlock, ISimulationEnvironment environment)
        {
            _environment = environment;
            _environment.Tick += _environment_Tick;

            _trainID = trainID;
            _totalMass = calculateMass();
            _informationLog = "";
            _informationCount = 0;
            _lightsOn = false;
            _doorsOpen = false;
            _temperature = 32;

            _currentAcceleration = 0;
            _currentVelocity = 0;
            _currentPosition = 0;

            _numPassengers = 0;
            _numCrew = 0;

            _brakeFailure = false;
            _engineFailure = false;
            _signalPickupFailure = false;

            _emergencyBrakePulled = false;

            _positionWarningGiven = false;
            _velocityWarningGiven = false;
            _accelerationWarningGiven = false;
            _decelerationWarningGiven = false;

            _currentBlock = startingBlock;
            _previousBlockID = 0;
            _currentBlockID = _currentBlock.BlockID;
            _blockLength = _currentBlock.BlockSize;
            _trackCircuitID = _currentBlock.TrackCirID;

            _trackModel = environment.TrackModel;
            _trainController = new TrainController.TrainController(_environment, this);

            // set allTrains equal to list contained in environment
            allTrains = environment.AllTrains;

            _timeInterval = (environment.GetInterval() / 1000.0);

            appendInformationLog("Created on block " + _currentBlockID + ".");
        }