Update to work without any comports on the system
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Jens True 2021-05-30 15:37:02 +02:00
parent ace6790c9c
commit 6b5ee02f26
8 changed files with 87 additions and 45 deletions

@ -48,19 +48,20 @@
this.txtHeader = new System.Windows.Forms.TextBox(); this.txtHeader = new System.Windows.Forms.TextBox();
this.grid = new System.Windows.Forms.DataGridView(); this.grid = new System.Windows.Forms.DataGridView();
this.Complete = new System.Windows.Forms.DataGridViewButtonColumn(); this.Complete = new System.Windows.Forms.DataGridViewButtonColumn();
this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.DNF = new System.Windows.Forms.DataGridViewButtonColumn(); this.DNF = new System.Windows.Forms.DataGridViewButtonColumn();
this.entryBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.txtLog = new System.Windows.Forms.TableLayoutPanel(); this.txtLog = new System.Windows.Forms.TableLayoutPanel();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.comboSoundTime = new System.Windows.Forms.ComboBox(); this.comboSoundTime = new System.Windows.Forms.ComboBox();
this.Clock = new System.Windows.Forms.Timer(this.components); this.Clock = new System.Windows.Forms.Timer(this.components);
this.label1 = new System.Windows.Forms.Label();
this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.entryBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.panel2.SuspendLayout(); this.panel2.SuspendLayout();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.grid)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.grid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.entryBindingSource)).BeginInit();
this.txtLog.SuspendLayout(); this.txtLog.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout(); this.flowLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.entryBindingSource)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// countdowntimer // countdowntimer
@ -75,7 +76,7 @@
this.btnTest.Name = "btnTest"; this.btnTest.Name = "btnTest";
this.btnTest.Size = new System.Drawing.Size(185, 37); this.btnTest.Size = new System.Drawing.Size(185, 37);
this.btnTest.TabIndex = 3; this.btnTest.TabIndex = 3;
this.btnTest.Text = "Test"; this.btnTest.Text = "Test horn";
this.btnTest.UseVisualStyleBackColor = true; this.btnTest.UseVisualStyleBackColor = true;
this.btnTest.Click += new System.EventHandler(this.btnTest_Click); this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
// //
@ -191,7 +192,7 @@
// btnAutoStart // btnAutoStart
// //
this.btnAutoStart.Font = new System.Drawing.Font("Microsoft Sans Serif", 18.25F); this.btnAutoStart.Font = new System.Drawing.Font("Microsoft Sans Serif", 18.25F);
this.btnAutoStart.Location = new System.Drawing.Point(0, 7); this.btnAutoStart.Location = new System.Drawing.Point(3, 3);
this.btnAutoStart.Name = "btnAutoStart"; this.btnAutoStart.Name = "btnAutoStart";
this.btnAutoStart.Size = new System.Drawing.Size(185, 37); this.btnAutoStart.Size = new System.Drawing.Size(185, 37);
this.btnAutoStart.TabIndex = 4; this.btnAutoStart.TabIndex = 4;
@ -203,9 +204,9 @@
// //
this.btnStop.Enabled = false; this.btnStop.Enabled = false;
this.btnStop.Font = new System.Drawing.Font("Microsoft Sans Serif", 18.25F); this.btnStop.Font = new System.Drawing.Font("Microsoft Sans Serif", 18.25F);
this.btnStop.Location = new System.Drawing.Point(0, 50); this.btnStop.Location = new System.Drawing.Point(3, 46);
this.btnStop.Name = "btnStop"; this.btnStop.Name = "btnStop";
this.btnStop.Size = new System.Drawing.Size(182, 40); this.btnStop.Size = new System.Drawing.Size(185, 40);
this.btnStop.TabIndex = 6; this.btnStop.TabIndex = 6;
this.btnStop.Text = "Stop"; this.btnStop.Text = "Stop";
this.btnStop.UseVisualStyleBackColor = true; this.btnStop.UseVisualStyleBackColor = true;
@ -255,13 +256,6 @@
this.Complete.ReadOnly = true; this.Complete.ReadOnly = true;
this.Complete.Text = "Mål"; this.Complete.Text = "Mål";
// //
// nameDataGridViewTextBoxColumn
//
this.nameDataGridViewTextBoxColumn.DataPropertyName = "SailNumber";
this.nameDataGridViewTextBoxColumn.HeaderText = "Sejlnummer";
this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn";
this.nameDataGridViewTextBoxColumn.ReadOnly = true;
//
// DNF // DNF
// //
this.DNF.HeaderText = "DNF"; this.DNF.HeaderText = "DNF";
@ -270,10 +264,6 @@
this.DNF.Text = "Udgået"; this.DNF.Text = "Udgået";
this.DNF.UseColumnTextForButtonValue = true; this.DNF.UseColumnTextForButtonValue = true;
// //
// entryBindingSource
//
this.entryBindingSource.DataSource = typeof(Tidstagning.Entry);
//
// txtLog // txtLog
// //
this.txtLog.ColumnCount = 3; this.txtLog.ColumnCount = 3;
@ -302,6 +292,7 @@
// //
this.flowLayoutPanel1.Controls.Add(this.btnTest); this.flowLayoutPanel1.Controls.Add(this.btnTest);
this.flowLayoutPanel1.Controls.Add(this.comboSoundTime); this.flowLayoutPanel1.Controls.Add(this.comboSoundTime);
this.flowLayoutPanel1.Controls.Add(this.label1);
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 311); this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 311);
this.flowLayoutPanel1.Name = "flowLayoutPanel1"; this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(194, 73); this.flowLayoutPanel1.Size = new System.Drawing.Size(194, 73);
@ -323,15 +314,34 @@
"5000"}); "5000"});
this.comboSoundTime.Location = new System.Drawing.Point(3, 46); this.comboSoundTime.Location = new System.Drawing.Point(3, 46);
this.comboSoundTime.Name = "comboSoundTime"; this.comboSoundTime.Name = "comboSoundTime";
this.comboSoundTime.Size = new System.Drawing.Size(121, 21); this.comboSoundTime.Size = new System.Drawing.Size(97, 21);
this.comboSoundTime.TabIndex = 26; this.comboSoundTime.TabIndex = 26;
// //
// Clock // Clock
// //
this.Clock.Enabled = true; this.Clock.Enabled = true;
this.Clock.Interval = 1000;
this.Clock.Tick += new System.EventHandler(this.Clock_Tick); this.Clock.Tick += new System.EventHandler(this.Clock_Tick);
// //
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(106, 43);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(68, 13);
this.label1.TabIndex = 27;
this.label1.Text = "Millisekunder";
//
// nameDataGridViewTextBoxColumn
//
this.nameDataGridViewTextBoxColumn.DataPropertyName = "SailNumber";
this.nameDataGridViewTextBoxColumn.HeaderText = "Sejlnummer";
this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn";
this.nameDataGridViewTextBoxColumn.ReadOnly = true;
//
// entryBindingSource
//
this.entryBindingSource.DataSource = typeof(Tidstagning.Entry);
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -341,7 +351,7 @@
this.HelpButton = true; this.HelpButton = true;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form1"; this.Name = "Form1";
this.Text = "Tidstagning Copyright © 2014 LEAX A/S"; this.Text = "Tidstagning";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.HelpButtonClicked += new System.ComponentModel.CancelEventHandler(this.Form1_HelpButtonClicked); this.HelpButtonClicked += new System.ComponentModel.CancelEventHandler(this.Form1_HelpButtonClicked);
this.Load += new System.EventHandler(this.Form1_Load); this.Load += new System.EventHandler(this.Form1_Load);
@ -349,10 +359,11 @@
this.panel1.ResumeLayout(false); this.panel1.ResumeLayout(false);
this.panel1.PerformLayout(); this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.grid)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.grid)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.entryBindingSource)).EndInit();
this.txtLog.ResumeLayout(false); this.txtLog.ResumeLayout(false);
this.txtLog.PerformLayout(); this.txtLog.PerformLayout();
this.flowLayoutPanel1.ResumeLayout(false); this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.entryBindingSource)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -383,7 +394,7 @@
private System.Windows.Forms.Label lblClock; private System.Windows.Forms.Label lblClock;
private System.Windows.Forms.CheckBox checkStartProcedure; private System.Windows.Forms.CheckBox checkStartProcedure;
private System.Windows.Forms.Timer Clock; private System.Windows.Forms.Timer Clock;
private System.Windows.Forms.Label label1;
} }
} }

@ -36,13 +36,17 @@ namespace Tidstagning
} }
procedure_handle.Dispose(); procedure_handle.Dispose();
foreach(string port in Relay.GetPorts()) { foreach(string port in Relay.GetPorts()) {
comboComport.Items.Add(port); comboComport.Items.Add(port);
} }
comboSoundTime.SelectedIndex = 3; comboSoundTime.SelectedIndex = 3;
if (comboComport.Items.Count != 0)
{
comboComport.SelectedIndex = 0; comboComport.SelectedIndex = 0;
} }
}
private void Form1_Load(object sender, EventArgs e) private void Form1_Load(object sender, EventArgs e)
@ -140,9 +144,10 @@ namespace Tidstagning
liste.WriteHeader(txtHeader.Text); liste.WriteHeader(txtHeader.Text);
btnAutoStart.Enabled = false; btnAutoStart.Enabled = false;
btnStop.Enabled = true; btnStop.Enabled = true;
if (comboComport.Items.Count != 0)
{
horn = new Relay(comboComport.SelectedItem.ToString()); horn = new Relay(comboComport.SelectedItem.ToString());
}
if (checkStartProcedure.Checked) if (checkStartProcedure.Checked)
{ {
startprocedure.setObjects(horn, liste); startprocedure.setObjects(horn, liste);

@ -112,30 +112,30 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="countdowntimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="countdowntimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>165, 17</value> <value>165, 17</value>
</metadata> </metadata>
<metadata name="comboComport.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="comboComport.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Complete.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Complete.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="DNF.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="DNF.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="entryBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="entryBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="Clock.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="Clock.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>297, 17</value> <value>297, 17</value>
</metadata> </metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
AAABAAYAAAAAAAEAIABLFAAAZgAAACAgAAABACAAqBAAALEUAAAwMAAAAQAgAKglAABZJQAAEBAAAAEA AAABAAYAAAAAAAEAIABLFAAAZgAAACAgAAABACAAqBAAALEUAAAwMAAAAQAgAKglAABZJQAAEBAAAAEA

@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Tidstagning")] [assembly: AssemblyTitle("Tidstagning")]
[assembly: AssemblyDescription("Contact jens.chr.true@gmail.com - https://jcktrue.dk")] [assembly: AssemblyDescription("Kontakt jens.chr.true@gmail.com - https://jcktrue.dk")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("LEAX")] [assembly: AssemblyCompany("LEAX")]
[assembly: AssemblyProduct("Tidstagning")] [assembly: AssemblyProduct("Tidstagning")]
[assembly: AssemblyCopyright("Copyright © 2020")] [assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]

@ -4,26 +4,47 @@ namespace Tidstagning
class Relay class Relay
{ {
SerialPort com; SerialPort com;
public Relay(string ComPort) public Relay(string ComPort = null)
{ {
com = new SerialPort(); com = new SerialPort();
com.PortName = ComPort; com.PortName = ComPort;
com.BaudRate = 9600; com.BaudRate = 9600;
try
{
com.Open(); com.Open();
} catch
{
}
} }
public void Set(int output, byte state) { public void Set(int output, byte state) {
byte[] command = {0xff, 0x01, state}; byte[] command = {0xff, 0x01, state};
if (com.IsOpen)
{
com.Write(command, 0, 3); com.Write(command, 0, 3);
} }
}
public void Close() { public void Close() {
if(com.IsOpen) if (com.IsOpen)
{
com.Close(); com.Close();
} }
}
public static string[] GetPorts() public static string[] GetPorts()
{ {
return SerialPort.GetPortNames(); string[] ports;
if (SerialPort.GetPortNames().Length != 0)
{
ports = SerialPort.GetPortNames();
}
else
{
ports = new string[]{ "N/A" };
}
return ports;
} }
} }
} }

@ -0,0 +1,4 @@
18:00:00,200
18:01:00,200
18:04:00,200
18:05:00,500

@ -45,10 +45,10 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>true</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

@ -9,5 +9,6 @@
<ErrorReportUrlHistory /> <ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture> <FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles> <VerifyUploadedFiles>false</VerifyUploadedFiles>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup> </PropertyGroup>
</Project> </Project>