From dbc3b886a7d448da8a8245179321b5c55c89b5a9 Mon Sep 17 00:00:00 2001 From: Aareschluchtje Date: Fri, 11 Sep 2015 15:40:38 +0200 Subject: [PATCH] Added the ability to set some values of the Simulator. --- .../ErgometerSimulator/CommandParser.cs | 25 ++++++++++++++++++- .../ErgometerSimulator.Designer.cs | 4 +-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ErgometerSimulator/ErgometerSimulator/CommandParser.cs b/ErgometerSimulator/ErgometerSimulator/CommandParser.cs index 0180f51..5210276 100644 --- a/ErgometerSimulator/ErgometerSimulator/CommandParser.cs +++ b/ErgometerSimulator/ErgometerSimulator/CommandParser.cs @@ -39,7 +39,30 @@ namespace ErgometerSimulator default: break; } - + if (input.StartsWith("PT")) + { + dg.Time.currentvalue = int.Parse(input.Substring(3, 2)) * 60 + int.Parse(input.Substring(5, 2)); + dg.Time.value1 = int.Parse(input.Substring(3,2)) * 60 + int.Parse(input.Substring(5,2)); + Console.WriteLine(dg.Time.currentvalue); + } + else if (input.StartsWith("PD")) + { + dg.Distance.currentvalue = int.Parse(input.Substring(3)); + dg.Distance.value1 = int.Parse(input.Substring(3)); + Console.WriteLine(dg.Distance.currentvalue); + } + else if (input.StartsWith("PW")) + { + dg.Power.currentvalue = int.Parse(input.Substring(3)); + dg.Power.value1 = int.Parse(input.Substring(3)); + Console.WriteLine(dg.Power.currentvalue); + } + else if (input.StartsWith("PE")) + { + dg.Energy.currentvalue = int.Parse(input.Substring(3)); + dg.Energy.value1 = int.Parse(input.Substring(3)); + Console.WriteLine(dg.Energy.currentvalue); + } return response; } } diff --git a/ErgometerSimulator/ErgometerSimulator/ErgometerSimulator.Designer.cs b/ErgometerSimulator/ErgometerSimulator/ErgometerSimulator.Designer.cs index 847bc62..992115a 100644 --- a/ErgometerSimulator/ErgometerSimulator/ErgometerSimulator.Designer.cs +++ b/ErgometerSimulator/ErgometerSimulator/ErgometerSimulator.Designer.cs @@ -96,9 +96,7 @@ namespace ErgometerSimulator // ComPortBox // this.ComPortBox.FormattingEnabled = true; - this.ComPortBox.Items.AddRange(new object[] { - "COM8", - "COM9"}); + this.ComPortBox.Items.AddRange(SerialPort.GetPortNames()); this.ComPortBox.Location = new System.Drawing.Point(15, 308); this.ComPortBox.Name = "ComPortBox"; this.ComPortBox.Size = new System.Drawing.Size(121, 24);