Example #1
0
 public void ReceiveMeasurement(Measurement measurement, string physcianName, trainingen sessionType)
 {
     UserClient userClient = (UserClient)user;
     Console.WriteLine("measurement shizzle");
     if(sessionType == trainingen.newAstrand || sessionType == trainingen.none)
         userClient.addSession(DateTime.Now, sessionType);
     else
     {
         userClient.addMeasurement(measurement);
         //ServerClient physician = server.getPhysicianClient(physcianName);
         //if (physician != null)
         //{
         //    Console.WriteLine("sending new user " + user.isOnline);
         //    NetworkFlow.SendPacket(new PacketGiveUserResponse(user), server.getPhysicianClient(((UserClient)user).physician).stream);
         //}
     }
 }
Example #2
0
 public Session(DateTime startedDate, trainingen training, int id)
 {
     this.startedDate = startedDate;
     this.training = (int)training;
     this.id = id;
 }
Example #3
0
 public PacketMeasurement(Measurement measurement, string physicianName, trainingen training)
 {
     this.measurement = measurement;
     this.physicianName = physicianName;
     this.training = training;
 }
Example #4
0
 public void sendMeasurement(Measurement measurement, string physicianName, trainingen training)
 {
     networkCommunication.sendPacket(new PacketMeasurement(measurement, physicianName, training));
 }
Example #5
0
 public void addSession(DateTime startedDate, trainingen training)
 {
     Session s = new Session(startedDate, training, sessions.Count + 1);
     sessions.Add(s);
 }
Example #6
0
 private void RefreshThread()
 {
     network.sendMeasurement(null, ((UserClient)currentUser).physician, training);
     if (training == trainingen.newAstrand)
         training = trainingen.astrand;
     if (training == trainingen.none)
         training = trainingen.other;
     do
     {
         //Set the status of connection:
         SetLabelText(statusLabel,bike.GetStatus());
         //Get latest measurement:
         Measurement measurement = bike.GetMeasurement();
         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");
         }
         //Send measurement to the server
         network.sendMeasurement(measurement,((UserClient)currentUser).physician, training);
         Thread.Sleep(1000);
     }
     while (statusLabel.Text != "Error: connection lost");
 }
Example #7
0
        private void BStartTraining_Click(object sender, EventArgs e)
        {
            if(bike == null)
            {
                bike = new Bike(3.ToString());
                // modelLabel.Text = bike.GetModel();
                while (modelLabel.Text.Equals("ERROR") || modelLabel.Text.Equals(""))
                    modelLabel.Text = bike.GetModel();
                //versionLabel.Text = bike.GetVersionNumber();
                while (versionLabel.Text.Equals("ERROR") || versionLabel.Text.Equals(""))
                    versionLabel.Text = bike.GetVersionNumber();
                statusLabel.Text = bike.GetStatus();
                Thread refreshThread = new Thread(new ThreadStart(RefreshThread));
                refreshThread.IsBackground = true;
                refreshThread.Start();
            }

            training = trainingen.newAstrand;
            Thread t = new Thread(new ThreadStart(Astrand));
            t.IsBackground = true;
            t.Start();
        }