Ejemplo n.º 1
0
        public void TheDataStreamTest()
        {
            var fileWriter = new StreamWriter("SimulatedDataSourceTest.csv");

            fileWriter.WriteLine("Registered,1,8/15/2017 7:00:00 AM,FN_F_1,LN_1,F,16");
            fileWriter.WriteLine("Registered,2,8/15/2017 7:00:00 AM,FN_M_2,LN_2,M,56");
            fileWriter.WriteLine("---");
            fileWriter.WriteLine("Started,1,8/15/2017 7:02:00 AM,8/15/2017 7:02:00 AM");
            fileWriter.WriteLine("---");
            fileWriter.WriteLine("OnCourse,1,8/15/2017 7:02:30 AM,276.098203867211");
            fileWriter.WriteLine("Started,2,8/15/2017 7:02:30 AM,8/15/2017 7:02:30 AM");
            fileWriter.WriteLine("---");
            fileWriter.WriteLine("Finished,1,8/15/2017 7:03:00 AM,8/15/2017 7:03:00 AM");
            fileWriter.Close();

            var testUpdateHandler = new TestUpdateHandler();

            var ds = new SimulatedDataSource
            {
                InputFilename = "SimulatedDataSourceTest.csv",
                Handler       = testUpdateHandler
            };

            ds.Start();

            // Wait for something about 1/2 second
            Thread.Sleep(500);

            // Two messages should have come in
            Assert.AreEqual(2, testUpdateHandler.NumberRecieved);
            Assert.AreEqual(AthleteRaceStatus.Registered, testUpdateHandler[0].UpdateType);
            Assert.AreEqual(AthleteRaceStatus.Registered, testUpdateHandler[1].UpdateType);

            // Wait for something less than a second
            Thread.Sleep(1000);

            // Another message should have some in
            Assert.AreEqual(3, testUpdateHandler.NumberRecieved);
            Assert.AreEqual(AthleteRaceStatus.Started, testUpdateHandler[2].UpdateType);

            // Wait for something less than a second
            Thread.Sleep(2000);

            // Another message should have some in
            Assert.AreEqual(6, testUpdateHandler.NumberRecieved);
            Assert.AreEqual(AthleteRaceStatus.OnCourse, testUpdateHandler[3].UpdateType);
            Assert.AreEqual(AthleteRaceStatus.Started, testUpdateHandler[4].UpdateType);
            Assert.AreEqual(AthleteRaceStatus.Finished, testUpdateHandler[5].UpdateType);

            ds.Stop();
            Thread.Sleep(1000);
            Assert.AreEqual(6, testUpdateHandler.NumberRecieved);
        }
Ejemplo n.º 2
0
        public void Run(string inputFile, Race race, List <Observer> os)
        {
            IAthleteUpdateHandler handler = new DataProcessor(race, os);

            _simulatedData = new SimulatedDataSource()
            {
                InputFilename = inputFile,
                Handler       = handler
            };

            _simulatedData.Start();

            Thread.Sleep(180000);

            _simulatedData.Stop();
        }
        public void Run(string inputFileName)
        {
            IAthleteUpdateHandler handler = new DataProcessor(gui);

            _simluatedData = new SimulatedDataSource()
            {
                InputFilename = inputFileName,
                Handler       = handler
            };

            _simluatedData.Start();

            // Let the simulator run for 3 minutes
            Thread.Sleep(180000);

            _simluatedData.Stop();
        }
Ejemplo n.º 4
0
        public void Run(string inputFileName)
        {
            DataProcessor handler = new DataProcessor();

            AthleteList = new Dictionary <int, Athlete>();
            handler.ProcessorAthleteList = AthleteList;
            _simluatedData = new SimulatedDataSource()
            {
                InputFilename = inputFileName,
                Handler       = handler
            };

            _simluatedData.Start();

            // Let the simulator run for 3 minutes
            Thread.Sleep(1800000000);

            _simluatedData.Stop();
        }
        /// <summary>
        /// Start the simulation with the provided course from Setup()
        /// </summary>
        public void Run()
        {
            control        = new ControlForm(raceCourses[choice - 1].TotalDistance);
            _simulatedData = new SimulatedDataSource()
            {
                InputFilename = trackFileName,
                Handler       = control
            };

            _simulatedData.Start();
            Application.Run(control);

            // Run simulator for RUN_TIME_IN_MINUTES
            const int RUN_TIME_IN_MINUTES = 3;

            Thread.Sleep(RUN_TIME_IN_MINUTES * 6000);

            _simulatedData.Stop();
        }
Ejemplo n.º 6
0
        public MainWindow()
        {
            InitializeComponent();
            cbxProcesToAdd.Items.Add(ProcessLocationLocal);
            cbxProcesToAdd.Items.Add(ProcessLocationRemote);

            _dataSource              = new NationalInstrumentsDataSource <double>(_subscribers);
            _dataSource.DataUpdated += ObservableSubscriberDataUpdated;
            _dataSource.Massage     += dataSource_OnMassage;
            _dataSource.SubscribeFromLocationAsync(ProcessLocationLocal);

            _data              = new NationalInstrumentsDataSource(_subscribers);
            _data.Massage     += dataSource_OnMassage;
            _data.DataUpdated += ObservableSubscriberDataUpdated;
            _data.SubscribeFromLocationAsync(ProcessLocationLocal);
            _data.SubscribeFromLocationAsync(ProcessLocationRemote);

            _simulatedDataSource              = new SimulatedDataSource <int>(_subscribers);
            _simulatedDataSource.DataUpdated += ObservableSubscriberDataUpdated;
            _simulatedDataSource.Massage     += dataSource_OnMassage;
            _simulatedDataSource.Subscribe(count: 3);

            DataContext = _subscribers;
        }