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

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

@ -112,30 +112,30 @@
<value>2.0</value>
</resheader>
<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 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>
<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>
</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>
</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>
</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>
</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>
</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>
</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">
<value>
AAABAAYAAAAAAAEAIABLFAAAZgAAACAgAAABACAAqBAAALEUAAAwMAAAAQAgAKglAABZJQAAEBAAAAEA

@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[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: AssemblyCompany("LEAX")]
[assembly: AssemblyProduct("Tidstagning")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

@ -4,26 +4,47 @@ namespace Tidstagning
class Relay
{
SerialPort com;
public Relay(string ComPort)
public Relay(string ComPort = null)
{
com = new SerialPort();
com.PortName = ComPort;
com.BaudRate = 9600;
com.Open();
try
{
com.Open();
} catch
{
}
}
public void Set(int output, byte state) {
byte[] command = {0xff, 0x01, state};
com.Write(command, 0, 3);
if (com.IsOpen)
{
com.Write(command, 0, 3);
}
}
public void Close() {
if(com.IsOpen)
if (com.IsOpen)
{
com.Close();
}
}
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>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>true</Prefer32Bit>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>

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