Compare commits

..

33 Commits

Author SHA1 Message Date
ColinD df3887c385 Merged in develop (pull request #10)
Version 0.7.1
2019-07-19 16:02:10 +00:00
ColinD 53150f9400 Reset all version info's to 0.0.0.0 as TeamCity deals with version numbering now. 2019-07-19 16:51:13 +01:00
ColinD ac887ccdff Code inspections 2019-07-19 14:42:25 +01:00
ColinD 0e98f0e370 Code inspections 2019-07-19 14:33:41 +01:00
ColinD 9cf63c4912 Code inspections 2019-07-19 14:23:27 +01:00
ColinD d6f72c8222 Code inspections 2019-07-19 13:22:15 +01:00
ColinD c1cae2b0c4 Removed redundant using statements 2019-07-19 13:13:15 +01:00
ColinD 2ce8c4e123 Removed redundant qualifiers 2019-07-19 13:12:22 +01:00
ColinD dfef48ff0c code tidy up 2019-07-19 13:06:56 +01:00
ColinD 4b65c946d2 Unit testing 2019-07-19 12:49:56 +01:00
ColinD 3579189465 SlewToAltAz unit tests 2019-07-18 13:45:26 +01:00
ColinD 8b31c8d7a9 SlewToAltAzAsync unit tests 2019-07-18 13:12:26 +01:00
ColinD 04845cea7a Unit tests for SlewToCoordinates 2019-07-18 12:54:18 +01:00
ColinD aeaaf9df95 More unit testing 2019-07-18 12:31:09 +01:00
ColinD 1d5dcb529e Unit tests for slew to target async 2019-07-17 23:20:26 +01:00
ColinD fdeee5b822 Unit tests for slewing 2019-07-17 22:58:53 +01:00
ColinD a53f99810d More unit testing 2019-07-17 15:35:32 +01:00
ColinD 325e9908a7 Unit testing for UTCDate 2019-07-17 14:42:28 +01:00
ColinD 83865a3911 Unit testing for TrackingRate 2019-07-17 11:30:49 +01:00
ColinD b3b1d95cda Unit tests for Tracking property 2019-07-16 23:33:53 +01:00
ColinD bfb8f257a1 Unit tests for TargetRightAscension 2019-07-16 23:22:41 +01:00
ColinD 3109d1dcef Merged in feature/DecompeSharedResources (pull request #9)
Feature/DecompeSharedResources
2019-07-16 21:59:51 +00:00
ColinD 0ac7b8b7bd Unit tests for TargetDeclination 2019-07-16 22:03:56 +01:00
ColinD ee60613a95 More unit testing 2019-07-15 00:16:08 +01:00
ColinD a6308f1a64 Added a missing . to the name file name. Working :) 2019-07-14 23:00:15 +01:00
ColinD 0475217d62 Trying to read the BUILD_NUMBER from the environment. 2019-07-14 22:56:32 +01:00
ColinD e89f01ed51 Another try 2019-07-14 22:40:45 +01:00
ColinD 2846e9f719 Anotther try. 2019-07-14 22:32:38 +01:00
ColinD a7904d7485 Another attempt at the version number rename. 2019-07-14 22:28:32 +01:00
ColinD 12c11b4987 Removed unneeded comments 2019-07-14 22:19:55 +01:00
ColinD 07569b146e Trying the nant variable inside the string. 2019-07-14 22:19:05 +01:00
ColinD 112fdf0bb9 Experiment on build.build to see if I can rename the msi file 2019-07-14 22:14:43 +01:00
ColinD 73e8e8ffe8 More unit testing 2019-07-14 22:05:25 +01:00
28 changed files with 1515 additions and 703 deletions
+6 -7
View File
@@ -1,5 +1,4 @@
using System; using System;
using ASCOM.Meade.net;
using ASCOM.Meade.net.AstroMaths; using ASCOM.Meade.net.AstroMaths;
using NUnit.Framework; using NUnit.Framework;
@@ -53,16 +52,16 @@ namespace AstroMath.UnitTests
public void UTtoGST_book() public void UTtoGST_book()
{ {
DateTime dateTime = new DateTime(1980, 04, 22, 14, 36, 51, 670, DateTimeKind.Utc); DateTime dateTime = new DateTime(1980, 04, 22, 14, 36, 51, 670, DateTimeKind.Utc);
double gst = _astroMath.UTtoGST(dateTime); double gst = _astroMath.UTtoGst(dateTime);
Assert.That(gst, Is.EqualTo(4.667932706211154)); Assert.That(gst, Is.EqualTo(4.667932706211154));
} }
[Test] [Test]
public void UTtoGST() public void UTtoGst()
{ {
DateTime dateTime = new DateTime(2019, 05, 18, 22, 26, 15, DateTimeKind.Utc); DateTime dateTime = new DateTime(2019, 05, 18, 22, 26, 15, DateTimeKind.Utc);
double gst = _astroMath.UTtoGST(dateTime); double gst = _astroMath.UTtoGst(dateTime);
Assert.That(gst, Is.EqualTo(14.191879687876451)); Assert.That(gst, Is.EqualTo(14.191879687876451));
} }
@@ -72,16 +71,16 @@ namespace AstroMath.UnitTests
{ {
double gst = 4.668119; double gst = 4.668119;
var longitude = -64; var longitude = -64;
var lst = _astroMath.GSTtoLST(gst, longitude); var lst = _astroMath.GsTtoLst(gst, longitude);
Assert.That(lst, Is.EqualTo(0.4014523333333333)); Assert.That(lst, Is.EqualTo(0.4014523333333333));
} }
[Test] [Test]
public void GSTtoLST() public void GsTtoLst()
{ {
double gst = 14.257589512545053; double gst = 14.257589512545053;
var longitude = -1.7833333333333332; var longitude = -1.7833333333333332;
var lst = _astroMath.GSTtoLST(gst, longitude); var lst = _astroMath.GsTtoLst(gst, longitude);
Assert.That(lst, Is.EqualTo(14.138700623656163)); Assert.That(lst, Is.EqualTo(14.138700623656163));
} }
@@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
@@ -32,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.7.0.0")] [assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("0.7.0.0")] [assembly: AssemblyFileVersion("0.0.0.0")]
+3 -6
View File
@@ -9,13 +9,10 @@
#define UseChooser #define UseChooser
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading; using System.Threading;
using ASCOM.DriverAccess; using ASCOM.DriverAccess;
namespace ASCOM namespace ASCOM.MeadeGeneric
{ {
class Program class Program
{ {
@@ -24,11 +21,11 @@ namespace ASCOM
// Uncomment the code that's required // Uncomment the code that's required
#if UseChooser #if UseChooser
// choose the device // choose the device
string id = ASCOM.DriverAccess.Focuser.Choose("ASCOM.MeadeGeneric.Focuser"); string id = Focuser.Choose("ASCOM.MeadeGeneric.Focuser");
if (string.IsNullOrEmpty(id)) if (string.IsNullOrEmpty(id))
return; return;
// create this device // create this device
ASCOM.DriverAccess.Focuser device = new ASCOM.DriverAccess.Focuser(id); Focuser device = new Focuser(id);
#else #else
// this can be replaced by this code, it avoids the chooser and creates the driver class directly. // this can be replaced by this code, it avoids the chooser and creates the driver class directly.
ASCOM.DriverAccess.Telescope device = new ASCOM.DriverAccess.Telescope("ASCOM.MeadeGeneric.Telescope"); ASCOM.DriverAccess.Telescope device = new ASCOM.DriverAccess.Telescope("ASCOM.MeadeGeneric.Telescope");
@@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
@@ -32,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("0.7.0.0")] [assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("0.7.0.0")] [assembly: AssemblyFileVersion("0.0.0.0")]
@@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
@@ -32,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("0.0.0.0")]
File diff suppressed because it is too large Load Diff
@@ -7,6 +7,6 @@ namespace ASCOM.Meade.net.AstroMaths
public DateTime UtcDateTime { get; set; } public DateTime UtcDateTime { get; set; }
public double SiteLatitude { get; set; } public double SiteLatitude { get; set; }
public double SiteLongitude { get; set; } public double SiteLongitude { get; set; }
public EquatorialCoordinates equatorialCoordinates { get; set; } public EquatorialCoordinates EquatorialCoordinates { get; set; }
} }
} }
+6 -6
View File
@@ -10,8 +10,8 @@ namespace ASCOM.Meade.net.AstroMaths
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;
var h1 = lst - raHours; var h1 = lst - raHours;
var h = h1; var h = h1;
@@ -24,8 +24,8 @@ namespace ASCOM.Meade.net.AstroMaths
public double HourAngleToRightAscension(DateTime utcDateTime, double longitude, double hourAngle ) public double HourAngleToRightAscension(DateTime utcDateTime, double longitude, double hourAngle )
{ {
var gst = UTtoGST(utcDateTime); var gst = UTtoGst(utcDateTime);
var lst = GSTtoLST( gst, longitude); var lst = GsTtoLst( gst, longitude);
var raHours = hourAngle; var raHours = hourAngle;
var h1 = lst - raHours; var h1 = lst - raHours;
var h = h1; var h = h1;
@@ -129,7 +129,7 @@ namespace ASCOM.Meade.net.AstroMaths
} }
//todo convert to extension method //todo convert to extension method
public double UTtoGST(DateTime utcDateTime) public double UTtoGst(DateTime utcDateTime)
{ {
Util util = new Util(); Util util = new Util();
@@ -171,7 +171,7 @@ namespace ASCOM.Meade.net.AstroMaths
return t1; return t1;
} }
public double GSTtoLST(double gst, double longitude) public double GsTtoLst(double gst, double longitude)
{ {
var l = longitude/ 15; var l = longitude/ 15;
@@ -11,7 +11,7 @@ namespace ASCOM.Meade.net.AstroMaths
double DegreesToRadians(double degrees); double DegreesToRadians(double degrees);
double RadiansToDegrees(double radians); double RadiansToDegrees(double radians);
double DateTimeToDecimalHours( DateTime utcDateTime); double DateTimeToDecimalHours( DateTime utcDateTime);
double UTtoGST(DateTime utcDateTime); double UTtoGst(DateTime utcDateTime);
double GSTtoLST(double gst, double longitude); double GsTtoLst(double gst, double longitude);
} }
} }
@@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
@@ -35,5 +34,5 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below: // by using the '*' as shown below:
// //
// TODO - Set your driver's version here // TODO - Set your driver's version here
[assembly: AssemblyVersion("0.7.0.0")] [assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("0.7.0.0")] [assembly: AssemblyFileVersion("0.0.0.0")]
+32 -48
View File
@@ -1,8 +1,4 @@
using System; using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using ASCOM.DeviceInterface; using ASCOM.DeviceInterface;
using System.Collections; using System.Collections;
using System.Threading; using System.Threading;
@@ -21,10 +17,10 @@ namespace ASCOM.Meade.net
[Guid("288838d1-bbf9-4ce0-9ee1-86ecf38b45c9")] [Guid("288838d1-bbf9-4ce0-9ee1-86ecf38b45c9")]
[ClassInterface(ClassInterfaceType.None)] [ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)] [ComVisible(true)]
public class Rate : ASCOM.DeviceInterface.IRate public class Rate : IRate
{ {
private double maximum = 0; private double _maximum = 0;
private double minimum = 0; private double _minimum = 0;
// //
// Default constructor - Internal prevents public creation // Default constructor - Internal prevents public creation
@@ -32,8 +28,8 @@ namespace ASCOM.Meade.net
// //
internal Rate(double minimum, double maximum) internal Rate(double minimum, double maximum)
{ {
this.maximum = maximum; _maximum = maximum;
this.minimum = minimum; _minimum = minimum;
} }
#region Implementation of IRate #region Implementation of IRate
@@ -45,14 +41,14 @@ namespace ASCOM.Meade.net
public double Maximum public double Maximum
{ {
get { return this.maximum; } get => _maximum;
set { this.maximum = value; } set => _maximum = value;
} }
public double Minimum public double Minimum
{ {
get { return this.minimum; } get => _minimum;
set { this.minimum = value; } set => _minimum = value;
} }
#endregion #endregion
@@ -74,8 +70,8 @@ namespace ASCOM.Meade.net
[ComVisible(true)] [ComVisible(true)]
public class AxisRates : IAxisRates, IEnumerable public class AxisRates : IAxisRates, IEnumerable
{ {
private TelescopeAxes axis; private TelescopeAxes _axis;
private readonly Rate[] rates; private readonly Rate[] _rates;
// //
// Constructor - Internal prevents public creation // Constructor - Internal prevents public creation
@@ -83,7 +79,7 @@ namespace ASCOM.Meade.net
// //
internal AxisRates(TelescopeAxes axis) internal AxisRates(TelescopeAxes axis)
{ {
this.axis = axis; _axis = axis;
// //
// This collection must hold zero or more Rate objects describing the // This collection must hold zero or more Rate objects describing the
// rates of motion ranges for the Telescope.MoveAxis() method // rates of motion ranges for the Telescope.MoveAxis() method
@@ -100,26 +96,23 @@ namespace ASCOM.Meade.net
// TODO Initialize this array with any Primary axis rates that your driver may provide // TODO Initialize this array with any Primary axis rates that your driver may provide
// Example: m_Rates = new Rate[] { new Rate(10.5, 30.2), new Rate(54.0, 43.6) } // Example: m_Rates = new Rate[] { new Rate(10.5, 30.2), new Rate(54.0, 43.6) }
//this.rates = new Rate[0]; //this.rates = new Rate[0];
this.rates = new Rate[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) }; _rates = new Rate[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) };
break; break;
case TelescopeAxes.axisSecondary: case TelescopeAxes.axisSecondary:
// TODO Initialize this array with any Secondary axis rates that your driver may provide // TODO Initialize this array with any Secondary axis rates that your driver may provide
//this.rates = new Rate[0]; //this.rates = new Rate[0];
this.rates = new Rate[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) }; _rates = new Rate[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) };
break; break;
case TelescopeAxes.axisTertiary: case TelescopeAxes.axisTertiary:
// TODO Initialize this array with any Tertiary axis rates that your driver may provide // TODO Initialize this array with any Tertiary axis rates that your driver may provide
this.rates = new Rate[0]; _rates = new Rate[0];
break; break;
} }
} }
#region IAxisRates Members #region IAxisRates Members
public int Count public int Count => _rates.Length;
{
get { return this.rates.Length; }
}
public void Dispose() public void Dispose()
{ {
@@ -128,13 +121,10 @@ namespace ASCOM.Meade.net
public IEnumerator GetEnumerator() public IEnumerator GetEnumerator()
{ {
return rates.GetEnumerator(); return _rates.GetEnumerator();
} }
public IRate this[int index] public IRate this[int index] => _rates[index - 1];
{
get { return this.rates[index - 1]; } // 1-based
}
#endregion #endregion
} }
@@ -159,11 +149,11 @@ namespace ASCOM.Meade.net
[ComVisible(true)] [ComVisible(true)]
public class TrackingRates : ITrackingRates, IEnumerable, IEnumerator public class TrackingRates : ITrackingRates, IEnumerable, IEnumerator
{ {
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>(() => { return -1; });
private static readonly object lockObj = new object(); private static readonly object LockObj = new object();
// //
// Default constructor - Internal prevents public creation // Default constructor - Internal prevents public creation
@@ -176,20 +166,17 @@ namespace ASCOM.Meade.net
// the tracking rates supported by your telescope. The one value // the tracking rates supported by your telescope. The one value
// (tracking rate) that MUST be supported is driveSidereal! // (tracking rate) that MUST be supported is driveSidereal!
// //
this.trackingRates = new[] { DriveRates.driveSidereal, DriveRates.driveLunar }; _trackingRates = new[] { DriveRates.driveSidereal, DriveRates.driveLunar };
// TODO Initialize this array with any additional tracking rates that your driver may provide // TODO Initialize this array with any additional tracking rates that your driver may provide
} }
#region ITrackingRates Members #region ITrackingRates Members
public int Count public int Count => _trackingRates.Length;
{
get { return this.trackingRates.Length; }
}
public IEnumerator GetEnumerator() public IEnumerator GetEnumerator()
{ {
pos.Value = -1; _pos.Value = -1;
return this as IEnumerator; return this as IEnumerator;
} }
@@ -198,10 +185,7 @@ namespace ASCOM.Meade.net
// TODO Add any required object cleanup here // TODO Add any required object cleanup here
} }
public DriveRates this[int index] public DriveRates this[int index] => _trackingRates[index - 1];
{
get { return this.trackingRates[index - 1]; } // 1-based
}
#endregion #endregion
@@ -211,22 +195,22 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
lock (lockObj) lock (LockObj)
{ {
if (pos.Value < 0 || pos.Value >= trackingRates.Length) if (_pos.Value < 0 || _pos.Value >= _trackingRates.Length)
{ {
throw new System.InvalidOperationException(); throw new System.InvalidOperationException();
} }
return trackingRates[pos.Value]; return _trackingRates[_pos.Value];
} }
} }
} }
public bool MoveNext() public bool MoveNext()
{ {
lock (lockObj) lock (LockObj)
{ {
if (++pos.Value >= trackingRates.Length) if (++_pos.Value >= _trackingRates.Length)
{ {
return false; return false;
} }
@@ -236,7 +220,7 @@ namespace ASCOM.Meade.net
public void Reset() public void Reset()
{ {
pos.Value = -1; _pos.Value = -1;
} }
#endregion #endregion
} }
+169 -155
View File
@@ -5,8 +5,8 @@ using System.Runtime.InteropServices;
using ASCOM.Astrometry.AstroUtils; using ASCOM.Astrometry.AstroUtils;
using ASCOM.Utilities; using ASCOM.Utilities;
using ASCOM.DeviceInterface; using ASCOM.DeviceInterface;
using System.Globalization;
using System.Collections; using System.Collections;
using System.Globalization;
using System.Reflection; using System.Reflection;
using ASCOM.Meade.net.AstroMaths; using ASCOM.Meade.net.AstroMaths;
using ASCOM.Meade.net.Wrapper; using ASCOM.Meade.net.Wrapper;
@@ -39,15 +39,15 @@ namespace ASCOM.Meade.net
/// The DeviceID is used by ASCOM applications to load the driver at runtime. /// The DeviceID is used by ASCOM applications to load the driver at runtime.
/// </summary> /// </summary>
//internal static string driverID = "ASCOM.Meade.net.Telescope"; //internal static string driverID = "ASCOM.Meade.net.Telescope";
internal static string driverID = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType); private static readonly string DriverId = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType);
// TODO Change the descriptive string for your driver then remove this line // TODO Change the descriptive string for your driver then remove this line
/// <summary> /// <summary>
/// Driver description that displays in the ASCOM Chooser. /// Driver description that displays in the ASCOM Chooser.
/// </summary> /// </summary>
private static string driverDescription = "Meade Generic"; private static readonly string DriverDescription = "Meade Generic";
internal static string comPort; // Variables to hold the currrent device configuration private static string _comPort; // Variables to hold the currrent device configuration
/// <summary> /// <summary>
/// Private variable to hold an ASCOM Utilities object /// Private variable to hold an ASCOM Utilities object
@@ -65,7 +65,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 TraceLogger tl; private TraceLogger _tl;
private readonly ISharedResourcesWrapper _sharedResourcesWrapper; private readonly ISharedResourcesWrapper _sharedResourcesWrapper;
@@ -100,7 +100,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.net.Telescope"); _tl = new TraceLogger("", "Meade.net.Telescope");
LogMessage("Telescope", "Starting initialisation"); LogMessage("Telescope", "Starting initialisation");
ReadProfile(); // Read device configuration from the ASCOM Profile store ReadProfile(); // Read device configuration from the ASCOM Profile store
@@ -231,12 +231,12 @@ namespace ASCOM.Meade.net
break; break;
default: default:
LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters); LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters);
throw new ASCOM.ActionNotImplementedException($"{actionName}({actionParameters})"); throw new ActionNotImplementedException($"{actionName}({actionParameters})");
} }
break; break;
default: default:
LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters); LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters);
throw new ASCOM.ActionNotImplementedException($"{actionName}"); throw new ActionNotImplementedException($"{actionName}");
} }
return string.Empty; return string.Empty;
@@ -259,7 +259,7 @@ namespace ASCOM.Meade.net
//string ret = CommandString(command, raw); //string ret = CommandString(command, raw);
// TODO decode the return string and return true or false // TODO decode the return string and return true or false
// or // or
throw new ASCOM.MethodNotImplementedException("CommandBool"); throw new MethodNotImplementedException("CommandBool");
// DO NOT have both these sections! One or the other // DO NOT have both these sections! One or the other
} }
@@ -279,9 +279,9 @@ namespace ASCOM.Meade.net
Connected = false; Connected = false;
// 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
@@ -299,18 +299,21 @@ namespace ASCOM.Meade.net
if (value) if (value)
{ {
LogMessage("Connected Set", "Connecting to port {0}", comPort); LogMessage("Connected Set", "Connecting to port {0}", _comPort);
try try
{ {
_sharedResourcesWrapper.Connect("Serial"); _sharedResourcesWrapper.Connect("Serial");
try try
{ {
LogMessage("Connected Set", $"Connected to port {comPort}. Product: {_sharedResourcesWrapper.ProductName} Version:{_sharedResourcesWrapper.FirmwareVersion}"); LogMessage("Connected Set", $"Connected to port {_comPort}. Product: {_sharedResourcesWrapper.ProductName} Version:{_sharedResourcesWrapper.FirmwareVersion}");
SetLongFormat(true); SetLongFormat(true);
_userNewerPulseGuiding = IsNewPulseGuidingSupported(); _userNewerPulseGuiding = IsNewPulseGuidingSupported();
LogMessage("Connected Set", $"New Pulse Guiding Supported: {_userNewerPulseGuiding}"); _targetDeclination = InvalidParameter;
_targetRightAscension = InvalidParameter;
_tracking = true;
LogMessage("Connected Set", $"New Pulse Guiding Supported: {_userNewerPulseGuiding}");
IsConnected = true; IsConnected = true;
} }
catch (Exception) catch (Exception)
@@ -321,12 +324,12 @@ namespace ASCOM.Meade.net
} }
catch (Exception ex) catch (Exception ex)
{ {
LogMessage("Connected Set", "Error connecting to port {0} - {1}", comPort, ex.Message); LogMessage("Connected Set", "Error connecting to port {0} - {1}", _comPort, ex.Message);
} }
} }
else else
{ {
LogMessage("Connected Set", "Disconnecting from port {0}", comPort); LogMessage("Connected Set", "Disconnecting from port {0}", _comPort);
_sharedResourcesWrapper.Disconnect("Serial"); _sharedResourcesWrapper.Disconnect("Serial");
IsConnected = false; IsConnected = false;
} }
@@ -335,9 +338,9 @@ namespace ASCOM.Meade.net
public bool IsNewPulseGuidingSupported() public bool IsNewPulseGuidingSupported()
{ {
if (_sharedResourcesWrapper.ProductName == _sharedResourcesWrapper.AUTOSTAR497) if (_sharedResourcesWrapper.ProductName == _sharedResourcesWrapper.Autostar497)
{ {
return FirmwareIsGreaterThan(_sharedResourcesWrapper.AUTOSTAR497_31EE); return FirmwareIsGreaterThan(_sharedResourcesWrapper.Autostar49731Ee);
} }
return false; return false;
@@ -346,7 +349,7 @@ namespace ASCOM.Meade.net
private bool FirmwareIsGreaterThan(string minVersion) private bool FirmwareIsGreaterThan(string minVersion)
{ {
var currentVersion = _sharedResourcesWrapper.FirmwareVersion; var currentVersion = _sharedResourcesWrapper.FirmwareVersion;
var comparison = currentVersion.CompareTo(minVersion); var comparison = String.Compare(currentVersion, minVersion, StringComparison.Ordinal);
return (comparison >= 0); return (comparison >= 0);
} }
@@ -392,8 +395,8 @@ namespace ASCOM.Meade.net
// TODO customise this device description // TODO customise this device description
get get
{ {
LogMessage("Description Get", driverDescription); LogMessage("Description Get", DriverDescription);
return driverDescription; return DriverDescription;
} }
} }
@@ -412,7 +415,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; Version version = Assembly.GetExecutingAssembly().GetName().Version;
string driverVersion = $"{version.Major}.{version.Minor}.{version.Revision}.{version.Build}"; string driverVersion = $"{version.Major}.{version.Minor}.{version.Revision}.{version.Build}";
LogMessage("DriverVersion Get", driverVersion); LogMessage("DriverVersion Get", driverVersion);
return driverVersion; return driverVersion;
@@ -444,7 +447,7 @@ namespace ASCOM.Meade.net
////Returns: dd.d# ////Returns: dd.d#
//string name = $"{telescopeProduceName} - {firmwareVersion}"; //string name = $"{telescopeProduceName} - {firmwareVersion}";
string name = driverDescription; string name = DriverDescription;
LogMessage("Name Get", name); LogMessage("Name Get", name);
return name; return name;
} }
@@ -462,6 +465,9 @@ namespace ASCOM.Meade.net
_sharedResourcesWrapper.SendBlind(":Q#"); _sharedResourcesWrapper.SendBlind(":Q#");
//:Q# Halt all current slewing //:Q# Halt all current slewing
//Returns:Nothing //Returns:Nothing
_movingPrimary = false;
_movingSecondary = false;
} }
public AlignmentModes AlignmentMode public AlignmentModes AlignmentMode
@@ -519,7 +525,7 @@ namespace ASCOM.Meade.net
CheckConnected("AlignmentMode Set"); CheckConnected("AlignmentMode Set");
//todo tidy this up into a better solution that means can :GW#, :AL#, :AA#, & :AP# and checked for Autostar properly //todo tidy this up into a better solution that means can :GW#, :AL#, :AA#, & :AP# and checked for Autostar properly
if (!FirmwareIsGreaterThan(_sharedResourcesWrapper.AUTOSTAR497_43EG)) if (!FirmwareIsGreaterThan(_sharedResourcesWrapper.Autostar49743Eg))
throw new PropertyNotImplementedException("AlignmentMode",true ); throw new PropertyNotImplementedException("AlignmentMode",true );
//todo make this only try with Autostar 43Eg and above. //todo make this only try with Autostar 43Eg and above.
@@ -550,7 +556,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
CheckConnected("Altitude get"); CheckConnected("Altitude Get");
var altAz = CalcAltAzFromTelescopeEqData(); var altAz = CalcAltAzFromTelescopeEqData();
LogMessage("Altitude", $"{altAz.Altitude}"); LogMessage("Altitude", $"{altAz.Altitude}");
@@ -575,19 +581,19 @@ namespace ASCOM.Meade.net
{ {
var altitudeData = _sharedResourcesWrapper.Lock(() => new AltitudeData var altitudeData = _sharedResourcesWrapper.Lock(() => new AltitudeData
{ {
UtcDateTime = this.UTCDate, UtcDateTime = UTCDate,
SiteLongitude = this.SiteLongitude, SiteLongitude = SiteLongitude,
SiteLatitude = this.SiteLatitude, SiteLatitude = SiteLatitude,
equatorialCoordinates = new EquatorialCoordinates() EquatorialCoordinates = new EquatorialCoordinates()
{ {
RightAscension = this.RightAscension, RightAscension = RightAscension,
Declination = this.Declination Declination = Declination
} }
}); });
double hourAngle = _astroMaths.RightAscensionToHourAngle(altitudeData.UtcDateTime, altitudeData.SiteLongitude, double hourAngle = _astroMaths.RightAscensionToHourAngle(altitudeData.UtcDateTime, altitudeData.SiteLongitude,
altitudeData.equatorialCoordinates.RightAscension); altitudeData.EquatorialCoordinates.RightAscension);
var altAz = _astroMaths.ConvertEqToHoz(hourAngle, altitudeData.SiteLatitude, altitudeData.equatorialCoordinates); var altAz = _astroMaths.ConvertEqToHoz(hourAngle, altitudeData.SiteLatitude, altitudeData.EquatorialCoordinates);
return altAz; return altAz;
} }
@@ -596,7 +602,7 @@ namespace ASCOM.Meade.net
get get
{ {
LogMessage("ApertureArea Get", "Not implemented"); LogMessage("ApertureArea Get", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("ApertureArea", false); throw new PropertyNotImplementedException("ApertureArea", false);
} }
} }
@@ -605,7 +611,7 @@ namespace ASCOM.Meade.net
get get
{ {
LogMessage("ApertureDiameter Get", "Not implemented"); LogMessage("ApertureDiameter Get", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("ApertureDiameter", false); throw new PropertyNotImplementedException("ApertureDiameter", false);
} }
} }
@@ -627,20 +633,20 @@ namespace ASCOM.Meade.net
LogMessage("AtPark", "Get - " + _atPark); LogMessage("AtPark", "Get - " + _atPark);
return _atPark; return _atPark;
} }
private set { _atPark = value; } private set => _atPark = value;
} }
public IAxisRates AxisRates(TelescopeAxes Axis) public IAxisRates AxisRates(TelescopeAxes axis)
{ {
LogMessage("AxisRates", "Get - " + Axis.ToString()); LogMessage("AxisRates", "Get - " + axis.ToString());
return new AxisRates(Axis); return new AxisRates(axis);
} }
public double Azimuth public double Azimuth
{ {
get get
{ {
CheckConnected("Azimuth get"); CheckConnected("Azimuth Get");
//var result = _sharedResourcesWrapper.SendString(":GZ#"); //var result = _sharedResourcesWrapper.SendString(":GZ#");
//:GZ# Get telescope azimuth //:GZ# Get telescope azimuth
@@ -667,15 +673,15 @@ namespace ASCOM.Meade.net
} }
} }
public bool CanMoveAxis(TelescopeAxes Axis) public bool CanMoveAxis(TelescopeAxes axis)
{ {
LogMessage("CanMoveAxis", "Get - " + Axis.ToString()); LogMessage("CanMoveAxis", "Get - " + axis.ToString());
switch (Axis) switch (axis)
{ {
case TelescopeAxes.axisPrimary: return true; //RA or AZ case TelescopeAxes.axisPrimary: return true; //RA or AZ
case TelescopeAxes.axisSecondary: return true; //Dev or Alt case TelescopeAxes.axisSecondary: return true; //Dev or Alt
case TelescopeAxes.axisTertiary: return false; //rotator / derotator case TelescopeAxes.axisTertiary: return false; //rotator / derotator
default: throw new InvalidValueException("CanMoveAxis", Axis.ToString(), "0 to 2"); default: throw new InvalidValueException("CanMoveAxis", axis.ToString(), "0 to 2");
} }
} }
@@ -837,20 +843,20 @@ namespace ASCOM.Meade.net
get get
{ {
double declination = 0.0; double declination = 0.0;
LogMessage("DeclinationRate", "Get - " + declination.ToString()); LogMessage("DeclinationRate", "Get - " + declination.ToString(CultureInfo.InvariantCulture));
return declination; return declination;
} }
set set
{ {
LogMessage("DeclinationRate Set", "Not implemented"); LogMessage("DeclinationRate Set", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("DeclinationRate", true); throw new PropertyNotImplementedException("DeclinationRate", true);
} }
} }
public PierSide DestinationSideOfPier(double rightAscension, double declination) public PierSide DestinationSideOfPier(double rightAscension, double declination)
{ {
LogMessage("DestinationSideOfPier Get", "Not implemented"); LogMessage("DestinationSideOfPier Get", "Not implemented");
throw new ASCOM.MethodNotImplementedException("DestinationSideOfPier"); throw new MethodNotImplementedException("DestinationSideOfPier");
} }
public bool DoesRefraction public bool DoesRefraction
@@ -858,12 +864,12 @@ namespace ASCOM.Meade.net
get get
{ {
LogMessage("DoesRefraction Get", "Not implemented"); LogMessage("DoesRefraction Get", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("DoesRefraction", false); throw new PropertyNotImplementedException("DoesRefraction", false);
} }
set set
{ {
LogMessage("DoesRefraction Set", "Not implemented"); LogMessage("DoesRefraction Set", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("DoesRefraction", true); throw new PropertyNotImplementedException("DoesRefraction", true);
} }
} }
@@ -880,7 +886,7 @@ namespace ASCOM.Meade.net
public void FindHome() public void FindHome()
{ {
LogMessage("FindHome", "Not implemented"); LogMessage("FindHome", "Not implemented");
throw new ASCOM.MethodNotImplementedException("FindHome"); throw new MethodNotImplementedException("FindHome");
} }
public double FocalLength public double FocalLength
@@ -888,7 +894,7 @@ namespace ASCOM.Meade.net
get get
{ {
LogMessage("FocalLength Get", "Not implemented"); LogMessage("FocalLength Get", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("FocalLength", false); throw new PropertyNotImplementedException("FocalLength", false);
} }
} }
@@ -897,12 +903,12 @@ namespace ASCOM.Meade.net
get get
{ {
LogMessage("GuideRateDeclination Get", "Not implemented"); LogMessage("GuideRateDeclination Get", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("GuideRateDeclination", false); throw new PropertyNotImplementedException("GuideRateDeclination", false);
} }
set set
{ {
LogMessage("GuideRateDeclination Set", "Not implemented"); LogMessage("GuideRateDeclination Set", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("GuideRateDeclination", true); throw new PropertyNotImplementedException("GuideRateDeclination", true);
} }
} }
@@ -911,12 +917,12 @@ namespace ASCOM.Meade.net
get get
{ {
LogMessage("GuideRateRightAscension Get", "Not implemented"); LogMessage("GuideRateRightAscension Get", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("GuideRateRightAscension", false); throw new PropertyNotImplementedException("GuideRateRightAscension", false);
} }
set set
{ {
LogMessage("GuideRateRightAscension Set", "Not implemented"); LogMessage("GuideRateRightAscension Set", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("GuideRateRightAscension", true); throw new PropertyNotImplementedException("GuideRateRightAscension", true);
} }
} }
@@ -967,7 +973,7 @@ namespace ASCOM.Meade.net
//Returns: Nothing //Returns: Nothing
break; break;
default: default:
throw new ASCOM.InvalidValueException($"Rate {rate} not supported"); throw new InvalidValueException($"Rate {rate} not supported");
} }
switch (axis) switch (axis)
@@ -1027,7 +1033,7 @@ namespace ASCOM.Meade.net
break; break;
default: default:
throw new ASCOM.InvalidValueException("Can not move this axis."); throw new InvalidValueException("Can not move this axis.");
} }
} }
@@ -1136,20 +1142,20 @@ namespace ASCOM.Meade.net
get get
{ {
double rightAscensionRate = 0.0; double rightAscensionRate = 0.0;
LogMessage("RightAscensionRate", "Get - " + rightAscensionRate.ToString()); LogMessage("RightAscensionRate", "Get - " + rightAscensionRate.ToString(CultureInfo.InvariantCulture));
return rightAscensionRate; return rightAscensionRate;
} }
set set
{ {
LogMessage("RightAscensionRate Set", "Not implemented"); LogMessage("RightAscensionRate Set", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("RightAscensionRate", true); throw new PropertyNotImplementedException("RightAscensionRate", true);
} }
} }
public void SetPark() public void SetPark()
{ {
LogMessage("SetPark", "Not implemented"); LogMessage("SetPark", "Not implemented");
throw new ASCOM.MethodNotImplementedException("SetPark"); throw new MethodNotImplementedException("SetPark");
} }
public PierSide SideOfPier public PierSide SideOfPier
@@ -1157,12 +1163,12 @@ namespace ASCOM.Meade.net
get get
{ {
LogMessage("SideOfPier Get", "Not implemented"); LogMessage("SideOfPier Get", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("SideOfPier", false); throw new PropertyNotImplementedException("SideOfPier", false);
} }
set set
{ {
LogMessage("SideOfPier Set", "Not implemented"); LogMessage("SideOfPier Set", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("SideOfPier", true); throw new PropertyNotImplementedException("SideOfPier", true);
} }
} }
@@ -1172,13 +1178,13 @@ namespace ASCOM.Meade.net
{ {
// Now using NOVAS 3.1 // Now using NOVAS 3.1
double siderealTime = 0.0; double siderealTime = 0.0;
using (var novas = new ASCOM.Astrometry.NOVAS.NOVAS31()) using (var novas = new Astrometry.NOVAS.NOVAS31())
{ {
var jd = _utilities.DateUTCToJulian(DateTime.UtcNow); var jd = _utilities.DateUTCToJulian(DateTime.UtcNow);
novas.SiderealTime(jd, 0, novas.DeltaT(jd), novas.SiderealTime(jd, 0, novas.DeltaT(jd),
ASCOM.Astrometry.GstType.GreenwichApparentSiderealTime, Astrometry.GstType.GreenwichApparentSiderealTime,
ASCOM.Astrometry.Method.EquinoxBased, Astrometry.Method.EquinoxBased,
ASCOM.Astrometry.Accuracy.Reduced, ref siderealTime); Astrometry.Accuracy.Reduced, ref siderealTime);
} }
// Allow for the longitude // Allow for the longitude
@@ -1187,7 +1193,7 @@ namespace ASCOM.Meade.net
// Reduce to the range 0 to 24 hours // Reduce to the range 0 to 24 hours
siderealTime = _astroUtilities.ConditionRA(siderealTime); siderealTime = _astroUtilities.ConditionRA(siderealTime);
LogMessage("SiderealTime", "Get - " + siderealTime.ToString()); LogMessage("SiderealTime", "Get - " + siderealTime.ToString(CultureInfo.InvariantCulture));
return siderealTime; return siderealTime;
} }
} }
@@ -1197,12 +1203,12 @@ namespace ASCOM.Meade.net
get get
{ {
LogMessage("SiteElevation Get", "Not implemented"); LogMessage("SiteElevation Get", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("SiteElevation", false); throw new PropertyNotImplementedException("SiteElevation", false);
} }
set set
{ {
LogMessage("SiteElevation Set", "Not implemented"); LogMessage("SiteElevation Set", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("SiteElevation", true); throw new PropertyNotImplementedException("SiteElevation", true);
} }
} }
@@ -1259,7 +1265,7 @@ namespace ASCOM.Meade.net
var longitude = _sharedResourcesWrapper.SendString(":Gg#"); var longitude = _sharedResourcesWrapper.SendString(":Gg#");
//:Gg# Get Current Site Longitude //:Gg# Get Current Site Longitude
//Returns: sDDD* MM# //Returns: sDDD*MM#
//The current site Longitude. East Longitudes are expressed as negative //The current site Longitude. East Longitudes are expressed as negative
double siteLongitude = _utilities.DMSToDegrees(longitude); double siteLongitude = _utilities.DMSToDegrees(longitude);
@@ -1293,7 +1299,9 @@ namespace ASCOM.Meade.net
int d = Convert.ToInt32(Math.Floor(newLongitude)); int d = Convert.ToInt32(Math.Floor(newLongitude));
int m = Convert.ToInt32(60 * (newLongitude - d)); int m = Convert.ToInt32(60 * (newLongitude - d));
var result = _sharedResourcesWrapper.SendChar($":Sg{d:000}*{m:00}#"); var commandstring = $":Sg{d:000}*{m:00}#";
var result = _sharedResourcesWrapper.SendChar(commandstring);
//:SgDDD*MM# //:SgDDD*MM#
//Set current sites longitude to DDD*MM an ASCII position string //Set current sites longitude to DDD*MM an ASCII position string
//Returns: //Returns:
@@ -1309,12 +1317,12 @@ namespace ASCOM.Meade.net
get get
{ {
LogMessage("SlewSettleTime Get", "Not implemented"); LogMessage("SlewSettleTime Get", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("SlewSettleTime", false); throw new PropertyNotImplementedException("SlewSettleTime", false);
} }
set set
{ {
LogMessage("SlewSettleTime Set", "Not implemented"); LogMessage("SlewSettleTime Set", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("SlewSettleTime", true); throw new PropertyNotImplementedException("SlewSettleTime", true);
} }
} }
@@ -1336,10 +1344,10 @@ namespace ASCOM.Meade.net
set set
{ {
if (value > 90) if (value > 90)
throw new ASCOM.InvalidValueException("Altitude cannot be greater than 90."); throw new InvalidValueException("Altitude cannot be greater than 90.");
if (value < 0) if (value < 0)
throw new ASCOM.InvalidValueException("Altitide cannot be less than 0."); throw new InvalidValueException("Altitide cannot be less than 0.");
CheckConnected("TargetAltitude Set"); CheckConnected("TargetAltitude Set");
@@ -1356,7 +1364,7 @@ namespace ASCOM.Meade.net
//0 Object out of slew range //0 Object out of slew range
if (result == "0") if (result == "0")
throw new ASCOM.InvalidOperationException("Target altitude out of slew range"); throw new InvalidOperationException("Target altitude out of slew range");
} }
} }
@@ -1365,10 +1373,10 @@ namespace ASCOM.Meade.net
set set
{ {
if (value >= 360) if (value >= 360)
throw new ASCOM.InvalidValueException("Azimuth cannot be 360 or higher."); throw new InvalidValueException("Azimuth cannot be 360 or higher.");
if (value < 0) if (value < 0)
throw new ASCOM.InvalidValueException("Azimuth cannot be less than 0."); throw new InvalidValueException("Azimuth cannot be less than 0.");
CheckConnected("TargetAzimuth Set"); CheckConnected("TargetAzimuth Set");
@@ -1384,28 +1392,29 @@ namespace ASCOM.Meade.net
//1 - Valid //1 - Valid
if (result == "0") if (result == "0")
throw new ASCOM.InvalidOperationException("Target Azimuth out of slew range"); throw new InvalidOperationException("Target Azimuth out of slew range");
} }
} }
public void SlewToAltAzAsync(double azimuth, double altitude) public void SlewToAltAzAsync(double azimuth, double altitude)
{ {
if (altitude > 90)
throw new ASCOM.InvalidValueException("Altitude cannot be greater than 90.");
if (altitude < 0)
throw new ASCOM.InvalidValueException("Altitide cannot be less than 0.");
if (azimuth >= 360)
throw new ASCOM.InvalidValueException("Azimuth cannot be 360 or higher.");
if (azimuth < 0)
throw new ASCOM.InvalidValueException("Azimuth cannot be less than 0.");
LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude}");
CheckConnected("SlewToAltAzAsync"); CheckConnected("SlewToAltAzAsync");
if (altitude > 90)
throw new InvalidValueException("Altitude cannot be greater than 90.");
if (altitude < 0)
throw new InvalidValueException("Altitide cannot be less than 0.");
if (azimuth >= 360)
throw new InvalidValueException("Azimuth cannot be 360 or higher.");
if (azimuth < 0)
throw new InvalidValueException("Azimuth cannot be less than 0.");
LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude}");
HorizonCoordinates altAz = new HorizonCoordinates(); HorizonCoordinates altAz = new HorizonCoordinates();
altAz.Azimuth = azimuth; altAz.Azimuth = azimuth;
altAz.Altitude = altitude; altAz.Altitude = altitude;
@@ -1456,15 +1465,15 @@ namespace ASCOM.Meade.net
//Below Horizon //Below Horizon
string belowHorizonMessage = _sharedResourcesWrapper.ReadTerminated(); string belowHorizonMessage = _sharedResourcesWrapper.ReadTerminated();
LogMessage("DoSlewAsync", $"Slew failed \"{belowHorizonMessage}\""); LogMessage("DoSlewAsync", $"Slew failed \"{belowHorizonMessage}\"");
throw new ASCOM.InvalidOperationException(belowHorizonMessage); throw new InvalidOperationException(belowHorizonMessage);
case "2": case "2":
//Below Horizon //Below Horizon
string belowMinimumElevationMessage = _sharedResourcesWrapper.ReadTerminated(); string belowMinimumElevationMessage = _sharedResourcesWrapper.ReadTerminated();
LogMessage("DoSlewAsync", $"Slew failed \"{belowMinimumElevationMessage}\""); LogMessage("DoSlewAsync", $"Slew failed \"{belowMinimumElevationMessage}\"");
throw new ASCOM.InvalidOperationException(belowMinimumElevationMessage); throw new InvalidOperationException(belowMinimumElevationMessage);
default: default:
LogMessage("DoSlewAsync", $"Slew failed - unknown response \"{response}\""); LogMessage("DoSlewAsync", $"Slew failed - unknown response \"{response}\"");
throw new ASCOM.DriverException("This error should not happen"); throw new DriverException("This error should not happen");
} }
@@ -1479,7 +1488,7 @@ namespace ASCOM.Meade.net
if (maResponse == "1") if (maResponse == "1")
{ {
throw new ASCOM.InvalidOperationException("fault"); throw new InvalidOperationException("fault");
} }
break; break;
@@ -1529,19 +1538,19 @@ namespace ASCOM.Meade.net
} }
} }
private const double INVALID_PARAMETER = -1000; private const double InvalidParameter = -1000;
public void SlewToTargetAsync() public void SlewToTargetAsync()
{ {
CheckConnected("SlewToTargetAsync"); CheckConnected("SlewToTargetAsync");
if (TargetDeclination == INVALID_PARAMETER || TargetRightAscension == INVALID_PARAMETER) if (TargetDeclination == InvalidParameter || TargetRightAscension == InvalidParameter)
throw new ASCOM.InvalidOperationException("No target selected to slew to."); throw new InvalidOperationException("No target selected to slew to.");
DoSlewAsync(true); DoSlewAsync(true);
} }
private bool movingAxis() private bool MovingAxis()
{ {
return _movingPrimary || _movingSecondary; return _movingPrimary || _movingSecondary;
} }
@@ -1553,7 +1562,7 @@ namespace ASCOM.Meade.net
if (!Connected) return false; if (!Connected) return false;
if (movingAxis()) if (MovingAxis())
return true; return true;
CheckConnected("Slewing Get"); CheckConnected("Slewing Get");
@@ -1563,6 +1572,12 @@ namespace ASCOM.Meade.net
//Returns: //Returns:
//LX200's a string of bar characters indicating the distance. //LX200's a string of bar characters indicating the distance.
//Autostars and Autostar II a string containing one bar until a slew is complete, then a null string is returned. //Autostars and Autostar II a string containing one bar until a slew is complete, then a null string is returned.
if (result == null)
{
return false;
}
bool isSlewing = result != string.Empty; bool isSlewing = result != string.Empty;
LogMessage("Slewing Get", $"Result = {isSlewing}"); LogMessage("Slewing Get", $"Result = {isSlewing}");
@@ -1573,7 +1588,7 @@ namespace ASCOM.Meade.net
public void SyncToAltAz(double azimuth, double altitude) public void SyncToAltAz(double azimuth, double altitude)
{ {
LogMessage("SyncToAltAz", "Not implemented"); LogMessage("SyncToAltAz", "Not implemented");
throw new ASCOM.MethodNotImplementedException("SyncToAltAz"); throw new MethodNotImplementedException("SyncToAltAz");
} }
public void SyncToCoordinates(double rightAscension, double declination) public void SyncToCoordinates(double rightAscension, double declination)
@@ -1599,19 +1614,19 @@ namespace ASCOM.Meade.net
//:CM# Synchronizes the telescope's position with the currently selected database object's coordinates. //:CM# Synchronizes the telescope's position with the currently selected database object's coordinates.
//Returns: //Returns:
//LX200's - a "#" terminated string with the name of the object that was synced. //LX200's - a "#" terminated string with the name of the object that was synced.
// Autostars & Autostar II - At static string: " M31 EX GAL MAG 3.5 SZ178.0'#" // Autostars & Autostar II - A static string: " M31 EX GAL MAG 3.5 SZ178.0'#"
if (result == string.Empty) if (result == string.Empty)
throw new ASCOM.InvalidOperationException("Unable to perform sync"); throw new InvalidOperationException("Unable to perform sync");
} }
private double _targetDeclination = INVALID_PARAMETER; private double _targetDeclination = InvalidParameter;
public double TargetDeclination public double TargetDeclination
{ {
get get
{ {
if (_targetDeclination == INVALID_PARAMETER) if (_targetDeclination == InvalidParameter)
throw new ASCOM.InvalidOperationException("Target not set"); throw new InvalidOperationException("Target not set");
//var result = SerialPort.CommandTerminated(":Gd#", "#"); //var result = SerialPort.CommandTerminated(":Gd#", "#");
////:Gd# Get Currently Selected Object/Target Declination ////:Gd# Get Currently Selected Object/Target Declination
@@ -1628,16 +1643,16 @@ namespace ASCOM.Meade.net
set set
{ {
LogMessage("TargetDeclination Set", $"{value}"); LogMessage("TargetDeclination Set", $"{value}");
//todo implement low precision version of this.
if (value > 90)
throw new ASCOM.InvalidValueException("Declination cannot be greater than 90.");
if (value < -90)
throw new ASCOM.InvalidValueException("Declination cannot be less than -90.");
CheckConnected("TargetDeclination Set"); CheckConnected("TargetDeclination Set");
//todo implement low precision version of this.
if (value > 90)
throw new InvalidValueException("Declination cannot be greater than 90.");
if (value < -90)
throw new InvalidValueException("Declination cannot be less than -90.");
var dms = _utilities.DegreesToDMS(value, "*", ":", ":", 2); var dms = _utilities.DegreesToDMS(value, "*", ":", ":", 2);
var s = value < 0 ? string.Empty : "+"; var s = value < 0 ? string.Empty : "+";
@@ -1653,20 +1668,20 @@ namespace ASCOM.Meade.net
if (result == "0") if (result == "0")
{ {
throw new ASCOM.InvalidOperationException("Target declination invalid"); throw new InvalidOperationException("Target declination invalid");
} }
_targetDeclination = value; _targetDeclination = value;
} }
} }
private double _targetRightAscension = INVALID_PARAMETER; private double _targetRightAscension = InvalidParameter;
public double TargetRightAscension public double TargetRightAscension
{ {
get get
{ {
if (_targetRightAscension == INVALID_PARAMETER) if (_targetRightAscension == InvalidParameter)
throw new ASCOM.InvalidOperationException("Target not set"); throw new InvalidOperationException("Target not set");
//var result = SerialPort.CommandTerminated(":Gr#", "#"); //var result = SerialPort.CommandTerminated(":Gr#", "#");
////:Gr# Get current/target object RA ////:Gr# Get current/target object RA
@@ -1682,14 +1697,13 @@ namespace ASCOM.Meade.net
set set
{ {
LogMessage("TargetRightAscension Set", $"{value}"); LogMessage("TargetRightAscension Set", $"{value}");
CheckConnected("TargetRightAscension Set");
if (value < 0) if (value < 0)
throw new InvalidValueException("Right ascension value cannot be below 0"); throw new InvalidValueException("Right ascension value cannot be below 0");
if (value >= 24) if (value >= 24)
throw new InvalidValueException("Right ascension value cannot be greater than 23:59:59"); throw new InvalidValueException("Right ascension value cannot be greater than 23:59:59");
CheckConnected("TargetRightAscension Set");
//todo implement the low precision version //todo implement the low precision version
var hms = _utilities.HoursToHMS(value, ":", ":", ":", 2); var hms = _utilities.HoursToHMS(value, ":", ":", ":", 2);
@@ -1794,8 +1808,6 @@ namespace ASCOM.Meade.net
private TimeSpan GetUtcCorrection() private TimeSpan GetUtcCorrection()
{ {
CheckConnected("GetUtcCorrection");
string utcOffSet = _sharedResourcesWrapper.SendString(":GG#"); string utcOffSet = _sharedResourcesWrapper.SendString(":GG#");
//:GG# Get UTC offset time //:GG# Get UTC offset time
//Returns: sHH# or sHH.H# //Returns: sHH# or sHH.H#
@@ -1806,11 +1818,11 @@ namespace ASCOM.Meade.net
return utcCorrection; return utcCorrection;
} }
private class TelescopeDateDetails public class TelescopeDateDetails
{ {
public string telescopeDate { get; set; } public string TelescopeDate { get; set; }
public string telescopeTime { get; set; } public string TelescopeTime { get; set; }
public TimeSpan utcCorrection { get; set; } public TimeSpan UtcCorrection { get; set; }
} }
public DateTime UTCDate public DateTime UTCDate
@@ -1824,34 +1836,34 @@ namespace ASCOM.Meade.net
TelescopeDateDetails telescopeDateDetails = _sharedResourcesWrapper.Lock(() => TelescopeDateDetails telescopeDateDetails = _sharedResourcesWrapper.Lock(() =>
{ {
TelescopeDateDetails tdd = new TelescopeDateDetails(); TelescopeDateDetails tdd = new TelescopeDateDetails();
tdd.telescopeDate = _sharedResourcesWrapper.SendString(":GC#"); tdd.TelescopeDate = _sharedResourcesWrapper.SendString(":GC#");
//:GC# Get current date. //:GC# Get current date.
//Returns: MM / DD / YY# //Returns: MM/DD/YY#
//The current local calendar date for the telescope. //The current local calendar date for the telescope.
tdd.telescopeTime = _sharedResourcesWrapper.SendString(":GL#"); tdd.TelescopeTime = _sharedResourcesWrapper.SendString(":GL#");
//:GL# Get Local Time in 24 hour format //:GL# Get Local Time in 24 hour format
//Returns: HH: MM: SS# //Returns: HH:MM:SS#
//The Local Time in 24 - hour Format //The Local Time in 24 - hour Format
tdd.utcCorrection = GetUtcCorrection(); tdd.UtcCorrection = GetUtcCorrection();
return tdd; return tdd;
}); });
int month = telescopeDateDetails.telescopeDate.Substring(0, 2).ToInteger(); int month = telescopeDateDetails.TelescopeDate.Substring(0, 2).ToInteger();
int day = telescopeDateDetails.telescopeDate.Substring(3, 2).ToInteger(); int day = telescopeDateDetails.TelescopeDate.Substring(3, 2).ToInteger();
int year = telescopeDateDetails.telescopeDate.Substring(6, 2).ToInteger(); int year = telescopeDateDetails.TelescopeDate.Substring(6, 2).ToInteger();
if (year < 2000) //todo fix this hack that will create a Y2K100 bug if (year < 2000) //todo fix this hack that will create a Y2K100 bug
{ {
year = year + 2000; year = year + 2000;
} }
int hour = telescopeDateDetails.telescopeTime.Substring(0, 2).ToInteger(); int hour = telescopeDateDetails.TelescopeTime.Substring(0, 2).ToInteger();
int minute = telescopeDateDetails.telescopeTime.Substring(3, 2).ToInteger(); int minute = telescopeDateDetails.TelescopeTime.Substring(3, 2).ToInteger();
int second = telescopeDateDetails.telescopeTime.Substring(6, 2).ToInteger(); int second = telescopeDateDetails.TelescopeTime.Substring(6, 2).ToInteger();
var utcDate = new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc) + var utcDate = new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc) +
telescopeDateDetails.utcCorrection; telescopeDateDetails.UtcCorrection;
LogMessage("UTCDate", "Get - " + utcDate.ToString("MM/dd/yy HH:mm:ss")); LogMessage("UTCDate", "Get - " + utcDate.ToString("MM/dd/yy HH:mm:ss"));
@@ -1868,7 +1880,8 @@ namespace ASCOM.Meade.net
var utcCorrection = GetUtcCorrection(); var utcCorrection = GetUtcCorrection();
var localDateTime = value - utcCorrection; var localDateTime = value - utcCorrection;
var timeResult = _sharedResourcesWrapper.SendChar($":SL{localDateTime:HH:mm:ss}#"); string localStingCommand = $":SL{localDateTime:HH:mm:ss}#";
var timeResult = _sharedResourcesWrapper.SendChar(localStingCommand);
//:SLHH:MM:SS# //:SLHH:MM:SS#
//Set the local Time //Set the local Time
//Returns: //Returns:
@@ -1879,7 +1892,8 @@ namespace ASCOM.Meade.net
throw new InvalidOperationException("Failed to set local time"); throw new InvalidOperationException("Failed to set local time");
} }
var dateResult = _sharedResourcesWrapper.SendChar($":SC{localDateTime:MM/dd/yy}#"); string localDateCommand = $":SC{localDateTime:MM/dd/yy}#";
var dateResult = _sharedResourcesWrapper.SendChar(localDateCommand);
//:SCMM/DD/YY# //:SCMM/DD/YY#
//Change Handbox Date to MM/DD/YY //Change Handbox Date to MM/DD/YY
//Returns: <D><string> //Returns: <D><string>
@@ -1901,7 +1915,7 @@ namespace ASCOM.Meade.net
public void Unpark() public void Unpark()
{ {
LogMessage("Unpark", "Not implemented"); LogMessage("Unpark", "Not implemented");
throw new ASCOM.MethodNotImplementedException("Unpark"); throw new MethodNotImplementedException("Unpark");
} }
#endregion #endregion
@@ -1920,18 +1934,18 @@ namespace ASCOM.Meade.net
/// This is harmless if the driver is already registered/unregistered. /// This is harmless if the driver is already registered/unregistered.
/// </summary> /// </summary>
/// <param name="bRegister">If <c>true</c>, registers the driver, otherwise unregisters it.</param> /// <param name="bRegister">If <c>true</c>, registers the driver, otherwise unregisters it.</param>
private static void RegUnregASCOM(bool bRegister) private static void RegUnregAscom(bool bRegister)
{ {
using (var P = new ASCOM.Utilities.Profile()) using (var p = new Profile())
{ {
P.DeviceType = "Telescope"; p.DeviceType = "Telescope";
if (bRegister) if (bRegister)
{ {
P.Register(driverID, driverDescription); p.Register(DriverId, DriverDescription);
} }
else else
{ {
P.Unregister(driverID); p.Unregister(DriverId);
} }
} }
} }
@@ -1954,9 +1968,9 @@ namespace ASCOM.Meade.net
/// This technique should mean that it is never necessary to manually register a driver with ASCOM. /// This technique should mean that it is never necessary to manually register a driver with ASCOM.
/// </remarks> /// </remarks>
[ComRegisterFunction] [ComRegisterFunction]
public static void RegisterASCOM(Type t) public static void RegisterAscom(Type t)
{ {
RegUnregASCOM(true); RegUnregAscom(true);
} }
/// <summary> /// <summary>
@@ -1977,9 +1991,9 @@ namespace ASCOM.Meade.net
/// This technique should mean that it is never necessary to manually unregister a driver from ASCOM. /// This technique should mean that it is never necessary to manually unregister a driver from ASCOM.
/// </remarks> /// </remarks>
[ComUnregisterFunction] [ComUnregisterFunction]
public static void UnregisterASCOM(Type t) public static void UnregisterAscom(Type t)
{ {
RegUnregASCOM(false); RegUnregAscom(false);
} }
#endregion #endregion
@@ -1997,7 +2011,7 @@ namespace ASCOM.Meade.net
{ {
if (!IsConnected) if (!IsConnected)
{ {
throw new ASCOM.NotConnectedException($"Not connected to telescope when trying to execute: {message}"); throw new NotConnectedException($"Not connected to telescope when trying to execute: {message}");
} }
} }
@@ -2007,8 +2021,8 @@ namespace ASCOM.Meade.net
internal void ReadProfile() internal void ReadProfile()
{ {
var profileProperties = _sharedResourcesWrapper.ReadProfile(); var profileProperties = _sharedResourcesWrapper.ReadProfile();
tl.Enabled = profileProperties.TraceLogger; _tl.Enabled = profileProperties.TraceLogger;
comPort = profileProperties.ComPort; _comPort = profileProperties.ComPort;
} }
/// <summary> /// <summary>
@@ -2020,7 +2034,7 @@ namespace ASCOM.Meade.net
internal void LogMessage(string identifier, string message, params object[] args) internal 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
} }
+66 -73
View File
@@ -38,14 +38,14 @@ namespace ASCOM.Meade.net
/// The DeviceID is used by ASCOM applications to load the driver at runtime. /// The DeviceID is used by ASCOM applications to load the driver at runtime.
/// </summary> /// </summary>
//internal static string driverID = "ASCOM.Meade.net.Focuser"; //internal static string driverID = "ASCOM.Meade.net.Focuser";
internal static string driverID = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType); private static readonly string DriverId = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType);
// TODO Change the descriptive string for your driver then remove this line // TODO Change the descriptive string for your driver then remove this line
/// <summary> /// <summary>
/// Driver description that displays in the ASCOM Chooser. /// Driver description that displays in the ASCOM Chooser.
/// </summary> /// </summary>
private static string driverDescription = "Meade Generic"; private static readonly string DriverDescription = "Meade Generic";
internal static string comPort; // Variables to hold the currrent device configuration private static string _comPort; // Variables to hold the currrent device configuration
/// <summary> /// <summary>
/// Private variable to hold an ASCOM Utilities object /// Private variable to hold an ASCOM Utilities object
@@ -55,7 +55,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>
internal static TraceLogger tl; internal static TraceLogger Tl;
private readonly ISharedResourcesWrapper _sharedResourcesWrapper; private readonly ISharedResourcesWrapper _sharedResourcesWrapper;
@@ -74,14 +74,14 @@ namespace ASCOM.Meade.net
private void Initialise() private void Initialise()
{ {
tl = new TraceLogger("", "Meade.net.focusser"); Tl = new TraceLogger("", "Meade.net.focusser");
tl.LogMessage("Focuser", "Starting initialisation"); Tl.LogMessage("Focuser", "Starting initialisation");
ReadProfile(); // Read device configuration from the ASCOM Profile store ReadProfile(); // Read device configuration from the ASCOM Profile store
IsConnected = false; // Initialise connected to false IsConnected = false; // Initialise connected to false
tl.LogMessage("Focuser", "Completed initialisation"); Tl.LogMessage("Focuser", "Completed initialisation");
} }
@@ -99,17 +99,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();
} }
} }
@@ -117,7 +117,7 @@ namespace ASCOM.Meade.net
public string Action(string actionName, string actionParameters) public string Action(string actionName, string actionParameters)
{ {
LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters); LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters);
throw new ASCOM.ActionNotImplementedException("Action " + actionName + " is not implemented by this driver"); throw new ActionNotImplementedException("Action " + actionName + " is not implemented by this driver");
} }
public void CommandBlind(string command, bool raw) public void CommandBlind(string command, bool raw)
@@ -137,7 +137,7 @@ namespace ASCOM.Meade.net
//string ret = CommandString(command, raw); //string ret = CommandString(command, raw);
// TODO decode the return string and return true or false // TODO decode the return string and return true or false
// or // or
throw new ASCOM.MethodNotImplementedException("CommandBool"); throw new MethodNotImplementedException("CommandBool");
// DO NOT have both these sections! One or the other // DO NOT have both these sections! One or the other
} }
@@ -149,15 +149,15 @@ namespace ASCOM.Meade.net
// you need something to ensure that only one command is in progress at a time // you need something to ensure that only one command is in progress at a time
return _sharedResourcesWrapper.SendString(command); return _sharedResourcesWrapper.SendString(command);
throw new ASCOM.MethodNotImplementedException("CommandString"); throw new MethodNotImplementedException("CommandString");
} }
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
@@ -169,7 +169,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;
@@ -193,12 +193,12 @@ namespace ASCOM.Meade.net
} }
catch (Exception ex) catch (Exception ex)
{ {
LogMessage("Connected Set", "Error connecting to port {0} - {1}", comPort, ex.Message); LogMessage("Connected Set", "Error connecting to port {0} - {1}", _comPort, ex.Message);
} }
} }
else else
{ {
LogMessage("Connected Set", "Disconnecting from port {0}", comPort); LogMessage("Connected Set", "Disconnecting from port {0}", _comPort);
_sharedResourcesWrapper.Disconnect("Serial"); _sharedResourcesWrapper.Disconnect("Serial");
IsConnected = false; IsConnected = false;
} }
@@ -241,8 +241,8 @@ 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;
} }
} }
@@ -250,10 +250,10 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; Version version = Assembly.GetExecutingAssembly().GetName().Version;
// TODO customise this driver description // TODO customise this driver description
string driverInfo = "Information about the driver itself. Version: " + String.Format(CultureInfo.InvariantCulture, "{0}.{1}", version.Major, version.Minor); string driverInfo = "Information about the driver itself. Version: " + String.Format(CultureInfo.InvariantCulture, "{0}.{1}", version.Major, version.Minor);
tl.LogMessage("DriverInfo Get", driverInfo); Tl.LogMessage("DriverInfo Get", driverInfo);
return driverInfo; return driverInfo;
} }
} }
@@ -262,9 +262,9 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; Version version = Assembly.GetExecutingAssembly().GetName().Version;
string driverVersion = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", version.Major, version.Minor); string driverVersion = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", version.Major, version.Minor);
tl.LogMessage("DriverVersion Get", driverVersion); Tl.LogMessage("DriverVersion Get", driverVersion);
return driverVersion; return driverVersion;
} }
} }
@@ -284,8 +284,8 @@ namespace ASCOM.Meade.net
get get
{ {
//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;
} }
} }
@@ -298,14 +298,14 @@ namespace ASCOM.Meade.net
{ {
get 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");
@@ -325,7 +325,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
} }
} }
@@ -334,13 +334,13 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
tl.LogMessage("Link Get", this.Connected.ToString()); Tl.LogMessage("Link Get", Connected.ToString());
return this.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());
this.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
} }
} }
@@ -349,7 +349,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
} }
} }
@@ -359,37 +359,37 @@ 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
//todo implement direction reverse //todo implement direction reverse
//todo implement dynamic braking //todo implement dynamic braking
if (Position < -MaxIncrement || Position > MaxIncrement) if (position < -MaxIncrement || position > MaxIncrement)
{ {
throw new ASCOM.InvalidValueException($"position out of range {-MaxIncrement} < {Position} < {MaxIncrement}"); throw new InvalidValueException($"position out of range {-MaxIncrement} < {position} < {MaxIncrement}");
} }
if (Position == 0) if (position == 0)
return; return;
if (Position > 0) if (position > 0)
{ {
//desired move direction is out //desired move direction is out
MoveFocuser(true, Math.Abs(Position)); MoveFocuser(true, Math.Abs(position));
} }
else else
{ {
//desired move direction is in //desired move direction is in
MoveFocuser(false, Math.Abs(Position)); MoveFocuser(false, Math.Abs(position));
} }
} }
@@ -430,21 +430,14 @@ namespace ASCOM.Meade.net
}); });
} }
public int Position public int Position => throw new PropertyNotImplementedException("Position", false);
{
get
{
throw new ASCOM.PropertyNotImplementedException("Position", false);
//return focuserPosition; // Return the focuser position
}
}
public double StepSize public double StepSize
{ {
get get
{ {
tl.LogMessage("StepSize Get", "Not implemented"); Tl.LogMessage("StepSize Get", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("StepSize", false); throw new PropertyNotImplementedException("StepSize", false);
} }
} }
@@ -452,13 +445,13 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
tl.LogMessage("TempComp Get", false.ToString()); Tl.LogMessage("TempComp Get", false.ToString());
return false; return false;
} }
set set
{ {
tl.LogMessage("TempComp Set", "Not implemented"); Tl.LogMessage("TempComp Set", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("TempComp", false); throw new PropertyNotImplementedException("TempComp", false);
} }
} }
@@ -466,7 +459,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
} }
} }
@@ -475,8 +468,8 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
tl.LogMessage("Temperature Get", "Not implemented"); Tl.LogMessage("Temperature Get", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("Temperature", false); throw new PropertyNotImplementedException("Temperature", false);
} }
} }
@@ -496,18 +489,18 @@ namespace ASCOM.Meade.net
/// This is harmless if the driver is already registered/unregistered. /// This is harmless if the driver is already registered/unregistered.
/// </summary> /// </summary>
/// <param name="bRegister">If <c>true</c>, registers the driver, otherwise unregisters it.</param> /// <param name="bRegister">If <c>true</c>, registers the driver, otherwise unregisters it.</param>
private static void RegUnregASCOM(bool bRegister) private static void RegUnregAscom(bool bRegister)
{ {
using (var P = new ASCOM.Utilities.Profile()) using (var p = new Profile())
{ {
P.DeviceType = "Focuser"; p.DeviceType = "Focuser";
if (bRegister) if (bRegister)
{ {
P.Register(driverID, driverDescription); p.Register(DriverId, DriverDescription);
} }
else else
{ {
P.Unregister(driverID); p.Unregister(DriverId);
} }
} }
} }
@@ -530,9 +523,9 @@ namespace ASCOM.Meade.net
/// This technique should mean that it is never necessary to manually register a driver with ASCOM. /// This technique should mean that it is never necessary to manually register a driver with ASCOM.
/// </remarks> /// </remarks>
[ComRegisterFunction] [ComRegisterFunction]
public static void RegisterASCOM(Type t) public static void RegisterAscom(Type t)
{ {
RegUnregASCOM(true); RegUnregAscom(true);
} }
/// <summary> /// <summary>
@@ -553,9 +546,9 @@ namespace ASCOM.Meade.net
/// This technique should mean that it is never necessary to manually unregister a driver from ASCOM. /// This technique should mean that it is never necessary to manually unregister a driver from ASCOM.
/// </remarks> /// </remarks>
[ComUnregisterFunction] [ComUnregisterFunction]
public static void UnregisterASCOM(Type t) public static void UnregisterAscom(Type t)
{ {
RegUnregASCOM(false); RegUnregAscom(false);
} }
#endregion #endregion
@@ -573,7 +566,7 @@ namespace ASCOM.Meade.net
{ {
if (!IsConnected) if (!IsConnected)
{ {
throw new ASCOM.NotConnectedException(message); throw new NotConnectedException(message);
} }
} }
@@ -583,8 +576,8 @@ namespace ASCOM.Meade.net
internal void ReadProfile() internal void ReadProfile()
{ {
var profileProperties = _sharedResourcesWrapper.ReadProfile(); var profileProperties = _sharedResourcesWrapper.ReadProfile();
tl.Enabled = profileProperties.TraceLogger; Tl.Enabled = profileProperties.TraceLogger;
comPort = profileProperties.ComPort; _comPort = profileProperties.ComPort;
} }
/// <summary> /// <summary>
@@ -596,7 +589,7 @@ namespace ASCOM.Meade.net
internal static void LogMessage(string identifier, string message, params object[] args) internal 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
} }
+2 -3
View File
@@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
@@ -35,5 +34,5 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below: // by using the '*' as shown below:
// //
// TODO - Set your driver's version here // TODO - Set your driver's version here
[assembly: AssemblyVersion("0.7.0.0")] [assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("0.7.0.0")] [assembly: AssemblyFileVersion("0.0.0.0")]
+59 -69
View File
@@ -33,43 +33,43 @@ 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.
public static Guid IID_IUnknown = new Guid("{00000000-0000-0000-C000-000000000046}"); private static readonly Guid _iidIUnknown = new Guid("{00000000-0000-0000-C000-000000000046}");
public static Guid IID_IDispatch = 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
{ {
CLSCTX_INPROC_SERVER = 0x1, ClsctxInprocServer = 0x1,
CLSCTX_INPROC_HANDLER = 0x2, ClsctxInprocHandler = 0x2,
CLSCTX_LOCAL_SERVER = 0x4, ClsctxLocalServer = 0x4,
CLSCTX_INPROC_SERVER16 = 0x8, ClsctxInprocServer16 = 0x8,
CLSCTX_REMOTE_SERVER = 0x10, ClsctxRemoteServer = 0x10,
CLSCTX_INPROC_HANDLER16 = 0x20, ClsctxInprocHandler16 = 0x20,
CLSCTX_RESERVED1 = 0x40, ClsctxReserved1 = 0x40,
CLSCTX_RESERVED2 = 0x80, ClsctxReserved2 = 0x80,
CLSCTX_RESERVED3 = 0x100, ClsctxReserved3 = 0x100,
CLSCTX_RESERVED4 = 0x200, ClsctxReserved4 = 0x200,
CLSCTX_NO_CODE_DOWNLOAD = 0x400, ClsctxNoCodeDownload = 0x400,
CLSCTX_RESERVED5 = 0x800, ClsctxReserved5 = 0x800,
CLSCTX_NO_CUSTOM_MARSHAL = 0x1000, ClsctxNoCustomMarshal = 0x1000,
CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000, ClsctxEnableCodeDownload = 0x2000,
CLSCTX_NO_FAILURE_LOG = 0x4000, ClsctxNoFailureLog = 0x4000,
CLSCTX_DISABLE_AAA = 0x8000, ClsctxDisableAaa = 0x8000,
CLSCTX_ENABLE_AAA = 0x10000, ClsctxEnableAaa = 0x10000,
CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000, ClsctxFromDefaultContext = 0x20000,
CLSCTX_INPROC = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, ClsctxInproc = ClsctxInprocServer | ClsctxInprocHandler,
CLSCTX_SERVER = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER, ClsctxServer = ClsctxInprocServer | ClsctxLocalServer | ClsctxRemoteServer,
CLSCTX_ALL = CLSCTX_SERVER | CLSCTX_INPROC_HANDLER ClsctxAll = ClsctxServer | ClsctxInprocHandler
} }
[Flags] [Flags]
enum REGCLS : uint enum Regcls : uint
{ {
REGCLS_SINGLEUSE = 0, RegclsSingleuse = 0,
REGCLS_MULTIPLEUSE = 1, RegclsMultipleuse = 1,
REGCLS_MULTI_SEPARATE = 2, RegclsMultiSeparate = 2,
REGCLS_SUSPENDED = 4, RegclsSuspended = 4,
REGCLS_SURROGATE = 8 RegclsSurrogate = 8
} }
// //
// CoRegisterClassObject() is used to register a Class Factory // CoRegisterClassObject() is used to register a Class Factory
@@ -109,70 +109,60 @@ namespace ASCOM.Meade.net
#region Constructor and Private ClassFactory Data #region Constructor and Private ClassFactory Data
protected Type m_ClassType; private readonly Type _mClassType;
protected Guid m_ClassId; private Guid _mClassId;
protected ArrayList m_InterfaceTypes; private readonly ArrayList _mInterfaceTypes;
protected uint m_ClassContext; private UInt32 _mLocked = 0;
protected uint m_Flags; private uint _mCookie;
protected UInt32 m_locked = 0; private readonly string _mProgid;
protected uint m_Cookie;
protected string m_progid;
public ClassFactory(Type type) public ClassFactory(Type type)
{ {
if (type == null) if (type == null)
throw new ArgumentNullException("type"); throw new ArgumentNullException("type");
m_ClassType = type; _mClassType = type;
//PWGS Get the ProgID from the MetaData //PWGS Get the ProgID from the MetaData
m_progid = Marshal.GenerateProgIdForType(type); _mProgid = Marshal.GenerateProgIdForType(type);
m_ClassId = Marshal.GenerateGuidForType(type); // Should be nailed down by [Guid(...)] _mClassId = Marshal.GenerateGuidForType(type); // Should be nailed down by [Guid(...)]
m_ClassContext = (uint)CLSCTX.CLSCTX_LOCAL_SERVER; // Default ClassContext = (uint)Clsctx.ClsctxLocalServer; // Default
m_Flags = (uint)REGCLS.REGCLS_MULTIPLEUSE | // Default Flags = (uint)Regcls.RegclsMultipleuse | // Default
(uint)REGCLS.REGCLS_SUSPENDED; (uint)Regcls.RegclsSuspended;
m_InterfaceTypes = new ArrayList(); _mInterfaceTypes = new ArrayList();
foreach (Type T in type.GetInterfaces()) // Save all of the implemented interfaces foreach (Type T in type.GetInterfaces()) // Save all of the implemented interfaces
m_InterfaceTypes.Add(T); _mInterfaceTypes.Add(T);
} }
#endregion #endregion
#region Common ClassFactory Methods #region Common ClassFactory Methods
public uint ClassContext public uint ClassContext { get; }
{
get { return m_ClassContext; }
set { m_ClassContext = value; }
}
public Guid ClassId public Guid ClassId
{ {
get { return m_ClassId; } get => _mClassId;
set { m_ClassId = value; } set => _mClassId = value;
} }
public uint Flags public uint Flags { get; }
{
get { return m_Flags; }
set { m_Flags = value; }
}
public bool RegisterClassObject() public bool RegisterClassObject()
{ {
// Register the class factory // Register the class factory
int i = CoRegisterClassObject int i = CoRegisterClassObject
( (
ref m_ClassId, ref _mClassId,
this, this,
m_ClassContext, ClassContext,
m_Flags, Flags,
out m_Cookie out _mCookie
); );
return (i == 0); return (i == 0);
} }
public bool RevokeClassObject() public bool RevokeClassObject()
{ {
int i = CoRevokeClassObject(m_Cookie); int i = CoRevokeClassObject(_mCookie);
return (i == 0); return (i == 0);
} }
@@ -201,25 +191,25 @@ namespace ASCOM.Meade.net
// //
// Handle specific requests for implemented interfaces // Handle specific requests for implemented interfaces
// //
foreach (Type iType in m_InterfaceTypes) foreach (Type iType in _mInterfaceTypes)
{ {
if (riid == Marshal.GenerateGuidForType(iType)) if (riid == Marshal.GenerateGuidForType(iType))
{ {
ppvObject = Marshal.GetComInterfaceForObject(Activator.CreateInstance(m_ClassType), iType); ppvObject = Marshal.GetComInterfaceForObject(Activator.CreateInstance(_mClassType), iType);
return; return;
} }
} }
// //
// Handle requests for IDispatch or IUnknown on the class // Handle requests for IDispatch or IUnknown on the class
// //
if (riid == IID_IDispatch) if (riid == _iidIDispatch)
{ {
ppvObject = Marshal.GetIDispatchForObject(Activator.CreateInstance(m_ClassType)); ppvObject = Marshal.GetIDispatchForObject(Activator.CreateInstance(_mClassType));
return; return;
} }
else if (riid == IID_IUnknown) else if (riid == _iidIUnknown)
{ {
ppvObject = Marshal.GetIUnknownForObject(Activator.CreateInstance(m_ClassType)); ppvObject = Marshal.GetIUnknownForObject(Activator.CreateInstance(_mClassType));
} }
else else
{ {
+15 -15
View File
@@ -8,35 +8,35 @@ namespace ASCOM.Meade.net
/// </summary> /// </summary>
class GarbageCollection class GarbageCollection
{ {
protected bool m_bContinueThread; private bool _mbContinueThread;
protected bool m_GCWatchStopped; private bool _mGcWatchStopped;
protected int m_iInterval; private readonly int _miInterval;
protected ManualResetEvent m_EventThreadEnded; private readonly ManualResetEvent _mEventThreadEnded;
public GarbageCollection(int iInterval) public GarbageCollection(int iInterval)
{ {
m_bContinueThread = true; _mbContinueThread = true;
m_GCWatchStopped = false; _mGcWatchStopped = false;
m_iInterval = iInterval; _miInterval = iInterval;
m_EventThreadEnded = new ManualResetEvent(false); _mEventThreadEnded = new ManualResetEvent(false);
} }
public void GCWatch() public void GcWatch()
{ {
// Pause for a moment to provide a delay to make threads more apparent. // Pause for a moment to provide a delay to make threads more apparent.
while (ContinueThread()) while (ContinueThread())
{ {
GC.Collect(); GC.Collect();
Thread.Sleep(m_iInterval); Thread.Sleep(_miInterval);
} }
m_EventThreadEnded.Set(); _mEventThreadEnded.Set();
} }
protected bool ContinueThread() protected bool ContinueThread()
{ {
lock (this) lock (this)
{ {
return m_bContinueThread; return _mbContinueThread;
} }
} }
@@ -44,14 +44,14 @@ namespace ASCOM.Meade.net
{ {
lock (this) lock (this)
{ {
m_bContinueThread = false; _mbContinueThread = false;
} }
} }
public void WaitForThreadToStop() public void WaitForThreadToStop()
{ {
m_EventThreadEnded.WaitOne(); _mEventThreadEnded.WaitOne();
m_EventThreadEnded.Reset(); _mEventThreadEnded.Reset();
} }
} }
} }
+87 -90
View File
@@ -15,17 +15,14 @@
using System; using System;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using System.Drawing;
using System.Collections; using System.Collections;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Reflection; using System.Reflection;
using ASCOM.Utilities; using ASCOM.Utilities;
using Microsoft.Win32; using Microsoft.Win32;
using System.Text;
using System.Threading; using System.Threading;
using System.Security.Principal; using System.Security.Principal;
using System.Diagnostics; using System.Diagnostics;
using ASCOM;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
{ {
@@ -34,52 +31,52 @@ namespace ASCOM.Meade.net
#region Access to kernel32.dll, user32.dll, and ole32.dll functions #region Access to kernel32.dll, user32.dll, and ole32.dll functions
[Flags] [Flags]
enum CLSCTX : uint enum Clsctx : uint
{ {
CLSCTX_INPROC_SERVER = 0x1, ClsctxInprocServer = 0x1,
CLSCTX_INPROC_HANDLER = 0x2, ClsctxInprocHandler = 0x2,
CLSCTX_LOCAL_SERVER = 0x4, ClsctxLocalServer = 0x4,
CLSCTX_INPROC_SERVER16 = 0x8, ClsctxInprocServer16 = 0x8,
CLSCTX_REMOTE_SERVER = 0x10, ClsctxRemoteServer = 0x10,
CLSCTX_INPROC_HANDLER16 = 0x20, ClsctxInprocHandler16 = 0x20,
CLSCTX_RESERVED1 = 0x40, ClsctxReserved1 = 0x40,
CLSCTX_RESERVED2 = 0x80, ClsctxReserved2 = 0x80,
CLSCTX_RESERVED3 = 0x100, ClsctxReserved3 = 0x100,
CLSCTX_RESERVED4 = 0x200, ClsctxReserved4 = 0x200,
CLSCTX_NO_CODE_DOWNLOAD = 0x400, ClsctxNoCodeDownload = 0x400,
CLSCTX_RESERVED5 = 0x800, ClsctxReserved5 = 0x800,
CLSCTX_NO_CUSTOM_MARSHAL = 0x1000, ClsctxNoCustomMarshal = 0x1000,
CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000, ClsctxEnableCodeDownload = 0x2000,
CLSCTX_NO_FAILURE_LOG = 0x4000, ClsctxNoFailureLog = 0x4000,
CLSCTX_DISABLE_AAA = 0x8000, ClsctxDisableAaa = 0x8000,
CLSCTX_ENABLE_AAA = 0x10000, ClsctxEnableAaa = 0x10000,
CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000, ClsctxFromDefaultContext = 0x20000,
CLSCTX_INPROC = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, ClsctxInproc = ClsctxInprocServer | ClsctxInprocHandler,
CLSCTX_SERVER = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER, ClsctxServer = ClsctxInprocServer | ClsctxLocalServer | ClsctxRemoteServer,
CLSCTX_ALL = CLSCTX_SERVER | CLSCTX_INPROC_HANDLER ClsctxAll = ClsctxServer | ClsctxInprocHandler
} }
[Flags] [Flags]
enum COINIT : uint enum Coinit : uint
{ {
/// Initializes the thread for multi-threaded object concurrency. /// Initializes the thread for multi-threaded object concurrency.
COINIT_MULTITHREADED = 0x0, CoinitMultithreaded = 0x0,
/// Initializes the thread for apartment-threaded object concurrency. /// Initializes the thread for apartment-threaded object concurrency.
COINIT_APARTMENTTHREADED = 0x2, CoinitApartmentthreaded = 0x2,
/// Disables DDE for Ole1 support. /// Disables DDE for Ole1 support.
COINIT_DISABLE_OLE1DDE = 0x4, CoinitDisableOle1Dde = 0x4,
/// Trades memory for speed. /// Trades memory for speed.
COINIT_SPEED_OVER_MEMORY = 0x8 CoinitSpeedOverMemory = 0x8
} }
[Flags] [Flags]
enum REGCLS : uint enum Regcls : uint
{ {
REGCLS_SINGLEUSE = 0, RegclsSingleuse = 0,
REGCLS_MULTIPLEUSE = 1, RegclsMultipleuse = 1,
REGCLS_MULTI_SEPARATE = 2, RegclsMultiSeparate = 2,
REGCLS_SUSPENDED = 4, RegclsSuspended = 4,
REGCLS_SURROGATE = 8 RegclsSurrogate = 8
} }
@@ -97,7 +94,7 @@ namespace ASCOM.Meade.net
// We will need this API to post a WM_QUIT message to the main // We will need this API to post a WM_QUIT message to the main
// thread in order to terminate this application. // thread in order to terminate this application.
[DllImport("user32.dll")] [DllImport("user32.dll")]
static extern bool PostThreadMessage(uint idThread, uint Msg, UIntPtr wParam, static extern bool PostThreadMessage(uint idThread, uint msg, UIntPtr wParam,
IntPtr lParam); IntPtr lParam);
// GetCurrentThreadId() allows us to obtain the thread id of the // GetCurrentThreadId() allows us to obtain the thread id of the
@@ -108,21 +105,21 @@ namespace ASCOM.Meade.net
#endregion #endregion
#region Private Data #region Private Data
private static int objsInUse; // Keeps a count on the total number of objects alive. private static int _objsInUse; // Keeps a count on the total number of objects alive.
private static int serverLocks; // Keeps a lock count on this application. private static int _serverLocks; // Keeps a lock count on this application.
private static frmMain s_MainForm = null; // Reference to our main form private static FrmMain _sMainForm = null; // Reference to our main form
private static ArrayList s_ComObjectAssys; // Dynamically loaded assemblies containing served COM objects private static ArrayList _sComObjectAssys; // Dynamically loaded assemblies containing served COM objects
private static ArrayList s_ComObjectTypes; // Served COM object types private static ArrayList _sComObjectTypes; // Served COM object types
private static ArrayList s_ClassFactories; // Served COM object class factories private static ArrayList _sClassFactories; // Served COM object class factories
private static string s_appId = "{4e68ec46-5ffc-49e7-b298-38a548df0bfd}"; // Our AppId private static string _sAppId = "{4e68ec46-5ffc-49e7-b298-38a548df0bfd}"; // Our AppId
private static readonly Object lockObject = new object(); private static readonly Object LockObject = new object();
#endregion #endregion
// This property returns the main thread's id. // This property returns the main thread's id.
public static uint MainThreadId { get; private set; } // Stores the main thread's thread id. public static uint MainThreadId { get; private set; } // Stores the main thread's thread id.
// Used to tell if started by COM or manually // Used to tell if started by COM or manually
public static bool StartedByCOM { get; private set; } // True if server started by COM (-embedding) public static bool StartedByCom { get; private set; } // True if server started by COM (-embedding)
#region Server Lock, Object Counting, and AutoQuit on COM startup #region Server Lock, Object Counting, and AutoQuit on COM startup
@@ -131,9 +128,9 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
lock (lockObject) lock (LockObject)
{ {
return objsInUse; return _objsInUse;
} }
} }
} }
@@ -142,14 +139,14 @@ namespace ASCOM.Meade.net
public static int CountObject() public static int CountObject()
{ {
// Increment the global count of objects. // Increment the global count of objects.
return Interlocked.Increment(ref objsInUse); return Interlocked.Increment(ref _objsInUse);
} }
// This method performs a thread-safe decrementation the objects count. // This method performs a thread-safe decrementation the objects count.
public static int UncountObject() public static int UncountObject()
{ {
// Decrement the global count of objects. // Decrement the global count of objects.
return Interlocked.Decrement(ref objsInUse); return Interlocked.Decrement(ref _objsInUse);
} }
// Returns the current server lock count. // Returns the current server lock count.
@@ -157,9 +154,9 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
lock (lockObject) lock (LockObject)
{ {
return serverLocks; return _serverLocks;
} }
} }
} }
@@ -169,7 +166,7 @@ namespace ASCOM.Meade.net
public static int CountLock() public static int CountLock()
{ {
// Increment the global lock count of this server. // Increment the global lock count of this server.
return Interlocked.Increment(ref serverLocks); return Interlocked.Increment(ref _serverLocks);
} }
// This method performs a thread-safe decrementation the // This method performs a thread-safe decrementation the
@@ -177,7 +174,7 @@ namespace ASCOM.Meade.net
public static int UncountLock() public static int UncountLock()
{ {
// Decrement the global lock count of this server. // Decrement the global lock count of this server.
return Interlocked.Decrement(ref serverLocks); return Interlocked.Decrement(ref _serverLocks);
} }
// AttemptToTerminateServer() will check to see if the objects count and the server // AttemptToTerminateServer() will check to see if the objects count and the server
@@ -189,11 +186,11 @@ namespace ASCOM.Meade.net
// //
public static void ExitIf() public static void ExitIf()
{ {
lock (lockObject) lock (LockObject)
{ {
if ((ObjectsCount <= 0) && (ServerLockCount <= 0)) if ((ObjectsCount <= 0) && (ServerLockCount <= 0))
{ {
if (StartedByCOM) if (StartedByCom)
{ {
UIntPtr wParam = new UIntPtr(0); UIntPtr wParam = new UIntPtr(0);
IntPtr lParam = new IntPtr(0); IntPtr lParam = new IntPtr(0);
@@ -216,8 +213,8 @@ namespace ASCOM.Meade.net
// //
private static bool LoadComObjectAssemblies() private static bool LoadComObjectAssemblies()
{ {
s_ComObjectAssys = new ArrayList(); _sComObjectAssys = new ArrayList();
s_ComObjectTypes = new ArrayList(); _sComObjectTypes = new ArrayList();
// put everything into one folder, the same as the server. // put everything into one folder, the same as the server.
string assyPath = Assembly.GetEntryAssembly().Location; string assyPath = Assembly.GetEntryAssembly().Location;
@@ -246,8 +243,8 @@ namespace ASCOM.Meade.net
if (attrbutes.Length > 0) if (attrbutes.Length > 0)
{ {
//MessageBox.Show("Adding Type: " + type.Name + " " + type.FullName); //MessageBox.Show("Adding Type: " + type.Name + " " + type.FullName);
s_ComObjectTypes.Add(type); //PWGS - much simpler _sComObjectTypes.Add(type); //PWGS - much simpler
s_ComObjectAssys.Add(so); _sComObjectAssys.Add(so);
} }
} }
} }
@@ -342,10 +339,10 @@ namespace ASCOM.Meade.net
// //
// HKCR\APPID\appid // HKCR\APPID\appid
// //
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey("APPID\\" + s_appId)) using (RegistryKey key = Registry.ClassesRoot.CreateSubKey("APPID\\" + _sAppId))
{ {
key.SetValue(null, assyDescription); key.SetValue(null, assyDescription);
key.SetValue("AppID", s_appId); key.SetValue("AppID", _sAppId);
key.SetValue("AuthenticationLevel", 1, RegistryValueKind.DWord); key.SetValue("AuthenticationLevel", 1, RegistryValueKind.DWord);
} }
// //
@@ -354,7 +351,7 @@ namespace ASCOM.Meade.net
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(string.Format("APPID\\{0}", using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(string.Format("APPID\\{0}",
Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)))) Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1))))
{ {
key.SetValue("AppID", s_appId); key.SetValue("AppID", _sAppId);
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -370,7 +367,7 @@ namespace ASCOM.Meade.net
// //
// For each of the driver assemblies // For each of the driver assemblies
// //
foreach (Type type in s_ComObjectTypes) foreach (Type type in _sComObjectTypes)
{ {
bool bFail = false; bool bFail = false;
try try
@@ -386,7 +383,7 @@ namespace ASCOM.Meade.net
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(string.Format("CLSID\\{0}", clsid))) using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(string.Format("CLSID\\{0}", 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", s_appId); key.SetValue("AppId", _sAppId);
using (RegistryKey key2 = key.CreateSubKey("Implemented Categories")) using (RegistryKey key2 = key.CreateSubKey("Implemented Categories"))
{ {
key2.CreateSubKey("{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}"); key2.CreateSubKey("{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}");
@@ -420,10 +417,10 @@ namespace ASCOM.Meade.net
// Pull the display name from the ServedClassName attribute. // Pull the display name from the ServedClassName attribute.
attr = Attribute.GetCustomAttribute(type, typeof(ServedClassNameAttribute)); //PWGS Changed to search type for attribute rather than assembly attr = Attribute.GetCustomAttribute(type, typeof(ServedClassNameAttribute)); //PWGS Changed to search type for attribute rather than assembly
string chooserName = ((ServedClassNameAttribute)attr).DisplayName ?? "MultiServer"; string chooserName = ((ServedClassNameAttribute)attr).DisplayName ?? "MultiServer";
using (var P = new ASCOM.Utilities.Profile()) using (var p = new Profile())
{ {
P.DeviceType = deviceType; p.DeviceType = deviceType;
P.Register(progid, chooserName); p.Register(progid, chooserName);
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -456,14 +453,14 @@ namespace ASCOM.Meade.net
// //
// Local server's DCOM/AppID information // Local server's DCOM/AppID information
// //
Registry.ClassesRoot.DeleteSubKey(string.Format("APPID\\{0}", s_appId), false); Registry.ClassesRoot.DeleteSubKey(string.Format("APPID\\{0}", _sAppId), false);
Registry.ClassesRoot.DeleteSubKey(string.Format("APPID\\{0}", Registry.ClassesRoot.DeleteSubKey(string.Format("APPID\\{0}",
Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)), false); Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)), false);
// //
// For each of the driver assemblies // For each of the driver assemblies
// //
foreach (Type type in s_ComObjectTypes) foreach (Type type in _sComObjectTypes)
{ {
string clsid = Marshal.GenerateGuidForType(type).ToString("B"); string clsid = Marshal.GenerateGuidForType(type).ToString("B");
string progid = Marshal.GenerateProgIdForType(type); string progid = Marshal.GenerateProgIdForType(type);
@@ -490,10 +487,10 @@ namespace ASCOM.Meade.net
// //
// ASCOM // ASCOM
// //
using (var P = new ASCOM.Utilities.Profile()) using (var p = new Profile())
{ {
P.DeviceType = deviceType; p.DeviceType = deviceType;
P.Unregister(progid); p.Unregister(progid);
} }
} }
catch (Exception) { } catch (Exception) { }
@@ -509,11 +506,11 @@ namespace ASCOM.Meade.net
// //
private static bool RegisterClassFactories() private static bool RegisterClassFactories()
{ {
s_ClassFactories = new ArrayList(); _sClassFactories = new ArrayList();
foreach (Type type in s_ComObjectTypes) foreach (Type type in _sComObjectTypes)
{ {
ClassFactory factory = new ClassFactory(type); // Use default context & flags ClassFactory factory = new ClassFactory(type); // Use default context & flags
s_ClassFactories.Add(factory); _sClassFactories.Add(factory);
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,
@@ -528,7 +525,7 @@ namespace ASCOM.Meade.net
private static void RevokeClassFactories() private static void RevokeClassFactories()
{ {
ClassFactory.SuspendClassObjects(); // Prevent race conditions ClassFactory.SuspendClassObjects(); // Prevent race conditions
foreach (ClassFactory factory in s_ClassFactories) foreach (ClassFactory factory in _sClassFactories)
factory.RevokeClassObject(); factory.RevokeClassObject();
} }
#endregion #endregion
@@ -552,7 +549,7 @@ namespace ASCOM.Meade.net
switch (args[0].ToLower()) switch (args[0].ToLower())
{ {
case "-embedding": case "-embedding":
StartedByCOM = true; // Indicate COM started us StartedByCom = true; // Indicate COM started us
break; break;
case "-register": case "-register":
@@ -578,7 +575,7 @@ namespace ASCOM.Meade.net
} }
} }
else else
StartedByCOM = false; StartedByCom = false;
return bRet; return bRet;
} }
@@ -598,24 +595,24 @@ namespace ASCOM.Meade.net
if (!ProcessArguments(args)) return; // Register/Unregister if (!ProcessArguments(args)) return; // Register/Unregister
// Initialize critical member variables. // Initialize critical member variables.
objsInUse = 0; _objsInUse = 0;
serverLocks = 0; _serverLocks = 0;
MainThreadId = GetCurrentThreadId(); MainThreadId = GetCurrentThreadId();
Thread.CurrentThread.Name = "Main Thread"; Thread.CurrentThread.Name = "Main Thread";
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
s_MainForm = new frmMain(); _sMainForm = new FrmMain();
if (StartedByCOM) s_MainForm.WindowState = FormWindowState.Minimized; if (StartedByCom) _sMainForm.WindowState = FormWindowState.Minimized;
// Register the class factories of the served objects // Register the class factories of the served objects
RegisterClassFactories(); RegisterClassFactories();
// Start up the garbage collection thread. // Start up the garbage collection thread.
GarbageCollection GarbageCollector = new GarbageCollection(1000); GarbageCollection garbageCollector = new GarbageCollection(1000);
Thread GCThread = new Thread(new ThreadStart(GarbageCollector.GCWatch)); Thread gcThread = new Thread(new ThreadStart(garbageCollector.GcWatch));
GCThread.Name = "Garbage Collection Thread"; gcThread.Name = "Garbage Collection Thread";
GCThread.Start(); gcThread.Start();
// //
// Start the message loop. This serializes incoming calls to our // Start the message loop. This serializes incoming calls to our
@@ -623,7 +620,7 @@ namespace ASCOM.Meade.net
// //
try try
{ {
Application.Run(s_MainForm); Application.Run(_sMainForm);
} }
finally finally
{ {
@@ -633,8 +630,8 @@ namespace ASCOM.Meade.net
RevokeClassFactories(); RevokeClassFactories();
// Now stop the Garbage Collector thread. // Now stop the Garbage Collector thread.
GarbageCollector.StopThread(); garbageCollector.StopThread();
GarbageCollector.WaitForThreadToStop(); garbageCollector.WaitForThreadToStop();
} }
} }
#endregion #endregion
+1 -1
View File
@@ -8,7 +8,7 @@ namespace ASCOM.Meade.net.Localization
internal class LocalisationHelper internal class LocalisationHelper
{ {
private const string LocalizationNamespace = "LocalisationTest.Localization.Resources.Localization"; private const string LocalizationNamespace = "LocalisationTest.Localization.Resources.Localization";
ResourceManager _resourceManager; private readonly ResourceManager _resourceManager;
public LocalisationHelper() public LocalisationHelper()
{ {
+2 -3
View File
@@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
@@ -21,7 +20,7 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("0.7.0.0")] [assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("0.7.0.0")] [assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: ComVisibleAttribute(false)] [assembly: ComVisibleAttribute(false)]
-1
View File
@@ -1,4 +1,3 @@
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
+2 -7
View File
@@ -1,12 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using ASCOM.Utilities;
using ASCOM.Meade.net;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
{ {
@@ -29,12 +24,12 @@ namespace ASCOM.Meade.net
{ {
System.Diagnostics.Process.Start("http://ascom-standards.org/"); System.Diagnostics.Process.Start("http://ascom-standards.org/");
} }
catch (System.ComponentModel.Win32Exception noBrowser) catch (Win32Exception noBrowser)
{ {
if (noBrowser.ErrorCode == -2147467259) if (noBrowser.ErrorCode == -2147467259)
MessageBox.Show(noBrowser.Message); MessageBox.Show(noBrowser.Message);
} }
catch (System.Exception other) catch (Exception other)
{ {
MessageBox.Show(other.Message); MessageBox.Show(other.Message);
} }
+52 -54
View File
@@ -15,8 +15,6 @@
// //
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using ASCOM;
using ASCOM.Utilities; using ASCOM.Utilities;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
@@ -32,10 +30,10 @@ namespace ASCOM.Meade.net
public static class SharedResources public static class SharedResources
{ {
// object used for locking to prevent multiple drivers accessing common code at the same time // object used for locking to prevent multiple drivers accessing common code at the same time
private static readonly object lockObject = new object(); private static readonly object LockObject = new object();
// Shared serial port. This will allow multiple drivers to use one single serial port. // Shared serial port. This will allow multiple drivers to use one single serial port.
private static ASCOM.Utilities.Serial s_sharedSerial; // Shared serial port private static Serial _sSharedSerial; // Shared serial port
// //
// Public access to shared resources // Public access to shared resources
@@ -60,7 +58,7 @@ namespace ASCOM.Meade.net
/// <summary> /// <summary>
/// Shared serial port /// Shared serial port
/// </summary> /// </summary>
public static ASCOM.Utilities.Serial SharedSerial => s_sharedSerial ?? (s_sharedSerial = new ASCOM.Utilities.Serial()); public static Serial SharedSerial => _sSharedSerial ?? (_sSharedSerial = new Serial());
/// <summary> /// <summary>
/// number of connections to the shared serial port /// number of connections to the shared serial port
@@ -69,7 +67,7 @@ namespace ASCOM.Meade.net
public static void SendBlind(string message) public static void SendBlind(string message)
{ {
lock (lockObject) lock (LockObject)
{ {
SharedSerial.ClearBuffers(); SharedSerial.ClearBuffers();
SharedSerial.Transmit(message); SharedSerial.Transmit(message);
@@ -92,7 +90,7 @@ namespace ASCOM.Meade.net
/// <returns></returns> /// <returns></returns>
public static string SendString(string message) public static string SendString(string message)
{ {
lock (lockObject) lock (LockObject)
{ {
SharedSerial.ClearBuffers(); SharedSerial.ClearBuffers();
SharedSerial.Transmit(message); SharedSerial.Transmit(message);
@@ -102,7 +100,7 @@ namespace ASCOM.Meade.net
public static string SendChar(string message) public static string SendChar(string message)
{ {
lock (lockObject) lock (LockObject)
{ {
SharedSerial.ClearBuffers(); SharedSerial.ClearBuffers();
SharedSerial.Transmit(message); SharedSerial.Transmit(message);
@@ -112,7 +110,7 @@ namespace ASCOM.Meade.net
public static string ReadTerminated() public static string ReadTerminated()
{ {
lock (lockObject) lock (LockObject)
{ {
return SharedSerial.ReceiveTerminated("#"); return SharedSerial.ReceiveTerminated("#");
} }
@@ -130,7 +128,7 @@ namespace ASCOM.Meade.net
{ {
set set
{ {
lock (lockObject) lock (LockObject)
{ {
if (value) if (value)
{ {
@@ -148,47 +146,47 @@ namespace ASCOM.Meade.net
} }
} }
} }
get { return SharedSerial.Connected; } get => SharedSerial.Connected;
} }
#endregion #endregion
#region Profile #region Profile
internal static string driverID = "ASCOM.MeadeGeneric.Telescope"; private const string DriverId = "ASCOM.MeadeGeneric.Telescope";
// Constants used for Profile persistence // Constants used for Profile persistence
internal static string comPortProfileName = "COM Port"; private const string ComPortProfileName = "COM Port";
internal static string traceStateProfileName = "Trace Level"; private const string TraceStateProfileName = "Trace Level";
public static void WriteProfile(ProfileProperties profileProperties) public static void WriteProfile(ProfileProperties profileProperties)
{ {
lock (lockObject) lock (LockObject)
{ {
using (Profile driverProfile = new Profile()) using (Profile driverProfile = new Profile())
{ {
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);
} }
} }
} }
private static readonly string comPortDefault = "COM1"; private const string ComPortDefault = "COM1";
internal static string traceStateDefault = "false"; private const string TraceStateDefault = "false";
public static ProfileProperties ReadProfile() public static ProfileProperties ReadProfile()
{ {
lock (lockObject) lock (LockObject)
{ {
ProfileProperties profileProperties = new ProfileProperties(); ProfileProperties profileProperties = new ProfileProperties();
using (Profile driverProfile = new Profile()) using (Profile driverProfile = new Profile())
{ {
driverProfile.DeviceType = "Telescope"; driverProfile.DeviceType = "Telescope";
profileProperties.ComPort = profileProperties.ComPort =
driverProfile.GetValue(driverID, comPortProfileName, string.Empty, comPortDefault); driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault);
profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(driverID, profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId,
traceStateProfileName, string.Empty, traceStateDefault)); TraceStateProfileName, string.Empty, TraceStateDefault));
} }
return profileProperties; return profileProperties;
@@ -211,14 +209,14 @@ namespace ASCOM.Meade.net
var profileProperties = ReadProfile(); var profileProperties = ReadProfile();
using (SetupDialogForm F = new SetupDialogForm()) using (SetupDialogForm f = new SetupDialogForm())
{ {
F.SetProfile(profileProperties); f.SetProfile(profileProperties);
var result = F.ShowDialog(); var result = f.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK) if (result == System.Windows.Forms.DialogResult.OK)
{ {
profileProperties = F.GetProfile(); profileProperties = f.GetProfile();
WriteProfile(profileProperties); // Persist device configuration values to the ASCOM Profile store WriteProfile(profileProperties); // Persist device configuration values to the ASCOM Profile store
} }
@@ -246,7 +244,7 @@ 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 Dictionary<string, DeviceHardware> connectedDevices = new Dictionary<string, DeviceHardware>(); private static readonly Dictionary<string, DeviceHardware> _connectedDevices = new Dictionary<string, DeviceHardware>();
/// <summary> /// <summary>
/// This is called in the driver Connect(true) property, /// This is called in the driver Connect(true) property,
@@ -255,26 +253,26 @@ namespace ASCOM.Meade.net
/// <param name="deviceId"></param> /// <param name="deviceId"></param>
public static void Connect(string deviceId) public static void Connect(string deviceId)
{ {
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 (deviceId == "Serial") if (deviceId == "Serial")
{ {
if (connectedDevices[deviceId].count == 1) if (_connectedDevices[deviceId].Count == 1)
{ {
var profileProperties = ReadProfile(); var profileProperties = ReadProfile();
SharedResources.SharedSerial.PortName = profileProperties.ComPort; SharedSerial.PortName = profileProperties.ComPort;
SharedResources.SharedSerial.DTREnable = false; SharedSerial.DTREnable = false;
SharedResources.SharedSerial.RTSEnable = false; SharedSerial.RTSEnable = false;
SharedResources.SharedSerial.DataBits = 8; SharedSerial.DataBits = 8;
SharedResources.SharedSerial.StopBits = SerialStopBits.One; SharedSerial.StopBits = SerialStopBits.One;
SharedResources.SharedSerial.Parity = SerialParity.None; SharedSerial.Parity = SerialParity.None;
SharedResources.SharedSerial.Speed = SerialSpeed.ps9600; SharedSerial.Speed = SerialSpeed.ps9600;
SharedResources.SharedSerial.Handshake = SerialHandshake.None; SharedSerial.Handshake = SerialHandshake.None;
SharedResources.SharedSerial.Connected = true; SharedSerial.Connected = true;
ProductName = SendString(":GVP#"); ProductName = SendString(":GVP#");
FirmwareVersion = SendString(":GVN#"); FirmwareVersion = SendString(":GVN#");
@@ -285,17 +283,17 @@ namespace ASCOM.Meade.net
public static void Disconnect(string deviceId) public static void Disconnect(string deviceId)
{ {
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")
{ {
SharedResources.SharedSerial.Connected = false; SharedSerial.Connected = false;
} }
} }
} }
@@ -304,8 +302,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;
} }
@@ -314,7 +312,7 @@ namespace ASCOM.Meade.net
public static void Lock(Action action) public static void Lock(Action action)
{ {
lock (lockObject) lock (LockObject)
{ {
action(); action();
} }
@@ -322,7 +320,7 @@ namespace ASCOM.Meade.net
public static T Lock<T>(Func<T> func) public static T Lock<T>(Func<T> func)
{ {
lock (lockObject) lock (LockObject)
{ {
return func(); return func();
} }
@@ -336,7 +334,7 @@ namespace ASCOM.Meade.net
{ {
private int _count; private int _count;
internal int count internal int Count
{ {
set => _count = value; set => _count = value;
get => _count; get => _count;
@@ -344,7 +342,7 @@ namespace ASCOM.Meade.net
internal DeviceHardware() internal DeviceHardware()
{ {
count = 0; Count = 0;
} }
} }
+6 -9
View File
@@ -1,16 +1,13 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ASCOM.Meade.net.Wrapper namespace ASCOM.Meade.net.Wrapper
{ {
public interface ISharedResourcesWrapper public interface ISharedResourcesWrapper
{ {
string AUTOSTAR497 { get; } string Autostar497 { get; }
string AUTOSTAR497_31EE { get; } string Autostar49731Ee { get; }
string AUTOSTAR497_43EG { get;} string Autostar49743Eg { get;}
void Connect(string deviceId); void Connect(string deviceId);
void Disconnect(string deviceId); void Disconnect(string deviceId);
@@ -37,10 +34,10 @@ namespace ASCOM.Meade.net.Wrapper
{ {
#region AutostarProducts #region AutostarProducts
public string AUTOSTAR497 => "Autostar"; public string Autostar497 => "Autostar";
public string AUTOSTAR497_31EE => "31Ee"; public string Autostar49731Ee => "31Ee";
public string AUTOSTAR497_43EG => "43Eg"; public string Autostar49743Eg => "43Eg";
#endregion #endregion
+2 -2
View File
@@ -2,7 +2,7 @@ using System;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
{ {
partial class frmMain partial class FrmMain
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -48,7 +48,7 @@ namespace ASCOM.Meade.net
this.ClientSize = new System.Drawing.Size(233, 52); this.ClientSize = new System.Drawing.Size(233, 52);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "frmMain"; this.Name = "FrmMain";
this.Text = "Meade.net Driver Server"; this.Text = "Meade.net Driver Server";
this.ResumeLayout(false); this.ResumeLayout(false);
+2 -7
View File
@@ -1,17 +1,12 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
{ {
public partial class frmMain : Form public partial class FrmMain : Form
{ {
delegate void SetTextCallback(string text); delegate void SetTextCallback(string text);
public frmMain() public FrmMain()
{ {
InitializeComponent(); InitializeComponent();
} }
+3 -6
View File
@@ -9,11 +9,8 @@
#define UseChooser #define UseChooser
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ASCOM namespace ASCOM.Meade.net
{ {
class Program class Program
{ {
@@ -22,11 +19,11 @@ namespace ASCOM
// Uncomment the code that's required // Uncomment the code that's required
#if UseChooser #if UseChooser
// choose the device // choose the device
string id = ASCOM.DriverAccess.Telescope.Choose("ASCOM.MeadeGeneric.Telescope"); string id = DriverAccess.Telescope.Choose("ASCOM.MeadeGeneric.Telescope");
if (string.IsNullOrEmpty(id)) if (string.IsNullOrEmpty(id))
return; return;
// create this device // create this device
ASCOM.DriverAccess.Telescope device = new ASCOM.DriverAccess.Telescope(id); DriverAccess.Telescope device = new DriverAccess.Telescope(id);
#else #else
// this can be replaced by this code, it avoids the chooser and creates the driver class directly. // this can be replaced by this code, it avoids the chooser and creates the driver class directly.
ASCOM.DriverAccess.Telescope device = new ASCOM.DriverAccess.Telescope("ASCOM.Meade.net.Telescope"); ASCOM.DriverAccess.Telescope device = new ASCOM.DriverAccess.Telescope("ASCOM.Meade.net.Telescope");
@@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
@@ -32,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("0.7.0.0")] [assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("0.7.0.0")] [assembly: AssemblyFileVersion("0.0.0.0")]
+6
View File
@@ -32,5 +32,11 @@
<include name="**/*" /> <include name="**/*" />
</fileset> </fileset>
</copy> </copy>
<foreach item="File" in="${build.output.directory}" property="fileName">
<if test="${string::to-lower(path::get-extension(fileName)) == '.msi'}">
<move file="${fileName}" tofile="${path::combine(path::get-directory-name(fileName), path::get-file-name-without-extension(fileName) + '.' + environment::get-variable('BUILD_NUMBER') + '.msi')}" />
</if>
</foreach>
</target> </target>
</project> </project>