예제 #1
0
        // METHOD: TrainOperator
        //--------------------------------------------------------------------------------------
        /// <summary>
        /// Secondary constructor, to be used by the CTC
        /// </summary>
        ///
        /// <param name="myTrain">The train associated with this GUI</param>
        /// <param name="myTrainController">The train controller associated with this GUI</param>
        //--------------------------------------------------------------------------------------
        public TrainOperator(ITrain myTrain, TrainController myTrainController)
        {
            InitializeComponent();
            m_isDemo                 = false;
            this.m_myTrain           = myTrain;
            this.m_myTrainState      = m_myTrain.GetState();
            this.m_myTrainController = myTrainController;

            engineFailure.Enabled  = false;
            brakeFailure.Enabled   = false;
            powerFailure.Enabled   = false;
            circuitFailure.Enabled = false;
        }
예제 #2
0
        // METHOD: TrainOperator
        //--------------------------------------------------------------------------------------
        /// <summary>
        /// Secondary constructor, to be used by the CTC
        /// </summary>
        /// 
        /// <param name="myTrain">The train associated with this GUI</param>
        /// <param name="myTrainController">The train controller associated with this GUI</param>
        //--------------------------------------------------------------------------------------
        public TrainOperator(ITrain myTrain, TrainController myTrainController)
        {
            InitializeComponent();
            m_isDemo = false;
            this.m_myTrain = myTrain;
            this.m_myTrainState = m_myTrain.GetState();
            this.m_myTrainController = myTrainController;

            engineFailure.Enabled = false;
            brakeFailure.Enabled = false;
            powerFailure.Enabled = false;
            circuitFailure.Enabled = false;
        }
예제 #3
0
        // METHOD: CreateTrain_Click
        //--------------------------------------------------------------------------------------
        /// <summary>
        /// Start the GUI, and create a train and train controller if in a demo
        /// </summary>
        ///
        /// <param name="sender">Sender</param>
        /// <param name="e">Event Arguments</param>
        //--------------------------------------------------------------------------------------
        private void CreateTrain_Click(object sender, EventArgs e)
        {
            if (m_isDemo)
            {
                m_startingBlock                                                   = new TrackBlock("Block1", TrackOrientation.EastWest, new Point(0, 0), 1650, 0, 0, false, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block0", "Block2");
                m_startingBlock.NextBlock                                         = new TrackBlock("Block2", TrackOrientation.EastWest, new Point(1650, 0), 50, 0, 0, true, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block1", "Block3");
                m_startingBlock.Authority                                         = new BlockAuthority(70, 3);
                m_startingBlock.NextBlock.Authority                               = new BlockAuthority(70, 2);
                m_startingBlock.NextBlock.NextBlock                               = new TrackBlock("Block3", TrackOrientation.EastWest, new Point(1700, 0), 1000, 0, 0, true, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block2", "Block4");
                m_startingBlock.NextBlock.NextBlock.NextBlock                     = new TrackBlock("Block4", TrackOrientation.EastWest, new Point(2700, 0), 100, 0, 0, false, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block3", "Block5");
                m_startingBlock.NextBlock.NextBlock.NextBlock.NextBlock           = new TrackBlock("Block5", TrackOrientation.EastWest, new Point(2800, 0), 100, 0, 0, false, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block4", "Block6");
                m_startingBlock.NextBlock.NextBlock.NextBlock.NextBlock.NextBlock = new TrackBlock("Block6", TrackOrientation.EastWest, new Point(2800, 0), 100, 0, 0, false, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block5", "Block7");
                m_startingBlock.NextBlock.NextBlock.Authority                     = new BlockAuthority(70, 1);

                m_startingBlock.NextBlock.NextBlock.NextBlock.Authority                     = new BlockAuthority(40, 0);
                m_startingBlock.NextBlock.NextBlock.NextBlock.NextBlock.Authority           = new BlockAuthority(40, 0);
                m_startingBlock.NextBlock.NextBlock.NextBlock.NextBlock.NextBlock.Authority = new BlockAuthority(40, 0);

                m_startingBlock.Transponder           = new Transponder("SHADYSIDE", 1);
                m_startingBlock.NextBlock.Transponder = new Transponder("SHADYSIDE", 0);

                m_myTrain                    = new TrainLib.Train("train1", m_startingBlock, Direction.East);
                m_myTrainState               = m_myTrain.GetState();
                m_myTrainController          = new TrainController(m_myTrain);
                m_myTrainController.Schedule = GetRedlineSchedule();

                Timer updateTimer = new Timer();
                updateTimer.Tick    += new EventHandler(Update);
                updateTimer.Interval = 40;
                updateTimer.Enabled  = true;
                updateTimer.Start();
            }

            m_myTimer          = new Timer();
            m_myTimer.Tick    += new EventHandler(UpdateDisplay);
            m_myTimer.Interval = 500;
            m_myTimer.Enabled  = true;
            m_myTimer.Start();
        }
예제 #4
0
        // METHOD: CreateTrain_Click
        //--------------------------------------------------------------------------------------
        /// <summary>
        /// Start the GUI, and create a train and train controller if in a demo
        /// </summary>
        /// 
        /// <param name="sender">Sender</param>
        /// <param name="e">Event Arguments</param>
        //--------------------------------------------------------------------------------------
        private void CreateTrain_Click(object sender, EventArgs e)
        {
            if (m_isDemo)
            {
                m_startingBlock = new TrackBlock("Block1", TrackOrientation.EastWest, new Point(0, 0), 1650, 0, 0, false, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block0", "Block2");
                m_startingBlock.NextBlock = new TrackBlock("Block2", TrackOrientation.EastWest, new Point(1650, 0), 50, 0, 0, true, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block1", "Block3");
                m_startingBlock.Authority = new BlockAuthority(70, 3);
                m_startingBlock.NextBlock.Authority = new BlockAuthority(70, 2);
                m_startingBlock.NextBlock.NextBlock = new TrackBlock("Block3", TrackOrientation.EastWest, new Point(1700, 0), 1000, 0, 0, true, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block2", "Block4");
                m_startingBlock.NextBlock.NextBlock.NextBlock = new TrackBlock("Block4", TrackOrientation.EastWest, new Point(2700, 0), 100, 0, 0, false, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block3", "Block5");
                m_startingBlock.NextBlock.NextBlock.NextBlock.NextBlock = new TrackBlock("Block5", TrackOrientation.EastWest, new Point(2800, 0), 100, 0, 0, false, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block4", "Block6");
                m_startingBlock.NextBlock.NextBlock.NextBlock.NextBlock.NextBlock = new TrackBlock("Block6", TrackOrientation.EastWest, new Point(2800, 0), 100, 0, 0, false, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block5", "Block7");
                m_startingBlock.NextBlock.NextBlock.Authority = new BlockAuthority(70, 1);

                m_startingBlock.NextBlock.NextBlock.NextBlock.Authority = new BlockAuthority(40, 0);
                m_startingBlock.NextBlock.NextBlock.NextBlock.NextBlock.Authority = new BlockAuthority(40, 0);
                m_startingBlock.NextBlock.NextBlock.NextBlock.NextBlock.NextBlock.Authority = new BlockAuthority(40, 0);

                m_startingBlock.Transponder = new Transponder("SHADYSIDE", 1);
                m_startingBlock.NextBlock.Transponder = new Transponder("SHADYSIDE", 0);

                m_myTrain = new TrainLib.Train("train1", m_startingBlock, Direction.East);
                m_myTrainState = m_myTrain.GetState();
                m_myTrainController = new TrainController(m_myTrain);
                m_myTrainController.Schedule = GetRedlineSchedule();

                Timer updateTimer = new Timer();
                updateTimer.Tick += new EventHandler(Update);
                updateTimer.Interval = 40;
                updateTimer.Enabled = true;
                updateTimer.Start();
            }

            m_myTimer = new Timer();
            m_myTimer.Tick += new EventHandler(UpdateDisplay);
            m_myTimer.Interval = 500;
            m_myTimer.Enabled = true;
            m_myTimer.Start();
        }
예제 #5
0
        /// <summary>
        /// Creates a new train on the track
        /// 
        /// </summary>
        /// <param name="initialBlock">Starting block of the train</param>
        /// <param name="name">Name of the train</param>
        public void SpawnNewTrain(TrackBlock initialBlock, string name)
        {
            if (initialBlock != null)
            {
                if (initialBlock.HasTransponder)
                {
                    string start = initialBlock.Transponder.StationName;
                    if (start.Contains(Constants.TRAINYARD)) //Can only spawn trains from stations
                    {
                        if (m_startingDirections.ContainsKey(start))
                        {
                            m_log.LogInfoFormat("Spawning new train \"{0}\" at start {1}", name, start);
                            //Create the new train and train controller
                            ITrain train = new TrainLib.Train(name, initialBlock, m_startingDirections[start]);
                            train.TrainEnteredNewBlock += OnTrainEnteredNewBlock;
                            TrainController trainController = new TrainController(train);
                            m_trainControllerList.Add(trainController);
                            m_trainControllerTable[train] = trainController;
                            CTCController.GetCTCController().AddTrainToList(train);

                            //Set the train schedule
                            if (start == Constants.REDYARD)
                            {
                                m_log.LogInfoFormat("Setting schedule of {0} to red line", name);
                                trainController.Schedule = CTCController.GetCTCController().GetRedlineSchedule();
                            }
                            else if (start == Constants.GREENYARDOUT)
                            {
                                m_log.LogInfoFormat("Setting schedule of {0} to green line", name);
                                trainController.Schedule = CTCController.GetCTCController().GetGreenlineSchedule();
                            }
                        }
                    }
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Creates a new train on the track
        /// 
        /// </summary>
        /// <param name="initialBlock">Starting block of the train</param>
        /// <param name="name">Name of the train</param>
        public void SpawnNewTrain(TrackBlock initialBlock, string name)
        {
            if (initialBlock != null)
            {
                if (initialBlock.HasTransponder)
                {
                    string start = initialBlock.Transponder.StationName;
                    if (m_startingDirections.ContainsKey(start))
                    {
                        m_log.LogInfoFormat("Spawning new train \"{0}\" at start {1}", name, start);
                        //Create the new train and train controller
                        ITrain train = new Train.Train(name, initialBlock, m_startingDirections[start]);
                        ITrainController trainController = new TrainController(train);
                        m_trainList.Add(trainController);

                        //Set the train schedule
                        if (start == Constants.REDYARD)
                        {
                            m_log.LogInfoFormat("Setting schedule of {0} to red line", name);
                            trainController.SetSchedule(CTCController.GetCTCController().GetRedlineSchedule());
                        }
                        else if (start == Constants.GREENYARDOUT)
                        {
                            m_log.LogInfoFormat("Setting schedule of {0} to green line", name);
                            trainController.SetSchedule(CTCController.GetCTCController().GetGreenlineSchedule());
                        }
                    }
                }
            }
        }