Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome user!");
            Console.WriteLine("Whats your name? ");
            Username = Console.ReadLine();
            //username = "******";

            VrController = new VRController();
            IBike bike;

            if (UseRealBike)
            {
                InitBLEConnection();
                bike           = new RealBike(BleBike, BleHeart);
                LastResistance = 0;
                LastSpeed      = -1;
                LastHeartRate  = -1;
            }
            else
            {
                Data           = new BikeData(5, 120, 30, 5);
                LastSpeed      = 5;
                LastHeartRate  = 120;
                LastResistance = 30;
                bike           = new SimBike(Data);
            }
            bike.OnSpeed     += Bike_OnSpeed;
            bike.OnHeartRate += Bike_OnHeartrate;
            bike.OnSend      += Bike_OnSend;

            Client = new TcpClient();
            Client.BeginConnect("localhost", 15243, new AsyncCallback(OnConnect), null);

            while (true)
            {
                if (RunningTraining)
                {
                    if (!UseRealBike)
                    {
                        if (Console.ReadLine() == "")
                        {
                            Console.WriteLine("Input Command(Speed/HeartRate): ");
                            string command = Console.ReadLine();
                            switch (command)
                            {
                            case "Speed":
                                Console.WriteLine("Input Speed: ");
                                float speed = float.Parse(Console.ReadLine());
                                Console.WriteLine(speed.ToString());
                                Data.Speed = speed;
                                break;

                            case "HeartRate":
                                Console.WriteLine("Input HeartRAte: ");
                                int heartRate = int.Parse(Console.ReadLine());
                                Data.HeartRate = heartRate;
                                break;

                            default:
                                Console.WriteLine($"{command} is not a valid input!");
                                break;
                            }
                        }
                    }
                }
            }
        }
 public SimBike(BikeData data)
 {
     this.Data = data;
     System.Threading.Thread thread = new System.Threading.Thread(new ThreadStart(WorkThreadFunction));
     thread.Start();
 }
Пример #3
0
        static void Main(string[] args)
        {
            TcpClient client = new TcpClient();

            client.Connect("localhost", 80);

            BikeData bikedata = new BikeData();

            stream = client.GetStream();

            stream.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(OnRead), null);

            // Console.WriteLine("login\r\nJoëlle\r\nJoëlle\r\n\r\n");

            //Console.WriteLine("Do you want to make account then type account do you wanna login then type login");

            //string choice = Console.ReadLine();

            /*if (choice.Equals("account")) {
             *
             *  Console.WriteLine("choose a name");
             *  string name = Console.ReadLine();
             *  Console.WriteLine("choose a password");
             *  string wachtwoord = Console.ReadLine();
             *
             *  Write("Account\r\n" + name + "\r\n" + wachtwoord);
             * }else if (choice.Equals("login"))
             * {
             *  Console.WriteLine("your name");
             *  string name = Console.ReadLine();
             *  Console.WriteLine("your password");
             *  string wachtwoord = Console.ReadLine();
             *
             *  Write("login\r\n" + name + "\r\n" + wachtwoord);
             * }
             * else
             * {
             *  Console.WriteLine("wrong answer");
             *  //Application.Restart();
             *  //Application.Exit();
             *
             *
             * }*/
            Console.WriteLine("your name");
            string name = Console.ReadLine();

            Console.WriteLine("your password");
            string wachtwoord = Console.ReadLine();

            //  Console.WriteLine("Select your bike: ");

            // bikedata.getBikes();


            // Console.ReadKey();

            Write("login\r\n" + name + "\r\n" + wachtwoord + "\r\n\r\n");



            //Write("login\r\nJoëlle\r\nJoëlle\r\n\r\n");
            writeVr("12");

            while (true)
            {
                string line = Console.ReadLine();
                Write($"broadcast\r\n{line}\r\n\r\n");
            }
        }