Selaa lähdekoodia

@fixing request data

Mauro de Lyon 10 vuotta sitten
vanhempi
commit
990766bd05

+ 0 - 98
Proftaak Remote Healthcare/FietsClientV2/AppGlobal.cs

@@ -1,98 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Fietsclient
-{
-    public class AppGlobal
-    {
-        private static AppGlobal _instance;
-
-        public int[] StatusItemsChecked;
-
-        Thread workerThread;
-        public static AppGlobal Instance
-        {
-            get { return _instance ?? (_instance = new AppGlobal()); }
-        }
-
-        
-
-        private KettlerBikeComm _bikeComm;
-
-
-        private AppGlobal()
-        {
-            _bikeComm = new KettlerBikeComm();
-            KettlerBikeComm.IncomingDataEvent += HandleBikeData; //initialize event
-        }
-
-        public void setTimeMode(string time)
-        {
-            _bikeComm.sendData("CU");
-            _bikeComm.sendData("PT " + time);
-        }
-
-        public void setPower(string power)
-        {
-            _bikeComm.sendData("CU");
-            _bikeComm.sendData("PW " + power);
-        }
-
-        public void setDistanceMode(string distance)
-        {
-            _bikeComm.sendData("CU");
-            _bikeComm.sendData("PD " + distance);
-        }
-
-        public void reset()
-        {
-            _bikeComm.sendData("RS");
-        }
-
-        public void startComPort()
-        {
-            startComPort("COM4");
-        }
-
-        public void startComPort(string portname)
-        {
-            _bikeComm.initComm(portname);
-        }
-
-        public void startAskingData()
-        {
-            workerThread = new Thread(() => workerThreadLoop());
-            workerThread.Start();
-        }
-
-        private void workerThreadLoop()
-        {
-            while(true)
-            {
-                Thread.Sleep(1000);
-                _bikeComm.sendData(KettlerBikeComm.STATUS);
-            }
-        }
-
-        //event handler
-        private void HandleBikeData(string[] data) 
-        {
-            //doe iets ermee...
-        }
-
-        public void closeComPort()
-        {
-            if (workerThread != null)
-                workerThread.Suspend();
-            _bikeComm.closeComm();
-        }
-
-
-
-
-    }
-}

+ 6 - 11
Proftaak Remote Healthcare/FietsClientV2/DataHandler.cs

@@ -63,11 +63,10 @@ namespace FietsClientV2
 
         public void initComm(string portname)
         {
-            if (ComPort != null)
-            {
-                ComPort.Close();
-            }
             this.portname = portname;
+            if (ComPort.IsOpen)
+                ComPort.Close();
+
             try
             {
                 ComPort = new SerialPort(this.portname, this.baudrate);
@@ -75,17 +74,13 @@ namespace FietsClientV2
                 ComPort.WriteLine(RESET);
                 ComPort.DataReceived += new SerialDataReceivedEventHandler(ComPort_DataReceived);
             }
-            catch (UnauthorizedAccessException)
+            catch (Exception)
             {
-                OnIncomingDebugLineEvent("ERROR: UnauthorizedAccessException throwed");
-                try { ComPort.Close(); } catch (Exception) { } // probeer om de ComPort wel te sluiten.
-            }
-            catch (InvalidOperationException)
-            {
-                OnIncomingDebugLineEvent("ERROR: InvalidOperationException throwed");
+                OnIncomingDebugLineEvent("ERROR: Exception throwed");
                 try { ComPort.Close(); } catch (Exception) { } // probeer om de ComPort wel te sluiten.
             }
 
+
         }
 
         public void closeComm()

+ 1 - 2
Proftaak Remote Healthcare/FietsClientV2/FietsClientV2.csproj

@@ -47,9 +47,7 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="AppGlobal.cs" />
     <Compile Include="DataHandler.cs" />
-    <Compile Include="KettlerBikeComm.cs" />
     <Compile Include="Login.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -68,6 +66,7 @@
     <Compile Include="PatientForm.Designer.cs">
       <DependentUpon>PatientForm.cs</DependentUpon>
     </Compile>
+    <Compile Include="PatientModel.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <EmbeddedResource Include="Login.resx">

+ 0 - 206
Proftaak Remote Healthcare/FietsClientV2/KettlerBikeComm.cs

@@ -1,206 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.IO.Ports;
-using System.Threading;
-
-namespace Fietsclient
-{
-    /// <summary>
-    /// Dit is de communicatieklasse met de simulator of de fiets.
-    /// </summary>
-    class KettlerBikeComm
-    {
-
-        // vaste waarden
-        public static readonly string COMMAND = "CU";
-        public static readonly string CMD_TIME = "PT";
-        public static readonly string CMD_DISTANCE = "PD";
-        public static readonly string CMD_POWER = "PW";
-        public static readonly string CMD_ENERGY = "PE";
-        public static readonly string RESET = "RS";
-        public static readonly string STATUS = "ST";
-
-        // private fields
-        private string _portname;
-        private int baudrate = 9600;
-        private string _bufferOut;
-        private string[] _bufferIn;
-
-        // public fields
-        public enum State { notConnected, connected, reset, command }
-        public enum ReturnData { ERROR, ACK, RUN, STATUS }
-
-        public State state = State.notConnected;
-        public ReturnData returnData;
-
-        private SerialPort ComPort;
-
-        // custom events
-        public delegate void DataDelegate(string[] data);
-        public static event DataDelegate IncomingDataEvent;
-
-        public delegate void DebugDelegate(string debugData);
-        public static event DebugDelegate IncomingDebugLineEvent;
-
-        public KettlerBikeComm()
-        {
-            
-        }
-
-        private static void OnIncomingDataEvent(string[] data)
-        {
-            DataDelegate handler = IncomingDataEvent;
-            if (handler != null) handler(data);
-        }
-
-        public static void OnIncomingDebugLineEvent(string debugData)
-        {
-            DebugDelegate handler = IncomingDebugLineEvent;
-            if (handler != null) handler(debugData);
-        }
-
-        public void initComm(string portname)
-        {
-            if (ComPort != null)
-            {
-                ComPort.Close();
-            }
-            _portname = portname;
-            try
-            {
-                ComPort = new SerialPort(_portname, this.baudrate);
-                ComPort.Open();
-                ComPort.WriteLine(RESET);
-                ComPort.DataReceived += new SerialDataReceivedEventHandler(ComPort_DataReceived);
-            }
-            catch (UnauthorizedAccessException)
-            {
-                OnIncomingDebugLineEvent("ERROR: UnauthorizedAccessException throwed");
-                try { ComPort.Close(); } catch (Exception) { } // probeer om de ComPort wel te sluiten.
-            }
-            catch (InvalidOperationException)
-            {
-                OnIncomingDebugLineEvent("ERROR: InvalidOperationException throwed");
-                try { ComPort.Close(); } catch (Exception) { } // probeer om de ComPort wel te sluiten.
-            }
-
-        }
-
-        public void closeComm()
-        {
-            ComPort.Close();
-        }
-
-        public void sendData(string data)
-        {
-            _bufferOut = data;
-            ComPort.WriteLine(data);
-        }
-
-        private void ComPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
-        {
-            string buffer = ComPort.ReadLine();
-            switch(buffer) //kijk wat er binnenkomt
-            {
-                case "ERROR": //wanneer "Error"
-                    returnData = ReturnData.ERROR;
-                    handleError();
-                    break;
-                case "ACK": // ACK betekent acknowledged.
-                    returnData = ReturnData.ACK;
-                    break;
-                case "RUN":
-                    returnData = ReturnData.RUN;
-                    break;
-                default:    // alle andere waarden.
-                    returnData = ReturnData.STATUS;
-                    handleBikeValues(buffer);
-                    break;
-            }
-        }
-
-        int trycount = 0;
-        private void handleError()
-        {
-            if (_bufferOut == "RS" && trycount < 3)
-            {
-                sendData("RS");  //gewoon nog een keer proberen tot 3 keer toe, net zolang totdat hij werkt.
-                trycount++;
-            }
-        }
-
-        private void handleBikeValues(string buffer)
-        {
-            buffer = buffer.TrimEnd('\r');
-            Console.WriteLine(buffer);
-            _bufferIn = buffer.Split('\t');
-            OnIncomingDataEvent(_bufferIn);
-        }
-
-        private bool checkBikeState()
-        {
-            bool success = false;
-            switch(state)
-            {
-                case State.reset:
-                    setCommandMode();
-                    
-                    if(returnData != ReturnData.ERROR)
-                    {
-                        success = true;
-                    }
-                    break;
-                case State.connected:
-                    setCommandMode();                   
-                    success = true;
-                    break;
-                case State.command:
-                    success = true;
-                    break;
-                case State.notConnected:
-                    Console.WriteLine("ERROR: not connected to bike.");
-                    success = false;
-                    break;
-            }
-            return success;
-        }
-
-        public void setCommandMode()
-        {
-            sendData(COMMAND);
-        }
-
-        public void setTime()
-        {
-            if (!checkBikeState())
-                return;
-            sendData(CMD_TIME);
-        }
-
-        public void setDistance()
-        {
-            if (!checkBikeState())
-                return;
-            sendData(CMD_DISTANCE);
-        }
-
-        public void setPower()
-        {
-            if (!checkBikeState())
-                return;
-            sendData(CMD_POWER);
-        }
-
-        public void setEnergy()
-        {
-            if (!checkBikeState())
-                return;
-            sendData(CMD_ENERGY);
-        }
-    }
-}
-
-

+ 1 - 1
Proftaak Remote Healthcare/FietsClientV2/Login.cs

@@ -24,7 +24,7 @@ namespace FietsClientV2
             PasswordBox.Text = "";
 
             //temporary fake login as patient
-            if (false)
+            if (true)
             {
                 PatientForm patientForm = new PatientForm();
                 this.Hide();

+ 342 - 291
Proftaak Remote Healthcare/FietsClientV2/PatientForm.Designer.cs

@@ -28,58 +28,63 @@
         /// </summary>
         private void InitializeComponent()
         {
-            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
-            System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
-            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.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
-            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.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend();
-            System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea10 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Legend legend10 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+            System.Windows.Forms.DataVisualization.Charting.Series series10 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea11 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Legend legend11 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+            System.Windows.Forms.DataVisualization.Charting.Series series11 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea12 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Legend legend12 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+            System.Windows.Forms.DataVisualization.Charting.Series series12 = new System.Windows.Forms.DataVisualization.Charting.Series();
             this.menuStrip1 = new System.Windows.Forms.MenuStrip();
             this.archiefToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.selectSessionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.sESSIONSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.bicycleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.selectPortToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox();
             this.speedBox = new System.Windows.Forms.GroupBox();
             this.speedChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
             this.bpmBox = new System.Windows.Forms.GroupBox();
             this.bpmChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
             this.sessionInfoBox = new System.Windows.Forms.GroupBox();
+            this.label18 = new System.Windows.Forms.Label();
+            this.label17 = new System.Windows.Forms.Label();
+            this.label16 = new System.Windows.Forms.Label();
+            this.label15 = new System.Windows.Forms.Label();
+            this.label14 = new System.Windows.Forms.Label();
+            this.label13 = new System.Windows.Forms.Label();
+            this.label12 = new System.Windows.Forms.Label();
+            this.label11 = new System.Windows.Forms.Label();
+            this.naamLabel = new System.Windows.Forms.Label();
+            this.sessionLabel = new System.Windows.Forms.Label();
+            this.pulseLabel = new System.Windows.Forms.Label();
+            this.rpmLabel = new System.Windows.Forms.Label();
+            this.speedLabel = new System.Windows.Forms.Label();
+            this.distanceLabel = new System.Windows.Forms.Label();
+            this.energyLabel = new System.Windows.Forms.Label();
+            this.timeLabel = new System.Windows.Forms.Label();
+            this.actualPowerLabel = new System.Windows.Forms.Label();
+            this.requestedPowerLabel = new System.Windows.Forms.Label();
+            this.label10 = new System.Windows.Forms.Label();
+            this.label9 = new System.Windows.Forms.Label();
+            this.label8 = new System.Windows.Forms.Label();
+            this.label7 = new System.Windows.Forms.Label();
+            this.label6 = new System.Windows.Forms.Label();
+            this.label5 = new System.Windows.Forms.Label();
+            this.label4 = new System.Windows.Forms.Label();
+            this.label3 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.label1 = new System.Windows.Forms.Label();
             this.rpmBox = new System.Windows.Forms.GroupBox();
             this.rpmChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
             this.chatBox = new System.Windows.Forms.TextBox();
             this.messageBox = new System.Windows.Forms.TextBox();
             this.chatArea = new System.Windows.Forms.GroupBox();
-            this.label1 = new System.Windows.Forms.Label();
-            this.label2 = new System.Windows.Forms.Label();
-            this.label3 = new System.Windows.Forms.Label();
-            this.label4 = new System.Windows.Forms.Label();
-            this.label5 = new System.Windows.Forms.Label();
-            this.label6 = new System.Windows.Forms.Label();
-            this.label7 = new System.Windows.Forms.Label();
-            this.label8 = new System.Windows.Forms.Label();
-            this.label9 = new System.Windows.Forms.Label();
-            this.label10 = new System.Windows.Forms.Label();
-            this.requestedPowerLabel = new System.Windows.Forms.Label();
-            this.actualPowerLabel = new System.Windows.Forms.Label();
-            this.timeLabel = new System.Windows.Forms.Label();
-            this.energyLabel = new System.Windows.Forms.Label();
-            this.distanceLabel = new System.Windows.Forms.Label();
-            this.speedLabel = new System.Windows.Forms.Label();
-            this.rpmLabel = new System.Windows.Forms.Label();
-            this.pulseLabel = new System.Windows.Forms.Label();
-            this.sessionLabel = new System.Windows.Forms.Label();
-            this.naamLabel = new System.Windows.Forms.Label();
-            this.label11 = new System.Windows.Forms.Label();
-            this.label12 = new System.Windows.Forms.Label();
-            this.label13 = new System.Windows.Forms.Label();
-            this.label14 = new System.Windows.Forms.Label();
-            this.label15 = new System.Windows.Forms.Label();
-            this.label16 = new System.Windows.Forms.Label();
-            this.label17 = new System.Windows.Forms.Label();
-            this.label18 = new System.Windows.Forms.Label();
             this.sendButton = new System.Windows.Forms.Button();
+            this.requestDataToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.closePortToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.menuStrip1.SuspendLayout();
             this.speedBox.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.speedChart)).BeginInit();
@@ -94,7 +99,8 @@
             // menuStrip1
             // 
             this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.archiefToolStripMenuItem});
+            this.archiefToolStripMenuItem,
+            this.bicycleToolStripMenuItem});
             this.menuStrip1.Location = new System.Drawing.Point(0, 0);
             this.menuStrip1.Name = "menuStrip1";
             this.menuStrip1.Size = new System.Drawing.Size(1064, 24);
@@ -106,8 +112,8 @@
             this.archiefToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.selectSessionToolStripMenuItem});
             this.archiefToolStripMenuItem.Name = "archiefToolStripMenuItem";
-            this.archiefToolStripMenuItem.Size = new System.Drawing.Size(57, 20);
-            this.archiefToolStripMenuItem.Text = "Archief";
+            this.archiefToolStripMenuItem.Size = new System.Drawing.Size(59, 20);
+            this.archiefToolStripMenuItem.Text = "Archive";
             // 
             // selectSessionToolStripMenuItem
             // 
@@ -123,6 +129,30 @@
             this.sESSIONSToolStripMenuItem.Size = new System.Drawing.Size(125, 22);
             this.sESSIONSToolStripMenuItem.Text = "SESSIONS";
             // 
+            // bicycleToolStripMenuItem
+            // 
+            this.bicycleToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.selectPortToolStripMenuItem});
+            this.bicycleToolStripMenuItem.Name = "bicycleToolStripMenuItem";
+            this.bicycleToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
+            this.bicycleToolStripMenuItem.Text = "Bicycle";
+            // 
+            // selectPortToolStripMenuItem
+            // 
+            this.selectPortToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.toolStripComboBox1,
+            this.requestDataToolStripMenuItem,
+            this.closePortToolStripMenuItem});
+            this.selectPortToolStripMenuItem.Name = "selectPortToolStripMenuItem";
+            this.selectPortToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+            this.selectPortToolStripMenuItem.Text = "Select port";
+            // 
+            // toolStripComboBox1
+            // 
+            this.toolStripComboBox1.Name = "toolStripComboBox1";
+            this.toolStripComboBox1.Size = new System.Drawing.Size(121, 23);
+            this.toolStripComboBox1.Click += new System.EventHandler(this.toolStripComboBox1_Click);
+            // 
             // speedBox
             // 
             this.speedBox.Controls.Add(this.speedChart);
@@ -135,16 +165,16 @@
             // 
             // speedChart
             // 
-            chartArea1.Name = "ChartArea1";
-            this.speedChart.ChartAreas.Add(chartArea1);
-            legend1.Name = "Legend1";
-            this.speedChart.Legends.Add(legend1);
+            chartArea10.Name = "ChartArea1";
+            this.speedChart.ChartAreas.Add(chartArea10);
+            legend10.Name = "Legend1";
+            this.speedChart.Legends.Add(legend10);
             this.speedChart.Location = new System.Drawing.Point(6, 19);
             this.speedChart.Name = "speedChart";
-            series1.ChartArea = "ChartArea1";
-            series1.Legend = "Legend1";
-            series1.Name = "Series1";
-            this.speedChart.Series.Add(series1);
+            series10.ChartArea = "ChartArea1";
+            series10.Legend = "Legend1";
+            series10.Name = "Series1";
+            this.speedChart.Series.Add(series10);
             this.speedChart.Size = new System.Drawing.Size(388, 285);
             this.speedChart.TabIndex = 0;
             this.speedChart.Text = "Speed chart";
@@ -161,16 +191,16 @@
             // 
             // bpmChart
             // 
-            chartArea2.Name = "ChartArea1";
-            this.bpmChart.ChartAreas.Add(chartArea2);
-            legend2.Name = "Legend1";
-            this.bpmChart.Legends.Add(legend2);
+            chartArea11.Name = "ChartArea1";
+            this.bpmChart.ChartAreas.Add(chartArea11);
+            legend11.Name = "Legend1";
+            this.bpmChart.Legends.Add(legend11);
             this.bpmChart.Location = new System.Drawing.Point(6, 19);
             this.bpmChart.Name = "bpmChart";
-            series2.ChartArea = "ChartArea1";
-            series2.Legend = "Legend1";
-            series2.Name = "Series1";
-            this.bpmChart.Series.Add(series2);
+            series11.ChartArea = "ChartArea1";
+            series11.Legend = "Legend1";
+            series11.Name = "Series1";
+            this.bpmChart.Series.Add(series11);
             this.bpmChart.Size = new System.Drawing.Size(388, 285);
             this.bpmChart.TabIndex = 1;
             this.bpmChart.Text = "beats per second";
@@ -212,158 +242,149 @@
             this.sessionInfoBox.TabStop = false;
             this.sessionInfoBox.Text = "Session info:";
             // 
-            // rpmBox
-            // 
-            this.rpmBox.Controls.Add(this.rpmChart);
-            this.rpmBox.Location = new System.Drawing.Point(418, 343);
-            this.rpmBox.Name = "rpmBox";
-            this.rpmBox.Size = new System.Drawing.Size(400, 310);
-            this.rpmBox.TabIndex = 5;
-            this.rpmBox.TabStop = false;
-            this.rpmBox.Text = "Rounds per minute:";
-            // 
-            // rpmChart
+            // label18
             // 
-            chartArea3.Name = "ChartArea1";
-            this.rpmChart.ChartAreas.Add(chartArea3);
-            legend3.Name = "Legend1";
-            this.rpmChart.Legends.Add(legend3);
-            this.rpmChart.Location = new System.Drawing.Point(6, 19);
-            this.rpmChart.Name = "rpmChart";
-            series3.ChartArea = "ChartArea1";
-            series3.Legend = "Legend1";
-            series3.Name = "Series1";
-            this.rpmChart.Series.Add(series3);
-            this.rpmChart.Size = new System.Drawing.Size(388, 285);
-            this.rpmChart.TabIndex = 2;
-            this.rpmChart.Text = "rounds per minute";
+            this.label18.AutoSize = true;
+            this.label18.Location = new System.Drawing.Point(165, 107);
+            this.label18.Name = "label18";
+            this.label18.Size = new System.Drawing.Size(42, 13);
+            this.label18.TabIndex = 27;
+            this.label18.Text = "MM:SS";
             // 
-            // chatBox
+            // label17
             // 
-            this.chatBox.Location = new System.Drawing.Point(0, 19);
-            this.chatBox.Multiline = true;
-            this.chatBox.Name = "chatBox";
-            this.chatBox.ReadOnly = true;
-            this.chatBox.Size = new System.Drawing.Size(228, 546);
-            this.chatBox.TabIndex = 3;
+            this.label17.AutoSize = true;
+            this.label17.Location = new System.Drawing.Point(165, 120);
+            this.label17.Name = "label17";
+            this.label17.Size = new System.Drawing.Size(30, 13);
+            this.label17.TabIndex = 26;
+            this.label17.Text = "Watt";
             // 
-            // messageBox
+            // label16
             // 
-            this.messageBox.Location = new System.Drawing.Point(0, 571);
-            this.messageBox.Name = "messageBox";
-            this.messageBox.Size = new System.Drawing.Size(228, 20);
-            this.messageBox.TabIndex = 6;
+            this.label16.AutoSize = true;
+            this.label16.Location = new System.Drawing.Point(165, 133);
+            this.label16.Name = "label16";
+            this.label16.Size = new System.Drawing.Size(30, 13);
+            this.label16.TabIndex = 25;
+            this.label16.Text = "Watt";
             // 
-            // chatArea
+            // label15
             // 
-            this.chatArea.Controls.Add(this.sendButton);
-            this.chatArea.Controls.Add(this.chatBox);
-            this.chatArea.Controls.Add(this.messageBox);
-            this.chatArea.Location = new System.Drawing.Point(824, 27);
-            this.chatArea.Name = "chatArea";
-            this.chatArea.Size = new System.Drawing.Size(228, 626);
-            this.chatArea.TabIndex = 5;
-            this.chatArea.TabStop = false;
-            this.chatArea.Text = "Chat:";
+            this.label15.AutoSize = true;
+            this.label15.Location = new System.Drawing.Point(165, 94);
+            this.label15.Name = "label15";
+            this.label15.Size = new System.Drawing.Size(30, 13);
+            this.label15.TabIndex = 24;
+            this.label15.Text = "Watt";
             // 
-            // label1
+            // label14
             // 
-            this.label1.AutoSize = true;
-            this.label1.Location = new System.Drawing.Point(6, 16);
-            this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(38, 13);
-            this.label1.TabIndex = 0;
-            this.label1.Text = "Naam:";
+            this.label14.AutoSize = true;
+            this.label14.Location = new System.Drawing.Point(165, 81);
+            this.label14.Name = "label14";
+            this.label14.Size = new System.Drawing.Size(54, 13);
+            this.label14.TabIndex = 23;
+            this.label14.Text = "kilometers";
             // 
-            // label2
+            // label13
             // 
-            this.label2.AutoSize = true;
-            this.label2.Location = new System.Drawing.Point(6, 42);
-            this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(36, 13);
-            this.label2.TabIndex = 1;
-            this.label2.Text = "Pulse:";
+            this.label13.AutoSize = true;
+            this.label13.Location = new System.Drawing.Point(165, 68);
+            this.label13.Name = "label13";
+            this.label13.Size = new System.Drawing.Size(96, 13);
+            this.label13.TabIndex = 22;
+            this.label13.Text = "kilometers per hour";
             // 
-            // label3
+            // label12
             // 
-            this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(6, 29);
-            this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(47, 13);
-            this.label3.TabIndex = 2;
-            this.label3.Text = "Session:";
+            this.label12.AutoSize = true;
+            this.label12.Location = new System.Drawing.Point(165, 55);
+            this.label12.Name = "label12";
+            this.label12.Size = new System.Drawing.Size(91, 13);
+            this.label12.TabIndex = 21;
+            this.label12.Text = "rounds per minute";
             // 
-            // label4
+            // label11
             // 
-            this.label4.AutoSize = true;
-            this.label4.Location = new System.Drawing.Point(6, 55);
-            this.label4.Name = "label4";
-            this.label4.Size = new System.Drawing.Size(34, 13);
-            this.label4.TabIndex = 3;
-            this.label4.Text = "RPM:";
+            this.label11.AutoSize = true;
+            this.label11.Location = new System.Drawing.Point(165, 42);
+            this.label11.Name = "label11";
+            this.label11.Size = new System.Drawing.Size(86, 13);
+            this.label11.TabIndex = 20;
+            this.label11.Text = "Beats per minute";
             // 
-            // label5
+            // naamLabel
             // 
-            this.label5.AutoSize = true;
-            this.label5.Location = new System.Drawing.Point(6, 68);
-            this.label5.Name = "label5";
-            this.label5.Size = new System.Drawing.Size(41, 13);
-            this.label5.TabIndex = 4;
-            this.label5.Text = "Speed:";
+            this.naamLabel.AutoSize = true;
+            this.naamLabel.Location = new System.Drawing.Point(106, 16);
+            this.naamLabel.Name = "naamLabel";
+            this.naamLabel.Size = new System.Drawing.Size(53, 13);
+            this.naamLabel.TabIndex = 19;
+            this.naamLabel.Text = "Unknown";
             // 
-            // label6
+            // sessionLabel
             // 
-            this.label6.AutoSize = true;
-            this.label6.Location = new System.Drawing.Point(6, 81);
-            this.label6.Name = "label6";
-            this.label6.Size = new System.Drawing.Size(52, 13);
-            this.label6.TabIndex = 5;
-            this.label6.Text = "Distance:";
+            this.sessionLabel.AutoSize = true;
+            this.sessionLabel.Location = new System.Drawing.Point(106, 29);
+            this.sessionLabel.Name = "sessionLabel";
+            this.sessionLabel.Size = new System.Drawing.Size(53, 13);
+            this.sessionLabel.TabIndex = 18;
+            this.sessionLabel.Text = "Unknown";
             // 
-            // label7
+            // pulseLabel
             // 
-            this.label7.AutoSize = true;
-            this.label7.Location = new System.Drawing.Point(6, 94);
-            this.label7.Name = "label7";
-            this.label7.Size = new System.Drawing.Size(43, 13);
-            this.label7.TabIndex = 6;
-            this.label7.Text = "Energy:";
+            this.pulseLabel.AutoSize = true;
+            this.pulseLabel.Location = new System.Drawing.Point(106, 42);
+            this.pulseLabel.Name = "pulseLabel";
+            this.pulseLabel.Size = new System.Drawing.Size(53, 13);
+            this.pulseLabel.TabIndex = 17;
+            this.pulseLabel.Text = "Unknown";
             // 
-            // label8
+            // rpmLabel
             // 
-            this.label8.AutoSize = true;
-            this.label8.Location = new System.Drawing.Point(6, 107);
-            this.label8.Name = "label8";
-            this.label8.Size = new System.Drawing.Size(33, 13);
-            this.label8.TabIndex = 7;
-            this.label8.Text = "Time:";
+            this.rpmLabel.AutoSize = true;
+            this.rpmLabel.Location = new System.Drawing.Point(106, 55);
+            this.rpmLabel.Name = "rpmLabel";
+            this.rpmLabel.Size = new System.Drawing.Size(53, 13);
+            this.rpmLabel.TabIndex = 16;
+            this.rpmLabel.Text = "Unknown";
             // 
-            // label9
+            // speedLabel
             // 
-            this.label9.AutoSize = true;
-            this.label9.Location = new System.Drawing.Point(6, 120);
-            this.label9.Name = "label9";
-            this.label9.Size = new System.Drawing.Size(94, 13);
-            this.label9.TabIndex = 8;
-            this.label9.Text = "Requested power:";
+            this.speedLabel.AutoSize = true;
+            this.speedLabel.Location = new System.Drawing.Point(106, 68);
+            this.speedLabel.Name = "speedLabel";
+            this.speedLabel.Size = new System.Drawing.Size(53, 13);
+            this.speedLabel.TabIndex = 15;
+            this.speedLabel.Text = "Unknown";
             // 
-            // label10
+            // distanceLabel
             // 
-            this.label10.AutoSize = true;
-            this.label10.Location = new System.Drawing.Point(6, 133);
-            this.label10.Name = "label10";
-            this.label10.Size = new System.Drawing.Size(69, 13);
-            this.label10.TabIndex = 9;
-            this.label10.Text = "Actual power";
+            this.distanceLabel.AutoSize = true;
+            this.distanceLabel.Location = new System.Drawing.Point(106, 81);
+            this.distanceLabel.Name = "distanceLabel";
+            this.distanceLabel.Size = new System.Drawing.Size(53, 13);
+            this.distanceLabel.TabIndex = 14;
+            this.distanceLabel.Text = "Unknown";
             // 
-            // requestedPowerLabel
+            // energyLabel
             // 
-            this.requestedPowerLabel.AutoSize = true;
-            this.requestedPowerLabel.Location = new System.Drawing.Point(106, 120);
-            this.requestedPowerLabel.Name = "requestedPowerLabel";
-            this.requestedPowerLabel.Size = new System.Drawing.Size(53, 13);
-            this.requestedPowerLabel.TabIndex = 10;
-            this.requestedPowerLabel.Text = "Unknown";
+            this.energyLabel.AutoSize = true;
+            this.energyLabel.Location = new System.Drawing.Point(106, 94);
+            this.energyLabel.Name = "energyLabel";
+            this.energyLabel.Size = new System.Drawing.Size(53, 13);
+            this.energyLabel.TabIndex = 13;
+            this.energyLabel.Text = "Unknown";
+            // 
+            // timeLabel
+            // 
+            this.timeLabel.AutoSize = true;
+            this.timeLabel.Location = new System.Drawing.Point(106, 107);
+            this.timeLabel.Name = "timeLabel";
+            this.timeLabel.Size = new System.Drawing.Size(53, 13);
+            this.timeLabel.TabIndex = 12;
+            this.timeLabel.Text = "Unknown";
             // 
             // actualPowerLabel
             // 
@@ -374,149 +395,158 @@
             this.actualPowerLabel.TabIndex = 11;
             this.actualPowerLabel.Text = "Unknown";
             // 
-            // timeLabel
+            // requestedPowerLabel
             // 
-            this.timeLabel.AutoSize = true;
-            this.timeLabel.Location = new System.Drawing.Point(106, 107);
-            this.timeLabel.Name = "timeLabel";
-            this.timeLabel.Size = new System.Drawing.Size(53, 13);
-            this.timeLabel.TabIndex = 12;
-            this.timeLabel.Text = "Unknown";
+            this.requestedPowerLabel.AutoSize = true;
+            this.requestedPowerLabel.Location = new System.Drawing.Point(106, 120);
+            this.requestedPowerLabel.Name = "requestedPowerLabel";
+            this.requestedPowerLabel.Size = new System.Drawing.Size(53, 13);
+            this.requestedPowerLabel.TabIndex = 10;
+            this.requestedPowerLabel.Text = "Unknown";
             // 
-            // energyLabel
+            // label10
             // 
-            this.energyLabel.AutoSize = true;
-            this.energyLabel.Location = new System.Drawing.Point(106, 94);
-            this.energyLabel.Name = "energyLabel";
-            this.energyLabel.Size = new System.Drawing.Size(53, 13);
-            this.energyLabel.TabIndex = 13;
-            this.energyLabel.Text = "Unknown";
+            this.label10.AutoSize = true;
+            this.label10.Location = new System.Drawing.Point(6, 133);
+            this.label10.Name = "label10";
+            this.label10.Size = new System.Drawing.Size(69, 13);
+            this.label10.TabIndex = 9;
+            this.label10.Text = "Actual power";
             // 
-            // distanceLabel
+            // label9
             // 
-            this.distanceLabel.AutoSize = true;
-            this.distanceLabel.Location = new System.Drawing.Point(106, 81);
-            this.distanceLabel.Name = "distanceLabel";
-            this.distanceLabel.Size = new System.Drawing.Size(53, 13);
-            this.distanceLabel.TabIndex = 14;
-            this.distanceLabel.Text = "Unknown";
+            this.label9.AutoSize = true;
+            this.label9.Location = new System.Drawing.Point(6, 120);
+            this.label9.Name = "label9";
+            this.label9.Size = new System.Drawing.Size(94, 13);
+            this.label9.TabIndex = 8;
+            this.label9.Text = "Requested power:";
             // 
-            // speedLabel
+            // label8
             // 
-            this.speedLabel.AutoSize = true;
-            this.speedLabel.Location = new System.Drawing.Point(106, 68);
-            this.speedLabel.Name = "speedLabel";
-            this.speedLabel.Size = new System.Drawing.Size(53, 13);
-            this.speedLabel.TabIndex = 15;
-            this.speedLabel.Text = "Unknown";
+            this.label8.AutoSize = true;
+            this.label8.Location = new System.Drawing.Point(6, 107);
+            this.label8.Name = "label8";
+            this.label8.Size = new System.Drawing.Size(33, 13);
+            this.label8.TabIndex = 7;
+            this.label8.Text = "Time:";
             // 
-            // rpmLabel
+            // label7
             // 
-            this.rpmLabel.AutoSize = true;
-            this.rpmLabel.Location = new System.Drawing.Point(106, 55);
-            this.rpmLabel.Name = "rpmLabel";
-            this.rpmLabel.Size = new System.Drawing.Size(53, 13);
-            this.rpmLabel.TabIndex = 16;
-            this.rpmLabel.Text = "Unknown";
+            this.label7.AutoSize = true;
+            this.label7.Location = new System.Drawing.Point(6, 94);
+            this.label7.Name = "label7";
+            this.label7.Size = new System.Drawing.Size(43, 13);
+            this.label7.TabIndex = 6;
+            this.label7.Text = "Energy:";
             // 
-            // pulseLabel
+            // label6
             // 
-            this.pulseLabel.AutoSize = true;
-            this.pulseLabel.Location = new System.Drawing.Point(106, 42);
-            this.pulseLabel.Name = "pulseLabel";
-            this.pulseLabel.Size = new System.Drawing.Size(53, 13);
-            this.pulseLabel.TabIndex = 17;
-            this.pulseLabel.Text = "Unknown";
+            this.label6.AutoSize = true;
+            this.label6.Location = new System.Drawing.Point(6, 81);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(52, 13);
+            this.label6.TabIndex = 5;
+            this.label6.Text = "Distance:";
             // 
-            // sessionLabel
+            // label5
             // 
-            this.sessionLabel.AutoSize = true;
-            this.sessionLabel.Location = new System.Drawing.Point(106, 29);
-            this.sessionLabel.Name = "sessionLabel";
-            this.sessionLabel.Size = new System.Drawing.Size(53, 13);
-            this.sessionLabel.TabIndex = 18;
-            this.sessionLabel.Text = "Unknown";
+            this.label5.AutoSize = true;
+            this.label5.Location = new System.Drawing.Point(6, 68);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(41, 13);
+            this.label5.TabIndex = 4;
+            this.label5.Text = "Speed:";
             // 
-            // naamLabel
+            // label4
             // 
-            this.naamLabel.AutoSize = true;
-            this.naamLabel.Location = new System.Drawing.Point(106, 16);
-            this.naamLabel.Name = "naamLabel";
-            this.naamLabel.Size = new System.Drawing.Size(53, 13);
-            this.naamLabel.TabIndex = 19;
-            this.naamLabel.Text = "Unknown";
+            this.label4.AutoSize = true;
+            this.label4.Location = new System.Drawing.Point(6, 55);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(34, 13);
+            this.label4.TabIndex = 3;
+            this.label4.Text = "RPM:";
             // 
-            // label11
+            // label3
             // 
-            this.label11.AutoSize = true;
-            this.label11.Location = new System.Drawing.Point(165, 42);
-            this.label11.Name = "label11";
-            this.label11.Size = new System.Drawing.Size(86, 13);
-            this.label11.TabIndex = 20;
-            this.label11.Text = "Beats per minute";
+            this.label3.AutoSize = true;
+            this.label3.Location = new System.Drawing.Point(6, 29);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(47, 13);
+            this.label3.TabIndex = 2;
+            this.label3.Text = "Session:";
             // 
-            // label12
+            // label2
             // 
-            this.label12.AutoSize = true;
-            this.label12.Location = new System.Drawing.Point(165, 55);
-            this.label12.Name = "label12";
-            this.label12.Size = new System.Drawing.Size(91, 13);
-            this.label12.TabIndex = 21;
-            this.label12.Text = "rounds per minute";
+            this.label2.AutoSize = true;
+            this.label2.Location = new System.Drawing.Point(6, 42);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(36, 13);
+            this.label2.TabIndex = 1;
+            this.label2.Text = "Pulse:";
             // 
-            // label13
+            // label1
             // 
-            this.label13.AutoSize = true;
-            this.label13.Location = new System.Drawing.Point(165, 68);
-            this.label13.Name = "label13";
-            this.label13.Size = new System.Drawing.Size(96, 13);
-            this.label13.TabIndex = 22;
-            this.label13.Text = "kilometers per hour";
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(6, 16);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(38, 13);
+            this.label1.TabIndex = 0;
+            this.label1.Text = "Naam:";
             // 
-            // label14
+            // rpmBox
             // 
-            this.label14.AutoSize = true;
-            this.label14.Location = new System.Drawing.Point(165, 81);
-            this.label14.Name = "label14";
-            this.label14.Size = new System.Drawing.Size(54, 13);
-            this.label14.TabIndex = 23;
-            this.label14.Text = "kilometers";
+            this.rpmBox.Controls.Add(this.rpmChart);
+            this.rpmBox.Location = new System.Drawing.Point(418, 343);
+            this.rpmBox.Name = "rpmBox";
+            this.rpmBox.Size = new System.Drawing.Size(400, 310);
+            this.rpmBox.TabIndex = 5;
+            this.rpmBox.TabStop = false;
+            this.rpmBox.Text = "Rounds per minute:";
             // 
-            // label15
+            // rpmChart
             // 
-            this.label15.AutoSize = true;
-            this.label15.Location = new System.Drawing.Point(165, 94);
-            this.label15.Name = "label15";
-            this.label15.Size = new System.Drawing.Size(30, 13);
-            this.label15.TabIndex = 24;
-            this.label15.Text = "Watt";
+            chartArea12.Name = "ChartArea1";
+            this.rpmChart.ChartAreas.Add(chartArea12);
+            legend12.Name = "Legend1";
+            this.rpmChart.Legends.Add(legend12);
+            this.rpmChart.Location = new System.Drawing.Point(6, 19);
+            this.rpmChart.Name = "rpmChart";
+            series12.ChartArea = "ChartArea1";
+            series12.Legend = "Legend1";
+            series12.Name = "Series1";
+            this.rpmChart.Series.Add(series12);
+            this.rpmChart.Size = new System.Drawing.Size(388, 285);
+            this.rpmChart.TabIndex = 2;
+            this.rpmChart.Text = "rounds per minute";
             // 
-            // label16
+            // chatBox
             // 
-            this.label16.AutoSize = true;
-            this.label16.Location = new System.Drawing.Point(165, 133);
-            this.label16.Name = "label16";
-            this.label16.Size = new System.Drawing.Size(30, 13);
-            this.label16.TabIndex = 25;
-            this.label16.Text = "Watt";
+            this.chatBox.Location = new System.Drawing.Point(0, 19);
+            this.chatBox.Multiline = true;
+            this.chatBox.Name = "chatBox";
+            this.chatBox.ReadOnly = true;
+            this.chatBox.Size = new System.Drawing.Size(228, 546);
+            this.chatBox.TabIndex = 3;
             // 
-            // label17
+            // messageBox
             // 
-            this.label17.AutoSize = true;
-            this.label17.Location = new System.Drawing.Point(165, 120);
-            this.label17.Name = "label17";
-            this.label17.Size = new System.Drawing.Size(30, 13);
-            this.label17.TabIndex = 26;
-            this.label17.Text = "Watt";
+            this.messageBox.Location = new System.Drawing.Point(0, 571);
+            this.messageBox.Name = "messageBox";
+            this.messageBox.Size = new System.Drawing.Size(228, 20);
+            this.messageBox.TabIndex = 6;
             // 
-            // label18
+            // chatArea
             // 
-            this.label18.AutoSize = true;
-            this.label18.Location = new System.Drawing.Point(165, 107);
-            this.label18.Name = "label18";
-            this.label18.Size = new System.Drawing.Size(42, 13);
-            this.label18.TabIndex = 27;
-            this.label18.Text = "MM:SS";
+            this.chatArea.Controls.Add(this.sendButton);
+            this.chatArea.Controls.Add(this.chatBox);
+            this.chatArea.Controls.Add(this.messageBox);
+            this.chatArea.Location = new System.Drawing.Point(824, 27);
+            this.chatArea.Name = "chatArea";
+            this.chatArea.Size = new System.Drawing.Size(228, 626);
+            this.chatArea.TabIndex = 5;
+            this.chatArea.TabStop = false;
+            this.chatArea.Text = "Chat:";
             // 
             // sendButton
             // 
@@ -527,6 +557,22 @@
             this.sendButton.Text = "send";
             this.sendButton.UseVisualStyleBackColor = true;
             // 
+            // requestDataToolStripMenuItem
+            // 
+            this.requestDataToolStripMenuItem.Enabled = false;
+            this.requestDataToolStripMenuItem.Name = "requestDataToolStripMenuItem";
+            this.requestDataToolStripMenuItem.Size = new System.Drawing.Size(181, 22);
+            this.requestDataToolStripMenuItem.Text = "Request data";
+            this.requestDataToolStripMenuItem.Click += new System.EventHandler(this.requestDataToolStripMenuItem_Click);
+            // 
+            // closePortToolStripMenuItem
+            // 
+            this.closePortToolStripMenuItem.Enabled = false;
+            this.closePortToolStripMenuItem.Name = "closePortToolStripMenuItem";
+            this.closePortToolStripMenuItem.Size = new System.Drawing.Size(181, 22);
+            this.closePortToolStripMenuItem.Text = "Close port";
+            this.closePortToolStripMenuItem.Click += new System.EventHandler(this.closePortToolStripMenuItem_Click);
+            // 
             // PatientForm
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -605,6 +651,11 @@
         private System.Windows.Forms.Label label2;
         private System.Windows.Forms.Label label1;
         private System.Windows.Forms.Button sendButton;
+        private System.Windows.Forms.ToolStripMenuItem bicycleToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem selectPortToolStripMenuItem;
+        private System.Windows.Forms.ToolStripComboBox toolStripComboBox1;
+        private System.Windows.Forms.ToolStripMenuItem requestDataToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem closePortToolStripMenuItem;
     }
 }
 

+ 22 - 1
Proftaak Remote Healthcare/FietsClientV2/PatientForm.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
+using System.IO.Ports;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -12,15 +13,35 @@ namespace FietsClientV2
 {
     public partial class PatientForm : Form
     {
+        private PatientModel patienModel;
         public PatientForm()
         {
             InitializeComponent();
+            patienModel = PatientModel.patientModel;
         }
 
         private void Form1_Load(object sender, EventArgs e)
         {
+            string[] ports = SerialPort.GetPortNames();
+            toolStripComboBox1.Items.AddRange(ports);
+        }
+
+        private void toolStripComboBox1_Click(object sender, EventArgs e)
+        {
+            if (!(toolStripComboBox1.Text == ""))
+                patienModel.startComPort(toolStripComboBox1.SelectedItem.ToString());
+            requestDataToolStripMenuItem.Enabled = true;
+            closePortToolStripMenuItem.Enabled = true;
+        }
 
+        private void requestDataToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            patienModel.startAskingData();
+        }
+
+        private void closePortToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            patienModel.closeComPort();
         }
-       
     }
 }

+ 55 - 0
Proftaak Remote Healthcare/FietsClientV2/PatientModel.cs

@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace FietsClientV2
+{
+    class PatientModel
+    {
+        public static PatientModel patientModel { get; private set; } = new PatientModel();
+        private DataHandler dataHandler;
+        private Thread workerThread;
+
+        private PatientModel()
+        {
+            dataHandler = new DataHandler();
+            DataHandler.IncomingDataEvent += HandleBikeData; //initialize event
+        } 
+
+        public void startComPort(string portname)
+        {
+            dataHandler.initComm(portname);
+        }
+
+        public void startAskingData()
+        {
+            workerThread = new Thread(() => workerThreadLoop());
+            workerThread.Start();
+        }
+
+        private void workerThreadLoop()
+        {
+            while (true)
+            {
+                Thread.Sleep(1000);
+                dataHandler.sendData(DataHandler.STATUS);
+            }
+        }
+
+        //event handler
+        private void HandleBikeData(string[] data)
+        {
+            //doe iets ermee...
+        }
+
+        public void closeComPort()
+        {
+            if (workerThread != null)
+                workerThread.Interrupt();
+            dataHandler.closeComm();
+        }
+    }
+}