Start of gentle refactoring.
This commit is contained in:
parent
44c3d9d4f5
commit
369f1934d3
@ -4,11 +4,24 @@ namespace Tidstagning
|
|||||||
{
|
{
|
||||||
class Entry
|
class Entry
|
||||||
{
|
{
|
||||||
|
enum Score
|
||||||
|
{
|
||||||
|
-,
|
||||||
|
DNC,
|
||||||
|
DNS,
|
||||||
|
OCS,
|
||||||
|
DNF,
|
||||||
|
RET,
|
||||||
|
DSQ
|
||||||
|
}
|
||||||
|
//Competitors name
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
//Competitor identifier (Sailnumber/Bownumber or other)
|
||||||
public string SailNumber { get; set; }
|
public string SailNumber { get; set; }
|
||||||
|
//DateTime the user completed the course
|
||||||
public DateTime Completed_Time { get; set; }
|
public DateTime Completed_Time { get; set; }
|
||||||
|
//Retirement score.
|
||||||
|
public Score Code {get; set; }
|
||||||
|
|
||||||
public Entry(string name, string number)
|
public Entry(string name, string number)
|
||||||
{
|
{
|
||||||
@ -24,6 +37,7 @@ namespace Tidstagning
|
|||||||
|
|
||||||
public void DNF()
|
public void DNF()
|
||||||
{
|
{
|
||||||
|
Code = DNF;
|
||||||
this.Completed_Time = DateTime.Now;
|
this.Completed_Time = DateTime.Now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ namespace Tidstagning
|
|||||||
|
|
||||||
};
|
};
|
||||||
ResultList? liste;
|
ResultList? liste;
|
||||||
Relay? horn;
|
Relay horn = new Relay();
|
||||||
Procedure startprocedure = new Procedure();
|
Procedure startprocedure = new Procedure();
|
||||||
|
|
||||||
public MainUI(bool ShowConfig = false)
|
public MainUI(bool ShowConfig = false)
|
||||||
@ -94,7 +94,6 @@ namespace Tidstagning
|
|||||||
grid.CurrentCell = null;
|
grid.CurrentCell = null;
|
||||||
entries.RemoveAt(e.RowIndex);
|
entries.RemoveAt(e.RowIndex);
|
||||||
|
|
||||||
if(horn is not null)
|
|
||||||
horn.Sound((uint)numericSignalLength.Value);
|
horn.Sound((uint)numericSignalLength.Value);
|
||||||
}
|
}
|
||||||
grid.Refresh();
|
grid.Refresh();
|
||||||
@ -116,7 +115,6 @@ namespace Tidstagning
|
|||||||
if (checkStartProcedure.Checked)
|
if (checkStartProcedure.Checked)
|
||||||
{
|
{
|
||||||
liste.Write("Automatisk Start Procedure er aktiv.");
|
liste.Write("Automatisk Start Procedure er aktiv.");
|
||||||
if(horn is not null)
|
|
||||||
startprocedure.setObjects(horn, liste);
|
startprocedure.setObjects(horn, liste);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -147,8 +145,7 @@ namespace Tidstagning
|
|||||||
|
|
||||||
private void btnTest_Click(object sender, EventArgs e)
|
private void btnTest_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if(horn is not null)
|
horn.Sound((uint)Properties.Settings.Default.SignalLength);
|
||||||
horn.Sound((uint)numericSignalLength.Value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Clock_Tick(object sender, EventArgs e)
|
private void Clock_Tick(object sender, EventArgs e)
|
||||||
@ -164,7 +161,7 @@ namespace Tidstagning
|
|||||||
{
|
{
|
||||||
if (comboComport is not null && comboComport.Items.Count != 0 && comboComport.SelectedItem is not null)
|
if (comboComport is not null && comboComport.Items.Count != 0 && comboComport.SelectedItem is not null)
|
||||||
{
|
{
|
||||||
horn = new Relay(comboComport.SelectedItem.ToString());
|
horn.Open(comboComport.SelectedItem.ToString());
|
||||||
Properties.Settings.Default.ComPort = comboComport.SelectedItem.ToString();
|
Properties.Settings.Default.ComPort = comboComport.SelectedItem.ToString();
|
||||||
Properties.Settings.Default.Save();
|
Properties.Settings.Default.Save();
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ namespace Tidstagning
|
|||||||
{
|
{
|
||||||
class Relay
|
class Relay
|
||||||
{
|
{
|
||||||
SerialPort com;
|
SerialPort com = new SerialPort();
|
||||||
|
|
||||||
struct SignalSpec
|
struct SignalSpec
|
||||||
{
|
{
|
||||||
@ -17,9 +17,16 @@ namespace Tidstagning
|
|||||||
};
|
};
|
||||||
Queue<SignalSpec> signals = new Queue<SignalSpec>();
|
Queue<SignalSpec> signals = new Queue<SignalSpec>();
|
||||||
bool processing_queue = false;
|
bool processing_queue = false;
|
||||||
public Relay(string ComPort)
|
|
||||||
|
public Relay()
|
||||||
{
|
{
|
||||||
com = new SerialPort();
|
}
|
||||||
|
|
||||||
|
public Open(string ComPort)
|
||||||
|
{
|
||||||
|
if(SerialPort.IsOpen())
|
||||||
|
SerialPort.Close();
|
||||||
|
|
||||||
com.PortName = ComPort;
|
com.PortName = ComPort;
|
||||||
com.BaudRate = 9600;
|
com.BaudRate = 9600;
|
||||||
try
|
try
|
||||||
@ -51,6 +58,12 @@ namespace Tidstagning
|
|||||||
*/
|
*/
|
||||||
public void Sound(uint time)
|
public void Sound(uint time)
|
||||||
{
|
{
|
||||||
|
if(!com.IsOpen)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("ComPort not open");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Debug.WriteLine("Requesting horn for: " + time.ToString() + "ms");
|
Debug.WriteLine("Requesting horn for: " + time.ToString() + "ms");
|
||||||
SignalSpec on_signal;
|
SignalSpec on_signal;
|
||||||
on_signal.duration = time;
|
on_signal.duration = time;
|
||||||
|
Loading…
Reference in New Issue
Block a user