Ejemplo n.º 1
0
        private void ResfreshThreadPhysician()
        {
            while (true)
            {
                if (currentUser != null)
                {
                    Measurement measurement = null;
                    try
                    {
                        measurement = ((UserClient)currentUser).lastSession().GetLastMeasurement();
                    }
                    catch (NullReferenceException e)
                    {
                    }
                    if (measurement != null)
                    {
                        SetLabelText(actualPowerLabel, measurement.actual_power.ToString() + " Watt");
                        SetLabelText(timeLabel, measurement.time);
                        SetLabelText(heartBeatLabel, measurement.pulse.ToString() + " bpm");
                        SetLabelText(rpmLabel, measurement.rpm.ToString());
                        SetLabelText(speedLabel, measurement.speed.ToString() + " km/h");
                        SetLabelText(distanceLabel, measurement.distance.ToString() + " km");
                        SetLabelText(energyLabel, measurement.energy.ToString() + " kJ");
                        SetLabelText(requestedPowerLabel, measurement.requested_power.ToString() + " Watt");
                    }
                    else
                    {
                        //System.Diagnostics.Debug.WriteLine("no measurement");
                    }
                    //network.GetAllConnectedUsers(username);
                    users = network.users;
                    if (currentUser != null)
                    {
                        System.Diagnostics.Debug.WriteLine(currentUser.username);
                        User user = network.getUser(currentUser.username);

                        currentUser = user;
                    }
                    //FillUserComboBox();
                    //System.Diagnostics.Debug.WriteLine("current user: " + currentUser);
                }
                Thread.Sleep(1000);
            }
        }
Ejemplo n.º 2
0
 public OldSesionData(Networkconnect network, string username)
 {
     this.network = network;
     InitializeComponent();
     user = network.getUser(username);
     if (user is Physician)
     {
         Physician p = (Physician)user;
         listBox_Data.DataSource = p.clients;
         users       = p.clients;
         isPhysician = true;
     }
     else
     {
         UserClient a = (UserClient)user;
         listBox_Data.DataSource = a.sessions;
         isPhysician             = false;
     }
 }
Ejemplo n.º 3
0
 public FormClient(Networkconnect network, bool isPhysician, string username)
 {
     InitializeComponent();
     network.SetParent(this);
     this.isPhysician = isPhysician;
     this.network     = network;
     this.username    = username;
     if (!isPhysician) //Client:
     {
         currentUser = network.getUser(username);
         pwrTxtBox.Hide();
         distanceTxtBox.Hide();
         timeTxtBox.Hide();
         label5.Hide();
         label6.Hide();
         label7.Hide();
         sendButton.Hide();
         broadCastButton.Hide();
         connectedUsers.Hide();
         newClient.Hide();
         dropDownTest.HideDropDown();
         bikeImprovementToolStripMenuItem.HideDropDown();
     }
     else //Specialist:
     {
         BComConnect.Hide();
         resetButton.Hide();
         //Getting all connected users:
         users = network.GetAllConnectedUsers(username);
         if (users != null)
         {
             if (users.Count > 0)
             {
                 currentUser = users.First();
             }
             FillUserComboBox();
         }
         Thread physicianThread = new Thread(new ThreadStart(ResfreshThreadPhysician));
         physicianThread.IsBackground = true;
         physicianThread.Start();
     }
 }
Ejemplo n.º 4
0
        public FormClient(Networkconnect network, bool isPhysician, string username)
        {
            InitializeComponent();

            timer1.Interval = 1000;
            timer1.Elapsed += new ElapsedEventHandler(timer1_Tick);

            network.SetParent(this);
            this.isPhysician = isPhysician;
            this.network = network;
            this.username = username;
            if(!isPhysician) //Client:
            {
                currentUser = network.getUser(username);
                pwrTxtBox.Hide();
                distanceTxtBox.Hide();
                timeTxtBox.Hide();
                label5.Hide();
                label6.Hide();
                label7.Hide();
                sendButton.Hide();
                broadCastButton.Hide();
                connectedUsers.Hide();
                newClient.Hide();
            }
            else //Specialist:
            {
                BComConnect.Hide();
                resetButton.Hide();
                //Getting all connected users:
                users = network.GetAllConnectedUsers(username);
                if (users != null)
                {
                    if (users.Count > 0)
                            currentUser = users.First();
                    FillUserComboBox();
                }
                Thread physicianThread = new Thread(new ThreadStart(ResfreshThreadPhysician));
                physicianThread.IsBackground = true;
                physicianThread.Start();
            }
        }