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