Exemplo n.º 1
0
        private void updateTimer_Tick(object sender, EventArgs e)
        {
            if (MainClient.Doctor.Connected)
            {
                MainClient.ComPort.Write("ST");
                string response = MainClient.ComPort.Read();
                if (response != "err")
                {
                    Meting m = MainClient.SaveMeting(response);

                    heartBeat.updateValue(m.HeartBeat);
                    RPM.updateValue(m.RPM);
                    speed.updateValue(m.Speed);
                    distance.updateValue(m.Distance);
                    power.updateValue(m.Power);
                    energy.updateValue(m.Energy);
                    actualpower.updateValue(m.ActualPower);
                    time.updateValue(m.Seconds);

                    if (count >= 10)
                    {
                        count = 0;
                        panelGraphView.updateAllCharts(MainClient.Metingen);
                    }

                    count++;
                }
                else
                {
                    logout("De Ergometer is niet meer verbonden.", Color.Red);
                }
            }
        }
Exemplo n.º 2
0
 public OldData(ClientApplicatie clientapp)
 {
     InitializeComponent();
     MainClient.SendNetCommand(new NetCommand(NetCommand.RequestType.ALLSESSIONS, MainClient.Session));
     this.clientapp = clientapp;
     timer1.Start();
 }
Exemplo n.º 3
0
        private void updateTimer_Tick(object sender, EventArgs e)
        {
            if (MainClient.Doctor.Connected)
            {
                MainClient.ComPort.Write("ST");
                string response = MainClient.ComPort.Read();
                if (response != "err")
                {
                    Meting m = MainClient.SaveMeting(response);

                    heartBeat.updateValue(m.HeartBeat);
                    RPM.updateValue(m.RPM);
                    power.updateValue(m.Power);
                    actualpower.updateValue(m.ActualPower);
                    time.updateValue(m.Seconds);

                    if (ergotest != null)
                    {
                        ergotest.timerTick();
                    }
                }
                else
                {
                    logout("De Ergometer is niet meer verbonden.", Color.Red);
                }
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     if (richTextBox1.TextLength > 1)
     {
         AddChatItem(new ChatMessage("Anon", richTextBox1.Text, false));
         MainClient.SendNetCommand(new NetCommand(richTextBox1.Text, false, MainClient.Session));
         richTextBox1.ResetText();
     }
 }
Exemplo n.º 5
0
 public void logout(string message, System.Drawing.Color cl)
 {
     panelLogin.BringToFront();
     panelTopBar.Visible                  = false;
     panelLogin.lblVerification.Text      = message;
     panelLogin.lblVerification.ForeColor = cl;
     panelLogin.lblVerification.Visible   = true;
     panelLogin.textBoxUsername.Text      = "";
     panelLogin.textBoxPassword.Text      = "";
     MainClient.Disconnect();
     updateTimer.Stop();
 }
Exemplo n.º 6
0
        public void validateLogin(string username, string password)
        {
            if (username.Length > 0)
            {
                if (password.Length == 0)
                {
                    panelLogin.lblVerification.Text      = "Vul een wachtwoord in.";
                    panelLogin.lblVerification.ForeColor = Color.Red;
                    panelLogin.lblVerification.Visible   = true;
                }
                if (password.Length > 0)
                {
                    if (SerialPort.GetPortNames().Length > 0)
                    {
                        string error   = "";
                        bool   connect = false;
                        foreach (string comport in SerialPort.GetPortNames())
                        {
                            connect = MainClient.Connect(comport, username, password, out error);
                            if (connect)
                            {
                                break;
                            }
                        }

                        if (connect)
                        {
                            panelGatherInfo.BringToFront();
                            panelTopBar.Visible     = true;
                            this.labelUsername.Text = panelLogin.textBoxUsername.Text;
                        }
                        else
                        {
                            panelLogin.lblVerification.Text      = error;
                            panelLogin.lblVerification.ForeColor = Color.Red;
                            panelLogin.lblVerification.Visible   = true;
                        }
                    }
                    else
                    {
                        panelLogin.lblVerification.Text      = "De Ergometer is niet verbonden.";
                        panelLogin.lblVerification.ForeColor = Color.Red;
                        panelLogin.lblVerification.Visible   = true;
                    }
                }
            }
            else
            {
                panelLogin.lblVerification.Text      = "Vul een gebruikersnaam in.";
                panelLogin.lblVerification.ForeColor = Color.Red;
                panelLogin.lblVerification.Visible   = true;
            }
        }
Exemplo n.º 7
0
 public void CreateNewTest(char geslacht, int leeftijd, int gewicht, int lengte)
 {
     panelTopBar.Visible = true;
     panelClientContainer.BringToFront();
     chat = panelClientChat;
     MainClient.SendNetCommand(new NetCommand(gewicht, lengte, leeftijd, geslacht, MainClient.Session));
     MainClient.ComPort.Write("RS");
     MainClient.ComPort.Read();
     Thread.Sleep(200);
     MainClient.ComPort.Write("CM");
     MainClient.ComPort.Read();
     ergotest = new ErgometerTest(gewicht, lengte, leeftijd, geslacht, this);
     updateTimer.Start();
     beeptimer.Start();
 }
Exemplo n.º 8
0
        public ErgometerTest(int weight, int length, int age, char gender, ClientApplicatie client)
        {
            this.weight  = weight;
            this.length  = length;
            this.age     = age;
            this.gender  = gender;
            currentstate = state.WARMUP;

            MainClient.SwitchTestModeAudio();

            deviation = 0;
            failed    = false;

            this.client = client;
            client.updateStepsText("U begint nu aan een warmup, probeer een tempo van 50 rpm aan te houden. De test gaat automatisch verder.");
            workloads = new List <Workload>();
            MainClient.ComPort.Write("PW 25");
            MainClient.ComPort.Read();
            currentPower = 25;
            MainClient.Client.heartBeat.max = (int)CalculateMaximumHeartRate();
        }
Exemplo n.º 9
0
        public void validateLogin(string username, string password)
        {
            if (username.Length > 0)
            {
                if (password.Length == 0)
                {
                    panelLogin.lblVerification.Text      = "Vul een wachtwoord in.";
                    panelLogin.lblVerification.ForeColor = Color.Red;
                    panelLogin.lblVerification.Visible   = true;
                }
                if (password.Length > 0)
                {
                    string error   = "";
                    bool   connect = MainClient.Connect("COM5", username, password, out error);

                    if (connect)
                    {
                        panelClientContainer.BringToFront();
                        chat = panelClientChat;
                        this.labelUsername.Text = panelLogin.textBoxUsername.Text;
                        panelTopBar.Visible     = true;
                        updateTimer.Start();
                    }
                    else
                    {
                        panelLogin.lblVerification.Text      = error;
                        panelLogin.lblVerification.ForeColor = Color.Red;
                        panelLogin.lblVerification.Visible   = true;
                    }
                }
            }
            else
            {
                panelLogin.lblVerification.Text      = "Vul een gebruikersnaam in.";
                panelLogin.lblVerification.ForeColor = Color.Red;
                panelLogin.lblVerification.Visible   = true;
            }
        }
Exemplo n.º 10
0
 public ClientApplicatie()
 {
     InitializeComponent();
     MainClient.Init(this);
     count = 0;
 }
Exemplo n.º 11
0
        public void timerTick()
        {
            if (MainClient.GetLastMeting().Seconds > 5 && currentPower != MainClient.GetLastMeting().Power)
            {
                MainClient.ComPort.Write("PW " + currentPower);
                MainClient.ComPort.Read();
                MainClient.QuickBeepAudio();
            }

            if (MainClient.GetLastMeting().RPM < 45 || MainClient.GetLastMeting().RPM > 55)
            {
                deviation++;
            }
            else
            {
                deviation = Math.Max(deviation - 1, 0);
            }

            if (deviation >= 60 && !failed)
            {
                workloadStarted = MainClient.GetLastMeting().Seconds;
                currentstate    = state.COOLINGDOWN;
                MainClient.SwitchTestModeAudio();
                client.updateStepsText("U wijkt te vaak af van 50rpm, de test wordt gestopt. U begint nu aan de cooldown.");
                failed = true;
                MainClient.ComPort.Write("PW 25");
                MainClient.ComPort.Read();
                currentPower = 25;
            }

            switch (currentstate)
            {
            case state.WARMUP:
                if (MainClient.GetLastMeting().Seconds > 30)
                {
                    List <ErgometerLibrary.Meting> last20 = MainClient.Metingen.GetRange(MainClient.Metingen.Count - 20, 20);
                    int max = FindMaxValue(last20, x => x.HeartBeat);
                    int min = FindMinValue(last20, x => x.HeartBeat);
                    if (max + min < 20)
                    {
                        client.updateStepsText("We detecteren geen hartslag. Controleer of de hartslagmeter is verbonden. De test gaat automatisch verder.");
                    }
                    else if (max - min > 10)     //Hartslag niet stabiel
                    {
                        client.updateStepsText("Uw hartslag is niet stabiel, probeer een tempo van 50 rpm aan te houden. De test gaat automatisch verder.");
                        return;
                    }
                    else
                    {
                        currentstate = state.WORKLOAD;
                        MainClient.SwitchTestModeAudio();
                        workloadStarted = MainClient.GetLastMeting().Seconds;
                        client.updateStepsText("De warmup is voltooid. De test gaat nu beginnen. U begint nu aan de " + NumToText(GetCurrentWorkload()) + " workload.");
                    }
                }
                if (MainClient.GetLastMeting().Seconds > 9 && MainClient.GetLastMeting().Seconds < 11)
                {
                    if (MainClient.GetLastMeting().HeartBeat < 20)
                    {
                        client.updateStepsText("We detecteren geen hartslag. Controleer of de hartslagmeter is verbonden.");
                    }
                }
                break;

            case state.WORKLOAD:
                if (MainClient.GetLastMeting().Seconds - workloadStarted > 180)
                {
                    currentPower = GetWorkloadPower(GetCurrentWorkload());
                    workloads.Add(new Workload(MainClient.GetLastMeting().Power, workloadHearthbeat));
                    MainClient.ComPort.Write("PW " + currentPower);
                    MainClient.ComPort.Read();
                    client.updateStepsText("U heeft de workload afgerond, u begint nu aan de " + NumToText(GetCurrentWorkload()) + " workload. Uw nieuwe weerstand is " + currentPower + " Watt.");
                    MainClient.SwitchWorkloadAudio();

                    workloadStarted    = MainClient.GetLastMeting().Seconds;
                    workloadHearthbeat = 0;
                    Console.WriteLine("3:00 gefietst, workload" + (GetCurrentWorkload()) + " af, nieuwe waardes maken");

                    //Checken of de heartrate niet groter is dan 75%, anders stoppen
                    if (workloadHearthbeat > (CalculateMaximumHeartRate() * 0.80))
                    {
                        workloadStarted = MainClient.GetLastMeting().Seconds;
                        currentstate    = state.COOLINGDOWN;
                        MainClient.SwitchTestModeAudio();
                        client.updateStepsText("Uw hartslag heeft het kritieke punt bereikt, we beginnen nu aan de cooldown.");
                        MainClient.ComPort.Write("PW 25");
                        MainClient.ComPort.Read();
                        currentPower = 25;
                    }
                }
                else if (MainClient.GetLastMeting().Seconds - workloadStarted > 160 && workloadHearthbeat == 0)
                {
                    List <ErgometerLibrary.Meting> last150 = MainClient.Metingen.GetRange(MainClient.Metingen.Count - 150, 150);
                    workloadHearthbeat = FindAverageValue(last150, x => x.HeartBeat);
                    Console.WriteLine("2:40 gefiets, gemiddelde harstslag berekenen:" + workloadHearthbeat);
                    client.updateStepsText("U bent nu met de " + NumToText(GetCurrentWorkload()) + " workload bezig. Uw gemiddelde hartslag is berekend als " + workloadHearthbeat + "bpm.");
                }
                else if (MainClient.GetLastMeting().Seconds - workloadStarted > 9 && MainClient.GetLastMeting().Seconds - workloadStarted < 11)
                {
                    client.updateStepsText("U bent nu met de " + NumToText(GetCurrentWorkload()) + " workload bezig. De fiets staat nu ingesteld op " + MainClient.GetLastMeting().Power + " Watt");
                }
                break;

            case state.COOLINGDOWN:
                if (MainClient.GetLastMeting().Seconds - workloadStarted > 360)
                {
                    currentstate = state.STOP;
                    MainClient.SwitchTestModeAudio();
                    client.updateStepsText("De test is afgelopen.");
                }
                else if (MainClient.GetLastMeting().Seconds - workloadStarted > 9 && MainClient.GetLastMeting().Seconds - workloadStarted < 11)
                {
                    client.updateStepsText("U bent momenteel met de cooldown bezig.");
                }
                break;

            case state.STOP:
                MainClient.Client.updateTimer.Stop();
                MainClient.Client.beeptimer.Stop();
                MainClient.ComPort.Write("RS");
                MainClient.ComPort.Read();
                currentPower = 0;
                if (failed)
                {
                    MainClient.Client.updateStepsText("De test is mislukt omdat u te vaak heeft afgeweken van 50rpm. Onze excuses voor het ongemak.");
                }
                else if (workloads.Count > 1)
                {
                    MainClient.Client.updateStepsText(String.Format("De test is afgelopen. Uw test resultaten zijn: \n VO2MAX: {0:0.00} MET: {1:0.00} Gemiddelde: {2:0.00} \n {3} ", CalculateVOMax(), CalculateMET(), CalculatePopulationAverage(), CalculateRating()));
                    MainClient.SendNetCommand(new ErgometerLibrary.NetCommand(CalculateVOMax(), CalculateMET(), CalculatePopulationAverage(), CalculateZScore(), CalculateRating(), MainClient.Session));
                }
                else
                {
                    MainClient.Client.updateStepsText("Er zijn te weinig workload tests afgenomen om een resultaat te maken. Onze excuses voor het ongemak.");
                }
                break;
            }
        }
Exemplo n.º 12
0
        //          WORKLOAD                //

        private int GetWorkloadPower(int workload)
        {
            if (gender == 'V')
            {
                if (workload == 1)
                {
                    if (workloadHearthbeat < 80)
                    {
                        return(125);
                    }
                    else if (workloadHearthbeat < 89)
                    {
                        return(100);
                    }
                    else if (workloadHearthbeat < 100)
                    {
                        return(75);
                    }
                    else
                    {
                        return(50);
                    }
                }
                else
                {
                    return(MainClient.GetLastMeting().Power + 25);
                }
            }
            else if (gender == 'M')
            {
                if (workload == 1)
                {
                    if (workloadHearthbeat < 90)
                    {
                        return(150);
                    }
                    else if (workloadHearthbeat < 105)
                    {
                        return(125);
                    }
                    else
                    {
                        return(100);
                    }
                }
                else if (workload == 2)
                {
                    if (workloadHearthbeat < 120)
                    {
                        if (MainClient.GetLastMeting().Power == 150)
                        {
                            return(225);
                        }
                        else if (MainClient.GetLastMeting().Power == 125)
                        {
                            return(200);
                        }
                        else
                        {
                            return(175);
                        }
                    }
                    else if (workloadHearthbeat < 135)
                    {
                        if (MainClient.GetLastMeting().Power == 150)
                        {
                            return(200);
                        }
                        else if (MainClient.GetLastMeting().Power == 125)
                        {
                            return(175);
                        }
                        else
                        {
                            return(150);
                        }
                    }
                    else
                    {
                        if (MainClient.GetLastMeting().Power == 150)
                        {
                            return(175);
                        }
                        else if (MainClient.GetLastMeting().Power == 125)
                        {
                            return(150);
                        }
                        else
                        {
                            return(125);
                        }
                    }
                }
                else
                {
                    return(MainClient.GetLastMeting().Power + 25);
                }
            }

            return(25);
        }
Exemplo n.º 13
0
 public void updateStepsText(string text)
 {
     steps.setText(text);
     MainClient.SendNetCommand(new NetCommand(MainClient.Session, text));
 }