Mauro de Lyon 10 tahun lalu
induk
melakukan
27fcddd077

+ 13 - 4
Proftaak Remote Healthcare/FietsClientV2/DoctorModel.cs

@@ -25,6 +25,8 @@ namespace FietsClient
         public List<string> onlinePatients { get; set; } = new List<string>();
         public Dictionary<string, Forms.DoctorSessionUC> doctorSessions { get; set; } = new Dictionary<string, Forms.DoctorSessionUC>();
 
+
+
         private DoctorModel()
         {
             startAskingData();
@@ -41,6 +43,13 @@ namespace FietsClient
             receiveDataThread.Abort();
         }
 
+        internal List<User> requestUsers()
+        {
+            tcpConnection.requestUsers();
+            Thread.Sleep(1000);
+            return tcpConnection.users;
+        }
+
         private void receiveDataThreadLoop()
         {
             while (true)
@@ -67,7 +76,7 @@ namespace FietsClient
                         doctorform.Invoke(new Action(() => doctorSessions.Remove(str)));
                     }
                     //onlinePatients.Find(username => username.Equals(str));
-                    
+
                 }
 
                 //voeg een onlinePatient toe aan een doctorSession
@@ -85,7 +94,7 @@ namespace FietsClient
         private List<DataPoint> rpmPoints = new List<DataPoint>();
         private void HandleBikeData(Measurement data)
         {
-            
+
             if (doctorform.InvokeRequired)
             {
                 doctorform.Invoke((new Action(() => HandleBikeData(data))));
@@ -99,7 +108,7 @@ namespace FietsClient
                 doctorform.summaryUserControl.distanceInfoBox.Text = data.distance.ToString();
                 doctorform.summaryUserControl.requestedBox.Text = data.requestedPower.ToString();
                 doctorform.summaryUserControl.energyInfoBox.Text = data.energy.ToString();
-                doctorform.summaryUserControl.timeBox.Text = data.time.ToString() ;
+                doctorform.summaryUserControl.timeBox.Text = data.time.ToString();
                 doctorform.summaryUserControl.actualBox.Text = data.actualPower.ToString();
 
                 //fill graph speed
@@ -129,7 +138,7 @@ namespace FietsClient
                     rpmPoints.RemoveAt(0);
                 doctorform.summaryUserControl.rpmChart.Update();
             }
-            
+
         }
     }
 }

+ 50 - 52
Proftaak Remote Healthcare/FietsClientV2/Forms/DoctorForm.Designer.cs

@@ -31,10 +31,9 @@
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DoctorForm));
             this.menuStrip1 = new System.Windows.Forms.MenuStrip();
             this.archiefToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.PatientBox = new System.Windows.Forms.ToolStripComboBox();
+            this.sessionsBox = new System.Windows.Forms.ToolStripComboBox();
             this.selectSessionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
-            this.sESSIONSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
-            this.nieuwePatientToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
-            this.selectArchiveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.chatBox = new System.Windows.Forms.TextBox();
             this.messageBox = new System.Windows.Forms.TextBox();
             this.chatArea = new System.Windows.Forms.GroupBox();
@@ -55,61 +54,55 @@
             this.archiefToolStripMenuItem});
             this.menuStrip1.Location = new System.Drawing.Point(0, 0);
             this.menuStrip1.Name = "menuStrip1";
-            this.menuStrip1.Size = new System.Drawing.Size(1084, 24);
+            this.menuStrip1.Padding = new System.Windows.Forms.Padding(8, 2, 0, 2);
+            this.menuStrip1.Size = new System.Drawing.Size(1445, 28);
             this.menuStrip1.TabIndex = 0;
             this.menuStrip1.Text = "menuStrip1";
             // 
             // archiefToolStripMenuItem
             // 
             this.archiefToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.selectSessionToolStripMenuItem,
-            this.selectArchiveToolStripMenuItem});
+            this.PatientBox,
+            this.sessionsBox,
+            this.selectSessionToolStripMenuItem});
             this.archiefToolStripMenuItem.Name = "archiefToolStripMenuItem";
-            this.archiefToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
-            this.archiefToolStripMenuItem.Text = "Patient";
+            this.archiefToolStripMenuItem.Size = new System.Drawing.Size(70, 24);
+            this.archiefToolStripMenuItem.Text = "Archive";
             // 
-            // selectSessionToolStripMenuItem
-            // 
-            this.selectSessionToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.sESSIONSToolStripMenuItem,
-            this.nieuwePatientToolStripMenuItem});
-            this.selectSessionToolStripMenuItem.Name = "selectSessionToolStripMenuItem";
-            this.selectSessionToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
-            this.selectSessionToolStripMenuItem.Text = "Select patient";
-            // 
-            // sESSIONSToolStripMenuItem
+            // PatientBox
             // 
-            this.sESSIONSToolStripMenuItem.Name = "sESSIONSToolStripMenuItem";
-            this.sESSIONSToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
-            this.sESSIONSToolStripMenuItem.Text = "Patients";
+            this.PatientBox.Name = "PatientBox";
+            this.PatientBox.Size = new System.Drawing.Size(121, 28);
+            this.PatientBox.SelectedIndexChanged += new System.EventHandler(this.PatientBox_SelectedIndexChanged);
             // 
-            // nieuwePatientToolStripMenuItem
+            // sessionsBox
             // 
-            this.nieuwePatientToolStripMenuItem.Name = "nieuwePatientToolStripMenuItem";
-            this.nieuwePatientToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
-            this.nieuwePatientToolStripMenuItem.Text = "Nieuwe Patient";
-            this.nieuwePatientToolStripMenuItem.Click += new System.EventHandler(this.nieuwePatientToolStripMenuItem_Click);
+            this.sessionsBox.Name = "sessionsBox";
+            this.sessionsBox.Size = new System.Drawing.Size(121, 28);
             // 
-            // selectArchiveToolStripMenuItem
+            // selectSessionToolStripMenuItem
             // 
-            this.selectArchiveToolStripMenuItem.Name = "selectArchiveToolStripMenuItem";
-            this.selectArchiveToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
-            this.selectArchiveToolStripMenuItem.Text = "Select archive";
+            this.selectSessionToolStripMenuItem.Name = "selectSessionToolStripMenuItem";
+            this.selectSessionToolStripMenuItem.Size = new System.Drawing.Size(187, 26);
+            this.selectSessionToolStripMenuItem.Text = "Select session";
+            this.selectSessionToolStripMenuItem.Click += new System.EventHandler(this.selectSessionToolStripMenuItem_Click);
             // 
             // chatBox
             // 
-            this.chatBox.Location = new System.Drawing.Point(0, 13);
+            this.chatBox.Location = new System.Drawing.Point(0, 16);
+            this.chatBox.Margin = new System.Windows.Forms.Padding(4);
             this.chatBox.Multiline = true;
             this.chatBox.Name = "chatBox";
             this.chatBox.ReadOnly = true;
-            this.chatBox.Size = new System.Drawing.Size(228, 560);
+            this.chatBox.Size = new System.Drawing.Size(303, 688);
             this.chatBox.TabIndex = 3;
             // 
             // messageBox
             // 
-            this.messageBox.Location = new System.Drawing.Point(0, 579);
+            this.messageBox.Location = new System.Drawing.Point(0, 713);
+            this.messageBox.Margin = new System.Windows.Forms.Padding(4);
             this.messageBox.Name = "messageBox";
-            this.messageBox.Size = new System.Drawing.Size(228, 20);
+            this.messageBox.Size = new System.Drawing.Size(303, 22);
             this.messageBox.TabIndex = 6;
             this.messageBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.messageBox_KeyPress);
             // 
@@ -118,18 +111,21 @@
             this.chatArea.Controls.Add(this.messageButton);
             this.chatArea.Controls.Add(this.chatBox);
             this.chatArea.Controls.Add(this.messageBox);
-            this.chatArea.Location = new System.Drawing.Point(849, 50);
+            this.chatArea.Location = new System.Drawing.Point(1132, 62);
+            this.chatArea.Margin = new System.Windows.Forms.Padding(4);
             this.chatArea.Name = "chatArea";
-            this.chatArea.Size = new System.Drawing.Size(228, 641);
+            this.chatArea.Padding = new System.Windows.Forms.Padding(4);
+            this.chatArea.Size = new System.Drawing.Size(304, 789);
             this.chatArea.TabIndex = 5;
             this.chatArea.TabStop = false;
             this.chatArea.Text = "Chat:";
             // 
             // messageButton
             // 
-            this.messageButton.Location = new System.Drawing.Point(0, 605);
+            this.messageButton.Location = new System.Drawing.Point(0, 745);
+            this.messageButton.Margin = new System.Windows.Forms.Padding(4);
             this.messageButton.Name = "messageButton";
-            this.messageButton.Size = new System.Drawing.Size(228, 30);
+            this.messageButton.Size = new System.Drawing.Size(304, 37);
             this.messageButton.TabIndex = 7;
             this.messageButton.Text = "send";
             this.messageButton.UseVisualStyleBackColor = true;
@@ -138,19 +134,21 @@
             // doctorTabControl
             // 
             this.doctorTabControl.Controls.Add(this.tabPageSummary);
-            this.doctorTabControl.Location = new System.Drawing.Point(13, 28);
+            this.doctorTabControl.Location = new System.Drawing.Point(17, 34);
+            this.doctorTabControl.Margin = new System.Windows.Forms.Padding(4);
             this.doctorTabControl.Name = "doctorTabControl";
             this.doctorTabControl.SelectedIndex = 0;
-            this.doctorTabControl.Size = new System.Drawing.Size(830, 666);
+            this.doctorTabControl.Size = new System.Drawing.Size(1107, 820);
             this.doctorTabControl.TabIndex = 6;
             // 
             // tabPageSummary
             // 
             this.tabPageSummary.BackColor = System.Drawing.Color.Transparent;
             this.tabPageSummary.Controls.Add(this.doctorSummaryUC1);
-            this.tabPageSummary.Location = new System.Drawing.Point(4, 22);
+            this.tabPageSummary.Location = new System.Drawing.Point(4, 25);
+            this.tabPageSummary.Margin = new System.Windows.Forms.Padding(4);
             this.tabPageSummary.Name = "tabPageSummary";
-            this.tabPageSummary.Size = new System.Drawing.Size(822, 640);
+            this.tabPageSummary.Size = new System.Drawing.Size(1099, 791);
             this.tabPageSummary.TabIndex = 0;
             this.tabPageSummary.Text = "Summary";
             // 
@@ -158,23 +156,24 @@
             // 
             this.doctorSummaryUC1.BackColor = System.Drawing.SystemColors.Control;
             this.doctorSummaryUC1.Location = new System.Drawing.Point(0, 0);
-            this.doctorSummaryUC1.Margin = new System.Windows.Forms.Padding(4);
+            this.doctorSummaryUC1.Margin = new System.Windows.Forms.Padding(5);
             this.doctorSummaryUC1.Name = "doctorSummaryUC1";
-            this.doctorSummaryUC1.Size = new System.Drawing.Size(822, 640);
+            this.doctorSummaryUC1.Size = new System.Drawing.Size(1096, 788);
             this.doctorSummaryUC1.TabIndex = 0;
             // 
             // DoctorForm
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.SystemColors.Control;
-            this.ClientSize = new System.Drawing.Size(1084, 711);
+            this.ClientSize = new System.Drawing.Size(1445, 875);
             this.Controls.Add(this.doctorTabControl);
             this.Controls.Add(this.chatArea);
             this.Controls.Add(this.menuStrip1);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.MainMenuStrip = this.menuStrip1;
+            this.Margin = new System.Windows.Forms.Padding(4);
             this.MaximizeBox = false;
             this.Name = "DoctorForm";
             this.Text = "Doctor";
@@ -194,18 +193,17 @@
         #endregion
 
         private System.Windows.Forms.MenuStrip menuStrip1;
-        private System.Windows.Forms.ToolStripMenuItem archiefToolStripMenuItem;
-        private System.Windows.Forms.ToolStripMenuItem selectSessionToolStripMenuItem;
-        private System.Windows.Forms.ToolStripMenuItem sESSIONSToolStripMenuItem;
         private System.Windows.Forms.TextBox chatBox;
         private System.Windows.Forms.TextBox messageBox;
         private System.Windows.Forms.GroupBox chatArea;
-        private System.Windows.Forms.ToolStripMenuItem selectArchiveToolStripMenuItem;
         private System.Windows.Forms.Button messageButton;
         private System.Windows.Forms.TabControl doctorTabControl;
-        private System.Windows.Forms.TabPage tabPageSummary;
         private Forms.DoctorSummaryUC doctorSummaryUC1;
-        private System.Windows.Forms.ToolStripMenuItem nieuwePatientToolStripMenuItem;
+        public System.Windows.Forms.ToolStripMenuItem archiefToolStripMenuItem;
+        private System.Windows.Forms.ToolStripComboBox PatientBox;
+        public System.Windows.Forms.TabPage tabPageSummary;
+        public System.Windows.Forms.ToolStripComboBox sessionsBox;
+        private System.Windows.Forms.ToolStripMenuItem selectSessionToolStripMenuItem;
     }
 }
 

+ 97 - 7
Proftaak Remote Healthcare/FietsClientV2/Forms/DoctorForm.cs

@@ -8,6 +8,8 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using FietsClient.Forms;
+using FietsLibrary.JSONObjecten;
+using System.Windows.Forms.DataVisualization.Charting;
 
 namespace FietsClient
 {
@@ -37,8 +39,14 @@ namespace FietsClient
             }
         }
 
+        private List<User> users;
         private void Form1_Load(object sender, EventArgs e)
         {
+            users = doctorModel.requestUsers();
+            foreach (User user in users)
+            {
+                PatientBox.Items.Add(user.id);
+            }
 
         }
 
@@ -62,13 +70,13 @@ namespace FietsClient
 
                 doctorModel.tcpConnection.SendChatMessage(data);
             }
-            
+
             else if (messageBox.Text != null && doctorTabControl.SelectedTab.Name == "tabPageSummary")
             {
                 String[] data = new String[2];
                 data[0] = "This is a broadcast: " + messageBox.Text + "\r\n";
                 //all patients:
-                for (int tabs = 1; tabs <= doctorTabControl.TabCount -1; tabs++)
+                for (int tabs = 1; tabs <= doctorTabControl.TabCount - 1; tabs++)
                 {
                     doctorTabControl.SelectTab(tabs);
                     data[1] = doctorTabControl.SelectedTab.Name;
@@ -76,16 +84,16 @@ namespace FietsClient
                 }
                 messageBox.Clear();
 
-            }  
+            }
         }
 
         private void printMessage(string[] data)
         {
             string finalMessage = data[0] + ":\t" + data[2] + "\r\n";
-            chatBox.Invoke((MethodInvoker) delegate ()
-            {
-                chatBox.AppendText(finalMessage);
-            });
+            chatBox.Invoke((MethodInvoker)delegate ()
+           {
+               chatBox.AppendText(finalMessage);
+           });
         }
 
         public void AddSessionToTabcontrol(string patientID)
@@ -118,5 +126,87 @@ namespace FietsClient
             var newPatient = new NewPatientForm(doctorModel.tcpConnection);
             newPatient.Show();
         }
+
+        private List<DataPoint> speedPoints = new List<DataPoint>();
+        private List<DataPoint> bpmPoints = new List<DataPoint>();
+        private List<DataPoint> rpmPoints = new List<DataPoint>();
+        private void selectSessionToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            //get measurments
+            List<Measurement> measurments = new List<Measurement>();
+            User user = null;
+            foreach (User userx in users)
+            {
+                if (PatientBox.Text == user.id)
+                {
+                    user = userx;
+                    List<Session> sessions = user.GetSessions();
+                    foreach (Session session in sessions)
+                    {
+                        if (sessionsBox.Text == session.date.ToString())
+                        {
+                            measurments = session.session;
+                        }
+                    }
+                }
+            }
+            //fill boxes
+
+            summaryUserControl.sessionBox.Text = user.id;
+            summaryUserControl.nameBox.Text = user.id;
+            summaryUserControl.pulseBox.Text = measurments[measurments.Count - 1].bpm.ToString();
+            summaryUserControl.rpmInfoBox.Text = measurments[measurments.Count - 1].rpm.ToString();
+            summaryUserControl.speedInfoBox.Text = measurments[measurments.Count - 1].speed.ToString();
+            summaryUserControl.distanceInfoBox.Text = measurments[measurments.Count - 1].distance.ToString();
+            summaryUserControl.requestedBox.Text = measurments[measurments.Count - 1].requestedPower.ToString();
+            summaryUserControl.energyInfoBox.Text = measurments[measurments.Count - 1].energy.ToString();
+            summaryUserControl.timeBox.Text = measurments[measurments.Count - 1].time.ToString();
+            summaryUserControl.actualBox.Text = measurments[measurments.Count - 1].actualPower.ToString();
+
+            //fill speedpoints
+            for (int i = 0; i < measurments.Count; i++)
+            {
+                speedPoints.Add(new DataPoint(measurments[i].time, measurments[i].speed));
+            }
+            //fill speedgraph
+            summaryUserControl.speedChart.Series[0].Points.Clear();
+            for (int i = 0; i < speedPoints.Count; i++)
+                summaryUserControl.speedChart.Series[0].Points.Add(speedPoints[i]);
+            summaryUserControl.speedChart.Update();
+
+            //fill bpm
+            for (int i = 0; i < measurments.Count; i++)
+            {
+                bpmPoints.Add(new DataPoint(measurments[i].time, measurments[i].bpm));
+            }
+            //fill bpmgraph
+            summaryUserControl.bpmChart.Series[0].Points.Clear();
+            for (int i = 0; i < bpmPoints.Count; i++)
+                summaryUserControl.bpmChart.Series[0].Points.Add(bpmPoints[i]);
+            summaryUserControl.bpmChart.Update();
+
+            //fill rpm
+            for (int i = 0; i < measurments.Count; i++)
+            {
+                rpmPoints.Add(new DataPoint(measurments[i].time, measurments[i].rpm));
+            }
+            //fill rpmgraph
+            summaryUserControl.rpmChart.Series[0].Points.Clear();
+            for (int i = 0; i < rpmPoints.Count; i++)
+                summaryUserControl.rpmChart.Series[0].Points.Add(rpmPoints[i]);
+            summaryUserControl.rpmChart.Update();
+        }
+
+        private void PatientBox_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            foreach (User user in users)
+            {
+                if (user.id == PatientBox.Text)
+                    foreach (Session session in user.GetSessions())
+                    {
+                        sessionsBox.Items.Add(session.date.ToString());
+                    }
+            }
+        }
     }
 }

+ 9 - 3
Proftaak Remote Healthcare/FietsClientV2/TCPConnection.cs

@@ -27,6 +27,7 @@ namespace FietsClient
 
         public delegate void ChatmassegeDelegate(string[] data);
         public event ChatmassegeDelegate IncomingChatmessageEvent;
+        public List<User> users;
 
         public TcpConnection()
         {
@@ -119,7 +120,7 @@ namespace FietsClient
 
         public void disconnect()
         {
-           
+
             sslStream.Close();
             client.Close();
             receiveThread.Abort();
@@ -151,7 +152,7 @@ namespace FietsClient
                         case "0":   //login and display correct window after login
                             if (response_parts.Length == 4)
                             {
-                                
+
 
                                 if (response_parts[1] == "1" && response_parts[2] == "1")
                                 {
@@ -217,7 +218,7 @@ namespace FietsClient
                             }
                             break;
                         case "9":
-                            JsonConvert.DeserializeObject<List<User>>(response_parts[1]);
+                            users = JsonConvert.DeserializeObject<List<User>>(response_parts[1]);
                             break;
                     }
                 }
@@ -273,6 +274,10 @@ namespace FietsClient
             SendString("8|" + userID + "|");
         }
 
+        public void requestUsers()
+        {
+            SendString("9|");
+        }
         public void SendDistance(int distance)
         {
             SendString("10|" + userID + "|" + distance + "|");
@@ -288,6 +293,7 @@ namespace FietsClient
             SendString("12|" + userID + "|" + power + "|");
         }
 
+
         public void SendString(string s)
         {