Procházet zdrojové kódy

Beter handling of start and stopping session

jancoow před 10 roky
rodič
revize
5e5e1202cf

+ 25 - 3
Proftaak Remote Healthcare/FietsClientV2/Forms/PatientForm.cs

@@ -78,9 +78,14 @@ namespace FietsClient
         private void confirmDistanceBox_Click(object sender, EventArgs e)
         {
             int n;
-            if (int.TryParse(distanceBox.Text, out n))
+            if (patientModel.askdata)
+            {
+                MessageBox.Show("Er is nog een sessie bezig, deze moet eerst gestopt worden");
+            }
+            else if (int.TryParse(distanceBox.Text, out n))
             {
                 patientModel.setDistanceMode(distanceBox.Text);
+                this.label19.Text = "Huidige sessie: Afstand: " + n;
             }
             else
             {
@@ -93,14 +98,20 @@ namespace FietsClient
             int minutes, seconds;
             bool isNumericS = int.TryParse(minuteBox.Text, out minutes);
             bool isNumericM = int.TryParse(secondBox.Text, out seconds);
-
-            if (isNumericM)
+            if (patientModel.askdata)
+            {
+                MessageBox.Show("Er is nog een sessie bezig, deze moet eerst gestopt worden");
+            }else if (isNumericM)
             {
                 if (isNumericS)
+                {
                     patientModel.setTimeMode(minutes + ":" + seconds);
+                    this.label19.Text = "Huidige sessie: Tijd: " + minutes + ":" + seconds;
+                }
                 else MessageBox.Show("Minutes is not a valid number.");
             }
             else MessageBox.Show("Seconds is not a valid number.");
+
         }
 
         private void stopTrainingToolStripMenuItem_Click(object sender, EventArgs e)
@@ -147,6 +158,7 @@ namespace FietsClient
                 selectSessionToolStripMenuItem.DropDownItems.Add(
                     new ToolStripMenuItem(s.id.ToString(), null, delegate
                     {
+                        patientModel.stopAskingData();
                         this.sessionBox.Text = s.id.ToString();
                         this.nameBox.Text = _connection.userID;
                         //get measurments
@@ -233,5 +245,15 @@ namespace FietsClient
             _connection.disconnect();
             Application.Exit();
         }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            patientModel.startAskingData();
+        }
+
+        private void button2_Click(object sender, EventArgs e)
+        {
+            patientModel.stopAskingData();
+        }
     }
 }

+ 73 - 36
Proftaak Remote Healthcare/FietsClientV2/Forms/PatientForm.designer.cs

@@ -30,12 +30,12 @@ namespace FietsClient
         /// </summary>
         private void InitializeComponent()
         {
-            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea4 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
-            System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
-            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea5 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
-            System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series();
-            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
-            System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea3 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PatientForm));
             this.menuStrip1 = new System.Windows.Forms.MenuStrip();
             this.archiefToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -67,6 +67,9 @@ namespace FietsClient
             this.bpmBox = new System.Windows.Forms.GroupBox();
             this.bpmChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
             this.sessionInfoBox = new System.Windows.Forms.GroupBox();
+            this.label19 = new System.Windows.Forms.Label();
+            this.button2 = new System.Windows.Forms.Button();
+            this.button1 = new System.Windows.Forms.Button();
             this.requestedBox = new System.Windows.Forms.TextBox();
             this.actualBox = new System.Windows.Forms.TextBox();
             this.nameBox = new System.Windows.Forms.TextBox();
@@ -317,18 +320,18 @@ namespace FietsClient
             // 
             // speedChart
             // 
-            chartArea4.Name = "ChartArea1";
-            this.speedChart.ChartAreas.Add(chartArea4);
+            chartArea1.Name = "ChartArea1";
+            this.speedChart.ChartAreas.Add(chartArea1);
             this.speedChart.Location = new System.Drawing.Point(6, 19);
             this.speedChart.Name = "speedChart";
-            series4.BorderWidth = 10;
-            series4.ChartArea = "ChartArea1";
-            series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
-            series4.Name = "Speed";
-            series4.XValueMember = "Time";
-            series4.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
-            series4.YValueMembers = "Speed";
-            this.speedChart.Series.Add(series4);
+            series1.BorderWidth = 10;
+            series1.ChartArea = "ChartArea1";
+            series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+            series1.Name = "Speed";
+            series1.XValueMember = "Time";
+            series1.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
+            series1.YValueMembers = "Speed";
+            this.speedChart.Series.Add(series1);
             this.speedChart.Size = new System.Drawing.Size(388, 285);
             this.speedChart.TabIndex = 0;
             this.speedChart.Text = "Speed chart";
@@ -345,24 +348,27 @@ namespace FietsClient
             // 
             // bpmChart
             // 
-            chartArea5.Name = "ChartArea1";
-            this.bpmChart.ChartAreas.Add(chartArea5);
+            chartArea2.Name = "ChartArea1";
+            this.bpmChart.ChartAreas.Add(chartArea2);
             this.bpmChart.Location = new System.Drawing.Point(6, 19);
             this.bpmChart.Name = "bpmChart";
-            series5.BorderWidth = 10;
-            series5.ChartArea = "ChartArea1";
-            series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
-            series5.Name = "Beats per minute";
-            series5.XValueMember = "Time";
-            series5.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
-            series5.YValueMembers = "Beats per minutes";
-            this.bpmChart.Series.Add(series5);
+            series2.BorderWidth = 10;
+            series2.ChartArea = "ChartArea1";
+            series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+            series2.Name = "Beats per minute";
+            series2.XValueMember = "Time";
+            series2.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
+            series2.YValueMembers = "Beats per minutes";
+            this.bpmChart.Series.Add(series2);
             this.bpmChart.Size = new System.Drawing.Size(388, 285);
             this.bpmChart.TabIndex = 1;
             this.bpmChart.Text = "beats per second";
             // 
             // sessionInfoBox
             // 
+            this.sessionInfoBox.Controls.Add(this.label19);
+            this.sessionInfoBox.Controls.Add(this.button2);
+            this.sessionInfoBox.Controls.Add(this.button1);
             this.sessionInfoBox.Controls.Add(this.requestedBox);
             this.sessionInfoBox.Controls.Add(this.actualBox);
             this.sessionInfoBox.Controls.Add(this.nameBox);
@@ -398,6 +404,34 @@ namespace FietsClient
             this.sessionInfoBox.TabStop = false;
             this.sessionInfoBox.Text = "Session info:";
             // 
+            // label19
+            // 
+            this.label19.AutoSize = true;
+            this.label19.Location = new System.Drawing.Point(197, 286);
+            this.label19.Name = "label19";
+            this.label19.Size = new System.Drawing.Size(0, 13);
+            this.label19.TabIndex = 40;
+            // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(99, 281);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(75, 23);
+            this.button2.TabIndex = 39;
+            this.button2.Text = "Stop sessie";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(9, 281);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(75, 23);
+            this.button1.TabIndex = 38;
+            this.button1.Text = "Start sessie";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
             // requestedBox
             // 
             this.requestedBox.Location = new System.Drawing.Point(99, 221);
@@ -652,18 +686,18 @@ namespace FietsClient
             // 
             // rpmChart
             // 
-            chartArea6.Name = "ChartArea1";
-            this.rpmChart.ChartAreas.Add(chartArea6);
+            chartArea3.Name = "ChartArea1";
+            this.rpmChart.ChartAreas.Add(chartArea3);
             this.rpmChart.Location = new System.Drawing.Point(6, 19);
             this.rpmChart.Name = "rpmChart";
-            series6.BorderWidth = 10;
-            series6.ChartArea = "ChartArea1";
-            series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
-            series6.Name = "Rounds per minute";
-            series6.XValueMember = "Time";
-            series6.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
-            series6.YValueMembers = "Rounds per minutes";
-            this.rpmChart.Series.Add(series6);
+            series3.BorderWidth = 10;
+            series3.ChartArea = "ChartArea1";
+            series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+            series3.Name = "Rounds per minute";
+            series3.XValueMember = "Time";
+            series3.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
+            series3.YValueMembers = "Rounds per minutes";
+            this.rpmChart.Series.Add(series3);
             this.rpmChart.Size = new System.Drawing.Size(388, 285);
             this.rpmChart.TabIndex = 2;
             this.rpmChart.Text = "rounds per minute";
@@ -810,6 +844,9 @@ namespace FietsClient
         public System.Windows.Forms.DataVisualization.Charting.Chart speedChart;
         public Chart bpmChart;
         public Chart rpmChart;
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.Button button2;
+        private System.Windows.Forms.Label label19;
     }
 }
 

+ 1 - 1
Proftaak Remote Healthcare/FietsClientV2/Forms/PatientForm.resx

@@ -124,7 +124,7 @@
     <value>True</value>
   </metadata>
   <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>53</value>
+    <value>25</value>
   </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">

+ 13 - 1
Proftaak Remote Healthcare/FietsClientV2/PatientModel.cs

@@ -21,6 +21,7 @@ namespace FietsClient
         private Thread workerThread;
 
         private string powerLog;
+        public Boolean askdata;
 
         public string CurrentDoctorID { get; set; }
 
@@ -37,13 +38,23 @@ namespace FietsClient
 
         public void startAskingData()
         {
+            askdata = true;
+            speedPoints.Clear();
+            bpmPoints.Clear();
+            rpmPoints.Clear();
             workerThread = new Thread(() => workerThreadLoop());
             workerThread.Start();
         }
 
+        public void stopAskingData()
+        {
+            askdata = false;
+            dataHandler.sendData(DataHandler.RESET);
+        }
+
         private void workerThreadLoop()
         {
-            while (true)
+            while (askdata)
             {
                 Thread.Sleep(1000);
 
@@ -117,6 +128,7 @@ namespace FietsClient
 
         public void closeComPort()
         {
+            stopAskingData();
             if (workerThread != null)
                 workerThread.Interrupt();
             dataHandler.closeComm();