Skip to content

Commit

Permalink
Added serial port locking in focuser driver for multi-threaded applic…
Browse files Browse the repository at this point in the history
…ations + cleanup and minor fixes
  • Loading branch information
jlecomte committed Sep 18, 2024
1 parent 801e2d3 commit 9b439f1
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 70 deletions.
28 changes: 14 additions & 14 deletions ASCOM_Driver/FilterWheelProxyDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class FilterWheelProxy : IFilterWheelV2
/// <summary>
/// Driver description that displays in the ASCOM Chooser.
/// </summary>
private static readonly string deviceName = "DarkSkyGeeks Filter Wheel Proxy For OAG Focuser";
private static readonly string deviceName = "DarkSkyGeek's Filter Wheel Proxy For OAG Focuser";

// Constants used for Profile persistence
internal static int MAX_FILTER_COUNT = 8;
Expand Down Expand Up @@ -87,7 +87,7 @@ public FilterWheelProxy()
{
tl = new TraceLogger("", "DarkSkyGeek");

tl.LogMessage("FilterWheel", "Starting initialization");
LogMessage("FilterWheel", "Starting initialization");

ReadProfile();

Expand All @@ -105,7 +105,7 @@ public FilterWheelProxy()

connectedState = false;

tl.LogMessage("FilterWheel", "Completed initialization");
LogMessage("FilterWheel", "Completed initialization");
}

//
Expand Down Expand Up @@ -142,7 +142,7 @@ public ArrayList SupportedActions
{
get
{
tl.LogMessage("SupportedActions Get", "Returning empty arraylist");
LogMessage("SupportedActions Get", "Returning empty arraylist");
return new ArrayList();
}
}
Expand Down Expand Up @@ -187,7 +187,7 @@ public bool Connected
}
set
{
tl.LogMessage("Connected", "Set {0}", value);
LogMessage("Connected", "Set {0}", value);
if (value == IsConnected)
return;

Expand Down Expand Up @@ -236,7 +236,7 @@ public string Description
{
get
{
tl.LogMessage("Description Get", deviceName);
LogMessage("Description Get", deviceName);
return deviceName;
}
}
Expand All @@ -247,7 +247,7 @@ public string DriverInfo
{
Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
string driverInfo = deviceName + " ASCOM Driver Version " + String.Format(CultureInfo.InvariantCulture, "{0}.{1}", version.Major, version.Minor);
tl.LogMessage("DriverInfo Get", driverInfo);
LogMessage("DriverInfo Get", driverInfo);
return driverInfo;
}
}
Expand All @@ -258,7 +258,7 @@ public string DriverVersion
{
Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
string driverVersion = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", version.Major, version.Minor);
tl.LogMessage("DriverVersion Get", driverVersion);
LogMessage("DriverVersion Get", driverVersion);
return driverVersion;
}
}
Expand All @@ -276,7 +276,7 @@ public string Name
{
get
{
tl.LogMessage("Name Get", deviceName);
LogMessage("Name Get", deviceName);
return deviceName;
}
}
Expand All @@ -290,7 +290,7 @@ public int[] FocusOffsets
get
{
var profile = GetSelectedProfile();
tl.LogMessage("FocusOffsets Get", "[ " + String.Join(", ", profile.filterOffsets) + " ]");
LogMessage("FocusOffsets Get", "[ " + String.Join(", ", profile.filterOffsets) + " ]");
return profile.filterOffsets.ToArray();
}
}
Expand All @@ -300,7 +300,7 @@ public string[] Names
get
{
var profile = GetSelectedProfile();
tl.LogMessage("Names Get", "[ " + String.Join(", ", profile.filterNames) + " ]");
LogMessage("Names Get", "[ " + String.Join(", ", profile.filterNames) + " ]");
return profile.filterNames.ToArray();
}
}
Expand All @@ -326,7 +326,7 @@ public short Position
}

var profile = GetSelectedProfile();
tl.LogMessage("FilterWheel", $"Using profile {profile.name}");
LogMessage("FilterWheel", $"Using profile {profile.name}");
short oldPosition = filterWheel.Position;
short newPosition = value;

Expand All @@ -335,7 +335,7 @@ public short Position
int oldFilterOffset = profile.filterOffsets[oldPosition];
int newFilterOffset = profile.filterOffsets[newPosition];
int delta = (int) ((newFilterOffset - oldFilterOffset) * profile.stepRatio);
tl.LogMessage("FilterWheel", $"oldFilterOffset = {oldFilterOffset}, newFilterOffset = {newFilterOffset}, delta = {delta}");
LogMessage("FilterWheel", $"oldFilterOffset = {oldFilterOffset}, newFilterOffset = {newFilterOffset}, delta = {delta}");
if (delta > 0)
{
// If we're moving OUT, we overshoot to deal with backlash...
Expand Down Expand Up @@ -481,7 +481,7 @@ internal void ReadProfile()
}
catch (Exception e)
{
tl.LogMessage("FilterWheel", "ReadProfile: Exception handled: " + e.Message);
LogMessage("FilterWheel", "ReadProfile: Exception handled: " + e.Message);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ASCOM_Driver/FilterWheelSetupDialogForm.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9b439f1

Please sign in to comment.