gedeeltelijke server connectie
This commit is contained in:
@@ -5,11 +5,12 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using ErgometerLibrary;
|
||||
namespace ErgometerApplication
|
||||
{
|
||||
class DataSaving
|
||||
{
|
||||
List<Meting> local_data = null;
|
||||
private List<Meting> ReadFile()
|
||||
{
|
||||
string path;
|
||||
@@ -28,10 +29,9 @@ namespace ErgometerApplication
|
||||
}
|
||||
private List<Meting> SaveData(Meting meting, List<Meting> _data)
|
||||
{
|
||||
List<Meting> local_data;
|
||||
List<Meting> local_data = _data;
|
||||
local_data.Add(meting);
|
||||
|
||||
return _data;
|
||||
return local_data;
|
||||
}
|
||||
private void WriteFile(List<Meting> _data)
|
||||
{
|
||||
@@ -40,6 +40,7 @@ namespace ErgometerApplication
|
||||
System.IO.File.WriteAllText(path, json);
|
||||
Console.WriteLine("Writing file: " + path);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+56
-56
@@ -38,7 +38,6 @@ namespace ErgometerApplication
|
||||
this.resetButton = new System.Windows.Forms.Button();
|
||||
this.updateTimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.timerStatus = new System.Windows.Forms.CheckBox();
|
||||
this.inputTextBox = new System.Windows.Forms.TextBox();
|
||||
this.powerButton = new System.Windows.Forms.Button();
|
||||
this.timeButton = new System.Windows.Forms.Button();
|
||||
this.energyButton = new System.Windows.Forms.Button();
|
||||
@@ -47,24 +46,25 @@ namespace ErgometerApplication
|
||||
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(10, 34);
|
||||
this.richTextBox1.Margin = new System.Windows.Forms.Padding(2);
|
||||
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(153, 198);
|
||||
this.richTextBox1.Size = new System.Drawing.Size(203, 243);
|
||||
this.richTextBox1.TabIndex = 0;
|
||||
this.richTextBox1.Text = "";
|
||||
//
|
||||
// connectButton
|
||||
//
|
||||
this.connectButton.Location = new System.Drawing.Point(86, 236);
|
||||
this.connectButton.Margin = new System.Windows.Forms.Padding(2);
|
||||
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(76, 21);
|
||||
this.connectButton.Size = new System.Drawing.Size(101, 26);
|
||||
this.connectButton.TabIndex = 1;
|
||||
this.connectButton.Text = "Connect";
|
||||
this.connectButton.UseVisualStyleBackColor = true;
|
||||
@@ -76,19 +76,19 @@ namespace ErgometerApplication
|
||||
this.ComPortBox.Items.AddRange(new object[] {
|
||||
"COM8",
|
||||
"COM9"});
|
||||
this.ComPortBox.Location = new System.Drawing.Point(9, 236);
|
||||
this.ComPortBox.Margin = new System.Windows.Forms.Padding(2);
|
||||
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(74, 21);
|
||||
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(95, 10);
|
||||
this.statusButton.Margin = new System.Windows.Forms.Padding(2);
|
||||
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(67, 21);
|
||||
this.statusButton.Size = new System.Drawing.Size(89, 26);
|
||||
this.statusButton.TabIndex = 3;
|
||||
this.statusButton.Text = "Status";
|
||||
this.statusButton.UseVisualStyleBackColor = true;
|
||||
@@ -97,10 +97,10 @@ namespace ErgometerApplication
|
||||
// resetButton
|
||||
//
|
||||
this.resetButton.Enabled = false;
|
||||
this.resetButton.Location = new System.Drawing.Point(9, 10);
|
||||
this.resetButton.Margin = new System.Windows.Forms.Padding(2);
|
||||
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(73, 21);
|
||||
this.resetButton.Size = new System.Drawing.Size(97, 26);
|
||||
this.resetButton.TabIndex = 4;
|
||||
this.resetButton.Text = "Reset";
|
||||
this.resetButton.UseVisualStyleBackColor = true;
|
||||
@@ -115,31 +115,22 @@ namespace ErgometerApplication
|
||||
//
|
||||
this.timerStatus.AutoSize = true;
|
||||
this.timerStatus.Enabled = false;
|
||||
this.timerStatus.Location = new System.Drawing.Point(167, 10);
|
||||
this.timerStatus.Margin = new System.Windows.Forms.Padding(2);
|
||||
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(88, 17);
|
||||
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);
|
||||
//
|
||||
// inputTextBox
|
||||
//
|
||||
this.inputTextBox.Enabled = false;
|
||||
this.inputTextBox.Location = new System.Drawing.Point(167, 34);
|
||||
this.inputTextBox.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.inputTextBox.Name = "inputTextBox";
|
||||
this.inputTextBox.Size = new System.Drawing.Size(86, 20);
|
||||
this.inputTextBox.TabIndex = 6;
|
||||
//
|
||||
// powerButton
|
||||
//
|
||||
this.powerButton.Enabled = false;
|
||||
this.powerButton.Location = new System.Drawing.Point(167, 109);
|
||||
this.powerButton.Margin = new System.Windows.Forms.Padding(2);
|
||||
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(85, 21);
|
||||
this.powerButton.Size = new System.Drawing.Size(113, 26);
|
||||
this.powerButton.TabIndex = 7;
|
||||
this.powerButton.Text = "Set Power";
|
||||
this.powerButton.UseVisualStyleBackColor = true;
|
||||
@@ -148,10 +139,10 @@ namespace ErgometerApplication
|
||||
// timeButton
|
||||
//
|
||||
this.timeButton.Enabled = false;
|
||||
this.timeButton.Location = new System.Drawing.Point(167, 57);
|
||||
this.timeButton.Margin = new System.Windows.Forms.Padding(2);
|
||||
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(85, 21);
|
||||
this.timeButton.Size = new System.Drawing.Size(113, 26);
|
||||
this.timeButton.TabIndex = 8;
|
||||
this.timeButton.Text = "Set Time";
|
||||
this.timeButton.UseVisualStyleBackColor = true;
|
||||
@@ -160,10 +151,10 @@ namespace ErgometerApplication
|
||||
// energyButton
|
||||
//
|
||||
this.energyButton.Enabled = false;
|
||||
this.energyButton.Location = new System.Drawing.Point(167, 135);
|
||||
this.energyButton.Margin = new System.Windows.Forms.Padding(2);
|
||||
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(85, 21);
|
||||
this.energyButton.Size = new System.Drawing.Size(113, 26);
|
||||
this.energyButton.TabIndex = 9;
|
||||
this.energyButton.Text = "Set Energy";
|
||||
this.energyButton.UseVisualStyleBackColor = true;
|
||||
@@ -172,10 +163,10 @@ namespace ErgometerApplication
|
||||
// distanceButton
|
||||
//
|
||||
this.distanceButton.Enabled = false;
|
||||
this.distanceButton.Location = new System.Drawing.Point(167, 83);
|
||||
this.distanceButton.Margin = new System.Windows.Forms.Padding(2);
|
||||
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(85, 21);
|
||||
this.distanceButton.Size = new System.Drawing.Size(113, 26);
|
||||
this.distanceButton.TabIndex = 10;
|
||||
this.distanceButton.Text = "Set Distance";
|
||||
this.distanceButton.UseVisualStyleBackColor = true;
|
||||
@@ -189,10 +180,10 @@ namespace ErgometerApplication
|
||||
// metingNextButton
|
||||
//
|
||||
this.metingNextButton.Enabled = false;
|
||||
this.metingNextButton.Location = new System.Drawing.Point(167, 235);
|
||||
this.metingNextButton.Margin = new System.Windows.Forms.Padding(2);
|
||||
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(85, 21);
|
||||
this.metingNextButton.Size = new System.Drawing.Size(113, 26);
|
||||
this.metingNextButton.TabIndex = 16;
|
||||
this.metingNextButton.Text = "Next ->";
|
||||
this.metingNextButton.UseVisualStyleBackColor = true;
|
||||
@@ -201,10 +192,10 @@ namespace ErgometerApplication
|
||||
// metingBackButton
|
||||
//
|
||||
this.metingBackButton.Enabled = false;
|
||||
this.metingBackButton.Location = new System.Drawing.Point(167, 210);
|
||||
this.metingBackButton.Margin = new System.Windows.Forms.Padding(2);
|
||||
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(85, 21);
|
||||
this.metingBackButton.Size = new System.Drawing.Size(113, 26);
|
||||
this.metingBackButton.TabIndex = 15;
|
||||
this.metingBackButton.Text = "<- Back";
|
||||
this.metingBackButton.UseVisualStyleBackColor = true;
|
||||
@@ -212,20 +203,30 @@ namespace ErgometerApplication
|
||||
//
|
||||
// readButton
|
||||
//
|
||||
this.readButton.Location = new System.Drawing.Point(167, 185);
|
||||
this.readButton.Margin = new System.Windows.Forms.Padding(2);
|
||||
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(85, 21);
|
||||
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(6F, 13F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(265, 273);
|
||||
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);
|
||||
@@ -233,16 +234,15 @@ namespace ErgometerApplication
|
||||
this.Controls.Add(this.energyButton);
|
||||
this.Controls.Add(this.timeButton);
|
||||
this.Controls.Add(this.powerButton);
|
||||
this.Controls.Add(this.inputTextBox);
|
||||
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(2);
|
||||
this.MaximumSize = new System.Drawing.Size(281, 312);
|
||||
this.MinimumSize = new System.Drawing.Size(281, 312);
|
||||
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);
|
||||
@@ -259,7 +259,6 @@ namespace ErgometerApplication
|
||||
private System.Windows.Forms.Button resetButton;
|
||||
private System.Windows.Forms.Timer updateTimer;
|
||||
private System.Windows.Forms.CheckBox timerStatus;
|
||||
private System.Windows.Forms.TextBox inputTextBox;
|
||||
private System.Windows.Forms.Button powerButton;
|
||||
private System.Windows.Forms.Button timeButton;
|
||||
private System.Windows.Forms.Button energyButton;
|
||||
@@ -268,5 +267,6 @@ namespace ErgometerApplication
|
||||
private System.Windows.Forms.Button metingNextButton;
|
||||
private System.Windows.Forms.Button metingBackButton;
|
||||
private System.Windows.Forms.Button readButton;
|
||||
private System.Windows.Forms.MaskedTextBox inputTextBox;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +82,25 @@ namespace ErgometerApplication
|
||||
|
||||
}
|
||||
}
|
||||
Thread threadRead = new Thread(HandleServerRead);
|
||||
threadRead.Start(client);
|
||||
Thread threadWrite = new Thread(HandleServerRead);
|
||||
threadWrite.Start(client);
|
||||
}
|
||||
|
||||
|
||||
private void HandleServerRead()
|
||||
{
|
||||
while (connectButton.Text == "Disconnect")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
private void HandleServerWrite()
|
||||
{
|
||||
while (connectButton.Text == "Disconnect")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void statusButton_Click(object sender, EventArgs e)
|
||||
@@ -252,5 +269,20 @@ namespace ErgometerApplication
|
||||
readFile = null;
|
||||
}
|
||||
}
|
||||
System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
|
||||
private String ReadServer()
|
||||
{
|
||||
|
||||
StreamReader reader = new StreamReader(client.GetStream(), Encoding.ASCII);
|
||||
String b = reader.ReadLine();
|
||||
return b;
|
||||
}
|
||||
private void WriteServer(String Send)
|
||||
{
|
||||
|
||||
StreamWriter stream = new StreamWriter(client.GetStream(), Encoding.ASCII);
|
||||
stream.WriteLine(Send);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ErgometerLibrary">
|
||||
<HintPath>..\..\..\ErgometerLibrary\ErgometerLibrary\ErgometerLibrary\bin\Debug\ErgometerLibrary.dll</HintPath>
|
||||
<HintPath>..\..\..\ErgometerLibrary\ErgometerLibrary\obj\Debug\ErgometerLibrary.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
@@ -53,6 +53,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DataSaving.cs" />
|
||||
<Compile Include="Ergometer.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
||||
+2
-1
@@ -17,4 +17,5 @@ C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\Ergom
|
||||
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.Ergometer.resources
|
||||
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.Properties.Resources.resources
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user