diff --git a/ErgometerApplication/.vs/ErgometerApplication/v14/.suo b/ErgometerApplication/.vs/ErgometerApplication/v14/.suo
index c31ed23..374aa9f 100644
Binary files a/ErgometerApplication/.vs/ErgometerApplication/v14/.suo and b/ErgometerApplication/.vs/ErgometerApplication/v14/.suo differ
diff --git a/ErgometerApplication/ErgometerApplication.sln b/ErgometerApplication/ErgometerApplication.sln
index 277efd8..5f9e622 100644
--- a/ErgometerApplication/ErgometerApplication.sln
+++ b/ErgometerApplication/ErgometerApplication.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
-VisualStudioVersion = 14.0.23107.0
+VisualStudioVersion = 14.0.22823.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ErgometerApplication", "ErgometerApplication\ErgometerApplication.csproj", "{1191E100-AA1B-4F41-85E2-EC2BE8ED39FD}"
EndProject
diff --git a/ErgometerApplication/ErgometerApplication/ClientApplicatie.Designer.cs b/ErgometerApplication/ErgometerApplication/ClientApplicatie.Designer.cs
new file mode 100644
index 0000000..3c48df2
--- /dev/null
+++ b/ErgometerApplication/ErgometerApplication/ClientApplicatie.Designer.cs
@@ -0,0 +1,102 @@
+using System.IO.Ports;
+
+namespace ErgometerApplication
+{
+ partial class ClientApplicatie
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.updateTimer = new System.Windows.Forms.Timer(this.components);
+ this.writeTimer = new System.Windows.Forms.Timer(this.components);
+ this.panelLogin = new System.Windows.Forms.Panel();
+ this.lblUsername = new System.Windows.Forms.Label();
+ this.lblPassword = new System.Windows.Forms.Label();
+ this.panelLogin.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // updateTimer
+ //
+ this.updateTimer.Interval = 1500;
+ //
+ // writeTimer
+ //
+ this.writeTimer.Interval = 10000;
+ //
+ // panelLogin
+ //
+ this.panelLogin.Controls.Add(this.lblUsername);
+ this.panelLogin.Controls.Add(this.lblPassword);
+ this.panelLogin.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.panelLogin.Location = new System.Drawing.Point(0, 0);
+ this.panelLogin.Name = "panelLogin";
+ this.panelLogin.Size = new System.Drawing.Size(800, 600);
+ this.panelLogin.TabIndex = 0;
+ //
+ // lblUsername
+ //
+ this.lblUsername.Anchor = System.Windows.Forms.AnchorStyles.None;
+ this.lblUsername.AutoSize = true;
+ this.lblUsername.Location = new System.Drawing.Point(243, 255);
+ this.lblUsername.Name = "lblUsername";
+ this.lblUsername.Size = new System.Drawing.Size(84, 13);
+ this.lblUsername.TabIndex = 1;
+ this.lblUsername.Text = "Gebruikersnaam";
+ //
+ // lblPassword
+ //
+ this.lblPassword.Anchor = System.Windows.Forms.AnchorStyles.None;
+ this.lblPassword.AutoSize = true;
+ this.lblPassword.Location = new System.Drawing.Point(243, 291);
+ this.lblPassword.Name = "lblPassword";
+ this.lblPassword.Size = new System.Drawing.Size(68, 13);
+ this.lblPassword.TabIndex = 0;
+ this.lblPassword.Text = "Wachtwoord";
+ //
+ // ClientApplicatie
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 600);
+ this.Controls.Add(this.panelLogin);
+ this.Name = "ClientApplicatie";
+ this.Text = "Client Applicatie";
+ this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
+ this.panelLogin.ResumeLayout(false);
+ this.panelLogin.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+ private System.Windows.Forms.Timer updateTimer;
+ private System.Windows.Forms.Timer writeTimer;
+ private System.Windows.Forms.Panel panelLogin;
+ private System.Windows.Forms.Label lblUsername;
+ private System.Windows.Forms.Label lblPassword;
+ }
+}
diff --git a/ErgometerApplication/ErgometerApplication/ClientApplicatie.cs b/ErgometerApplication/ErgometerApplication/ClientApplicatie.cs
new file mode 100644
index 0000000..74e65a6
--- /dev/null
+++ b/ErgometerApplication/ErgometerApplication/ClientApplicatie.cs
@@ -0,0 +1,282 @@
+using System;
+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;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using Newtonsoft.Json;
+using System.IO;
+//using ErgometerLibrary;
+using System.Net.Sockets;
+using System.Net;
+using System.Timers;
+
+namespace ErgometerApplication
+{
+ public partial class ClientApplicatie : Form
+ {
+ //private ComPort comPort;
+ //private List _data;
+ //private int i = 0;
+ //NetCommand command;
+ //private ServerCommunicator communicator = new ServerCommunicator();
+ //List readFile = new List();
+ public ClientApplicatie()
+ {
+ InitializeComponent();
+ // comPort = new ComPort();
+ // _data = new List();
+ // communicator.data = _data;
+ }
+
+ //private void connectButton_Click(object sender, EventArgs e)
+ //{
+ // if (!comPort.IsOpen())
+ // {
+ // if (comPort.Connect(ComPortBox.Text))
+ // {
+ // connectButton.Text = "Disconnect";
+ // statusButton.Enabled = true;
+ // resetButton.Enabled = true;
+ // timerStatus.Enabled = true;
+ // inputTextBox.Enabled = true;
+ // timeButton.Enabled = true;
+ // distanceButton.Enabled = true;
+ // powerButton.Enabled = true;
+ // energyButton.Enabled = true;
+ // ComPortBox.Enabled = false;
+
+ // comPort.Write("RS");
+ // comPort.Read();
+ // Thread.Sleep(200);
+ // comPort.Write("CM");
+ // comPort.Read();
+ // Thread.Sleep(200);
+
+ // comPort.Write("ST");
+ // string response = comPort.Read();
+ // Console.WriteLine(response);
+
+ // Meting m = Meting.Parse(response);
+ // SaveData(m);
+ // // richTextBox1.Text = m.ToString();
+ // }
+ // }
+ // else
+ // {
+ // if (comPort.Disconnect())
+ // {
+ // connectButton.Text = "Connect";
+ // timerStatus.Checked = false;
+ // statusButton.Enabled = false;
+ // resetButton.Enabled = false;
+ // timerStatus.Enabled = false;
+ // inputTextBox.Enabled = false;
+ // timeButton.Enabled = false;
+ // distanceButton.Enabled = false;
+ // powerButton.Enabled = false;
+ // energyButton.Enabled = false;
+ // ComPortBox.Enabled = true;
+ // richTextBox1.Text = "";
+
+ // WriteFile();
+
+ // }
+ // }
+ // communicator.client = new TcpClient();
+ // communicator.client.Connect("127.0.0.1", 8888);
+ // Thread thread = new Thread(ServerCommunication);
+ // thread.Start(communicator);
+ //}
+
+ //private void statusButton_Click(object sender, EventArgs e)
+ //{
+ // comPort.Write("ST");
+ // string response = comPort.Read();
+ // Console.WriteLine(response);
+ // Meting m = Meting.Parse(response, '\t');
+ // Console.WriteLine(m);
+ // SaveData(m);
+ // communicator.data.Add(m);
+ // command = new NetCommand(m, communicator.sessionId);
+ // NetHelper.SendNetCommand(communicator.client, command);
+ // richTextBox1.Text = m.ToString();
+ // WriteFile();
+ //}
+
+ //static void ServerCommunication(object obj)
+ //{
+ // ServerCommunicator communicator = obj as ServerCommunicator;
+
+ // NetCommand net = NetHelper.ReadNetCommand(communicator.client);
+ // if (net.Type == NetCommand.CommandType.SESSION)
+ // communicator.sessionId = net.Session;
+
+ // NetCommand command = new NetCommand("name", false, "pass", communicator.sessionId);
+ // NetHelper.SendNetCommand(communicator.client, command);
+ //}
+
+ //private void resetButton_Click(object sender, EventArgs e)
+ //{
+ // comPort.Write("RS");
+ // comPort.Read();
+ // Thread.Sleep(200);
+ // comPort.Write("CM");
+ // comPort.Read();
+ //}
+
+ //private void updateTimer_Tick(object sender, EventArgs e)
+ //{
+ // if (timerStatus.Checked)
+ // {
+ // comPort.Write("ST");
+ // string response = comPort.Read();
+ // Console.WriteLine(response);
+ // Meting m = Meting.Parse(response);
+ // SaveData(m);
+ // communicator.data.Add(m);
+ // command = new NetCommand(m, communicator.sessionId);
+ // NetHelper.SendNetCommand(communicator.client, command);
+ // richTextBox1.Text = m.ToString();
+ // command = new NetCommand(communicator.data[0], communicator.sessionId);
+ // NetHelper.SendNetCommand(communicator.client, command);
+ // }
+ //}
+
+ //private void timeButton_Click(object sender, EventArgs e)
+ //{
+ // comPort.Write("RS");
+ // comPort.Read();
+ // Thread.Sleep(200);
+ // string[] temp = inputTextBox.Text.Split(':');
+ // comPort.Write("PT " + temp[0] + temp[1]);
+ // Console.WriteLine("PT " + temp[0] + temp[1]);
+ // inputTextBox.Text = "";
+ // comPort.Read();
+ //}
+
+ //private void distanceButton_Click(object sender, EventArgs e)
+ //{
+ // comPort.Write("RS");
+ // comPort.Read();
+ // Thread.Sleep(200);
+ // int temp = int.Parse(inputTextBox.Text);
+ // comPort.Write("PD " + temp.ToString());
+ // inputTextBox.Text = "";
+ // comPort.Read();
+ //}
+
+ //private void powerButton_Click(object sender, EventArgs e)
+ //{
+ // int temp = int.Parse(inputTextBox.Text);
+ // comPort.Write("PW " + temp.ToString());
+ // inputTextBox.Text = "";
+ // comPort.Read();
+ //}
+
+ //private void energyButton_Click(object sender, EventArgs e)
+ //{
+ // comPort.Write("RS");
+ // comPort.Read();
+ // Thread.Sleep(200);
+ // int temp = int.Parse(inputTextBox.Text);
+ // comPort.Write("PE " + temp.ToString());
+ // inputTextBox.Text = "";
+ // comPort.Read();
+ //}
+
+ //private void timerStatus_CheckedChanged(object sender, EventArgs e)
+ //{
+ // if (timerStatus.Checked)
+ // {
+ // statusButton.Enabled = false;
+ // updateTimer.Start();
+ // writeTimer.Start();
+ // }
+ // else
+ // {
+ // statusButton.Enabled = true;
+ // updateTimer.Stop();
+ // writeTimer.Stop();
+ // }
+ //}
+
+ //private void readButton_Click(object sender, EventArgs e)
+ //{
+ // ReadFile();
+ // if (readFile != null)
+ // {
+ // metingNextButton.Enabled = true;
+ // metingBackButton.Enabled = true;
+ // }
+
+ //}
+
+ //private void metingBackButton_Click(object sender, EventArgs e)
+ //{
+ // if (i > 0)
+ // { i--;
+ // metingNextButton.Enabled = true;
+ // }
+ // if (i == 0)
+ // {
+ // metingBackButton.Enabled = false;
+ // }
+ // richTextBox1.Text = readFile.ElementAt(i).ToString();
+ //}
+
+ //private void metingNextButton_Click(object sender, EventArgs e)
+ //{
+ // if (i < (readFile.Count - 1))
+ // { i++;
+ // metingBackButton.Enabled = true;
+ // }
+ // if (i == (readFile.Count - 1))
+ // {
+ // metingNextButton.Enabled = false;
+ // }
+ // richTextBox1.Text = readFile.ElementAt(i).ToString();
+ //}
+
+ //private void writeTimer_Tick(object sender, EventArgs e)
+ //{
+ // WriteFile();
+ //}
+
+
+ //private void WriteFile()
+ //{
+ // string json = Newtonsoft.Json.JsonConvert.SerializeObject(_data);
+ // string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ErgometerSessionData.ergo");
+ // System.IO.File.WriteAllText(path, json);
+ // Console.WriteLine("Writing file: " + path);
+ //}
+
+ //private void SaveData(Meting meting)
+ //{
+ // _data.Add(meting);
+ //}
+
+ //private void ReadFile()
+ //{
+ // string path;
+ // OpenFileDialog file = new OpenFileDialog();
+ // file.Filter = "Ergometer files(*.ergo) | *.ergo | All files(*.*) | *.*";
+ // if (file.ShowDialog() == DialogResult.OK)
+ // {
+ // path = file.FileName;
+ // readFile = Newtonsoft.Json.JsonConvert.DeserializeObject>(System.IO.File.ReadAllText(path));
+ // richTextBox1.Text = readFile.ElementAt(i).ToString();
+ // }
+ // else
+ // {
+ // readFile = null;
+ // }
+ //}
+ }
+}
\ No newline at end of file
diff --git a/ErgometerApplication/ErgometerApplication/Ergometer.resx b/ErgometerApplication/ErgometerApplication/ClientApplicatie.resx
similarity index 94%
rename from ErgometerApplication/ErgometerApplication/Ergometer.resx
rename to ErgometerApplication/ErgometerApplication/ClientApplicatie.resx
index 5223d06..29ee7eb 100644
--- a/ErgometerApplication/ErgometerApplication/Ergometer.resx
+++ b/ErgometerApplication/ErgometerApplication/ClientApplicatie.resx
@@ -123,10 +123,7 @@
147, 19
-
- 276, 19
-
-
- 377, 19
+
+ 25
\ No newline at end of file
diff --git a/ErgometerApplication/ErgometerApplication/DataSaving.cs b/ErgometerApplication/ErgometerApplication/DataSaving.cs
index 87c02ab..7bdb2fb 100644
--- a/ErgometerApplication/ErgometerApplication/DataSaving.cs
+++ b/ErgometerApplication/ErgometerApplication/DataSaving.cs
@@ -5,41 +5,41 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
-using ErgometerLibrary;
+//using ErgometerLibrary;
namespace ErgometerApplication
{
class DataSaving
{
- List local_data = null;
- private List ReadFile()
- {
- string path;
- OpenFileDialog file = new OpenFileDialog();
- file.Filter = "Ergometer files(*.ergo) | *.ergo | All files(*.*) | *.*";
- if (file.ShowDialog() == DialogResult.OK)
- {
- path = file.FileName;
- List readFile = Newtonsoft.Json.JsonConvert.DeserializeObject>(System.IO.File.ReadAllText(path));
- return readFile;
- }
- else
- {
- return null;
- }
- }
- private List SaveData(Meting meting, List _data)
- {
- List local_data = _data;
- local_data.Add(meting);
- return local_data;
- }
- private void WriteFile(List _data)
- {
- string json = Newtonsoft.Json.JsonConvert.SerializeObject(_data);
- string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ErgometerSessionData.ergo");
- System.IO.File.WriteAllText(path, json);
- Console.WriteLine("Writing file: " + path);
- }
+ //List local_data = null;
+ //private List ReadFile()
+ //{
+ // string path;
+ // OpenFileDialog file = new OpenFileDialog();
+ // file.Filter = "Ergometer files(*.ergo) | *.ergo | All files(*.*) | *.*";
+ // if (file.ShowDialog() == DialogResult.OK)
+ // {
+ // path = file.FileName;
+ // List readFile = Newtonsoft.Json.JsonConvert.DeserializeObject>(System.IO.File.ReadAllText(path));
+ // return readFile;
+ // }
+ // else
+ // {
+ // return null;
+ // }
+ //}
+ //private List SaveData(Meting meting, List _data)
+ //{
+ // List local_data = _data;
+ // local_data.Add(meting);
+ // return local_data;
+ //}
+ //private void WriteFile(List _data)
+ //{
+ // string json = Newtonsoft.Json.JsonConvert.SerializeObject(_data);
+ // string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ErgometerSessionData.ergo");
+ // System.IO.File.WriteAllText(path, json);
+ // Console.WriteLine("Writing file: " + path);
+ //}
}
diff --git a/ErgometerApplication/ErgometerApplication/Ergometer.Designer.cs b/ErgometerApplication/ErgometerApplication/Ergometer.Designer.cs
deleted file mode 100644
index f1dc963..0000000
--- a/ErgometerApplication/ErgometerApplication/Ergometer.Designer.cs
+++ /dev/null
@@ -1,270 +0,0 @@
-using System.IO.Ports;
-
-namespace ErgometerApplication
-{
- partial class Ergometer
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.richTextBox1 = new System.Windows.Forms.RichTextBox();
- this.connectButton = new System.Windows.Forms.Button();
- this.ComPortBox = new System.Windows.Forms.ComboBox();
- this.statusButton = new System.Windows.Forms.Button();
- this.resetButton = new System.Windows.Forms.Button();
- this.updateTimer = new System.Windows.Forms.Timer(this.components);
- this.timerStatus = new System.Windows.Forms.CheckBox();
- this.powerButton = new System.Windows.Forms.Button();
- this.timeButton = new System.Windows.Forms.Button();
- this.energyButton = new System.Windows.Forms.Button();
- this.distanceButton = new System.Windows.Forms.Button();
- this.writeTimer = new System.Windows.Forms.Timer(this.components);
- this.metingNextButton = new System.Windows.Forms.Button();
- this.metingBackButton = new System.Windows.Forms.Button();
- this.readButton = new System.Windows.Forms.Button();
- this.inputTextBox = new System.Windows.Forms.MaskedTextBox();
- this.SuspendLayout();
- //
- // richTextBox1
- //
- this.richTextBox1.Location = new System.Drawing.Point(13, 42);
- this.richTextBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.richTextBox1.Name = "richTextBox1";
- this.richTextBox1.ReadOnly = true;
- this.richTextBox1.Size = new System.Drawing.Size(203, 243);
- this.richTextBox1.TabIndex = 0;
- this.richTextBox1.Text = "";
- //
- // connectButton
- //
- this.connectButton.Location = new System.Drawing.Point(115, 290);
- this.connectButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.connectButton.Name = "connectButton";
- this.connectButton.Size = new System.Drawing.Size(101, 26);
- this.connectButton.TabIndex = 1;
- this.connectButton.Text = "Connect";
- this.connectButton.UseVisualStyleBackColor = true;
- this.connectButton.Click += new System.EventHandler(this.connectButton_Click);
- //
- // ComPortBox
- //
- this.ComPortBox.FormattingEnabled = true;
- this.ComPortBox.Items.AddRange(SerialPort.GetPortNames());
- this.ComPortBox.Location = new System.Drawing.Point(12, 290);
- this.ComPortBox.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.ComPortBox.Name = "ComPortBox";
- this.ComPortBox.Size = new System.Drawing.Size(97, 24);
- this.ComPortBox.TabIndex = 11;
- //
- // statusButton
- //
- this.statusButton.Enabled = false;
- this.statusButton.Location = new System.Drawing.Point(127, 12);
- this.statusButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.statusButton.Name = "statusButton";
- this.statusButton.Size = new System.Drawing.Size(89, 26);
- this.statusButton.TabIndex = 3;
- this.statusButton.Text = "Status";
- this.statusButton.UseVisualStyleBackColor = true;
- this.statusButton.Click += new System.EventHandler(this.statusButton_Click);
- //
- // resetButton
- //
- this.resetButton.Enabled = false;
- this.resetButton.Location = new System.Drawing.Point(12, 12);
- this.resetButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.resetButton.Name = "resetButton";
- this.resetButton.Size = new System.Drawing.Size(97, 26);
- this.resetButton.TabIndex = 4;
- this.resetButton.Text = "Reset";
- this.resetButton.UseVisualStyleBackColor = true;
- this.resetButton.Click += new System.EventHandler(this.resetButton_Click);
- //
- // updateTimer
- //
- this.updateTimer.Interval = 1500;
- this.updateTimer.Tick += new System.EventHandler(this.updateTimer_Tick);
- //
- // timerStatus
- //
- this.timerStatus.AutoSize = true;
- this.timerStatus.Enabled = false;
- this.timerStatus.Location = new System.Drawing.Point(223, 12);
- this.timerStatus.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.timerStatus.Name = "timerStatus";
- this.timerStatus.Size = new System.Drawing.Size(113, 21);
- this.timerStatus.TabIndex = 5;
- this.timerStatus.Text = "Auto Refresh";
- this.timerStatus.UseVisualStyleBackColor = true;
- this.timerStatus.CheckedChanged += new System.EventHandler(this.timerStatus_CheckedChanged);
- //
- // powerButton
- //
- this.powerButton.Enabled = false;
- this.powerButton.Location = new System.Drawing.Point(223, 134);
- this.powerButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.powerButton.Name = "powerButton";
- this.powerButton.Size = new System.Drawing.Size(113, 26);
- this.powerButton.TabIndex = 7;
- this.powerButton.Text = "Set Power";
- this.powerButton.UseVisualStyleBackColor = true;
- this.powerButton.Click += new System.EventHandler(this.powerButton_Click);
- //
- // timeButton
- //
- this.timeButton.Enabled = false;
- this.timeButton.Location = new System.Drawing.Point(223, 70);
- this.timeButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.timeButton.Name = "timeButton";
- this.timeButton.Size = new System.Drawing.Size(113, 26);
- this.timeButton.TabIndex = 8;
- this.timeButton.Text = "Set Time";
- this.timeButton.UseVisualStyleBackColor = true;
- this.timeButton.Click += new System.EventHandler(this.timeButton_Click);
- //
- // energyButton
- //
- this.energyButton.Enabled = false;
- this.energyButton.Location = new System.Drawing.Point(223, 166);
- this.energyButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.energyButton.Name = "energyButton";
- this.energyButton.Size = new System.Drawing.Size(113, 26);
- this.energyButton.TabIndex = 9;
- this.energyButton.Text = "Set Energy";
- this.energyButton.UseVisualStyleBackColor = true;
- this.energyButton.Click += new System.EventHandler(this.energyButton_Click);
- //
- // distanceButton
- //
- this.distanceButton.Enabled = false;
- this.distanceButton.Location = new System.Drawing.Point(223, 102);
- this.distanceButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.distanceButton.Name = "distanceButton";
- this.distanceButton.Size = new System.Drawing.Size(113, 26);
- this.distanceButton.TabIndex = 10;
- this.distanceButton.Text = "Set Distance";
- this.distanceButton.UseVisualStyleBackColor = true;
- this.distanceButton.Click += new System.EventHandler(this.distanceButton_Click);
- //
- // writeTimer
- //
- this.writeTimer.Interval = 10000;
- this.writeTimer.Tick += new System.EventHandler(this.writeTimer_Tick);
- //
- // metingNextButton
- //
- this.metingNextButton.Enabled = false;
- this.metingNextButton.Location = new System.Drawing.Point(223, 289);
- this.metingNextButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.metingNextButton.Name = "metingNextButton";
- this.metingNextButton.Size = new System.Drawing.Size(113, 26);
- this.metingNextButton.TabIndex = 16;
- this.metingNextButton.Text = "Next ->";
- this.metingNextButton.UseVisualStyleBackColor = true;
- this.metingNextButton.Click += new System.EventHandler(this.metingNextButton_Click);
- //
- // metingBackButton
- //
- this.metingBackButton.Enabled = false;
- this.metingBackButton.Location = new System.Drawing.Point(223, 258);
- this.metingBackButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.metingBackButton.Name = "metingBackButton";
- this.metingBackButton.Size = new System.Drawing.Size(113, 26);
- this.metingBackButton.TabIndex = 15;
- this.metingBackButton.Text = "<- Back";
- this.metingBackButton.UseVisualStyleBackColor = true;
- this.metingBackButton.Click += new System.EventHandler(this.metingBackButton_Click);
- //
- // readButton
- //
- this.readButton.Location = new System.Drawing.Point(223, 228);
- this.readButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.readButton.Name = "readButton";
- this.readButton.Size = new System.Drawing.Size(113, 26);
- this.readButton.TabIndex = 17;
- this.readButton.Text = "Read File";
- this.readButton.UseVisualStyleBackColor = true;
- this.readButton.Click += new System.EventHandler(this.readButton_Click);
- //
- // inputTextBox
- //
- this.inputTextBox.Location = new System.Drawing.Point(223, 43);
- this.inputTextBox.Mask = "0L0L0L0";
- this.inputTextBox.Name = "inputTextBox";
- this.inputTextBox.Size = new System.Drawing.Size(106, 22);
- this.inputTextBox.TabIndex = 18;
- this.inputTextBox.ValidatingType = typeof(int);
- //
- // Ergometer
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(351, 326);
- this.Controls.Add(this.inputTextBox);
- this.Controls.Add(this.readButton);
- this.Controls.Add(this.metingNextButton);
- this.Controls.Add(this.metingBackButton);
- this.Controls.Add(this.distanceButton);
- this.Controls.Add(this.energyButton);
- this.Controls.Add(this.timeButton);
- this.Controls.Add(this.powerButton);
- this.Controls.Add(this.timerStatus);
- this.Controls.Add(this.resetButton);
- this.Controls.Add(this.statusButton);
- this.Controls.Add(this.ComPortBox);
- this.Controls.Add(this.connectButton);
- this.Controls.Add(this.richTextBox1);
- this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.MaximumSize = new System.Drawing.Size(369, 373);
- this.MinimumSize = new System.Drawing.Size(369, 373);
- this.Name = "Ergometer";
- this.Text = "Ergometer";
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.RichTextBox richTextBox1;
- private System.Windows.Forms.Button connectButton;
- private System.Windows.Forms.ComboBox ComPortBox;
- private System.Windows.Forms.Button statusButton;
- private System.Windows.Forms.Button resetButton;
- private System.Windows.Forms.Timer updateTimer;
- private System.Windows.Forms.CheckBox timerStatus;
- private System.Windows.Forms.Button powerButton;
- private System.Windows.Forms.Button timeButton;
- private System.Windows.Forms.Button energyButton;
- private System.Windows.Forms.Button distanceButton;
- private System.Windows.Forms.Timer writeTimer;
- private System.Windows.Forms.Button metingNextButton;
- private System.Windows.Forms.Button metingBackButton;
- private System.Windows.Forms.Button readButton;
- private System.Windows.Forms.MaskedTextBox inputTextBox;
- }
-}
diff --git a/ErgometerApplication/ErgometerApplication/Ergometer.cs b/ErgometerApplication/ErgometerApplication/Ergometer.cs
deleted file mode 100644
index 0afecb6..0000000
--- a/ErgometerApplication/ErgometerApplication/Ergometer.cs
+++ /dev/null
@@ -1,282 +0,0 @@
-using System;
-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;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using Newtonsoft.Json;
-using System.IO;
-using ErgometerLibrary;
-using System.Net.Sockets;
-using System.Net;
-using System.Timers;
-
-namespace ErgometerApplication
-{
- public partial class Ergometer : Form
- {
- private ComPort comPort;
- private List _data;
- private int i = 0;
- NetCommand command;
- private ServerCommunicator communicator = new ServerCommunicator();
- List readFile = new List();
- public Ergometer()
- {
- InitializeComponent();
- comPort = new ComPort();
- _data = new List();
- communicator.data = _data;
- }
-
- private void connectButton_Click(object sender, EventArgs e)
- {
- if (!comPort.IsOpen())
- {
- if (comPort.Connect(ComPortBox.Text))
- {
- connectButton.Text = "Disconnect";
- statusButton.Enabled = true;
- resetButton.Enabled = true;
- timerStatus.Enabled = true;
- inputTextBox.Enabled = true;
- timeButton.Enabled = true;
- distanceButton.Enabled = true;
- powerButton.Enabled = true;
- energyButton.Enabled = true;
- ComPortBox.Enabled = false;
-
- comPort.Write("RS");
- comPort.Read();
- Thread.Sleep(200);
- comPort.Write("CM");
- comPort.Read();
- Thread.Sleep(200);
-
- comPort.Write("ST");
- string response = comPort.Read();
- Console.WriteLine(response);
-
- Meting m = Meting.Parse(response);
- SaveData(m);
- // richTextBox1.Text = m.ToString();
- }
- }
- else
- {
- if (comPort.Disconnect())
- {
- connectButton.Text = "Connect";
- timerStatus.Checked = false;
- statusButton.Enabled = false;
- resetButton.Enabled = false;
- timerStatus.Enabled = false;
- inputTextBox.Enabled = false;
- timeButton.Enabled = false;
- distanceButton.Enabled = false;
- powerButton.Enabled = false;
- energyButton.Enabled = false;
- ComPortBox.Enabled = true;
- richTextBox1.Text = "";
-
- WriteFile();
-
- }
- }
- communicator.client = new TcpClient();
- communicator.client.Connect("127.0.0.1", 8888);
- Thread thread = new Thread(ServerCommunication);
- thread.Start(communicator);
- }
-
- private void statusButton_Click(object sender, EventArgs e)
- {
- comPort.Write("ST");
- string response = comPort.Read();
- Console.WriteLine(response);
- Meting m = Meting.Parse(response, '\t');
- Console.WriteLine(m);
- SaveData(m);
- communicator.data.Add(m);
- command = new NetCommand(m, communicator.sessionId);
- NetHelper.SendNetCommand(communicator.client, command);
- richTextBox1.Text = m.ToString();
- WriteFile();
- }
-
- static void ServerCommunication(object obj)
- {
- ServerCommunicator communicator = obj as ServerCommunicator;
-
- NetCommand net = NetHelper.ReadNetCommand(communicator.client);
- if (net.Type == NetCommand.CommandType.SESSION)
- communicator.sessionId = net.Session;
-
- NetCommand command = new NetCommand("name", false, "pass", communicator.sessionId);
- NetHelper.SendNetCommand(communicator.client, command);
- }
-
- private void resetButton_Click(object sender, EventArgs e)
- {
- comPort.Write("RS");
- comPort.Read();
- Thread.Sleep(200);
- comPort.Write("CM");
- comPort.Read();
- }
-
- private void updateTimer_Tick(object sender, EventArgs e)
- {
- if (timerStatus.Checked)
- {
- comPort.Write("ST");
- string response = comPort.Read();
- Console.WriteLine(response);
- Meting m = Meting.Parse(response);
- SaveData(m);
- communicator.data.Add(m);
- command = new NetCommand(m, communicator.sessionId);
- NetHelper.SendNetCommand(communicator.client, command);
- richTextBox1.Text = m.ToString();
- command = new NetCommand(communicator.data[0], communicator.sessionId);
- NetHelper.SendNetCommand(communicator.client, command);
- }
- }
-
- private void timeButton_Click(object sender, EventArgs e)
- {
- comPort.Write("RS");
- comPort.Read();
- Thread.Sleep(200);
- string[] temp = inputTextBox.Text.Split(':');
- comPort.Write("PT " + temp[0] + temp[1]);
- Console.WriteLine("PT " + temp[0] + temp[1]);
- inputTextBox.Text = "";
- comPort.Read();
- }
-
- private void distanceButton_Click(object sender, EventArgs e)
- {
- comPort.Write("RS");
- comPort.Read();
- Thread.Sleep(200);
- int temp = int.Parse(inputTextBox.Text);
- comPort.Write("PD " + temp.ToString());
- inputTextBox.Text = "";
- comPort.Read();
- }
-
- private void powerButton_Click(object sender, EventArgs e)
- {
- int temp = int.Parse(inputTextBox.Text);
- comPort.Write("PW " + temp.ToString());
- inputTextBox.Text = "";
- comPort.Read();
- }
-
- private void energyButton_Click(object sender, EventArgs e)
- {
- comPort.Write("RS");
- comPort.Read();
- Thread.Sleep(200);
- int temp = int.Parse(inputTextBox.Text);
- comPort.Write("PE " + temp.ToString());
- inputTextBox.Text = "";
- comPort.Read();
- }
-
- private void timerStatus_CheckedChanged(object sender, EventArgs e)
- {
- if (timerStatus.Checked)
- {
- statusButton.Enabled = false;
- updateTimer.Start();
- writeTimer.Start();
- }
- else
- {
- statusButton.Enabled = true;
- updateTimer.Stop();
- writeTimer.Stop();
- }
- }
-
- private void readButton_Click(object sender, EventArgs e)
- {
- ReadFile();
- if (readFile != null)
- {
- metingNextButton.Enabled = true;
- metingBackButton.Enabled = true;
- }
-
- }
-
- private void metingBackButton_Click(object sender, EventArgs e)
- {
- if (i > 0)
- { i--;
- metingNextButton.Enabled = true;
- }
- if (i == 0)
- {
- metingBackButton.Enabled = false;
- }
- richTextBox1.Text = readFile.ElementAt(i).ToString();
- }
-
- private void metingNextButton_Click(object sender, EventArgs e)
- {
- if (i < (readFile.Count - 1))
- { i++;
- metingBackButton.Enabled = true;
- }
- if (i == (readFile.Count - 1))
- {
- metingNextButton.Enabled = false;
- }
- richTextBox1.Text = readFile.ElementAt(i).ToString();
- }
-
- private void writeTimer_Tick(object sender, EventArgs e)
- {
- WriteFile();
- }
-
-
- private void WriteFile()
- {
- string json = Newtonsoft.Json.JsonConvert.SerializeObject(_data);
- string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ErgometerSessionData.ergo");
- System.IO.File.WriteAllText(path, json);
- Console.WriteLine("Writing file: " + path);
- }
-
- private void SaveData(Meting meting)
- {
- _data.Add(meting);
- }
-
- private void ReadFile()
- {
- string path;
- OpenFileDialog file = new OpenFileDialog();
- file.Filter = "Ergometer files(*.ergo) | *.ergo | All files(*.*) | *.*";
- if (file.ShowDialog() == DialogResult.OK)
- {
- path = file.FileName;
- readFile = Newtonsoft.Json.JsonConvert.DeserializeObject>(System.IO.File.ReadAllText(path));
- richTextBox1.Text = readFile.ElementAt(i).ToString();
- }
- else
- {
- readFile = null;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ErgometerApplication/ErgometerApplication/ErgometerApplication.csproj b/ErgometerApplication/ErgometerApplication/ErgometerApplication.csproj
index c9b18b6..3ccd635 100644
--- a/ErgometerApplication/ErgometerApplication/ErgometerApplication.csproj
+++ b/ErgometerApplication/ErgometerApplication/ErgometerApplication.csproj
@@ -56,16 +56,16 @@
-
+
Form
-
- Ergometer.cs
+
+ ClientApplicatie.cs
-
- Ergometer.cs
+
+ ClientApplicatie.cs
ResXFileCodeGenerator
diff --git a/ErgometerApplication/ErgometerApplication/Program.cs b/ErgometerApplication/ErgometerApplication/Program.cs
index 33015b4..cb1e68e 100644
--- a/ErgometerApplication/ErgometerApplication/Program.cs
+++ b/ErgometerApplication/ErgometerApplication/Program.cs
@@ -17,7 +17,7 @@ namespace ErgometerApplication
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new Ergometer());
+ Application.Run(new ClientApplicatie());
}
}
}
diff --git a/ErgometerApplication/ErgometerApplication/ServerCommunicator.cs b/ErgometerApplication/ErgometerApplication/ServerCommunicator.cs
index a7bb350..79c49cf 100644
--- a/ErgometerApplication/ErgometerApplication/ServerCommunicator.cs
+++ b/ErgometerApplication/ErgometerApplication/ServerCommunicator.cs
@@ -5,7 +5,7 @@ using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
-using ErgometerLibrary;
+//using ErgometerLibrary;
namespace ErgometerApplication
{
@@ -13,6 +13,6 @@ namespace ErgometerApplication
{
public TcpClient client { get; set; }
public int sessionId { get; set; }
- public List data { get; set; }
+// public List data { get; set; }
}
}
diff --git a/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerApplication.exe b/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerApplication.exe
index a7fe05f..2bc4b6d 100644
Binary files a/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerApplication.exe and b/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerApplication.exe differ
diff --git a/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerApplication.pdb b/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerApplication.pdb
index 27bbcd8..ce2b5fa 100644
Binary files a/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerApplication.pdb and b/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerApplication.pdb differ
diff --git a/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerApplication.vshost.exe b/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerApplication.vshost.exe
index 681ab77..03e9101 100644
Binary files a/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerApplication.vshost.exe and b/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerApplication.vshost.exe differ
diff --git a/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerLibrary.pdb b/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerLibrary.pdb
deleted file mode 100644
index d196f20..0000000
Binary files a/ErgometerApplication/ErgometerApplication/bin/Debug/ErgometerLibrary.pdb and /dev/null differ
diff --git a/ErgometerApplication/ErgometerApplication/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/ErgometerApplication/ErgometerApplication/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
index 4d58ec9..bacc9d8 100644
Binary files a/ErgometerApplication/ErgometerApplication/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/ErgometerApplication/ErgometerApplication/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.Ergometer.resources b/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.Ergometer.resources
deleted file mode 100644
index 6c05a97..0000000
Binary files a/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.Ergometer.resources and /dev/null differ
diff --git a/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.csproj.FileListAbsolute.txt b/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.csproj.FileListAbsolute.txt
index 0821f57..94a47b9 100644
--- a/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.csproj.FileListAbsolute.txt
+++ b/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.csproj.FileListAbsolute.txt
@@ -19,3 +19,14 @@ C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\Ergom
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.csproj.GenerateResource.Cache
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\bin\Debug\ErgometerLibrary.dll
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\bin\Debug\ErgometerLibrary.pdb
+C:\Users\startklaar\Source\Repos\ErgometerApplication\ErgometerApplication\ErgometerApplication\bin\Debug\ErgometerApplication.exe.config
+C:\Users\startklaar\Source\Repos\ErgometerApplication\ErgometerApplication\ErgometerApplication\bin\Debug\ErgometerApplication.exe
+C:\Users\startklaar\Source\Repos\ErgometerApplication\ErgometerApplication\ErgometerApplication\bin\Debug\ErgometerApplication.pdb
+C:\Users\startklaar\Source\Repos\ErgometerApplication\ErgometerApplication\ErgometerApplication\bin\Debug\Newtonsoft.Json.dll
+C:\Users\startklaar\Source\Repos\ErgometerApplication\ErgometerApplication\ErgometerApplication\bin\Debug\Newtonsoft.Json.xml
+C:\Users\startklaar\Source\Repos\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.csprojResolveAssemblyReference.cache
+C:\Users\startklaar\Source\Repos\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.Properties.Resources.resources
+C:\Users\startklaar\Source\Repos\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.csproj.GenerateResource.Cache
+C:\Users\startklaar\Source\Repos\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.exe
+C:\Users\startklaar\Source\Repos\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.pdb
+C:\Users\startklaar\Source\Repos\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.ClientApplicatie.resources
diff --git a/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.csproj.GenerateResource.Cache b/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.csproj.GenerateResource.Cache
index 8a650fb..1d013ca 100644
Binary files a/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.csproj.GenerateResource.Cache and b/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.csproj.GenerateResource.Cache differ
diff --git a/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.csprojResolveAssemblyReference.cache b/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.csprojResolveAssemblyReference.cache
index 0eb0388..debeed8 100644
Binary files a/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.csprojResolveAssemblyReference.cache and b/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.csprojResolveAssemblyReference.cache differ
diff --git a/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.exe b/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.exe
index a7fe05f..2bc4b6d 100644
Binary files a/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.exe and b/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.exe differ
diff --git a/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.pdb b/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.pdb
index 27bbcd8..ce2b5fa 100644
Binary files a/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.pdb and b/ErgometerApplication/ErgometerApplication/obj/Debug/ErgometerApplication.pdb differ