Пример #1
0
        public void ShowSimulator()
        {
            if (Simulator != null)
            {
                Simulator.BringToFront();
                return;
            }

            Simulator             = new SimForm(this);
            Simulator.FormClosed += new FormClosedEventHandler(Window_FormClosed);
            Simulator.Show();
        }
Пример #2
0
        public Simulator(ServerConnection sc, SimForm simForm) : base(sc)
        {
            // Set the base values for the speed and the heart rate
            selectedSpeed       = 0;
            SpeedSway           = true;
            SpeedSwayAmount     = 2;
            selectedHeartRate   = 80;
            HeartRateSway       = true;
            HeartRateSwayAmount = 5;
            resistance          = 0;
            random  = new Random();
            SimForm = simForm;

            // Create a new thread that updates our values
            UpdateThread = new Thread(UpdateValues);
        }
Пример #3
0
        static void Main()
        {
            MotorSignalSettings settings = (MotorSignalSettings)Util.ModuleConfig.GetSettings(new MotorSignalSettings().GetType(), "MotorSignal.config");

            IMonitor     monitor    = new MotorMonitor(settings);
            ITranslater  translator = new MotorSignalTranslator(monitor);
            StateManager sm         = new MotorStateManager(translator, settings);

            SimForm simForm = new SimForm();

            monitor.HotKeyHandle = simForm.Handle;
            monitor.RegMonitor(simForm);
            monitor.Start();
            Application.Run(simForm);
            //Use StateManager to set the entry state temporarily in dev
            sm.CurrentState = sm.EntryState;
        }
Пример #4
0
        void Window_FormClosed(object sender, FormClosedEventArgs e)
        {
            foreach (LoginForm form in Logins)
            {
                if (sender == form)
                {
                    Logins.Remove(form);
                    break;
                }
            }

            if (sender == Simulator)
            {
                Simulator = null;
            }

            CheckExit();
        }
        public static void Initialize()
        {
            var             serverCon = new ServerConnection();
            SimForm         simForm   = null;
            ConnectorOption connector = null;

            mainWindow = new MainWindow();

            if (!serverCon.IsLoggedIn())
            {
                mainWindow.ShowDialog();

                switch (mainWindow.LoginKind)
                {
                case LoginEnum.Login:
                    if (mainWindow.BluetoothEnabled())
                    {
                        serverCon.LoginToServer(mainWindow.Username, mainWindow.Password);
                        mainWindow.Hide();
                        connector = new Bluetooth("Avans Bike AC74", "Avans Bike AC74", serverCon);
                    }
                    else if (mainWindow.SimulatorEnabled())
                    {
                        serverCon.LoginToServer(mainWindow.Username, mainWindow.Password);
                        //SimulatorGui setup
                        mainWindow.Hide();
                        Application.SetHighDpiMode(HighDpiMode.SystemAware);
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        simForm   = new SimForm();
                        connector = new Simulator(serverCon, simForm);
                    }
                    break;

                case LoginEnum.Register:
                    if (mainWindow.BluetoothEnabled())
                    {
                        serverCon.RegisterToServer(mainWindow.Username, mainWindow.Password);
                        mainWindow.Hide();
                        connector = new Bluetooth("Avans Bike AC74", "Avans Bike AC74", serverCon);
                    }
                    else if (mainWindow.SimulatorEnabled())
                    {
                        serverCon.RegisterToServer(mainWindow.Username, mainWindow.Password);
                        //SimulatorGui setup
                        mainWindow.Hide();
                        Application.SetHighDpiMode(HighDpiMode.SystemAware);
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        simForm   = new SimForm();
                        connector = new Simulator(serverCon, simForm);
                    }
                    break;
                }
            }

            serverCon.SetConnectorOption(connector);

            if (connector is Simulator simulator)
            {
                //Start the update thread
                simulator.UpdateThread.Start();

                //Start the simulatorGui
                Application.Run(simForm);
            }
            else
            {
                Thread.Sleep(4000);
                Console.Read();
            }
        }