浏览代码

Can now view archived session on the GUI

Mauro de Lyon 10 年之前
父节点
当前提交
2b82a1b02e

+ 1 - 1
Proftaak Remote Healthcare/FietsClientV2/Forms/PatientForm.Designer.cs

@@ -136,7 +136,7 @@ namespace FietsClient
             // selectSessionToolStripMenuItem
             // 
             this.selectSessionToolStripMenuItem.Name = "selectSessionToolStripMenuItem";
-            this.selectSessionToolStripMenuItem.Size = new System.Drawing.Size(181, 26);
+            this.selectSessionToolStripMenuItem.Size = new System.Drawing.Size(177, 26);
             this.selectSessionToolStripMenuItem.Text = "Select Session";
             // 
             // bicycleToolStripMenuItem

+ 53 - 9
Proftaak Remote Healthcare/FietsClientV2/Forms/PatientForm.cs

@@ -10,6 +10,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using FietsClient.JSONObjecten;
+using System.Windows.Forms.DataVisualization.Charting;
 
 namespace FietsClient
 {
@@ -17,7 +18,7 @@ namespace FietsClient
     {
         private TcpConnection _connection;
         private PatientModel patienModel;
-        
+
         public PatientForm(TcpConnection connection)
         {
             this._connection = connection;
@@ -49,8 +50,6 @@ namespace FietsClient
         {
             string[] ports = SerialPort.GetPortNames();
             toolStripComboBox1.Items.AddRange(ports);
-           
-            
             MenuSessionItems();
         }
 
@@ -115,7 +114,7 @@ namespace FietsClient
 
         private void sendButton_Click(object sender, EventArgs e)
         {
-            if(messageBox.Text != null)
+            if (messageBox.Text != null)
             {
                 string message = messageBox.Text;
                 messageBox.Clear();
@@ -136,7 +135,56 @@ namespace FietsClient
                 selectSessionToolStripMenuItem.DropDownItems.Add(
                     new ToolStripMenuItem(s.id.ToString(), null, delegate
                     {
-                       // Load Session data
+                        this.sessionBox.Text = s.id.ToString();
+                        this.nameBox.Text = _connection.userID;
+                        //get measurments
+                        List<Measurement> measurments = s.session;
+                        //fill boxes
+
+                        this.pulseBox.Text = measurments[measurments.Count - 1].bpm.ToString();
+                        this.rpmInfoBox.Text = measurments[measurments.Count - 1].rpm.ToString();
+                        this.speedInfoBox.Text = measurments[measurments.Count - 1].speed.ToString();
+                        this.distanceInfoBox.Text = measurments[measurments.Count - 1].distance.ToString();
+                        this.requestedBox.Text = measurments[measurments.Count - 1].requestedPower.ToString();
+                        this.energyInfoBox.Text = measurments[measurments.Count - 1].energy.ToString();
+                        this.timeBox.Text = measurments[measurments.Count - 1].time.ToString();
+                        this.actualBox.Text = measurments[measurments.Count - 1].actualPower.ToString();
+
+                        //fill speedpoints
+                        patienModel.speedPoints = new List<DataPoint>();
+                        for (int i = 0; i < measurments.Count; i++)
+                        {
+                            patienModel.speedPoints.Add(new DataPoint(measurments[i].time, measurments[i].speed));
+                        }
+                        //fill speedgraph
+                        this.speedChart.Series[0].Points.Clear();
+                        for (int i = 0; i < patienModel.speedPoints.Count; i++)
+                            this.speedChart.Series[0].Points.Add(patienModel.speedPoints[i]);
+                        this.speedChart.Update();
+
+                        //fill bpm
+                        patienModel.bpmPoints = new List<DataPoint>();
+                        for (int i = 0; i < measurments.Count; i++)
+                        {
+                            patienModel.bpmPoints.Add(new DataPoint(measurments[i].time, measurments[i].bpm));
+                        }
+                        //fill bpmgraph
+                        this.bpmChart.Series[0].Points.Clear();
+                        for (int i = 0; i < patienModel.bpmPoints.Count; i++)
+                            this.bpmChart.Series[0].Points.Add(patienModel.bpmPoints[i]);
+                        this.bpmChart.Update();
+
+                        //fill rpm
+                        patienModel.rpmPoints = new List<DataPoint>();
+                        for (int i = 0; i < measurments.Count; i++)
+                        {
+                            patienModel.rpmPoints.Add(new DataPoint(measurments[i].time, measurments[i].rpm));
+                        }
+                        //fill rpmgraph
+                        this.rpmChart.Series[0].Points.Clear();
+                        for (int i = 0; i < patienModel.rpmPoints.Count; i++)
+                            this.rpmChart.Series[0].Points.Add(patienModel.rpmPoints[i]);
+                        this.rpmChart.Update();
                     })
                 );
 
@@ -148,9 +196,5 @@ namespace FietsClient
             string finalMessage = data[1] + ":\t\t" + data[3] + "\r\n";
             chatBox.AppendText(finalMessage);
         }
-
-
-
-        
     }
 }

+ 3 - 3
Proftaak Remote Healthcare/FietsClientV2/PatientModel.cs

@@ -62,9 +62,9 @@ namespace FietsClient
             }
         }
         //event handler
-        private List<DataPoint> speedPoints = new List<DataPoint>();
-        private List<DataPoint> bpmPoints = new List<DataPoint>();
-        private List<DataPoint> rpmPoints = new List<DataPoint>();
+        public List<DataPoint> speedPoints { get; set; } = new List<DataPoint>();
+        public List<DataPoint> bpmPoints { get; set; } = new List<DataPoint>();
+        public List<DataPoint> rpmPoints { set; get; } = new List<DataPoint>();
         private void HandleBikeData(string[] data)
         {
             if (patientform.InvokeRequired)

+ 24 - 18
Proftaak Remote Healthcare/Server/AppGlobal.cs

@@ -22,20 +22,30 @@ namespace Server
             get { return _instance ?? (_instance = new AppGlobal()); }
         }
 
-        public AppGlobal() 
+        public AppGlobal()
         {
             users = new List<User>();
             Clients = new List<Client>();
+            TestMethode();
+            Console.WriteLine(JsonConverter.GetUserSessions(users.ElementAt(1)));
+        }
+
+        private void TestMethode()
+        {
             users.Add(new User("no", "no", 0, false, 0));
             users.Add(new User("JK123", "jancoow", 5, true, 100));
             users.Add(new User("TOM", "tommie", 80, false, 77, true));
 
-            users.ElementAt(1).tests.Add(new Session(1, "100"));
-            users.ElementAt(1).tests.Add(new Session(2, "110"));
-            users.ElementAt(0).tests.Add(new Session(3, "230"));
-            users.ElementAt(2).tests.Add(new Session(4, "300"));
+            Random r = new Random();
+            Session session = new Session(1, "100");
+            for (int i = 0; i < 100; i++)
+                session.AddMeasurement(new Measurement(r.Next(100, 200), r.Next(60, 100), r.Next(100, 150), r.Next(0, 100), i, r.Next(100), r.Next(100), r.Next(100), i, r.Next(100)));
+            users.ElementAt(1).tests.Add(session);
 
-            Console.WriteLine(JsonConverter.GetUserSessions(users.ElementAt(1)));
+            Session session2 = new Session(2, "100");
+            for (int i = 0; i < 200; i++)
+                session2.AddMeasurement(new Measurement(r.Next(100, 200), r.Next(60, 100), r.Next(100, 150), r.Next(0, 100), i, r.Next(100), r.Next(100), r.Next(100), i, r.Next(100)));
+            users.ElementAt(1).tests.Add(session2);
         }
 
         public void CheckLogin(string username, string password, out int admin, out int id)
@@ -44,19 +54,15 @@ namespace Server
             admin = 0;
             foreach (User u in users)
             {
-                if(u.id == username && u.password == password)
+                if (u.id == username && u.password == password)
                 {
                     admin = u.isDoctor ? 1 : 0;
                     id = users.IndexOf(u);
-                    if (u.isDoctor)
-                    {
-                        activeDoctor.Add(u);
-                    }
-                    else
-                    {
-                        activePatient.Add(u);
-                    }
-
+                    /* if (u.isDoctor)
+                     {
+                         activeDoctor.Add(u);
+                     }
+                     activePatient.Add(u);*/
                 }
             }
         }
@@ -64,7 +70,7 @@ namespace Server
         public List<User> GetUsers()
         {
             return users;
-        } 
+        }
 
         public List<Session> GetTests(string patientid)
         {
@@ -85,7 +91,7 @@ namespace Server
             {
                 if (u.id == patientid)
                 {
-                    u.AddSession(new Session( mode, modevalue ));
+                    u.AddSession(new Session(mode, modevalue));
                 }
             }
 

+ 1 - 7
Proftaak Remote Healthcare/Server/JSONObjecten/Session.cs

@@ -21,20 +21,14 @@ namespace Server.JSONObjecten
         public string note { get; private set; }
         public string modevalue { get; private set; }
 
-        public Session( int bikeMode, string modevalue )
+        public Session(int bikeMode, string modevalue)
         {
             string[] fileEntries = Directory.GetFiles(@"../../JSONObjecten/JSON Files/");
 
             if (fileEntries.Length > 0)
-            {
                 this.id = int.Parse(fileEntries[fileEntries.Length]);
-            }
             else
-            {
                 this.id = 1;
-            }
-
-
 
             this.session = new List<Measurement>();
             this.isActive = true;