Compare commits

..

9 Commits

11 changed files with 336 additions and 109 deletions
@@ -181,7 +181,7 @@ namespace Meade.net.Focuser.UnitTests
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware); _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware);
_focuser.Connected = true; _focuser.Connected = true;
_sharedResourcesWrapperMock.Verify(x => x.Connect("Serial", It.IsAny<string>()), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.Connect("Serial", It.IsAny<string>(), It.IsAny<ITraceLogger>()), Times.Once);
} }
@@ -189,20 +189,20 @@ namespace Meade.net.Focuser.UnitTests
public void Connected_Set_SettingTrueWhenTrue_ThenDoesNothing() public void Connected_Set_SettingTrueWhenTrue_ThenDoesNothing()
{ {
ConnectFocuser(); ConnectFocuser();
_sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>()), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<ITraceLogger>()), Times.Once);
//act //act
_focuser.Connected = true; _focuser.Connected = true;
//assert //assert
_sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>()), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<ITraceLogger>()), Times.Once);
} }
[Test] [Test]
public void Connected_Set_SettingFalseWhenTrue_ThenDisconnects() public void Connected_Set_SettingFalseWhenTrue_ThenDisconnects()
{ {
ConnectFocuser(); ConnectFocuser();
_sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>()), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<ITraceLogger>()), Times.Once);
//act //act
_focuser.Connected = false; _focuser.Connected = false;
@@ -34,7 +34,8 @@ namespace Meade.net.Telescope.UnitTests
TraceLogger = false, TraceLogger = false,
ComPort = "TestCom1", ComPort = "TestCom1",
GuideRateArcSecondsPerSecond = 1.23, GuideRateArcSecondsPerSecond = 1.23,
Precision = "Unchanged" Precision = "Unchanged",
GuidingStyle = "Auto"
}; };
_utilMock = new Mock<IUtil>(); _utilMock = new Mock<IUtil>();
@@ -55,7 +56,7 @@ namespace Meade.net.Telescope.UnitTests
SameDevice = 1 SameDevice = 1
}; };
_sharedResourcesWrapperMock.Setup(x => x.Connect("Serial", It.IsAny<string>())).Returns( () => _connectionInfo ); _sharedResourcesWrapperMock.Setup(x => x.Connect("Serial", It.IsAny<string>(), It.IsAny<ITraceLogger>())).Returns( () => _connectionInfo );
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(_profileProperties); _sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(_profileProperties);
@@ -383,7 +384,7 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware); _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware);
_telescope.Connected = true; _telescope.Connected = true;
_sharedResourcesWrapperMock.Verify( x => x.Connect("Serial", It.IsAny<string>()), Times.Once); _sharedResourcesWrapperMock.Verify( x => x.Connect("Serial", It.IsAny<string>(), It.IsAny<ITraceLogger>()), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendString("#:GZ#"), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendString("#:GZ#"), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($"#:Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"),Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendBlind($"#:Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"),Times.Once);
@@ -399,7 +400,7 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware); _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware);
_telescope.Connected = true; _telescope.Connected = true;
_sharedResourcesWrapperMock.Verify(x => x.Connect("Serial", It.IsAny<string>()), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.Connect("Serial", It.IsAny<string>(), It.IsAny<ITraceLogger>()), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendString("#:GZ#"), Times.Never); _sharedResourcesWrapperMock.Verify(x => x.SendString("#:GZ#"), Times.Never);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($"#:Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"), Times.Never); _sharedResourcesWrapperMock.Verify(x => x.SendBlind($"#:Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"), Times.Never);
} }
@@ -409,20 +410,20 @@ namespace Meade.net.Telescope.UnitTests
public void Connected_Set_SettingTrueWhenTrue_ThenDoesNothing() public void Connected_Set_SettingTrueWhenTrue_ThenDoesNothing()
{ {
ConnectTelescope(); ConnectTelescope();
_sharedResourcesWrapperMock.Verify( x => x.Connect(It.IsAny<string>(), It.IsAny<string>()),Times.Once); _sharedResourcesWrapperMock.Verify( x => x.Connect(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<ITraceLogger>()),Times.Once);
//act //act
_telescope.Connected = true; _telescope.Connected = true;
//assert //assert
_sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>()), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<ITraceLogger>()), Times.Once);
} }
[Test] [Test]
public void Connected_Set_SettingFalseWhenTrue_ThenDisconnects() public void Connected_Set_SettingFalseWhenTrue_ThenDisconnects()
{ {
ConnectTelescope(); ConnectTelescope();
_sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>()), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<ITraceLogger>()), Times.Once);
//act //act
_telescope.Connected = false; _telescope.Connected = false;
@@ -446,17 +447,24 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Verify(x => x.Disconnect(It.IsAny<string>(), It.IsAny<string>()), Times.Once()); _sharedResourcesWrapperMock.Verify(x => x.Disconnect(It.IsAny<string>(), It.IsAny<string>()), Times.Once());
} }
[TestCase("Autostar", "30Ab", false)] [TestCase("Auto", "Autostar", "30Ab", false)]
[TestCase("Autostar", "31Ee", true)] [TestCase("Auto","Autostar", "31Ee", true)]
[TestCase("Autostar", "43Eg", true)] [TestCase("Auto","Autostar", "43Eg", true)]
[TestCase("Autostar II", "", false)] [TestCase("Auto","Autostar II", "", false)]
[TestCase("LX2001", "", true)] [TestCase("Auto","LX2001", "", true)]
[TestCase(":GVP", "", false)] //LX200 Classic [TestCase("Auto",":GVP", "", false)] //LX200 Classic
public void IsNewPulseGuidingSupported_ThenIsSupported_ThenReturnsTrue(string productName, string firmware, bool isSupported) [TestCase("Guide Rate Slew", "LX2001", "", false)] //force old style
[TestCase("Pulse Guiding", ":GVP", "", true)] //force new style
public void IsNewPulseGuidingSupported_ThenIsSupported_ThenReturnsTrue(string guidingStyle, string productName, string firmware, bool isSupported)
{ {
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName); _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware); _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware);
_profileProperties.GuidingStyle = guidingStyle;
_telescope.Connected = true;
var result = _telescope.IsNewPulseGuidingSupported(); var result = _telescope.IsNewPulseGuidingSupported();
Assert.That(result, Is.EqualTo(isSupported)); Assert.That(result, Is.EqualTo(isSupported));
@@ -1322,6 +1330,63 @@ namespace Meade.net.Telescope.UnitTests
_utilMock.Verify( x => x.WaitForMilliseconds(duration), Times.Once); _utilMock.Verify( x => x.WaitForMilliseconds(duration), Times.Once);
} }
[TestCase(GuideDirections.guideEast)]
[TestCase(GuideDirections.guideWest)]
[TestCase(GuideDirections.guideNorth)]
[TestCase(GuideDirections.guideSouth)]
public void PulseGuide_WhenSlewingAndPulseGuideAttempted_ThenThrowsExpectedException(GuideDirections direction)
{
_sharedResourcesWrapperMock.Setup(x => x.SendString("#:D#")).Returns("|");
var duration = 0;
ConnectTelescope();
var exception = Assert.Throws<InvalidOperationException>(() => { _telescope.PulseGuide(direction, duration); });
Assert.That(exception.Message, Is.EqualTo("Unable to PulseGuide whilst slewing to target."));
}
[TestCase(GuideDirections.guideEast, TelescopeAxes.axisPrimary)]
[TestCase(GuideDirections.guideWest, TelescopeAxes.axisPrimary)]
[TestCase(GuideDirections.guideNorth, TelescopeAxes.axisSecondary)]
[TestCase(GuideDirections.guideSouth, TelescopeAxes.axisSecondary)]
public void PulseGuide_WhenMovingAxisAndPulseGuideAttempted_ThenThrowsExpectedException(GuideDirections direction, TelescopeAxes axes)
{
_sharedResourcesWrapperMock.Setup(x => x.SendString("#:D#")).Returns("");
var duration = 0;
ConnectTelescope();
_telescope.MoveAxis(axes, 1);
var exception = Assert.Throws<InvalidOperationException>(() => { _telescope.PulseGuide(direction, duration); });
Assert.That(exception.Message, Is.EqualTo("Unable to PulseGuide while moving same axis."));
}
[TestCase(GuideDirections.guideEast)]
[TestCase(GuideDirections.guideWest)]
[TestCase(GuideDirections.guideNorth)]
[TestCase(GuideDirections.guideSouth)]
public void PulseGuide_WhenConnectedAndNewerPulseGuidingNotAvailable_ThenIsSlewingRespondsFalse(GuideDirections direction)
{
var duration = 0;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee);
var isSlewing = true;
_utilMock.Setup(x => x.WaitForMilliseconds(duration)).Callback(() =>
{
isSlewing = _telescope.Slewing;
});
_telescope.Connected = true;
_telescope.PulseGuide(direction, duration);
Assert.That(isSlewing, Is.False);
}
[TestCase(GuideDirections.guideEast)] [TestCase(GuideDirections.guideEast)]
[TestCase(GuideDirections.guideWest)] [TestCase(GuideDirections.guideWest)]
[TestCase(GuideDirections.guideNorth)] [TestCase(GuideDirections.guideNorth)]
+43 -2
View File
@@ -134,6 +134,7 @@ namespace ASCOM.Meade.net
} }
private double _guideRate; private double _guideRate;
private bool _isGuiding;
private void Initialise() private void Initialise()
{ {
@@ -405,7 +406,7 @@ namespace ASCOM.Meade.net
ReadProfile(); ReadProfile();
LogMessage("Connected Set", "Connecting to port {0}", _comPort); LogMessage("Connected Set", "Connecting to port {0}", _comPort);
var connectionInfo = _sharedResourcesWrapper.Connect("Serial", DriverId); var connectionInfo = _sharedResourcesWrapper.Connect("Serial", DriverId, _tl);
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}");
@@ -480,6 +481,14 @@ namespace ASCOM.Meade.net
public bool IsNewPulseGuidingSupported() public bool IsNewPulseGuidingSupported()
{ {
switch (_guidingStyle)
{
case "guide rate slew":
return false;
case "pulse guiding":
return true;
default:
if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497) if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497)
{ {
return FirmwareIsGreaterThan(TelescopeList.Autostar497_31Ee); return FirmwareIsGreaterThan(TelescopeList.Autostar497_31Ee);
@@ -492,6 +501,7 @@ namespace ASCOM.Meade.net
return false; return false;
} }
}
private bool IsLongFormatSupported() private bool IsLongFormatSupported()
{ {
@@ -1415,6 +1425,15 @@ namespace ASCOM.Meade.net
LogMessage("PulseGuide", $"pulse guide direction {direction} duration {duration}"); LogMessage("PulseGuide", $"pulse guide direction {direction} duration {duration}");
CheckConnected("PulseGuide"); CheckConnected("PulseGuide");
if (IsSlewingToTarget())
throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target.");
if (_movingPrimary && (direction == GuideDirections.guideEast || direction == GuideDirections.guideWest))
throw new InvalidOperationException("Unable to PulseGuide while moving same axis.");
if (_movingSecondary && (direction == GuideDirections.guideNorth || direction == GuideDirections.guideSouth))
throw new InvalidOperationException("Unable to PulseGuide while moving same axis.");
var coordinatesBeforeMove = GetTelescopeRaAndDec(); var coordinatesBeforeMove = GetTelescopeRaAndDec();
if (_userNewerPulseGuiding && duration < 10000) if (_userNewerPulseGuiding && duration < 10000)
@@ -1449,6 +1468,9 @@ namespace ASCOM.Meade.net
_utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed _utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed
} }
else else
{
_isGuiding = true;
try
{ {
switch (direction) switch (direction)
{ {
@@ -1474,6 +1496,11 @@ namespace ASCOM.Meade.net
break; break;
} }
} }
finally
{
_isGuiding = false;
}
}
var coordinatesAfterMove = GetTelescopeRaAndDec(); var coordinatesAfterMove = GetTelescopeRaAndDec();
@@ -1915,6 +1942,9 @@ namespace ASCOM.Meade.net
private bool MovingAxis() private bool MovingAxis()
{ {
if (_isGuiding)
return false;
return _movingPrimary || _movingSecondary; return _movingPrimary || _movingSecondary;
} }
@@ -1928,8 +1958,17 @@ namespace ASCOM.Meade.net
if (MovingAxis()) if (MovingAxis())
return true; return true;
return IsSlewingToTarget();
}
}
private bool IsSlewingToTarget()
{
CheckConnected("Slewing Get"); CheckConnected("Slewing Get");
if (_isGuiding)
return false;
var result = _sharedResourcesWrapper.SendString("#:D#"); var result = _sharedResourcesWrapper.SendString("#:D#");
//:D# Requests a string of bars indicating the distance to the current target location. //:D# Requests a string of bars indicating the distance to the current target location.
//Returns: //Returns:
@@ -1946,7 +1985,6 @@ namespace ASCOM.Meade.net
LogMessage("Slewing Get", $"Result = {isSlewing}"); LogMessage("Slewing Get", $"Result = {isSlewing}");
return isSlewing; return isSlewing;
} }
}
public void SyncToAltAz(double azimuth, double altitude) public void SyncToAltAz(double azimuth, double altitude)
{ {
@@ -2102,6 +2140,7 @@ namespace ASCOM.Meade.net
private DriveRates _trackingRate = DriveRates.driveSidereal; private DriveRates _trackingRate = DriveRates.driveSidereal;
private string _precision; private string _precision;
private string _guidingStyle;
public DriveRates TrackingRate public DriveRates TrackingRate
{ {
@@ -2398,11 +2437,13 @@ namespace ASCOM.Meade.net
_comPort = profileProperties.ComPort; _comPort = profileProperties.ComPort;
_guideRate = profileProperties.GuideRateArcSecondsPerSecond; _guideRate = profileProperties.GuideRateArcSecondsPerSecond;
_precision = profileProperties.Precision; _precision = profileProperties.Precision;
_guidingStyle = profileProperties.GuidingStyle.ToLower();
LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}");
LogMessage("ReadProfile", $"Com Port: {_comPort}"); LogMessage("ReadProfile", $"Com Port: {_comPort}");
LogMessage("ReadProfile", $"Guide Rate: {_guideRate}"); LogMessage("ReadProfile", $"Guide Rate: {_guideRate}");
LogMessage("ReadProfile", $"Precision: {_precision}"); LogMessage("ReadProfile", $"Precision: {_precision}");
LogMessage("ReadProfile", $"Guiding Style: {_guidingStyle}");
} }
private void WriteProfile() private void WriteProfile()
@@ -13,6 +13,7 @@ namespace Meade.net.UnitTests
public class SharedResourcesUnitTests public class SharedResourcesUnitTests
{ {
private Mock<ISerial> _serialMock; private Mock<ISerial> _serialMock;
private Mock<ITraceLogger> _traceLoggerMock;
[SetUp] [SetUp]
public void Setup() public void Setup()
@@ -20,6 +21,8 @@ namespace Meade.net.UnitTests
_serialMock = new Mock<ISerial>(); _serialMock = new Mock<ISerial>();
_serialMock.SetupAllProperties(); _serialMock.SetupAllProperties();
_traceLoggerMock = new Mock<ITraceLogger>();
SharedResources.SharedSerial = _serialMock.Object; SharedResources.SharedSerial = _serialMock.Object;
} }
@@ -123,6 +126,7 @@ namespace Meade.net.UnitTests
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "COM Port", profileProperties.ComPort), Times.Once); profileWrapperMock.Verify(x => x.WriteValue(DriverId, "COM Port", profileProperties.ComPort), Times.Once);
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Guide Rate Arc Seconds Per Second", profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture)), Times.Once); profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Guide Rate Arc Seconds Per Second", profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture)), Times.Once);
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Precision", profileProperties.Precision), Times.Once); profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Precision", profileProperties.Precision), Times.Once);
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Guiding Style", profileProperties.GuidingStyle), Times.Once);
} }
[Test] [Test]
@@ -134,6 +138,7 @@ namespace Meade.net.UnitTests
string TraceStateDefault = "false"; string TraceStateDefault = "false";
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
string PrecisionDefault = "Unchanged"; string PrecisionDefault = "Unchanged";
string GuidingStyleDefault = "Auto";
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>(); Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
profileWrapperMock.SetupAllProperties(); profileWrapperMock.SetupAllProperties();
@@ -147,6 +152,8 @@ namespace Meade.net.UnitTests
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault); GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
.Returns(PrecisionDefault); .Returns(PrecisionDefault);
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Guiding Style", string.Empty, GuidingStyleDefault))
.Returns(GuidingStyleDefault);
IProfileWrapper profeWrapper = profileWrapperMock.Object; IProfileWrapper profeWrapper = profileWrapperMock.Object;
@@ -163,13 +170,14 @@ namespace Meade.net.UnitTests
Is.EqualTo(double.Parse(GuideRateProfileNameDefault))); Is.EqualTo(double.Parse(GuideRateProfileNameDefault)));
Assert.That(profileProperties.TraceLogger, Is.EqualTo(bool.Parse(TraceStateDefault))); Assert.That(profileProperties.TraceLogger, Is.EqualTo(bool.Parse(TraceStateDefault)));
Assert.That(profileProperties.Precision, Is.EqualTo(PrecisionDefault)); Assert.That(profileProperties.Precision, Is.EqualTo(PrecisionDefault));
Assert.That(profileProperties.GuidingStyle, Is.EqualTo(GuidingStyleDefault));
} }
[TestCase("TCP")] [TestCase("TCP")]
[TestCase("Carrier Pigeon")] [TestCase("Carrier Pigeon")]
public void Connect_WhenDeviceIdIsNotSerial_ThenThrowsException( string deviceId) public void Connect_WhenDeviceIdIsNotSerial_ThenThrowsException( string deviceId)
{ {
var result = Assert.Throws<ArgumentException>( () => { SharedResources.Connect(deviceId, string.Empty); } ); var result = Assert.Throws<ArgumentException>( () => { SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object); } );
Assert.That( result.Message, Is.EqualTo($"deviceId {deviceId} not currently supported") ); Assert.That( result.Message, Is.EqualTo($"deviceId {deviceId} not currently supported") );
} }
@@ -209,7 +217,7 @@ namespace Meade.net.UnitTests
_serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { serialPortReturn = ":GVP#"; }); _serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { serialPortReturn = ":GVP#"; });
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns( () => serialPortReturn); _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns( () => serialPortReturn);
var result = Assert.Throws<Exception>(() => { SharedResources.Connect(deviceId, string.Empty); }); var result = Assert.Throws<Exception>(() => { SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object); });
Assert.That(result.Message, Is.EqualTo("Serial port is looping back data, something is wrong with the hardware.")); Assert.That(result.Message, Is.EqualTo("Serial port is looping back data, something is wrong with the hardware."));
} }
@@ -246,13 +254,19 @@ namespace Meade.net.UnitTests
_serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { }); _serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { });
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => throw new Exception("Testerror")); _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => throw new Exception("Testerror"));
var connectionResult = SharedResources.Connect(deviceId, string.Empty); var connectionResult = SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object);
try
{
Assert.That(connectionResult.SameDevice, Is.EqualTo(1)); Assert.That(connectionResult.SameDevice, Is.EqualTo(1));
Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.LX200CLASSIC)); Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.LX200CLASSIC));
}
finally
{
SharedResources.Disconnect(deviceId, String.Empty); SharedResources.Disconnect(deviceId, String.Empty);
} }
}
[Test] [Test]
public void Connect_WhenDeviceIdIsSerialButGVPIsAutostar_ThenConnectsAndSetsProductToAutostarAndFirmware() public void Connect_WhenDeviceIdIsSerialButGVPIsAutostar_ThenConnectsAndSetsProductToAutostarAndFirmware()
@@ -290,13 +304,17 @@ namespace Meade.net.UnitTests
_serialMock.Setup(x => x.Transmit(":GVN#")).Callback(() => { serialPortReturn = TelescopeList.Autostar497_43Eg; }); _serialMock.Setup(x => x.Transmit(":GVN#")).Callback(() => { serialPortReturn = TelescopeList.Autostar497_43Eg; });
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn); _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn);
var connectionResult = SharedResources.Connect(deviceId, string.Empty); var connectionResult = SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object);
try
{
Assert.That(connectionResult.SameDevice, Is.EqualTo(1)); Assert.That(connectionResult.SameDevice, Is.EqualTo(1));
Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.Autostar497)); Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.Autostar497));
Assert.That(SharedResources.FirmwareVersion, Is.EqualTo(TelescopeList.Autostar497_43Eg)); Assert.That(SharedResources.FirmwareVersion, Is.EqualTo(TelescopeList.Autostar497_43Eg));
}
finally
{
SharedResources.Disconnect(deviceId, String.Empty); SharedResources.Disconnect(deviceId, String.Empty);
} }
} }
}
} }
+1 -1
View File
@@ -187,7 +187,7 @@ namespace ASCOM.Meade.net
try try
{ {
ReadProfile(); ReadProfile();
_sharedResourcesWrapper.Connect("Serial", DriverId); _sharedResourcesWrapper.Connect("Serial", DriverId, _tl);
try try
{ {
IsConnected = true; IsConnected = true;
+1
View File
@@ -7,5 +7,6 @@ namespace ASCOM.Meade.net
public bool TraceLogger { get; set; } public bool TraceLogger { get; set; }
public double GuideRateArcSecondsPerSecond { get; set; } public double GuideRateArcSecondsPerSecond { get; set; }
public string Precision { get; set; } public string Precision { get; set; }
public string GuidingStyle { get; set; }
} }
} }
+12 -1
View File
@@ -71,6 +71,16 @@ namespace ASCOM.Meade.net
{ {
cboPrecision.SelectedItem = "Unchanged"; cboPrecision.SelectedItem = "Unchanged";
} }
try
{
cboGuidingStyle.SelectedItem = profileProperties.GuidingStyle;
}
catch (Exception)
{
cboGuidingStyle.SelectedItem = "Auto";
}
} }
public ProfileProperties GetProfile() public ProfileProperties GetProfile()
@@ -80,7 +90,8 @@ namespace ASCOM.Meade.net
TraceLogger = chkTrace.Checked, TraceLogger = chkTrace.Checked,
ComPort = comboBoxComPort.SelectedItem.ToString(), ComPort = comboBoxComPort.SelectedItem.ToString(),
GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()), GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()),
Precision = cboPrecision.SelectedItem.ToString() Precision = cboPrecision.SelectedItem.ToString(),
GuidingStyle = cboGuidingStyle.SelectedItem.ToString()
}; };
return profileProperties; return profileProperties;
+22
View File
@@ -45,6 +45,8 @@ namespace ASCOM.Meade.net
this.lblPercentOfSiderealRate = new System.Windows.Forms.Label(); this.lblPercentOfSiderealRate = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label();
this.cboPrecision = new System.Windows.Forms.ComboBox(); this.cboPrecision = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.cboGuidingStyle = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@@ -133,10 +135,28 @@ namespace ASCOM.Meade.net
resources.ApplyResources(this.cboPrecision, "cboPrecision"); resources.ApplyResources(this.cboPrecision, "cboPrecision");
this.cboPrecision.Name = "cboPrecision"; this.cboPrecision.Name = "cboPrecision";
// //
// label6
//
resources.ApplyResources(this.label6, "label6");
this.label6.Name = "label6";
//
// cboGuidingStyle
//
this.cboGuidingStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboGuidingStyle.FormattingEnabled = true;
this.cboGuidingStyle.Items.AddRange(new object[] {
resources.GetString("cboGuidingStyle.Items"),
resources.GetString("cboGuidingStyle.Items1"),
resources.GetString("cboGuidingStyle.Items2")});
resources.ApplyResources(this.cboGuidingStyle, "cboGuidingStyle");
this.cboGuidingStyle.Name = "cboGuidingStyle";
//
// SetupDialogForm // SetupDialogForm
// //
resources.ApplyResources(this, "$this"); resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.cboGuidingStyle);
this.Controls.Add(this.label6);
this.Controls.Add(this.cboPrecision); this.Controls.Add(this.cboPrecision);
this.Controls.Add(this.label5); this.Controls.Add(this.label5);
this.Controls.Add(this.lblPercentOfSiderealRate); this.Controls.Add(this.lblPercentOfSiderealRate);
@@ -178,5 +198,7 @@ namespace ASCOM.Meade.net
private Label lblPercentOfSiderealRate; private Label lblPercentOfSiderealRate;
private Label label5; private Label label5;
private ComboBox cboPrecision; private ComboBox cboPrecision;
private Label label6;
private ComboBox cboGuidingStyle;
} }
} }
+81 -21
View File
@@ -123,7 +123,7 @@
</data> </data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="cmdOK.Location" type="System.Drawing.Point, System.Drawing"> <data name="cmdOK.Location" type="System.Drawing.Point, System.Drawing">
<value>281, 225</value> <value>281, 250</value>
</data> </data>
<data name="cmdOK.Size" type="System.Drawing.Size, System.Drawing"> <data name="cmdOK.Size" type="System.Drawing.Size, System.Drawing">
<value>59, 24</value> <value>59, 24</value>
@@ -145,13 +145,13 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;cmdOK.ZOrder" xml:space="preserve"> <data name="&gt;&gt;cmdOK.ZOrder" xml:space="preserve">
<value>12</value> <value>14</value>
</data> </data>
<data name="cmdCancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms"> <data name="cmdCancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value> <value>Bottom, Right</value>
</data> </data>
<data name="cmdCancel.Location" type="System.Drawing.Point, System.Drawing"> <data name="cmdCancel.Location" type="System.Drawing.Point, System.Drawing">
<value>281, 255</value> <value>281, 280</value>
</data> </data>
<data name="cmdCancel.Size" type="System.Drawing.Size, System.Drawing"> <data name="cmdCancel.Size" type="System.Drawing.Size, System.Drawing">
<value>59, 25</value> <value>59, 25</value>
@@ -172,7 +172,7 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;cmdCancel.ZOrder" xml:space="preserve"> <data name="&gt;&gt;cmdCancel.ZOrder" xml:space="preserve">
<value>11</value> <value>13</value>
</data> </data>
<data name="label1.Location" type="System.Drawing.Point, System.Drawing"> <data name="label1.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 9</value> <value>12, 9</value>
@@ -196,7 +196,7 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve"> <data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>10</value> <value>12</value>
</data> </data>
<data name="picASCOM.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms"> <data name="picASCOM.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value> <value>Top, Right</value>
@@ -223,7 +223,7 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;picASCOM.ZOrder" xml:space="preserve"> <data name="&gt;&gt;picASCOM.ZOrder" xml:space="preserve">
<value>9</value> <value>11</value>
</data> </data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib"> <data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
@@ -250,13 +250,13 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve"> <data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>8</value> <value>10</value>
</data> </data>
<data name="chkTrace.AutoSize" type="System.Boolean, mscorlib"> <data name="chkTrace.AutoSize" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
</data> </data>
<data name="chkTrace.Location" type="System.Drawing.Point, System.Drawing"> <data name="chkTrace.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 136</value> <value>86, 136</value>
</data> </data>
<data name="chkTrace.Size" type="System.Drawing.Size, System.Drawing"> <data name="chkTrace.Size" type="System.Drawing.Size, System.Drawing">
<value>69, 17</value> <value>69, 17</value>
@@ -277,10 +277,10 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;chkTrace.ZOrder" xml:space="preserve"> <data name="&gt;&gt;chkTrace.ZOrder" xml:space="preserve">
<value>7</value> <value>9</value>
</data> </data>
<data name="comboBoxComPort.Location" type="System.Drawing.Point, System.Drawing"> <data name="comboBoxComPort.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 87</value> <value>86, 87</value>
</data> </data>
<data name="comboBoxComPort.Size" type="System.Drawing.Size, System.Drawing"> <data name="comboBoxComPort.Size" type="System.Drawing.Size, System.Drawing">
<value>90, 21</value> <value>90, 21</value>
@@ -298,7 +298,7 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;comboBoxComPort.ZOrder" xml:space="preserve"> <data name="&gt;&gt;comboBoxComPort.ZOrder" xml:space="preserve">
<value>6</value> <value>8</value>
</data> </data>
<data name="label3.AutoSize" type="System.Boolean, mscorlib"> <data name="label3.AutoSize" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
@@ -325,10 +325,10 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;label3.ZOrder" xml:space="preserve"> <data name="&gt;&gt;label3.ZOrder" xml:space="preserve">
<value>5</value> <value>7</value>
</data> </data>
<data name="txtGuideRate.Location" type="System.Drawing.Point, System.Drawing"> <data name="txtGuideRate.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 159</value> <value>86, 159</value>
</data> </data>
<data name="txtGuideRate.Size" type="System.Drawing.Size, System.Drawing"> <data name="txtGuideRate.Size" type="System.Drawing.Size, System.Drawing">
<value>46, 20</value> <value>46, 20</value>
@@ -349,13 +349,13 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;txtGuideRate.ZOrder" xml:space="preserve"> <data name="&gt;&gt;txtGuideRate.ZOrder" xml:space="preserve">
<value>4</value> <value>6</value>
</data> </data>
<data name="label4.AutoSize" type="System.Boolean, mscorlib"> <data name="label4.AutoSize" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
</data> </data>
<data name="label4.Location" type="System.Drawing.Point, System.Drawing"> <data name="label4.Location" type="System.Drawing.Point, System.Drawing">
<value>129, 162</value> <value>138, 162</value>
</data> </data>
<data name="label4.Size" type="System.Drawing.Size, System.Drawing"> <data name="label4.Size" type="System.Drawing.Size, System.Drawing">
<value>122, 13</value> <value>122, 13</value>
@@ -376,13 +376,13 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;label4.ZOrder" xml:space="preserve"> <data name="&gt;&gt;label4.ZOrder" xml:space="preserve">
<value>3</value> <value>5</value>
</data> </data>
<data name="lblPercentOfSiderealRate.AutoSize" type="System.Boolean, mscorlib"> <data name="lblPercentOfSiderealRate.AutoSize" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
</data> </data>
<data name="lblPercentOfSiderealRate.Location" type="System.Drawing.Point, System.Drawing"> <data name="lblPercentOfSiderealRate.Location" type="System.Drawing.Point, System.Drawing">
<value>129, 175</value> <value>138, 175</value>
</data> </data>
<data name="lblPercentOfSiderealRate.Size" type="System.Drawing.Size, System.Drawing"> <data name="lblPercentOfSiderealRate.Size" type="System.Drawing.Size, System.Drawing">
<value>105, 13</value> <value>105, 13</value>
@@ -403,7 +403,7 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;lblPercentOfSiderealRate.ZOrder" xml:space="preserve"> <data name="&gt;&gt;lblPercentOfSiderealRate.ZOrder" xml:space="preserve">
<value>2</value> <value>4</value>
</data> </data>
<data name="label5.AutoSize" type="System.Boolean, mscorlib"> <data name="label5.AutoSize" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
@@ -430,7 +430,7 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;label5.ZOrder" xml:space="preserve"> <data name="&gt;&gt;label5.ZOrder" xml:space="preserve">
<value>1</value> <value>3</value>
</data> </data>
<data name="cboPrecision.Items" xml:space="preserve"> <data name="cboPrecision.Items" xml:space="preserve">
<value>Unchanged</value> <value>Unchanged</value>
@@ -442,7 +442,7 @@
<value>High</value> <value>High</value>
</data> </data>
<data name="cboPrecision.Location" type="System.Drawing.Point, System.Drawing"> <data name="cboPrecision.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 191</value> <value>86, 191</value>
</data> </data>
<data name="cboPrecision.Size" type="System.Drawing.Size, System.Drawing"> <data name="cboPrecision.Size" type="System.Drawing.Size, System.Drawing">
<value>90, 21</value> <value>90, 21</value>
@@ -460,6 +460,66 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;cboPrecision.ZOrder" xml:space="preserve"> <data name="&gt;&gt;cboPrecision.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="label6.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label6.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="label6.Location" type="System.Drawing.Point, System.Drawing">
<value>13, 221</value>
</data>
<data name="label6.Size" type="System.Drawing.Size, System.Drawing">
<value>67, 13</value>
</data>
<data name="label6.TabIndex" type="System.Int32, mscorlib">
<value>14</value>
</data>
<data name="label6.Text" xml:space="preserve">
<value>Guiding style</value>
</data>
<data name="&gt;&gt;label6.Name" xml:space="preserve">
<value>label6</value>
</data>
<data name="&gt;&gt;label6.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label6.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label6.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="cboGuidingStyle.Items" xml:space="preserve">
<value>Auto</value>
</data>
<data name="cboGuidingStyle.Items1" xml:space="preserve">
<value>Guide rate slew</value>
</data>
<data name="cboGuidingStyle.Items2" xml:space="preserve">
<value>Pulse guiding</value>
</data>
<data name="cboGuidingStyle.Location" type="System.Drawing.Point, System.Drawing">
<value>86, 218</value>
</data>
<data name="cboGuidingStyle.Size" type="System.Drawing.Size, System.Drawing">
<value>90, 21</value>
</data>
<data name="cboGuidingStyle.TabIndex" type="System.Int32, mscorlib">
<value>15</value>
</data>
<data name="&gt;&gt;cboGuidingStyle.Name" xml:space="preserve">
<value>cboGuidingStyle</value>
</data>
<data name="&gt;&gt;cboGuidingStyle.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cboGuidingStyle.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;cboGuidingStyle.ZOrder" xml:space="preserve">
<value>0</value> <value>0</value>
</data> </data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
@@ -469,7 +529,7 @@
<value>6, 13</value> <value>6, 13</value>
</data> </data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing"> <data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>350, 288</value> <value>350, 313</value>
</data> </data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms"> <data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterScreen</value> <value>CenterScreen</value>
+10 -2
View File
@@ -139,6 +139,7 @@ namespace ASCOM.Meade.net
private const string TraceStateProfileName = "Trace Level"; private const string TraceStateProfileName = "Trace Level";
private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second"; private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second";
private const string PrecisionProfileName = "Precision"; private const string PrecisionProfileName = "Precision";
private const string GuidingStyleProfileName = "Guiding Style";
public static void WriteProfile(ProfileProperties profileProperties) public static void WriteProfile(ProfileProperties profileProperties)
{ {
@@ -151,6 +152,7 @@ namespace ASCOM.Meade.net
driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort); driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort);
driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.InvariantCulture)); driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.InvariantCulture));
driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision); driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision);
driverProfile.WriteValue(DriverId, GuidingStyleProfileName, profileProperties.GuidingStyle);
} }
} }
} }
@@ -159,6 +161,8 @@ namespace ASCOM.Meade.net
private const string TraceStateDefault = "false"; private const string TraceStateDefault = "false";
private const string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate private const string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
private const string PrecisionDefault = "Unchanged"; private const string PrecisionDefault = "Unchanged";
private const string GuidingStyleDefault = "Auto";
public static ProfileProperties ReadProfile() public static ProfileProperties ReadProfile()
{ {
@@ -172,6 +176,7 @@ namespace ASCOM.Meade.net
profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault)); profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault));
profileProperties.GuideRateArcSecondsPerSecond = double.Parse(driverProfile.GetValue(DriverId, GuideRateProfileName, string.Empty, GuideRateProfileNameDefault), NumberFormatInfo.InvariantInfo); profileProperties.GuideRateArcSecondsPerSecond = double.Parse(driverProfile.GetValue(DriverId, GuideRateProfileName, string.Empty, GuideRateProfileNameDefault), NumberFormatInfo.InvariantInfo);
profileProperties.Precision = driverProfile.GetValue(DriverId, PrecisionProfileName, string.Empty, PrecisionDefault); profileProperties.Precision = driverProfile.GetValue(DriverId, PrecisionProfileName, string.Empty, PrecisionDefault);
profileProperties.GuidingStyle = driverProfile.GetValue(DriverId, GuidingStyleProfileName, string.Empty, GuidingStyleDefault);
} }
return profileProperties; return profileProperties;
@@ -238,7 +243,8 @@ namespace ASCOM.Meade.net
/// </summary> /// </summary>
/// <param name="deviceId"></param> /// <param name="deviceId"></param>
/// <param name="driverId"></param> /// <param name="driverId"></param>
public static ConnectionInfo Connect(string deviceId, string driverId) /// <param name="traceLogger"></param>
public static ConnectionInfo Connect(string deviceId, string driverId, ITraceLogger traceLogger)
{ {
lock (LockObject) lock (LockObject)
{ {
@@ -268,14 +274,16 @@ namespace ASCOM.Meade.net
ProductName = SendString(":GVP#"); ProductName = SendString(":GVP#");
FirmwareVersion = SendString(":GVN#"); FirmwareVersion = SendString(":GVN#");
} }
catch (Exception) catch (Exception ex)
{ {
traceLogger.LogIssue("Connect", $"Error getting telescope information \"{ex.Message}\" setting to LX200 Classic mode.");
ProductName = TelescopeList.LX200CLASSIC; ProductName = TelescopeList.LX200CLASSIC;
FirmwareVersion = "Unknown"; FirmwareVersion = "Unknown";
} }
if (ProductName == ":GVP") if (ProductName == ":GVP")
{ {
traceLogger.LogIssue("Connect", "Serial port is looping back data, something is wrong with the hardware.");
//This means that the serial port is looping back what's been sent, something is very wrong. //This means that the serial port is looping back what's been sent, something is very wrong.
SharedSerial.Connected = false; SharedSerial.Connected = false;
+4 -3
View File
@@ -1,10 +1,11 @@
using System; using System;
using ASCOM.Utilities.Interfaces;
namespace ASCOM.Meade.net.Wrapper namespace ASCOM.Meade.net.Wrapper
{ {
public interface ISharedResourcesWrapper public interface ISharedResourcesWrapper
{ {
ConnectionInfo Connect(string deviceId, string driverId); ConnectionInfo Connect(string deviceId, string driverId, ITraceLogger traceLogger);
void Disconnect(string deviceId, string driverId); void Disconnect(string deviceId, string driverId);
string ProductName { get; } string ProductName { get; }
@@ -29,9 +30,9 @@ namespace ASCOM.Meade.net.Wrapper
public class SharedResourcesWrapper : ISharedResourcesWrapper public class SharedResourcesWrapper : ISharedResourcesWrapper
{ {
public ConnectionInfo Connect(string deviceId, string driverId) public ConnectionInfo Connect(string deviceId, string driverId, ITraceLogger traceLogger)
{ {
return SharedResources.Connect(deviceId, driverId); return SharedResources.Connect(deviceId, driverId, traceLogger);
} }
public void Disconnect(string deviceId, string driverId) public void Disconnect(string deviceId, string driverId)