Code inspection cleanup
This commit is contained in:
@@ -113,11 +113,13 @@ namespace AstroMath.UnitTests
|
|||||||
{
|
{
|
||||||
var latitude = 52.0;
|
var latitude = 52.0;
|
||||||
|
|
||||||
EquatorialCoordinates equatorialCoordinates = new EquatorialCoordinates();
|
var equatorialCoordinates = new EquatorialCoordinates
|
||||||
equatorialCoordinates.RightAscension = 5.862222222222222;//5 51' 44"
|
{
|
||||||
equatorialCoordinates.Declination = 23.21944444444444;//23 13' 10"
|
RightAscension = 5.862222222222222, //5 51' 44"
|
||||||
|
Declination = 23.21944444444444 //23 13' 10"
|
||||||
|
};
|
||||||
|
|
||||||
var hourAngle = 5.682222;
|
const double hourAngle = 5.682222;
|
||||||
|
|
||||||
var altAz = _astroMath.ConvertEqToHoz(hourAngle, latitude, equatorialCoordinates);
|
var altAz = _astroMath.ConvertEqToHoz(hourAngle, latitude, equatorialCoordinates);
|
||||||
|
|
||||||
@@ -131,9 +133,11 @@ namespace AstroMath.UnitTests
|
|||||||
DateTime dateTime = new DateTime(2019, 05, 18, 22, 26, 15, DateTimeKind.Utc);
|
DateTime dateTime = new DateTime(2019, 05, 18, 22, 26, 15, DateTimeKind.Utc);
|
||||||
var longitude = -1.7833333333333332;
|
var longitude = -1.7833333333333332;
|
||||||
var latitude = 52.0;
|
var latitude = 52.0;
|
||||||
EquatorialCoordinates equatorialCoordinates = new EquatorialCoordinates();
|
EquatorialCoordinates equatorialCoordinates = new EquatorialCoordinates
|
||||||
equatorialCoordinates.RightAscension = 4.15361111111111;
|
{
|
||||||
equatorialCoordinates.Declination = 30.0019444444444;
|
RightAscension = 4.15361111111111,
|
||||||
|
Declination = 30.0019444444444
|
||||||
|
};
|
||||||
|
|
||||||
var hourAngle = _astroMath.RightAscensionToHourAngle(dateTime, longitude, equatorialCoordinates.RightAscension);
|
var hourAngle = _astroMath.RightAscensionToHourAngle(dateTime, longitude, equatorialCoordinates.RightAscension);
|
||||||
var altaz = _astroMath.ConvertEqToHoz(hourAngle, latitude, equatorialCoordinates);
|
var altaz = _astroMath.ConvertEqToHoz(hourAngle, latitude, equatorialCoordinates);
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ namespace Meade.net.Focuser.UnitTests
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
_profileProperties = new ProfileProperties();
|
_profileProperties = new ProfileProperties
|
||||||
_profileProperties.TraceLogger = false;
|
{
|
||||||
_profileProperties.ComPort = "TestCom1";
|
TraceLogger = false,
|
||||||
_profileProperties.GuideRateArcSecondsPerSecond = 1.23;
|
ComPort = "TestCom1",
|
||||||
_profileProperties.Precision = "Unchanged";
|
GuideRateArcSecondsPerSecond = 1.23,
|
||||||
|
Precision = "Unchanged"
|
||||||
|
};
|
||||||
|
|
||||||
_utilMock = new Mock<IUtil>();
|
_utilMock = new Mock<IUtil>();
|
||||||
|
|
||||||
@@ -84,7 +86,7 @@ namespace Meade.net.Focuser.UnitTests
|
|||||||
{
|
{
|
||||||
var actionName = "Action";
|
var actionName = "Action";
|
||||||
|
|
||||||
var exception = Assert.Throws<ActionNotImplementedException>(() => { var actualResult = _focuser.Action(actionName, string.Empty); });
|
Assert.Throws<ActionNotImplementedException>(() => { var actualResult = _focuser.Action(actionName, string.Empty); });
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -246,8 +248,6 @@ namespace Meade.net.Focuser.UnitTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void DriverInfo_Get()
|
public void DriverInfo_Get()
|
||||||
{
|
{
|
||||||
Version version = System.Reflection.Assembly.GetAssembly(typeof(ASCOM.Meade.net.Focuser)).GetName().Version;
|
|
||||||
|
|
||||||
string exptectedDriverInfo = $"{_focuser.Description} .net driver. Version: {_focuser.DriverVersion}";
|
string exptectedDriverInfo = $"{_focuser.Description} .net driver. Version: {_focuser.DriverVersion}";
|
||||||
|
|
||||||
var driverInfo = _focuser.DriverInfo;
|
var driverInfo = _focuser.DriverInfo;
|
||||||
|
|||||||
@@ -28,11 +28,13 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
_profileProperties = new ProfileProperties();
|
_profileProperties = new ProfileProperties
|
||||||
_profileProperties.TraceLogger = false;
|
{
|
||||||
_profileProperties.ComPort = "TestCom1";
|
TraceLogger = false,
|
||||||
_profileProperties.GuideRateArcSecondsPerSecond = 1.23;
|
ComPort = "TestCom1",
|
||||||
_profileProperties.Precision = "Unchanged";
|
GuideRateArcSecondsPerSecond = 1.23,
|
||||||
|
Precision = "Unchanged"
|
||||||
|
};
|
||||||
|
|
||||||
_utilMock = new Mock<IUtil>();
|
_utilMock = new Mock<IUtil>();
|
||||||
_utilExtraMock = new Mock<IUtilExtra>();
|
_utilExtraMock = new Mock<IUtilExtra>();
|
||||||
@@ -521,8 +523,6 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void DriverInfo_Get()
|
public void DriverInfo_Get()
|
||||||
{
|
{
|
||||||
Version version = System.Reflection.Assembly.GetAssembly(typeof(ASCOM.Meade.net.Telescope)).GetName().Version;
|
|
||||||
|
|
||||||
string exptectedDriverInfo = $"{_telescope.Description} .net driver. Version: {_telescope.DriverVersion}";
|
string exptectedDriverInfo = $"{_telescope.Description} .net driver. Version: {_telescope.DriverVersion}";
|
||||||
|
|
||||||
var driverInfo = _telescope.DriverInfo;
|
var driverInfo = _telescope.DriverInfo;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace ASCOM.Meade.net.AstroMaths
|
|||||||
//returns the decimal hour angle for given right ascension on a given datetime for a given logitude.
|
//returns the decimal hour angle for given right ascension on a given datetime for a given logitude.
|
||||||
public double RightAscensionToHourAngle(DateTime utcDateTime, double longitude, double rightAscension)
|
public double RightAscensionToHourAngle(DateTime utcDateTime, double longitude, double rightAscension)
|
||||||
{
|
{
|
||||||
var ut = DateTimeToDecimalHours( utcDateTime);
|
//var ut = DateTimeToDecimalHours( utcDateTime);
|
||||||
var gst = UTtoGst( utcDateTime);
|
var gst = UTtoGst( utcDateTime);
|
||||||
var lst = GsTtoLst( gst, longitude);
|
var lst = GsTtoLst( gst, longitude);
|
||||||
var raHours = rightAscension;
|
var raHours = rightAscension;
|
||||||
@@ -82,10 +82,11 @@ namespace ASCOM.Meade.net.AstroMaths
|
|||||||
var upperA = Math.Atan2(y, x);
|
var upperA = Math.Atan2(y, x);
|
||||||
var upperB = RadiansToDegrees(upperA);
|
var upperB = RadiansToDegrees(upperA);
|
||||||
|
|
||||||
var horizonCoordinates = new HorizonCoordinates();
|
var horizonCoordinates = new HorizonCoordinates
|
||||||
horizonCoordinates.Altitude = RadiansToDegrees(Math.Asin(sinA));
|
{
|
||||||
|
Altitude = RadiansToDegrees(Math.Asin(sinA)), Azimuth = upperB
|
||||||
|
};
|
||||||
|
|
||||||
horizonCoordinates.Azimuth = upperB;
|
|
||||||
|
|
||||||
if (upperB < 0)
|
if (upperB < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,17 +19,14 @@ namespace ASCOM.Meade.net
|
|||||||
[ComVisible(true)]
|
[ComVisible(true)]
|
||||||
public class Rate : IRate
|
public class Rate : IRate
|
||||||
{
|
{
|
||||||
private double _maximum = 0;
|
|
||||||
private double _minimum = 0;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Default constructor - Internal prevents public creation
|
// Default constructor - Internal prevents public creation
|
||||||
// of instances. These are values for AxisRates.
|
// of instances. These are values for AxisRates.
|
||||||
//
|
//
|
||||||
internal Rate(double minimum, double maximum)
|
internal Rate(double minimum, double maximum)
|
||||||
{
|
{
|
||||||
_maximum = maximum;
|
Maximum = maximum;
|
||||||
_minimum = minimum;
|
Minimum = minimum;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Implementation of IRate
|
#region Implementation of IRate
|
||||||
@@ -39,17 +36,9 @@ namespace ASCOM.Meade.net
|
|||||||
// TODO Add any required object cleanup here
|
// TODO Add any required object cleanup here
|
||||||
}
|
}
|
||||||
|
|
||||||
public double Maximum
|
public double Maximum { get; set; }
|
||||||
{
|
|
||||||
get => _maximum;
|
|
||||||
set => _maximum = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double Minimum
|
public double Minimum { get; set; }
|
||||||
{
|
|
||||||
get => _minimum;
|
|
||||||
set => _minimum = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -152,7 +141,7 @@ namespace ASCOM.Meade.net
|
|||||||
private readonly DriveRates[] _trackingRates;
|
private readonly DriveRates[] _trackingRates;
|
||||||
|
|
||||||
// this is used to make the index thread safe
|
// this is used to make the index thread safe
|
||||||
private readonly ThreadLocal<int> _pos = new ThreadLocal<int>(() => { return -1; });
|
private readonly ThreadLocal<int> _pos = new ThreadLocal<int>(() => -1);
|
||||||
private static readonly object LockObj = new object();
|
private static readonly object LockObj = new object();
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -176,7 +165,11 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
public IEnumerator GetEnumerator()
|
public IEnumerator GetEnumerator()
|
||||||
{
|
{
|
||||||
_pos.Value = -1;
|
lock (LockObj)
|
||||||
|
{
|
||||||
|
_pos.Value = -1;
|
||||||
|
}
|
||||||
|
|
||||||
return this as IEnumerator;
|
return this as IEnumerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +213,10 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
_pos.Value = -1;
|
lock (LockObj)
|
||||||
|
{
|
||||||
|
_pos.Value = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,9 +98,7 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double _guideRate;
|
private double _guideRate;
|
||||||
|
|
||||||
private const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second
|
|
||||||
|
|
||||||
private void Initialise()
|
private void Initialise()
|
||||||
{
|
{
|
||||||
//todo move the TraceLogger out to a factory class.
|
//todo move the TraceLogger out to a factory class.
|
||||||
@@ -152,9 +150,7 @@ namespace ASCOM.Meade.net
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
LogMessage("SupportedActions Get", "Returning empty arraylist");
|
LogMessage("SupportedActions Get", "Returning empty arraylist");
|
||||||
var supportedActions = new ArrayList();
|
var supportedActions = new ArrayList {"handbox", "site"};
|
||||||
supportedActions.Add("handbox");
|
|
||||||
supportedActions.Add("site");
|
|
||||||
return supportedActions;
|
return supportedActions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -540,9 +536,9 @@ namespace ASCOM.Meade.net
|
|||||||
CheckConnected("SelectSite");
|
CheckConnected("SelectSite");
|
||||||
|
|
||||||
if (site < 1)
|
if (site < 1)
|
||||||
throw new ArgumentOutOfRangeException("site",site,"Site cannot be lower than 1");
|
throw new ArgumentOutOfRangeException(nameof(site),site,"Site cannot be lower than 1");
|
||||||
else if (site > 4)
|
else if (site > 4)
|
||||||
throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4");
|
throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4");
|
||||||
|
|
||||||
_sharedResourcesWrapper.SendBlind($":W{site}#");
|
_sharedResourcesWrapper.SendBlind($":W{site}#");
|
||||||
//:W<n>#
|
//:W<n>#
|
||||||
@@ -555,9 +551,9 @@ namespace ASCOM.Meade.net
|
|||||||
CheckConnected("SetSiteName");
|
CheckConnected("SetSiteName");
|
||||||
|
|
||||||
if (site < 1)
|
if (site < 1)
|
||||||
throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1");
|
throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be lower than 1");
|
||||||
else if (site > 4)
|
else if (site > 4)
|
||||||
throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4");
|
throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4");
|
||||||
|
|
||||||
string command = String.Empty;
|
string command = String.Empty;
|
||||||
switch (site)
|
switch (site)
|
||||||
@@ -609,9 +605,9 @@ namespace ASCOM.Meade.net
|
|||||||
CheckConnected("GetSiteName");
|
CheckConnected("GetSiteName");
|
||||||
|
|
||||||
if (site < 1)
|
if (site < 1)
|
||||||
throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1");
|
throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be lower than 1");
|
||||||
else if (site > 4)
|
else if (site > 4)
|
||||||
throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4");
|
throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4");
|
||||||
|
|
||||||
switch (site)
|
switch (site)
|
||||||
{
|
{
|
||||||
@@ -637,7 +633,7 @@ namespace ASCOM.Meade.net
|
|||||||
//A ‘#’ terminated string with the name of the requested site.
|
//A ‘#’ terminated string with the name of the requested site.
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ArgumentOutOfRangeException("site", site, "Site out of range");
|
throw new ArgumentOutOfRangeException(nameof(site), site, "Site out of range");
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Description
|
public string Description
|
||||||
@@ -874,7 +870,7 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _atPark = false;
|
private bool _atPark;
|
||||||
|
|
||||||
public bool AtPark
|
public bool AtPark
|
||||||
{
|
{
|
||||||
@@ -1162,10 +1158,10 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
if (!value.InRange(0, 15.0417))
|
if (!value.InRange(0, 15.0417))
|
||||||
{
|
{
|
||||||
throw new InvalidValueException(propertyName, value.ToString(), "0 to 15.0417”/sec");
|
throw new InvalidValueException(propertyName, value.ToString(CultureInfo.CurrentCulture), $"{0.ToString(CultureInfo.CurrentCulture)} to {15.0417.ToString(CultureInfo.CurrentCulture)}”/sec");
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString()} arc seconds/second ({value.ToString()} degrees/second)");
|
LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString(CultureInfo.CurrentCulture)} arc seconds/second ({value.ToString(CultureInfo.CurrentCulture)} degrees/second)");
|
||||||
_sharedResourcesWrapper.SendBlind($":Rg{value:00.0}#");
|
_sharedResourcesWrapper.SendBlind($":Rg{value:00.0}#");
|
||||||
//:RgSS.S#
|
//:RgSS.S#
|
||||||
//Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking
|
//Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking
|
||||||
@@ -1708,10 +1704,8 @@ namespace ASCOM.Meade.net
|
|||||||
throw new InvalidValueException("Azimuth cannot be less than 0.");
|
throw new InvalidValueException("Azimuth cannot be less than 0.");
|
||||||
|
|
||||||
LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude}");
|
LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude}");
|
||||||
|
|
||||||
HorizonCoordinates altAz = new HorizonCoordinates();
|
HorizonCoordinates altAz = new HorizonCoordinates {Azimuth = azimuth, Altitude = altitude};
|
||||||
altAz.Azimuth = azimuth;
|
|
||||||
altAz.Altitude = altitude;
|
|
||||||
|
|
||||||
var utcDateTime = UTCDate;
|
var utcDateTime = UTCDate;
|
||||||
var latitude = SiteLatitude;
|
var latitude = SiteLatitude;
|
||||||
@@ -2128,18 +2122,20 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
LogMessage("UTCDate", "Get started");
|
LogMessage("UTCDate", "Get started");
|
||||||
|
|
||||||
TelescopeDateDetails telescopeDateDetails = _sharedResourcesWrapper.Lock(() =>
|
var telescopeDateDetails = _sharedResourcesWrapper.Lock(() =>
|
||||||
{
|
{
|
||||||
TelescopeDateDetails tdd = new TelescopeDateDetails();
|
var tdd = new TelescopeDateDetails
|
||||||
tdd.TelescopeDate = _sharedResourcesWrapper.SendString(":GC#");
|
{
|
||||||
//:GC# Get current date.
|
TelescopeDate = _sharedResourcesWrapper.SendString(":GC#"),
|
||||||
//Returns: MM/DD/YY#
|
//:GC# Get current date.
|
||||||
//The current local calendar date for the telescope.
|
//Returns: MM/DD/YY#
|
||||||
tdd.TelescopeTime = _sharedResourcesWrapper.SendString(":GL#");
|
//The current local calendar date for the telescope.
|
||||||
//:GL# Get Local Time in 24 hour format
|
TelescopeTime = _sharedResourcesWrapper.SendString(":GL#"),
|
||||||
//Returns: HH:MM:SS#
|
//:GL# Get Local Time in 24 hour format
|
||||||
//The Local Time in 24 - hour Format
|
//Returns: HH:MM:SS#
|
||||||
tdd.UtcCorrection = GetUtcCorrection();
|
//The Local Time in 24 - hour Format
|
||||||
|
UtcCorrection = GetUtcCorrection()
|
||||||
|
};
|
||||||
|
|
||||||
return tdd;
|
return tdd;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace ASCOM.Meade.net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify)
|
/// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static TraceLogger Tl;
|
private static TraceLogger _tl;
|
||||||
|
|
||||||
private readonly ISharedResourcesWrapper _sharedResourcesWrapper;
|
private readonly ISharedResourcesWrapper _sharedResourcesWrapper;
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ namespace ASCOM.Meade.net
|
|||||||
private void Initialise()
|
private void Initialise()
|
||||||
{
|
{
|
||||||
//todo move the TraceLogger out to a factory class.
|
//todo move the TraceLogger out to a factory class.
|
||||||
Tl = new TraceLogger("", "Meade.Generic.focusser");
|
_tl = new TraceLogger("", "Meade.Generic.focusser");
|
||||||
|
|
||||||
ReadProfile(); // Read device configuration from the ASCOM Profile store
|
ReadProfile(); // Read device configuration from the ASCOM Profile store
|
||||||
|
|
||||||
@@ -108,17 +108,17 @@ namespace ASCOM.Meade.net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetupDialog()
|
public void SetupDialog()
|
||||||
{
|
{
|
||||||
Tl.LogMessage("SetupDialog", "Opening setup dialog");
|
_tl.LogMessage("SetupDialog", "Opening setup dialog");
|
||||||
_sharedResourcesWrapper.SetupDialog();
|
_sharedResourcesWrapper.SetupDialog();
|
||||||
ReadProfile();
|
ReadProfile();
|
||||||
Tl.LogMessage("SetupDialog", "complete");
|
_tl.LogMessage("SetupDialog", "complete");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList SupportedActions
|
public ArrayList SupportedActions
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Tl.LogMessage("SupportedActions Get", "Returning empty arraylist");
|
_tl.LogMessage("SupportedActions Get", "Returning empty arraylist");
|
||||||
return new ArrayList();
|
return new ArrayList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,9 +163,9 @@ namespace ASCOM.Meade.net
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
// Clean up the tracelogger and util objects
|
// Clean up the tracelogger and util objects
|
||||||
Tl.Enabled = false;
|
_tl.Enabled = false;
|
||||||
Tl.Dispose();
|
_tl.Dispose();
|
||||||
Tl = null;
|
_tl = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Connected
|
public bool Connected
|
||||||
@@ -177,7 +177,7 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Tl.LogMessage("Connected", "Set {0}", value);
|
_tl.LogMessage("Connected", "Set {0}", value);
|
||||||
if (value == IsConnected)
|
if (value == IsConnected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ namespace ASCOM.Meade.net
|
|||||||
// TODO customise this device description
|
// TODO customise this device description
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Tl.LogMessage("Description Get", DriverDescription);
|
_tl.LogMessage("Description Get", DriverDescription);
|
||||||
return DriverDescription;
|
return DriverDescription;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,7 +259,7 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
//string name = "Short driver name - please customise";
|
//string name = "Short driver name - please customise";
|
||||||
string name = DriverDescription;
|
string name = DriverDescription;
|
||||||
Tl.LogMessage("Name Get", name);
|
_tl.LogMessage("Name Get", name);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -274,14 +274,14 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
CheckConnected("Absolute Get");
|
CheckConnected("Absolute Get");
|
||||||
|
|
||||||
Tl.LogMessage("Absolute Get", false.ToString());
|
_tl.LogMessage("Absolute Get", false.ToString());
|
||||||
return false; // This is a relative focuser
|
return false; // This is a relative focuser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Halt()
|
public void Halt()
|
||||||
{
|
{
|
||||||
Tl.LogMessage("Halt", "Halting");
|
_tl.LogMessage("Halt", "Halting");
|
||||||
|
|
||||||
CheckConnected("Halt");
|
CheckConnected("Halt");
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Tl.LogMessage("IsMoving Get", false.ToString());
|
_tl.LogMessage("IsMoving Get", false.ToString());
|
||||||
return false; // This focuser always moves instantaneously so no need for IsMoving ever to be True
|
return false; // This focuser always moves instantaneously so no need for IsMoving ever to be True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,12 +311,12 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Tl.LogMessage("Link Get", Connected.ToString());
|
_tl.LogMessage("Link Get", Connected.ToString());
|
||||||
return Connected; // Direct function to the connected method, the Link method is just here for backwards compatibility
|
return Connected; // Direct function to the connected method, the Link method is just here for backwards compatibility
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Tl.LogMessage("Link Set", value.ToString());
|
_tl.LogMessage("Link Set", value.ToString());
|
||||||
Connected = value; // Direct function to the connected method, the Link method is just here for backwards compatibility
|
Connected = value; // Direct function to the connected method, the Link method is just here for backwards compatibility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,7 +326,7 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Tl.LogMessage("MaxIncrement Get", _maxIncrement.ToString());
|
_tl.LogMessage("MaxIncrement Get", _maxIncrement.ToString());
|
||||||
return _maxIncrement; // Maximum change in one move
|
return _maxIncrement; // Maximum change in one move
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -336,14 +336,14 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Tl.LogMessage("MaxStep Get", _maxStep.ToString());
|
_tl.LogMessage("MaxStep Get", _maxStep.ToString());
|
||||||
return _maxStep;
|
return _maxStep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Move(int position)
|
public void Move(int position)
|
||||||
{
|
{
|
||||||
Tl.LogMessage("Move", position.ToString());
|
_tl.LogMessage("Move", position.ToString());
|
||||||
CheckConnected("Move");
|
CheckConnected("Move");
|
||||||
|
|
||||||
//todo implement backlash compensation
|
//todo implement backlash compensation
|
||||||
@@ -405,7 +405,7 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Tl.LogMessage("StepSize Get", "Not implemented");
|
_tl.LogMessage("StepSize Get", "Not implemented");
|
||||||
throw new PropertyNotImplementedException("StepSize", false);
|
throw new PropertyNotImplementedException("StepSize", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -414,13 +414,13 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Tl.LogMessage("TempComp Get", false.ToString());
|
_tl.LogMessage("TempComp Get", false.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// ReSharper disable once ValueParameterNotUsed
|
// ReSharper disable once ValueParameterNotUsed
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Tl.LogMessage("TempComp Set", "Not implemented");
|
_tl.LogMessage("TempComp Set", "Not implemented");
|
||||||
throw new PropertyNotImplementedException("TempComp", false);
|
throw new PropertyNotImplementedException("TempComp", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -429,7 +429,7 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Tl.LogMessage("TempCompAvailable Get", false.ToString());
|
_tl.LogMessage("TempCompAvailable Get", false.ToString());
|
||||||
return false; // Temperature compensation is not available in this driver
|
return false; // Temperature compensation is not available in this driver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -438,7 +438,7 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Tl.LogMessage("Temperature Get", "Not implemented");
|
_tl.LogMessage("Temperature Get", "Not implemented");
|
||||||
throw new PropertyNotImplementedException("Temperature", false);
|
throw new PropertyNotImplementedException("Temperature", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -546,10 +546,10 @@ namespace ASCOM.Meade.net
|
|||||||
private void ReadProfile()
|
private void ReadProfile()
|
||||||
{
|
{
|
||||||
var profileProperties = _sharedResourcesWrapper.ReadProfile();
|
var profileProperties = _sharedResourcesWrapper.ReadProfile();
|
||||||
Tl.Enabled = profileProperties.TraceLogger;
|
_tl.Enabled = profileProperties.TraceLogger;
|
||||||
_comPort = profileProperties.ComPort;
|
_comPort = profileProperties.ComPort;
|
||||||
|
|
||||||
LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}");
|
LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}");
|
||||||
LogMessage("ReadProfile", $"Com Port: {_comPort}");
|
LogMessage("ReadProfile", $"Com Port: {_comPort}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,7 +562,7 @@ namespace ASCOM.Meade.net
|
|||||||
private static void LogMessage(string identifier, string message, params object[] args)
|
private static void LogMessage(string identifier, string message, params object[] args)
|
||||||
{
|
{
|
||||||
var msg = string.Format(message, args);
|
var msg = string.Format(message, args);
|
||||||
Tl.LogMessage(identifier, msg);
|
_tl.LogMessage(identifier, msg);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace ASCOM.Meade.net
|
|||||||
Product = "", Copyright = "", Trademark = "",
|
Product = "", Copyright = "", Trademark = "",
|
||||||
AssemblyVersion = "", FileVersion = "", Guid = "",
|
AssemblyVersion = "", FileVersion = "", Guid = "",
|
||||||
NeutralLanguage = "";
|
NeutralLanguage = "";
|
||||||
public bool IsComVisible = false;
|
public bool IsComVisible;
|
||||||
|
|
||||||
// Return a particular assembly attribute value.
|
// Return a particular assembly attribute value.
|
||||||
public static T GetAssemblyAttribute<T>(Assembly assembly)
|
public static T GetAssemblyAttribute<T>(Assembly assembly)
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ namespace ASCOM.Meade.net
|
|||||||
#region Access to ole32.dll functions for class factories
|
#region Access to ole32.dll functions for class factories
|
||||||
|
|
||||||
// Define two common GUID objects for public usage.
|
// Define two common GUID objects for public usage.
|
||||||
private static readonly Guid _iidIUnknown = new Guid("{00000000-0000-0000-C000-000000000046}");
|
private static readonly Guid IidIUnknown = new Guid("{00000000-0000-0000-C000-000000000046}");
|
||||||
private static readonly Guid _iidIDispatch = new Guid("{00020400-0000-0000-C000-000000000046}");
|
private static readonly Guid IidIDispatch = new Guid("{00020400-0000-0000-C000-000000000046}");
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
enum Clsctx : uint
|
enum Clsctx : uint
|
||||||
@@ -118,7 +118,7 @@ namespace ASCOM.Meade.net
|
|||||||
public ClassFactory(Type type)
|
public ClassFactory(Type type)
|
||||||
{
|
{
|
||||||
if (type == null)
|
if (type == null)
|
||||||
throw new ArgumentNullException("type");
|
throw new ArgumentNullException(nameof(type));
|
||||||
_mClassType = type;
|
_mClassType = type;
|
||||||
|
|
||||||
//PWGS Get the ProgID from the MetaData
|
//PWGS Get the ProgID from the MetaData
|
||||||
@@ -201,12 +201,12 @@ namespace ASCOM.Meade.net
|
|||||||
//
|
//
|
||||||
// Handle requests for IDispatch or IUnknown on the class
|
// Handle requests for IDispatch or IUnknown on the class
|
||||||
//
|
//
|
||||||
if (riid == _iidIDispatch)
|
if (riid == IidIDispatch)
|
||||||
{
|
{
|
||||||
ppvObject = Marshal.GetIDispatchForObject(Activator.CreateInstance(_mClassType));
|
ppvObject = Marshal.GetIDispatchForObject(Activator.CreateInstance(_mClassType));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (riid == _iidIUnknown)
|
else if (riid == IidIUnknown)
|
||||||
{
|
{
|
||||||
ppvObject = Marshal.GetIUnknownForObject(Activator.CreateInstance(_mClassType));
|
ppvObject = Marshal.GetIUnknownForObject(Activator.CreateInstance(_mClassType));
|
||||||
}
|
}
|
||||||
|
|||||||
+37
-30
@@ -29,7 +29,7 @@ namespace ASCOM.Meade.net
|
|||||||
public static class Server
|
public static class Server
|
||||||
{
|
{
|
||||||
|
|
||||||
private const string DRIVER_NAME = "Meade Generic";
|
private const string DriverName = "Meade Generic";
|
||||||
|
|
||||||
#region Access to kernel32.dll, user32.dll, and ole32.dll functions
|
#region Access to kernel32.dll, user32.dll, and ole32.dll functions
|
||||||
[Flags]
|
[Flags]
|
||||||
@@ -259,7 +259,7 @@ namespace ASCOM.Meade.net
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"Failed to load served COM class assembly {fi.Name} - {e.Message}",
|
MessageBox.Show($"Failed to load served COM class assembly {fi.Name} - {e.Message}",
|
||||||
DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,19 +287,21 @@ namespace ASCOM.Meade.net
|
|||||||
//
|
//
|
||||||
private static void ElevateSelf(string arg)
|
private static void ElevateSelf(string arg)
|
||||||
{
|
{
|
||||||
ProcessStartInfo si = new ProcessStartInfo();
|
var si = new ProcessStartInfo
|
||||||
si.Arguments = arg;
|
{
|
||||||
si.WorkingDirectory = Environment.CurrentDirectory;
|
Arguments = arg,
|
||||||
si.FileName = Application.ExecutablePath;
|
WorkingDirectory = Environment.CurrentDirectory,
|
||||||
si.Verb = "runas";
|
FileName = Application.ExecutablePath,
|
||||||
|
Verb = "runas"
|
||||||
|
};
|
||||||
try { Process.Start(si); }
|
try { Process.Start(si); }
|
||||||
catch (System.ComponentModel.Win32Exception)
|
catch (System.ComponentModel.Win32Exception)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"The {DRIVER_NAME} was not {(arg == "/register" ? "registered" : "unregistered")} because you did not allow it.", DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
MessageBox.Show($"The {DriverName} was not {(arg == "/register" ? "registered" : "unregistered")} because you did not allow it.", DriverName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.ToString(), DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
MessageBox.Show(ex.ToString(), DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -349,8 +351,8 @@ namespace ASCOM.Meade.net
|
|||||||
//
|
//
|
||||||
// HKCR\APPID\exename.ext
|
// HKCR\APPID\exename.ext
|
||||||
//
|
//
|
||||||
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(string.Format("APPID\\{0}",
|
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(
|
||||||
Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1))))
|
$"APPID\\{Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)}"))
|
||||||
{
|
{
|
||||||
key.SetValue("AppID", _sAppId);
|
key.SetValue("AppID", _sAppId);
|
||||||
}
|
}
|
||||||
@@ -358,7 +360,7 @@ namespace ASCOM.Meade.net
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"Error while registering the server:\n{ex}",
|
MessageBox.Show($"Error while registering the server:\n{ex}",
|
||||||
DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -381,7 +383,7 @@ namespace ASCOM.Meade.net
|
|||||||
//PWGS Generate device type from the Class name
|
//PWGS Generate device type from the Class name
|
||||||
string deviceType = type.Name;
|
string deviceType = type.Name;
|
||||||
|
|
||||||
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(string.Format("CLSID\\{0}", clsid)))
|
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey($"CLSID\\{clsid}"))
|
||||||
{
|
{
|
||||||
key.SetValue(null, progid); // Could be assyTitle/Desc??, but .NET components show ProgId here
|
key.SetValue(null, progid); // Could be assyTitle/Desc??, but .NET components show ProgId here
|
||||||
key.SetValue("AppId", _sAppId);
|
key.SetValue("AppId", _sAppId);
|
||||||
@@ -427,7 +429,7 @@ namespace ASCOM.Meade.net
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Error while registering the server:\n" + ex.ToString(),
|
MessageBox.Show("Error while registering the server:\n" + ex.ToString(),
|
||||||
DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||||
bFail = true;
|
bFail = true;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -454,9 +456,9 @@ namespace ASCOM.Meade.net
|
|||||||
//
|
//
|
||||||
// Local server's DCOM/AppID information
|
// Local server's DCOM/AppID information
|
||||||
//
|
//
|
||||||
Registry.ClassesRoot.DeleteSubKey(string.Format("APPID\\{0}", _sAppId), false);
|
Registry.ClassesRoot.DeleteSubKey($"APPID\\{_sAppId}", false);
|
||||||
Registry.ClassesRoot.DeleteSubKey(string.Format("APPID\\{0}",
|
Registry.ClassesRoot.DeleteSubKey(
|
||||||
Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)), false);
|
$"APPID\\{Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)}", false);
|
||||||
|
|
||||||
//
|
//
|
||||||
// For each of the driver assemblies
|
// For each of the driver assemblies
|
||||||
@@ -472,17 +474,17 @@ namespace ASCOM.Meade.net
|
|||||||
//
|
//
|
||||||
// HKCR\progid
|
// HKCR\progid
|
||||||
//
|
//
|
||||||
Registry.ClassesRoot.DeleteSubKey(String.Format("{0}\\CLSID", progid), false);
|
Registry.ClassesRoot.DeleteSubKey($"{progid}\\CLSID", false);
|
||||||
Registry.ClassesRoot.DeleteSubKey(progid, false);
|
Registry.ClassesRoot.DeleteSubKey(progid, false);
|
||||||
//
|
//
|
||||||
// HKCR\CLSID\clsid
|
// HKCR\CLSID\clsid
|
||||||
//
|
//
|
||||||
Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Implemented Categories\\{{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}}", clsid), false);
|
Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\Implemented Categories\\{{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}}", false);
|
||||||
Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Implemented Categories", clsid), false);
|
Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\Implemented Categories", false);
|
||||||
Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\ProgId", clsid), false);
|
Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\ProgId", false);
|
||||||
Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\LocalServer32", clsid), false);
|
Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\LocalServer32", false);
|
||||||
Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Programmable", clsid), false);
|
Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\Programmable", false);
|
||||||
Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}", clsid), false);
|
Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}", false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -494,7 +496,10 @@ namespace ASCOM.Meade.net
|
|||||||
p.Unregister(progid);
|
p.Unregister(progid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception) { }
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -515,7 +520,7 @@ namespace ASCOM.Meade.net
|
|||||||
if (!factory.RegisterClassObject())
|
if (!factory.RegisterClassObject())
|
||||||
{
|
{
|
||||||
MessageBox.Show("Failed to register class factory for " + type.Name,
|
MessageBox.Show("Failed to register class factory for " + type.Name,
|
||||||
DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -571,7 +576,7 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
MessageBox.Show("Unknown argument: " + args[0] + "\nValid are : -register, -unregister and -embedding",
|
MessageBox.Show("Unknown argument: " + args[0] + "\nValid are : -register, -unregister and -embedding",
|
||||||
DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
DriverName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -610,9 +615,11 @@ namespace ASCOM.Meade.net
|
|||||||
RegisterClassFactories();
|
RegisterClassFactories();
|
||||||
|
|
||||||
// Start up the garbage collection thread.
|
// Start up the garbage collection thread.
|
||||||
GarbageCollection garbageCollector = new GarbageCollection(1000);
|
var garbageCollector = new GarbageCollection(1000);
|
||||||
Thread gcThread = new Thread(new ThreadStart(garbageCollector.GcWatch));
|
var gcThread = new Thread(garbageCollector.GcWatch)
|
||||||
gcThread.Name = "Garbage Collection Thread";
|
{
|
||||||
|
Name = "Garbage Collection Thread"
|
||||||
|
};
|
||||||
gcThread.Start();
|
gcThread.Start();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Globalization;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ namespace ASCOM.Meade.net
|
|||||||
comboBoxComPort.SelectedItem = profileProperties.ComPort;
|
comboBoxComPort.SelectedItem = profileProperties.ComPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
txtGuideRate.Text = profileProperties.GuideRateArcSecondsPerSecond.ToString();
|
txtGuideRate.Text = profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cboPrecision.SelectedItem = profileProperties.Precision;
|
cboPrecision.SelectedItem = profileProperties.Precision;
|
||||||
@@ -86,7 +87,6 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
private void TextBox1_TextChanged(object sender, EventArgs e)
|
private void TextBox1_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
//const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
double newGuideRate = double.Parse(txtGuideRate.Text.Trim());
|
double newGuideRate = double.Parse(txtGuideRate.Text.Trim());
|
||||||
@@ -103,17 +103,17 @@ namespace ASCOM.Meade.net
|
|||||||
_guideRateValid = false;
|
_guideRateValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateOKButton();
|
UpdateOkButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateOKButton()
|
private void UpdateOkButton()
|
||||||
{
|
{
|
||||||
cmdOK.Enabled = _guideRateValid && (comboBoxComPort.SelectedItem != null);
|
cmdOK.Enabled = _guideRateValid && (comboBoxComPort.SelectedItem != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComboBoxComPort_SelectedValueChanged(object sender, EventArgs e)
|
private void ComboBoxComPort_SelectedValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
UpdateOKButton();
|
UpdateOkButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetReadOnlyMode()
|
public void SetReadOnlyMode()
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
//
|
//
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ASCOM.Utilities;
|
using ASCOM.Utilities;
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ namespace ASCOM.Meade.net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// number of connections to the shared serial port
|
/// number of connections to the shared serial port
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int Connections { get; set; } = 0;
|
public static int Connections { get; set; }
|
||||||
|
|
||||||
public static void SendBlind(string message)
|
public static void SendBlind(string message)
|
||||||
{
|
{
|
||||||
@@ -179,7 +180,7 @@ namespace ASCOM.Meade.net
|
|||||||
driverProfile.DeviceType = "Telescope";
|
driverProfile.DeviceType = "Telescope";
|
||||||
driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString());
|
driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString());
|
||||||
driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort);
|
driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort);
|
||||||
driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString());
|
driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture));
|
||||||
driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision);
|
driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,9 +265,9 @@ namespace ASCOM.Meade.net
|
|||||||
/// The Key is the connection number that identifies the device, it could be the COM port name,
|
/// The Key is the connection number that identifies the device, it could be the COM port name,
|
||||||
/// USB ID or IP Address, the Value is the DeviceHardware class
|
/// USB ID or IP Address, the Value is the DeviceHardware class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly Dictionary<string, DeviceHardware> _connectedDevices = new Dictionary<string, DeviceHardware>();
|
private static readonly Dictionary<string, DeviceHardware> ConnectedDevices = new Dictionary<string, DeviceHardware>();
|
||||||
|
|
||||||
private static readonly Dictionary<string, DeviceHardware> _connectedDeviceIds = new Dictionary<string, DeviceHardware>();
|
private static readonly Dictionary<string, DeviceHardware> ConnectedDeviceIds = new Dictionary<string, DeviceHardware>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -278,17 +279,17 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
lock (LockObject)
|
lock (LockObject)
|
||||||
{
|
{
|
||||||
if (!_connectedDevices.ContainsKey(deviceId))
|
if (!ConnectedDevices.ContainsKey(deviceId))
|
||||||
_connectedDevices.Add(deviceId, new DeviceHardware());
|
ConnectedDevices.Add(deviceId, new DeviceHardware());
|
||||||
_connectedDevices[deviceId].Count++; // increment the value
|
ConnectedDevices[deviceId].Count++; // increment the value
|
||||||
|
|
||||||
if (!_connectedDeviceIds.ContainsKey(driverId))
|
if (!ConnectedDeviceIds.ContainsKey(driverId))
|
||||||
_connectedDeviceIds.Add(driverId, new DeviceHardware());
|
ConnectedDeviceIds.Add(driverId, new DeviceHardware());
|
||||||
_connectedDeviceIds[driverId].Count++; // increment the value
|
ConnectedDeviceIds[driverId].Count++; // increment the value
|
||||||
|
|
||||||
if (deviceId == "Serial")
|
if (deviceId == "Serial")
|
||||||
{
|
{
|
||||||
if (_connectedDevices[deviceId].Count == 1)
|
if (ConnectedDevices[deviceId].Count == 1)
|
||||||
{
|
{
|
||||||
var profileProperties = ReadProfile();
|
var profileProperties = ReadProfile();
|
||||||
SharedSerial.PortName = profileProperties.ComPort;
|
SharedSerial.PortName = profileProperties.ComPort;
|
||||||
@@ -308,8 +309,8 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
return new ConnectionInfo
|
return new ConnectionInfo
|
||||||
{
|
{
|
||||||
Connections = _connectedDevices[deviceId].Count,
|
Connections = ConnectedDevices[deviceId].Count,
|
||||||
SameDevice = _connectedDeviceIds[driverId].Count
|
SameDevice = ConnectedDeviceIds[driverId].Count
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -318,12 +319,12 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
lock (LockObject)
|
lock (LockObject)
|
||||||
{
|
{
|
||||||
if (_connectedDevices.ContainsKey(deviceId))
|
if (ConnectedDevices.ContainsKey(deviceId))
|
||||||
{
|
{
|
||||||
_connectedDevices[deviceId].Count--;
|
ConnectedDevices[deviceId].Count--;
|
||||||
if (_connectedDevices[deviceId].Count <= 0)
|
if (ConnectedDevices[deviceId].Count <= 0)
|
||||||
{
|
{
|
||||||
_connectedDevices.Remove(deviceId);
|
ConnectedDevices.Remove(deviceId);
|
||||||
if (deviceId == "Serial")
|
if (deviceId == "Serial")
|
||||||
{
|
{
|
||||||
SharedSerial.Connected = false;
|
SharedSerial.Connected = false;
|
||||||
@@ -331,16 +332,16 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_connectedDeviceIds.ContainsKey(driverId))
|
if (ConnectedDeviceIds.ContainsKey(driverId))
|
||||||
{
|
{
|
||||||
_connectedDeviceIds[driverId].Count--;
|
ConnectedDeviceIds[driverId].Count--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsConnected()
|
public static bool IsConnected()
|
||||||
{
|
{
|
||||||
foreach (var device in _connectedDevices)
|
foreach (var device in ConnectedDevices)
|
||||||
{
|
{
|
||||||
if (device.Value.Count > 0)
|
if (device.Value.Count > 0)
|
||||||
return true;
|
return true;
|
||||||
@@ -351,8 +352,8 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
public static bool IsConnected(string deviceId)
|
public static bool IsConnected(string deviceId)
|
||||||
{
|
{
|
||||||
if (_connectedDevices.ContainsKey(deviceId))
|
if (ConnectedDevices.ContainsKey(deviceId))
|
||||||
return (_connectedDevices[deviceId].Count > 0);
|
return (ConnectedDevices[deviceId].Count > 0);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -381,13 +382,7 @@ namespace ASCOM.Meade.net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class DeviceHardware
|
public class DeviceHardware
|
||||||
{
|
{
|
||||||
private int _count;
|
internal int Count { set; get; }
|
||||||
|
|
||||||
internal int Count
|
|
||||||
{
|
|
||||||
set => _count = value;
|
|
||||||
get => _count;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal DeviceHardware()
|
internal DeviceHardware()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,20 +10,20 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
#region Autostar 497/Audiostar
|
#region Autostar 497/Audiostar
|
||||||
|
|
||||||
public readonly static string Autostar497 = "Autostar";
|
public static readonly string Autostar497 = "Autostar";
|
||||||
|
|
||||||
//Autostar/Audiostar firmware revisions
|
//Autostar/Audiostar firmware revisions
|
||||||
public readonly static string Autostar497_30Ee = "30Ee";
|
public static readonly string Autostar497_30Ee = "30Ee";
|
||||||
public readonly static string Autostar497_31Ee = "31Ee";
|
public static readonly string Autostar497_31Ee = "31Ee";
|
||||||
public readonly static string Autostar497_43Eg = "43Eg";
|
public static readonly string Autostar497_43Eg = "43Eg";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region LX200GPS
|
#region LX200GPS
|
||||||
|
|
||||||
public readonly static string LX200GPS = "LX2001";
|
public static readonly string LX200GPS = "LX2001";
|
||||||
|
|
||||||
public readonly static string LX200GPS_42G = "4.2G";
|
public static readonly string LX200GPS_42G = "4.2G";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,11 +77,11 @@ namespace ASCOM.Meade.net
|
|||||||
// Published in The Delphi Magazine 55, page 16
|
// Published in The Delphi Magazine 55, page 16
|
||||||
// Converted to C# by Kevin Gale
|
// Converted to C# by Kevin Gale
|
||||||
IntPtr foregroundWindow = GetForegroundWindow();
|
IntPtr foregroundWindow = GetForegroundWindow();
|
||||||
IntPtr Dummy = IntPtr.Zero;
|
IntPtr dummy = IntPtr.Zero;
|
||||||
|
|
||||||
uint foregroundThreadId = GetWindowThreadProcessId(foregroundWindow, Dummy);
|
uint foregroundThreadId = GetWindowThreadProcessId(foregroundWindow, dummy);
|
||||||
|
|
||||||
uint thisThreadId = GetWindowThreadProcessId(hWnd, Dummy);
|
uint thisThreadId = GetWindowThreadProcessId(hWnd, dummy);
|
||||||
|
|
||||||
if (AttachThreadInput(thisThreadId, foregroundThreadId, true))
|
if (AttachThreadInput(thisThreadId, foregroundThreadId, true))
|
||||||
{
|
{
|
||||||
@@ -94,12 +94,12 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
// Code by Daniel P. Stasinski
|
// Code by Daniel P. Stasinski
|
||||||
// Converted to C# by Kevin Gale
|
// Converted to C# by Kevin Gale
|
||||||
IntPtr Timeout = IntPtr.Zero;
|
IntPtr timeout = IntPtr.Zero;
|
||||||
SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, Timeout, 0);
|
SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, timeout, 0);
|
||||||
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Dummy, SPIF_SENDCHANGE);
|
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, dummy, SPIF_SENDCHANGE);
|
||||||
BringWindowToTop(hWnd); // IE 5.5 related hack
|
BringWindowToTop(hWnd); // IE 5.5 related hack
|
||||||
SetForegroundWindow(hWnd);
|
SetForegroundWindow(hWnd);
|
||||||
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Timeout, SPIF_SENDCHANGE);
|
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, timeout, SPIF_SENDCHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
public partial class FrmMain : Form
|
public partial class FrmMain : Form
|
||||||
{
|
{
|
||||||
delegate void SetTextCallback(string text);
|
|
||||||
|
|
||||||
public FrmMain()
|
public FrmMain()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|||||||
Reference in New Issue
Block a user