Large refactoring of Start procedure handling + horn signaling.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
2
Tidstagning/AboutBox.Designer.cs
generated
2
Tidstagning/AboutBox.Designer.cs
generated
@ -110,7 +110,7 @@
|
||||
this.labelCopyright.Name = "labelCopyright";
|
||||
this.labelCopyright.Size = new System.Drawing.Size(271, 17);
|
||||
this.labelCopyright.TabIndex = 21;
|
||||
this.labelCopyright.Text = "Copyright © 2014";
|
||||
this.labelCopyright.Text = "Copyright © 2021";
|
||||
this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// labelCompanyName
|
||||
|
122
Tidstagning/Form1.Designer.cs
generated
122
Tidstagning/Form1.Designer.cs
generated
@ -29,23 +29,20 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
|
||||
this.countdowntimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.btnTest = new System.Windows.Forms.Button();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.txtDebug = new System.Windows.Forms.TextBox();
|
||||
this.panel2 = new System.Windows.Forms.Panel();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.startProcedureParsed = new System.Windows.Forms.Label();
|
||||
this.checkStartProcedure = new System.Windows.Forms.CheckBox();
|
||||
this.btnAutoStart = new System.Windows.Forms.Button();
|
||||
this.btnStart = new System.Windows.Forms.Button();
|
||||
this.btnStop = new System.Windows.Forms.Button();
|
||||
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();
|
||||
@ -53,18 +50,15 @@
|
||||
this.comboComport = new System.Windows.Forms.ComboBox();
|
||||
this.lblClock = new System.Windows.Forms.Label();
|
||||
this.Clock = new System.Windows.Forms.Timer(this.components);
|
||||
this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.entryBindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||
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
|
||||
//
|
||||
this.countdowntimer.Interval = 1000;
|
||||
this.countdowntimer.Tick += new System.EventHandler(this.timer_Tick);
|
||||
//
|
||||
// btnTest
|
||||
//
|
||||
this.btnTest.Font = new System.Drawing.Font("Microsoft Sans Serif", 18.25F);
|
||||
@ -78,7 +72,7 @@
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(966, 3);
|
||||
this.button1.Location = new System.Drawing.Point(3, 100);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 14;
|
||||
@ -90,53 +84,56 @@
|
||||
//
|
||||
this.txtDebug.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txtDebug.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F);
|
||||
this.txtDebug.Location = new System.Drawing.Point(203, 557);
|
||||
this.txtDebug.Location = new System.Drawing.Point(253, 557);
|
||||
this.txtDebug.Multiline = true;
|
||||
this.txtDebug.Name = "txtDebug";
|
||||
this.txtDebug.ReadOnly = true;
|
||||
this.txtDebug.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.txtDebug.Size = new System.Drawing.Size(757, 134);
|
||||
this.txtDebug.Size = new System.Drawing.Size(707, 134);
|
||||
this.txtDebug.TabIndex = 10;
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel2.Location = new System.Drawing.Point(3, 72);
|
||||
this.panel2.Name = "panel2";
|
||||
this.panel2.Size = new System.Drawing.Size(194, 479);
|
||||
this.panel2.TabIndex = 9;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.startProcedureParsed);
|
||||
this.panel1.Controls.Add(this.checkStartProcedure);
|
||||
this.panel1.Controls.Add(this.btnAutoStart);
|
||||
this.panel1.Controls.Add(this.btnStart);
|
||||
this.panel1.Controls.Add(this.btnStop);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel1.Location = new System.Drawing.Point(966, 72);
|
||||
this.panel1.Location = new System.Drawing.Point(3, 72);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(346, 479);
|
||||
this.panel1.Size = new System.Drawing.Size(244, 479);
|
||||
this.panel1.TabIndex = 8;
|
||||
//
|
||||
// startProcedureParsed
|
||||
//
|
||||
this.startProcedureParsed.AutoSize = true;
|
||||
this.startProcedureParsed.Font = new System.Drawing.Font("Consolas", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.startProcedureParsed.Location = new System.Drawing.Point(7, 138);
|
||||
this.startProcedureParsed.Name = "startProcedureParsed";
|
||||
this.startProcedureParsed.Size = new System.Drawing.Size(0, 19);
|
||||
this.startProcedureParsed.TabIndex = 9;
|
||||
//
|
||||
// checkStartProcedure
|
||||
//
|
||||
this.checkStartProcedure.AutoSize = true;
|
||||
this.checkStartProcedure.Location = new System.Drawing.Point(7, 114);
|
||||
this.checkStartProcedure.Name = "checkStartProcedure";
|
||||
this.checkStartProcedure.Size = new System.Drawing.Size(100, 17);
|
||||
this.checkStartProcedure.Size = new System.Drawing.Size(155, 17);
|
||||
this.checkStartProcedure.TabIndex = 8;
|
||||
this.checkStartProcedure.Text = "Start Procedure";
|
||||
this.checkStartProcedure.Text = "Automatisk Start Procedure";
|
||||
this.checkStartProcedure.UseVisualStyleBackColor = true;
|
||||
this.checkStartProcedure.CheckedChanged += new System.EventHandler(this.checkStartProcedure_CheckedChanged);
|
||||
//
|
||||
// btnAutoStart
|
||||
// btnStart
|
||||
//
|
||||
this.btnAutoStart.Font = new System.Drawing.Font("Microsoft Sans Serif", 18.25F);
|
||||
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;
|
||||
this.btnAutoStart.Text = "Start";
|
||||
this.btnAutoStart.UseVisualStyleBackColor = true;
|
||||
this.btnAutoStart.Click += new System.EventHandler(this.btnAutoStart_Click);
|
||||
this.btnStart.Font = new System.Drawing.Font("Microsoft Sans Serif", 18.25F);
|
||||
this.btnStart.Location = new System.Drawing.Point(3, 3);
|
||||
this.btnStart.Name = "btnStart";
|
||||
this.btnStart.Size = new System.Drawing.Size(185, 37);
|
||||
this.btnStart.TabIndex = 4;
|
||||
this.btnStart.Text = "Start";
|
||||
this.btnStart.UseVisualStyleBackColor = true;
|
||||
this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
|
||||
//
|
||||
// btnStop
|
||||
//
|
||||
@ -156,7 +153,7 @@
|
||||
this.txtHeader.Font = new System.Drawing.Font("Microsoft Sans Serif", 18.25F);
|
||||
this.txtHeader.Location = new System.Drawing.Point(3, 3);
|
||||
this.txtHeader.Name = "txtHeader";
|
||||
this.txtHeader.Size = new System.Drawing.Size(194, 35);
|
||||
this.txtHeader.Size = new System.Drawing.Size(244, 35);
|
||||
this.txtHeader.TabIndex = 3;
|
||||
//
|
||||
// grid
|
||||
@ -170,17 +167,18 @@
|
||||
this.Complete,
|
||||
this.nameDataGridViewTextBoxColumn,
|
||||
this.DNF});
|
||||
this.txtLog.SetColumnSpan(this.grid, 2);
|
||||
this.grid.DataSource = this.entryBindingSource;
|
||||
this.grid.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.grid.Location = new System.Drawing.Point(203, 3);
|
||||
this.grid.Location = new System.Drawing.Point(253, 3);
|
||||
this.grid.Name = "grid";
|
||||
this.grid.ReadOnly = true;
|
||||
this.grid.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
|
||||
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F);
|
||||
this.grid.RowsDefaultCellStyle = dataGridViewCellStyle1;
|
||||
dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F);
|
||||
this.grid.RowsDefaultCellStyle = dataGridViewCellStyle2;
|
||||
this.txtLog.SetRowSpan(this.grid, 2);
|
||||
this.grid.RowTemplate.Height = 30;
|
||||
this.grid.Size = new System.Drawing.Size(757, 548);
|
||||
this.grid.Size = new System.Drawing.Size(1059, 548);
|
||||
this.grid.TabIndex = 0;
|
||||
this.grid.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.grid_Click);
|
||||
this.grid.MouseMove += new System.Windows.Forms.MouseEventHandler(this.grid_MouseMove);
|
||||
@ -194,13 +192,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";
|
||||
@ -209,24 +200,18 @@
|
||||
this.DNF.Text = "Udgået";
|
||||
this.DNF.UseColumnTextForButtonValue = true;
|
||||
//
|
||||
// entryBindingSource
|
||||
//
|
||||
this.entryBindingSource.DataSource = typeof(Tidstagning.Entry);
|
||||
//
|
||||
// txtLog
|
||||
//
|
||||
this.txtLog.ColumnCount = 3;
|
||||
this.txtLog.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 200F));
|
||||
this.txtLog.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 250F));
|
||||
this.txtLog.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.txtLog.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 352F));
|
||||
this.txtLog.Controls.Add(this.grid, 1, 0);
|
||||
this.txtLog.Controls.Add(this.txtHeader, 0, 0);
|
||||
this.txtLog.Controls.Add(this.panel1, 2, 1);
|
||||
this.txtLog.Controls.Add(this.panel2, 0, 1);
|
||||
this.txtLog.Controls.Add(this.txtDebug, 1, 2);
|
||||
this.txtLog.Controls.Add(this.button1, 2, 0);
|
||||
this.txtLog.Controls.Add(this.flowLayoutPanel1, 0, 2);
|
||||
this.txtLog.Controls.Add(this.lblClock, 2, 2);
|
||||
this.txtLog.Controls.Add(this.panel1, 0, 1);
|
||||
this.txtLog.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txtLog.Location = new System.Drawing.Point(0, 0);
|
||||
this.txtLog.Name = "txtLog";
|
||||
@ -243,6 +228,7 @@
|
||||
this.flowLayoutPanel1.Controls.Add(this.comboSoundTime);
|
||||
this.flowLayoutPanel1.Controls.Add(this.label1);
|
||||
this.flowLayoutPanel1.Controls.Add(this.comboComport);
|
||||
this.flowLayoutPanel1.Controls.Add(this.button1);
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 557);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(194, 125);
|
||||
@ -265,6 +251,7 @@
|
||||
this.comboSoundTime.Name = "comboSoundTime";
|
||||
this.comboSoundTime.Size = new System.Drawing.Size(97, 21);
|
||||
this.comboSoundTime.TabIndex = 26;
|
||||
this.comboSoundTime.SelectedIndexChanged += new System.EventHandler(this.comboSoundTime_SelectedIndexChanged);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
@ -283,6 +270,7 @@
|
||||
this.comboComport.Name = "comboComport";
|
||||
this.comboComport.Size = new System.Drawing.Size(121, 21);
|
||||
this.comboComport.TabIndex = 28;
|
||||
this.comboComport.SelectedIndexChanged += new System.EventHandler(this.comboComport_SelectedIndexChanged);
|
||||
//
|
||||
// lblClock
|
||||
//
|
||||
@ -303,6 +291,17 @@
|
||||
this.Clock.Enabled = true;
|
||||
this.Clock.Tick += new System.EventHandler(this.Clock_Tick);
|
||||
//
|
||||
// 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);
|
||||
@ -311,21 +310,19 @@
|
||||
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.ClientSize = new System.Drawing.Size(1315, 694);
|
||||
this.Controls.Add(this.txtLog);
|
||||
this.HelpButton = true;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "Form1";
|
||||
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);
|
||||
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);
|
||||
|
||||
}
|
||||
@ -333,13 +330,11 @@
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.BindingSource entryBindingSource;
|
||||
private System.Windows.Forms.Timer countdowntimer;
|
||||
private System.Windows.Forms.Button btnTest;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.TextBox txtDebug;
|
||||
private System.Windows.Forms.Panel panel2;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.Button btnAutoStart;
|
||||
private System.Windows.Forms.Button btnStart;
|
||||
private System.Windows.Forms.Button btnStop;
|
||||
private System.Windows.Forms.TextBox txtHeader;
|
||||
private System.Windows.Forms.DataGridView grid;
|
||||
@ -354,6 +349,7 @@
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.ComboBox comboComport;
|
||||
private System.Windows.Forms.Label lblClock;
|
||||
private System.Windows.Forms.Label startProcedureParsed;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ namespace Tidstagning
|
||||
};
|
||||
ResultList liste;
|
||||
Relay horn;
|
||||
Procedure startprocedure;
|
||||
Procedure startprocedure = new Procedure();
|
||||
|
||||
int OldRow = 0;
|
||||
public Form1()
|
||||
@ -27,25 +27,13 @@ namespace Tidstagning
|
||||
}
|
||||
deltager_handle.Dispose();
|
||||
|
||||
startprocedure = new Procedure();
|
||||
System.IO.StreamReader procedure_handle = new System.IO.StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + "Startprocedure.txt");
|
||||
string line;
|
||||
while ((line = procedure_handle.ReadLine()) != null)
|
||||
{
|
||||
startprocedure.addEntry(line);
|
||||
}
|
||||
procedure_handle.Dispose();
|
||||
|
||||
|
||||
foreach(string port in Relay.GetPorts()) {
|
||||
comboSoundTime.SelectedIndex = 0;
|
||||
|
||||
foreach (string port in Relay.GetPorts()) {
|
||||
comboComport.Items.Add(port);
|
||||
}
|
||||
|
||||
comboSoundTime.SelectedIndex = 0;
|
||||
if (comboComport.Items.Count != 0)
|
||||
{
|
||||
comboComport.SelectedIndex = 0;
|
||||
}
|
||||
comboComport.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -89,54 +77,49 @@ namespace Tidstagning
|
||||
grid.CurrentCell = null;
|
||||
entries.RemoveAt(e.RowIndex);
|
||||
|
||||
horn.Set(0x00, 0x01);
|
||||
countdowntimer.Interval = int.Parse(comboSoundTime.SelectedItem.ToString());
|
||||
countdowntimer.Start();
|
||||
|
||||
horn.Sound(int.Parse(comboSoundTime.SelectedItem.ToString()));
|
||||
}
|
||||
grid.Refresh();
|
||||
|
||||
}
|
||||
|
||||
private void btnAutoStart_Click(object sender, EventArgs e)
|
||||
private void btnStart_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (txtHeader.Text == "")
|
||||
{
|
||||
MessageBox.Show("Udfyld løbs titel");
|
||||
return;
|
||||
}
|
||||
liste = new ResultList("Resultat", this);
|
||||
liste = new ResultList(txtHeader.Text, this);
|
||||
liste.WriteHeader(txtHeader.Text);
|
||||
btnAutoStart.Enabled = false;
|
||||
btnStart.Enabled = false;
|
||||
btnStop.Enabled = true;
|
||||
if (comboComport.Items.Count != 0)
|
||||
{
|
||||
horn = new Relay(comboComport.SelectedItem.ToString());
|
||||
}
|
||||
checkStartProcedure.Enabled = false;
|
||||
comboComport.Enabled = false;
|
||||
comboSoundTime.Enabled = false;
|
||||
if (checkStartProcedure.Checked)
|
||||
{
|
||||
liste.Write("Automatisk Start Procedure er aktiv.");
|
||||
startprocedure.setObjects(horn, liste);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
liste.Write("Manuel start procedure");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void btnStop_Click(object sender, EventArgs e)
|
||||
{
|
||||
btnStop.Enabled = false;
|
||||
btnStart.Enabled = true;
|
||||
liste.WriteFooter();
|
||||
liste.Close();
|
||||
checkStartProcedure.Enabled = true;
|
||||
checkStartProcedure.Checked = false;
|
||||
comboComport.Enabled = true;
|
||||
comboSoundTime.Enabled = true;
|
||||
startprocedure.Clear();
|
||||
|
||||
horn.Close();
|
||||
|
||||
liste.Write("Nedtælling stoppet");
|
||||
|
||||
countdowntimer.Stop();
|
||||
|
||||
}
|
||||
|
||||
private void timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
countdowntimer.Stop();
|
||||
horn.Set(0x00, 0x00);
|
||||
}
|
||||
|
||||
private void grid_MouseMove(object sender, MouseEventArgs e)
|
||||
@ -156,14 +139,6 @@ namespace Tidstagning
|
||||
|
||||
}
|
||||
|
||||
private void Form1_HelpButtonClicked(object sender, CancelEventArgs e)
|
||||
{
|
||||
AboutBox aboutbox = new AboutBox();
|
||||
aboutbox.Show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
AboutBox aboutbox = new AboutBox();
|
||||
@ -172,17 +147,35 @@ namespace Tidstagning
|
||||
|
||||
private void btnTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!btnStop.Enabled)
|
||||
return;
|
||||
|
||||
horn.Set(0x00, 0x01);
|
||||
countdowntimer.Interval = int.Parse(comboSoundTime.SelectedItem.ToString());
|
||||
countdowntimer.Start();
|
||||
horn.Sound(int.Parse(comboSoundTime.SelectedItem.ToString()));
|
||||
}
|
||||
|
||||
private void Clock_Tick(object sender, EventArgs e)
|
||||
{
|
||||
lblClock.Text = DateTime.Now.ToString("HH:mm:ss");
|
||||
startProcedureParsed.Text = startprocedure.TextualRepresentation();
|
||||
}
|
||||
|
||||
private void comboSoundTime_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
startprocedure.adjustSignalLength(int.Parse(comboSoundTime.SelectedItem.ToString()));
|
||||
}
|
||||
|
||||
private void comboComport_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (comboComport.Items.Count != 0)
|
||||
{
|
||||
horn = new Relay(comboComport.SelectedItem.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void checkStartProcedure_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
startprocedure.Clear();
|
||||
if (checkStartProcedure.Checked)
|
||||
{
|
||||
startprocedure.ReadFile(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + "Startprocedure.txt");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,9 +117,6 @@
|
||||
<resheader name="writer">
|
||||
<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=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>165, 17</value>
|
||||
</metadata>
|
||||
<metadata name="Complete.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
@ -130,7 +127,7 @@
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="Clock.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>297, 17</value>
|
||||
<value>166, 16</value>
|
||||
</metadata>
|
||||
<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">
|
||||
|
@ -1,38 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Tidstagning
|
||||
{
|
||||
class Procedure
|
||||
{
|
||||
|
||||
struct Signal
|
||||
{
|
||||
public TimeSpan tid;
|
||||
public Int32 Duration;
|
||||
|
||||
public Signal(string parse)
|
||||
{
|
||||
string[] parts = parse.Split(',');
|
||||
this.tid = TimeSpan.Parse(parts[0]);
|
||||
this.Duration = Int32.Parse(parts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
Relay horn;
|
||||
ResultList log;
|
||||
readonly List<Signal> signaler;
|
||||
Timer cooldownTimer;
|
||||
List<DateTime> signaler;
|
||||
int signalLength = 500;
|
||||
|
||||
Timer timer;
|
||||
Int16 idx = 0;
|
||||
|
||||
public Procedure()
|
||||
{
|
||||
signaler = new List<Signal>();
|
||||
signaler = new List<DateTime>();
|
||||
}
|
||||
|
||||
public void ReadFile(string file)
|
||||
{
|
||||
System.IO.StreamReader procedure_handle = new System.IO.StreamReader(file);
|
||||
string line;
|
||||
while ((line = procedure_handle.ReadLine()) != null)
|
||||
{
|
||||
addEntry(line);
|
||||
}
|
||||
procedure_handle.Dispose();
|
||||
}
|
||||
|
||||
public void addEntry(string input) {
|
||||
signaler.Add(new Signal(input));
|
||||
string input_filtered = input.Trim();
|
||||
if (input_filtered.Length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
signaler.Add(DateTime.Parse(input_filtered));
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Failed to parse: "+ input);
|
||||
}
|
||||
signaler.Sort();
|
||||
}
|
||||
}
|
||||
|
||||
public string TextualRepresentation()
|
||||
{
|
||||
string t = "";
|
||||
if (signaler.Count > 0)
|
||||
{
|
||||
t += "Signaler:\n";
|
||||
foreach (DateTime signal in signaler)
|
||||
{
|
||||
if (DateTime.Now > (signal.AddMilliseconds(signalLength)))
|
||||
{
|
||||
t += "✔";
|
||||
}
|
||||
else if (DateTime.Now > signal)
|
||||
{
|
||||
t += "o ";
|
||||
}
|
||||
else
|
||||
{
|
||||
t += " ";
|
||||
}
|
||||
t += signal.ToString() + "\n";
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
signaler = new List<DateTime>();
|
||||
idx = 0;
|
||||
if(timer != null)
|
||||
timer.Dispose();
|
||||
}
|
||||
|
||||
public void setObjects(Relay horn_obj, ResultList log_obj)
|
||||
@ -42,24 +88,31 @@ namespace Tidstagning
|
||||
Run();
|
||||
}
|
||||
|
||||
public void adjustSignalLength(int lengthMS)
|
||||
{
|
||||
signalLength = lengthMS;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
SetUpTimer(signaler[idx].tid);
|
||||
SetUpTimer(signaler[idx]);
|
||||
|
||||
}
|
||||
private void SetUpTimer(TimeSpan alertTime)
|
||||
private void SetUpTimer(DateTime alertTime)
|
||||
{
|
||||
|
||||
DateTime current = DateTime.Now;
|
||||
TimeSpan timeToGo = alertTime - current.TimeOfDay;
|
||||
TimeSpan timeToGo = alertTime.TimeOfDay - current.TimeOfDay;
|
||||
|
||||
log.Write("Næste signal: " + alertTime.ToString() + " Om: " + timeToGo.ToString());
|
||||
if (timeToGo < TimeSpan.Zero)
|
||||
{
|
||||
next();
|
||||
if(!next())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Run();
|
||||
return;//time already passed
|
||||
}
|
||||
log.Write("Næste signal: " + alertTime.ToString() + " Om: " + timeToGo.ToString());
|
||||
timer = new System.Threading.Timer(x =>
|
||||
{
|
||||
this.Alarm();
|
||||
@ -69,27 +122,20 @@ namespace Tidstagning
|
||||
private void Alarm()
|
||||
{
|
||||
log.Write("HORN!");
|
||||
horn.Set(0x00, 0x01);
|
||||
cooldownTimer = new System.Threading.Timer(x =>
|
||||
{
|
||||
this.Cooldown();
|
||||
}, null, new TimeSpan(0,0,signaler[idx].Duration/1000), new System.TimeSpan(0));
|
||||
|
||||
}
|
||||
|
||||
private void Cooldown()
|
||||
{
|
||||
horn.Set(0x00, 0x00);
|
||||
horn.Sound(signalLength);
|
||||
next();
|
||||
this.Run();
|
||||
Run();
|
||||
|
||||
}
|
||||
|
||||
private void next()
|
||||
private bool next()
|
||||
{
|
||||
if (idx >= (signaler.Count - 1))
|
||||
return;
|
||||
return false;
|
||||
|
||||
idx++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
using System.IO.Ports;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
namespace Tidstagning
|
||||
{
|
||||
class Relay
|
||||
{
|
||||
SerialPort com;
|
||||
Timer cooldownTimer;
|
||||
public Relay(string ComPort = null)
|
||||
{
|
||||
com = new SerialPort();
|
||||
@ -12,22 +17,46 @@ namespace Tidstagning
|
||||
try
|
||||
{
|
||||
com.Open();
|
||||
} catch
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void Set(int output, byte state) {
|
||||
private void On()
|
||||
{
|
||||
Set(0x00, 0x01);
|
||||
}
|
||||
|
||||
private void Off()
|
||||
{
|
||||
Set(0x00, 0x00);
|
||||
}
|
||||
|
||||
|
||||
public void Sound(int time)
|
||||
{
|
||||
Debug.WriteLine("Requesting horn for: " + time.ToString() + "ms");
|
||||
On();
|
||||
cooldownTimer = new System.Threading.Timer(x =>
|
||||
{
|
||||
Off();
|
||||
}, null, new TimeSpan(0, 0, time / 1000), new System.TimeSpan(0));
|
||||
}
|
||||
|
||||
private void Set(int output, byte state) {
|
||||
byte[] command = {0xff, 0x01, state};
|
||||
if (com.IsOpen)
|
||||
{
|
||||
Debug.WriteLine("COM: " + com.PortName + " Write: 0x" + Convert.ToString(command[2], 16));
|
||||
com.Write(command, 0, 3);
|
||||
}
|
||||
}
|
||||
public void Close() {
|
||||
if (com.IsOpen)
|
||||
{
|
||||
Off(); //Make sure the horn is off before closing the com port...
|
||||
com.Close();
|
||||
}
|
||||
}
|
||||
|
@ -11,31 +11,52 @@ namespace Tidstagning
|
||||
string racenumber;
|
||||
public ResultList(string filename, Tidstagning.Form1 log_object)
|
||||
{
|
||||
filehandle = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename +"_" + DateTime.Now.ToString("dd-MM-yyyy-HH-mm") + ".txt");
|
||||
filehandle2 = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename + "_" + DateTime.Now.ToString("dd-MM-yyyy-HH-mm") + ".csv");
|
||||
filename = MakeSafeFilename(filename, '_');
|
||||
filehandle = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename +"_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss") + ".txt");
|
||||
filehandle2 = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename + "_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss") + ".csv");
|
||||
parentForm = log_object;
|
||||
}
|
||||
|
||||
private string MakeSafeFilename(string filename, char replaceChar)
|
||||
{
|
||||
foreach (char c in System.IO.Path.GetInvalidFileNameChars())
|
||||
{
|
||||
filename = filename.Replace(c, replaceChar);
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void WriteHeader(string header) {
|
||||
this.racenumber = header;
|
||||
Write("----------------------------");
|
||||
Write(header);
|
||||
Write("Løb startet den: " + DateTime.Now.ToString());
|
||||
Write("----------------------------");
|
||||
|
||||
WriteCSV("RaceNo,SailNo,Finish,Code,");
|
||||
|
||||
}
|
||||
public void WriteComplete(Entry Boat) {
|
||||
|
||||
|
||||
public void WriteFooter()
|
||||
{
|
||||
Write("----------------------------");
|
||||
Write("Løb afsluttet den: " + DateTime.Now.ToString());
|
||||
Write("----------------------------");
|
||||
}
|
||||
|
||||
public void WriteComplete(Entry Boat)
|
||||
{
|
||||
Write("Fuldført! - " + Boat.Name + " - " + Boat.Completed_Time.ToString());
|
||||
WriteCSV(this.racenumber + "," +Boat.SailNumber + "," + Boat.Completed_Time.ToString("HH:mm:ss") + ", ,");
|
||||
}
|
||||
public void WriteDNF(Entry Boat) {
|
||||
|
||||
public void WriteDNF(Entry Boat)
|
||||
{
|
||||
Write("Udgået! - " + Boat.Name + " - " + Boat.Completed_Time.ToString());
|
||||
WriteCSV(this.racenumber + "," +Boat.SailNumber + "," + "00:00:00,DNC,");
|
||||
}
|
||||
|
||||
public void Write(string textstring) {
|
||||
public void Write(string textstring)
|
||||
{
|
||||
filehandle.WriteLine(textstring);
|
||||
parentForm.LogAppend(textstring + "\r\n");
|
||||
filehandle.Flush();
|
||||
|
Reference in New Issue
Block a user