Start modernization
# Conflicts: # .gitignore # App.xaml # App.xaml.cs # AudioWatcher.cs # Delcom/DeviceManagement.cs # Delcom/StoplightIndicator.cs # LICENSE.md # LightController.cs # Properties/AssemblyInfo.cs # Properties/Resources.Designer.cs # Properties/Resources.resx # Properties/Settings.Designer.cs # Properties/Settings.settings # README.md # UpdateCheck.cs # WorkIndicator.csproj # WorkIndicator.sln # WorkIndicator.sln.DotSettings
This commit is contained in:
@@ -4,7 +4,7 @@ using System.Windows.Forms;
|
||||
|
||||
namespace WorkIndicator.Delcom
|
||||
{
|
||||
sealed internal partial class DeviceManagement
|
||||
internal sealed partial class DeviceManagement
|
||||
{
|
||||
/// <summary>
|
||||
/// Compares two device path names. Used to find out if the device name
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Common.Extensions;
|
||||
using System;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace WorkIndicator.Delcom
|
||||
@@ -20,29 +19,24 @@ namespace WorkIndicator.Delcom
|
||||
Blink
|
||||
}
|
||||
|
||||
private readonly Delcom _delcom;
|
||||
|
||||
private LightState _green = LightState.Off;
|
||||
private LightState _yellow = LightState.Off;
|
||||
private LightState _red = LightState.Off;
|
||||
|
||||
public StoplightIndicator()
|
||||
{
|
||||
_delcom = new Delcom();
|
||||
_delcom.Open();
|
||||
Device = new Delcom();
|
||||
Device.Open();
|
||||
|
||||
SetLights(_red, _yellow, _green);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_delcom.Close();
|
||||
Device.Close();
|
||||
}
|
||||
|
||||
public Delcom Device
|
||||
{
|
||||
get { return _delcom; }
|
||||
}
|
||||
public Delcom Device { get; }
|
||||
|
||||
public void GetLights(out LightState red, out LightState yellow, out LightState green)
|
||||
{
|
||||
@@ -65,7 +59,7 @@ namespace WorkIndicator.Delcom
|
||||
return _green;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("light");
|
||||
throw new ArgumentOutOfRangeException(nameof(light));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +80,7 @@ namespace WorkIndicator.Delcom
|
||||
port1 = port1.SetBitValue((int) Light.Yellow, yellow == LightState.Off);
|
||||
port1 = port1.SetBitValue((int) Light.Red, red == LightState.Off);
|
||||
|
||||
_delcom.WritePorts(0, port1);
|
||||
Device.WritePorts(0, port1);
|
||||
|
||||
var blinkEnable = 0;
|
||||
var blinkDisable = 0;
|
||||
@@ -106,7 +100,7 @@ namespace WorkIndicator.Delcom
|
||||
else
|
||||
blinkDisable = blinkDisable.SetBitValue((int) Light.Green, true);
|
||||
|
||||
_delcom.WriteBlink(blinkDisable, blinkEnable);
|
||||
Device.WriteBlink(blinkDisable, blinkEnable);
|
||||
}
|
||||
|
||||
public void SetLight(Light light, LightState state)
|
||||
@@ -130,7 +124,7 @@ namespace WorkIndicator.Delcom
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("light");
|
||||
throw new ArgumentOutOfRangeException(nameof(light));
|
||||
}
|
||||
|
||||
SetLights(red, yellow, green);
|
||||
|
||||
Reference in New Issue
Block a user