예제 #1
0
        static void Main(string[] args)
        {
            //Generate new route with each run if route doesn't exist so debugging is consistent between users
            string RouteName = "TestRoute1"; //This is what we decide to call a specific route. It is a folder containing track.txt and route.txt

            if (!Directory.Exists(Environment.CurrentDirectory + "/" + RouteName))
            {
                List <Location> destinationsToGenerateRoute = new List <Location>()
                {
                    new Location("2021/03/08 15:30", "Göteborg"),
                    new Location("2021/03/08 15:52", "Alingsås"),
                    new Location("2021/03/08 16:23", "Vårgårda"),
                    new Location("2021/03/08 17:42", "Herrljunga"),
                    new Location("2021/03/08 18:50", "Falköping"),
                    new Location("2021/03/08 19:30", "Stockholm")
                };
                GenerateRoute(RouteName, destinationsToGenerateRoute);
            }
            var      destinations = TrainSchedule.ParseRoute(RouteName); //Here we put the RouteName
            ITrackIO trackIO      = new TrackIO(RouteName);              //Here we put the RouteName

            Train[] trains = Train.Parse("trains.txt");
            trackIO.Parse();

            ITrainSimulation simulation = new TrainSimulation(175, trackIO).AddDestinations(destinations).AddTrain(trains[0]);

            simulation.Start();

            //trains[0] because we only have one train at the moment. But trains.txt can and will contain multiple ones.
        }
예제 #2
0
        public CustomClock(TrainSimulation s)
        {
            Console.WriteLine("Starting System Clock");
            interval = 1000; //starting in real time, 1000ms
            String input = "Please enter train station opening time";

            startTime    = ShowInputDialog(ref input);
            numIntervals = (startTime - 1) * 3570; //8 AM because 0000 is 1AM :)
            homepage     = s;
            t            = new System.Timers.Timer(interval);
            t.Elapsed   += HandleIntervalElapsed;
            t.Start();
        }
예제 #3
0
        public MainWindow()
        {
            _shunterLocoSimulation = new ShunterLocoSimulation();
            _trainSimulation       = new TrainSimulation(_shunterLocoSimulation);
            InitializeComponent();

            var soundMixer = new MixingWaveProvider32();

            InitializeSounds(soundMixer);

            _waveOut.Init(soundMixer);
            _waveOut.Volume = 1.0f;

            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromSeconds(TimerInterval);
            timer.Tick    += timer_Tick;
            timer.Start();
            _waveOut.Play();
        }