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);
_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()
{
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
_focuser.Connected = true;
//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]
public void Connected_Set_SettingFalseWhenTrue_ThenDisconnects()
{
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
_focuser.Connected = false;
@@ -34,7 +34,8 @@ namespace Meade.net.Telescope.UnitTests
TraceLogger = false,
ComPort = "TestCom1",
GuideRateArcSecondsPerSecond = 1.23,
Precision = "Unchanged"
Precision = "Unchanged",
GuidingStyle = "Auto"
};
_utilMock = new Mock<IUtil>();
@@ -55,7 +56,7 @@ namespace Meade.net.Telescope.UnitTests
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);
@@ -383,7 +384,7 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware);
_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.SendBlind($"#:Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"),Times.Once);
@@ -399,7 +400,7 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware);
_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.SendBlind($"#:Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"), Times.Never);
}
@@ -409,20 +410,20 @@ namespace Meade.net.Telescope.UnitTests
public void Connected_Set_SettingTrueWhenTrue_ThenDoesNothing()
{
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
_telescope.Connected = true;
//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]
public void Connected_Set_SettingFalseWhenTrue_ThenDisconnects()
{
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
_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());
}
[TestCase("Autostar", "30Ab", false)]
[TestCase("Autostar", "31Ee", true)]
[TestCase("Autostar", "43Eg", true)]
[TestCase("Autostar II", "", false)]
[TestCase("LX2001", "", true)]
[TestCase(":GVP", "", false)] //LX200 Classic
public void IsNewPulseGuidingSupported_ThenIsSupported_ThenReturnsTrue(string productName, string firmware, bool isSupported)
[TestCase("Auto", "Autostar", "30Ab", false)]
[TestCase("Auto","Autostar", "31Ee", true)]
[TestCase("Auto","Autostar", "43Eg", true)]
[TestCase("Auto","Autostar II", "", false)]
[TestCase("Auto","LX2001", "", true)]
[TestCase("Auto",":GVP", "", false)] //LX200 Classic
[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.FirmwareVersion).Returns(firmware);
_profileProperties.GuidingStyle = guidingStyle;
_telescope.Connected = true;
var result = _telescope.IsNewPulseGuidingSupported();
Assert.That(result, Is.EqualTo(isSupported));
@@ -1322,6 +1330,63 @@ namespace Meade.net.Telescope.UnitTests
_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.guideWest)]
[TestCase(GuideDirections.guideNorth)]
+89 -48
View File
@@ -134,7 +134,8 @@ namespace ASCOM.Meade.net
}
private double _guideRate;
private bool _isGuiding;
private void Initialise()
{
//todo move the TraceLogger out to a factory class.
@@ -405,7 +406,7 @@ namespace ASCOM.Meade.net
ReadProfile();
LogMessage("Connected Set", "Connecting to port {0}", _comPort);
var connectionInfo = _sharedResourcesWrapper.Connect("Serial", DriverId);
var connectionInfo = _sharedResourcesWrapper.Connect("Serial", DriverId, _tl);
try
{
LogMessage("Connected Set", $"Connected to port {_comPort}. Product: {_sharedResourcesWrapper.ProductName} Version:{_sharedResourcesWrapper.FirmwareVersion}");
@@ -480,17 +481,26 @@ namespace ASCOM.Meade.net
public bool IsNewPulseGuidingSupported()
{
if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497)
switch (_guidingStyle)
{
return FirmwareIsGreaterThan(TelescopeList.Autostar497_31Ee);
}
case "guide rate slew":
return false;
case "pulse guiding":
return true;
if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
{
return true;
}
default:
if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497)
{
return FirmwareIsGreaterThan(TelescopeList.Autostar497_31Ee);
}
return false;
if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
{
return true;
}
return false;
}
}
private bool IsLongFormatSupported()
@@ -1415,6 +1425,15 @@ namespace ASCOM.Meade.net
LogMessage("PulseGuide", $"pulse guide direction {direction} duration {duration}");
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();
if (_userNewerPulseGuiding && duration < 10000)
@@ -1450,28 +1469,36 @@ namespace ASCOM.Meade.net
}
else
{
switch (direction)
_isGuiding = true;
try
{
case GuideDirections.guideEast:
MoveAxis(TelescopeAxes.axisPrimary, 1);
_utilities.WaitForMilliseconds(duration);
MoveAxis(TelescopeAxes.axisPrimary, 0);
break;
case GuideDirections.guideNorth:
MoveAxis(TelescopeAxes.axisSecondary, 1);
_utilities.WaitForMilliseconds(duration);
MoveAxis(TelescopeAxes.axisSecondary, 0);
break;
case GuideDirections.guideSouth:
MoveAxis(TelescopeAxes.axisSecondary, -1);
_utilities.WaitForMilliseconds(duration);
MoveAxis(TelescopeAxes.axisSecondary, 0);
break;
case GuideDirections.guideWest:
MoveAxis(TelescopeAxes.axisPrimary, -1);
_utilities.WaitForMilliseconds(duration);
MoveAxis(TelescopeAxes.axisPrimary, 0);
break;
switch (direction)
{
case GuideDirections.guideEast:
MoveAxis(TelescopeAxes.axisPrimary, 1);
_utilities.WaitForMilliseconds(duration);
MoveAxis(TelescopeAxes.axisPrimary, 0);
break;
case GuideDirections.guideNorth:
MoveAxis(TelescopeAxes.axisSecondary, 1);
_utilities.WaitForMilliseconds(duration);
MoveAxis(TelescopeAxes.axisSecondary, 0);
break;
case GuideDirections.guideSouth:
MoveAxis(TelescopeAxes.axisSecondary, -1);
_utilities.WaitForMilliseconds(duration);
MoveAxis(TelescopeAxes.axisSecondary, 0);
break;
case GuideDirections.guideWest:
MoveAxis(TelescopeAxes.axisPrimary, -1);
_utilities.WaitForMilliseconds(duration);
MoveAxis(TelescopeAxes.axisPrimary, 0);
break;
}
}
finally
{
_isGuiding = false;
}
}
@@ -1915,6 +1942,9 @@ namespace ASCOM.Meade.net
private bool MovingAxis()
{
if (_isGuiding)
return false;
return _movingPrimary || _movingSecondary;
}
@@ -1928,26 +1958,34 @@ namespace ASCOM.Meade.net
if (MovingAxis())
return true;
CheckConnected("Slewing Get");
var result = _sharedResourcesWrapper.SendString("#:D#");
//:D# Requests a string of bars indicating the distance to the current target location.
//Returns:
//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.
if (result == null)
{
return false;
}
bool isSlewing = result != string.Empty;
LogMessage("Slewing Get", $"Result = {isSlewing}");
return isSlewing;
return IsSlewingToTarget();
}
}
private bool IsSlewingToTarget()
{
CheckConnected("Slewing Get");
if (_isGuiding)
return false;
var result = _sharedResourcesWrapper.SendString("#:D#");
//:D# Requests a string of bars indicating the distance to the current target location.
//Returns:
//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.
if (result == null)
{
return false;
}
bool isSlewing = result != string.Empty;
LogMessage("Slewing Get", $"Result = {isSlewing}");
return isSlewing;
}
public void SyncToAltAz(double azimuth, double altitude)
{
LogMessage("SyncToAltAz", "Not implemented");
@@ -2102,6 +2140,7 @@ namespace ASCOM.Meade.net
private DriveRates _trackingRate = DriveRates.driveSidereal;
private string _precision;
private string _guidingStyle;
public DriveRates TrackingRate
{
@@ -2398,11 +2437,13 @@ namespace ASCOM.Meade.net
_comPort = profileProperties.ComPort;
_guideRate = profileProperties.GuideRateArcSecondsPerSecond;
_precision = profileProperties.Precision;
_guidingStyle = profileProperties.GuidingStyle.ToLower();
LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}");
LogMessage("ReadProfile", $"Com Port: {_comPort}");
LogMessage("ReadProfile", $"Guide Rate: {_guideRate}");
LogMessage("ReadProfile", $"Precision: {_precision}");
LogMessage("ReadProfile", $"Guiding Style: {_guidingStyle}");
}
private void WriteProfile()
+32 -14
View File
@@ -13,6 +13,7 @@ namespace Meade.net.UnitTests
public class SharedResourcesUnitTests
{
private Mock<ISerial> _serialMock;
private Mock<ITraceLogger> _traceLoggerMock;
[SetUp]
public void Setup()
@@ -20,6 +21,8 @@ namespace Meade.net.UnitTests
_serialMock = new Mock<ISerial>();
_serialMock.SetupAllProperties();
_traceLoggerMock = new Mock<ITraceLogger>();
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, "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, "Guiding Style", profileProperties.GuidingStyle), Times.Once);
}
[Test]
@@ -134,6 +138,7 @@ namespace Meade.net.UnitTests
string TraceStateDefault = "false";
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
string PrecisionDefault = "Unchanged";
string GuidingStyleDefault = "Auto";
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
profileWrapperMock.SetupAllProperties();
@@ -147,6 +152,8 @@ namespace Meade.net.UnitTests
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
.Returns(PrecisionDefault);
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Guiding Style", string.Empty, GuidingStyleDefault))
.Returns(GuidingStyleDefault);
IProfileWrapper profeWrapper = profileWrapperMock.Object;
@@ -163,13 +170,14 @@ namespace Meade.net.UnitTests
Is.EqualTo(double.Parse(GuideRateProfileNameDefault)));
Assert.That(profileProperties.TraceLogger, Is.EqualTo(bool.Parse(TraceStateDefault)));
Assert.That(profileProperties.Precision, Is.EqualTo(PrecisionDefault));
Assert.That(profileProperties.GuidingStyle, Is.EqualTo(GuidingStyleDefault));
}
[TestCase("TCP")]
[TestCase("Carrier Pigeon")]
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") );
}
@@ -209,7 +217,7 @@ namespace Meade.net.UnitTests
_serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { serialPortReturn = ":GVP#"; });
_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."));
}
@@ -246,12 +254,18 @@ namespace Meade.net.UnitTests
_serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { });
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => throw new Exception("Testerror"));
var connectionResult = SharedResources.Connect(deviceId, string.Empty);
Assert.That(connectionResult.SameDevice, Is.EqualTo(1));
Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.LX200CLASSIC));
var connectionResult = SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object);
try
{
SharedResources.Disconnect(deviceId, String.Empty);
Assert.That(connectionResult.SameDevice, Is.EqualTo(1));
Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.LX200CLASSIC));
}
finally
{
SharedResources.Disconnect(deviceId, String.Empty);
}
}
[Test]
@@ -290,13 +304,17 @@ namespace Meade.net.UnitTests
_serialMock.Setup(x => x.Transmit(":GVN#")).Callback(() => { serialPortReturn = TelescopeList.Autostar497_43Eg; });
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn);
var connectionResult = SharedResources.Connect(deviceId, string.Empty);
Assert.That(connectionResult.SameDevice, Is.EqualTo(1));
Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.Autostar497));
Assert.That(SharedResources.FirmwareVersion, Is.EqualTo(TelescopeList.Autostar497_43Eg));
SharedResources.Disconnect(deviceId, String.Empty);
var connectionResult = SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object);
try
{
Assert.That(connectionResult.SameDevice, Is.EqualTo(1));
Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.Autostar497));
Assert.That(SharedResources.FirmwareVersion, Is.EqualTo(TelescopeList.Autostar497_43Eg));
}
finally
{
SharedResources.Disconnect(deviceId, String.Empty);
}
}
}
}
+1 -1
View File
@@ -187,7 +187,7 @@ namespace ASCOM.Meade.net
try
{
ReadProfile();
_sharedResourcesWrapper.Connect("Serial", DriverId);
_sharedResourcesWrapper.Connect("Serial", DriverId, _tl);
try
{
IsConnected = true;
+1
View File
@@ -7,5 +7,6 @@ namespace ASCOM.Meade.net
public bool TraceLogger { get; set; }
public double GuideRateArcSecondsPerSecond { 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";
}
try
{
cboGuidingStyle.SelectedItem = profileProperties.GuidingStyle;
}
catch (Exception)
{
cboGuidingStyle.SelectedItem = "Auto";
}
}
public ProfileProperties GetProfile()
@@ -80,7 +90,8 @@ namespace ASCOM.Meade.net
TraceLogger = chkTrace.Checked,
ComPort = comboBoxComPort.SelectedItem.ToString(),
GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()),
Precision = cboPrecision.SelectedItem.ToString()
Precision = cboPrecision.SelectedItem.ToString(),
GuidingStyle = cboGuidingStyle.SelectedItem.ToString()
};
return profileProperties;
+22
View File
@@ -45,6 +45,8 @@ namespace ASCOM.Meade.net
this.lblPercentOfSiderealRate = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
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();
this.SuspendLayout();
//
@@ -133,10 +135,28 @@ namespace ASCOM.Meade.net
resources.ApplyResources(this.cboPrecision, "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
//
resources.ApplyResources(this, "$this");
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.label5);
this.Controls.Add(this.lblPercentOfSiderealRate);
@@ -178,5 +198,7 @@ namespace ASCOM.Meade.net
private Label lblPercentOfSiderealRate;
private Label label5;
private ComboBox cboPrecision;
private Label label6;
private ComboBox cboGuidingStyle;
}
}
+81 -21
View File
@@ -123,7 +123,7 @@
</data>
<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">
<value>281, 225</value>
<value>281, 250</value>
</data>
<data name="cmdOK.Size" type="System.Drawing.Size, System.Drawing">
<value>59, 24</value>
@@ -145,13 +145,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cmdOK.ZOrder" xml:space="preserve">
<value>12</value>
<value>14</value>
</data>
<data name="cmdCancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="cmdCancel.Location" type="System.Drawing.Point, System.Drawing">
<value>281, 255</value>
<value>281, 280</value>
</data>
<data name="cmdCancel.Size" type="System.Drawing.Size, System.Drawing">
<value>59, 25</value>
@@ -172,7 +172,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cmdCancel.ZOrder" xml:space="preserve">
<value>11</value>
<value>13</value>
</data>
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 9</value>
@@ -196,7 +196,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>10</value>
<value>12</value>
</data>
<data name="picASCOM.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
@@ -223,7 +223,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;picASCOM.ZOrder" xml:space="preserve">
<value>9</value>
<value>11</value>
</data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -250,13 +250,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>8</value>
<value>10</value>
</data>
<data name="chkTrace.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="chkTrace.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 136</value>
<value>86, 136</value>
</data>
<data name="chkTrace.Size" type="System.Drawing.Size, System.Drawing">
<value>69, 17</value>
@@ -277,10 +277,10 @@
<value>$this</value>
</data>
<data name="&gt;&gt;chkTrace.ZOrder" xml:space="preserve">
<value>7</value>
<value>9</value>
</data>
<data name="comboBoxComPort.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 87</value>
<value>86, 87</value>
</data>
<data name="comboBoxComPort.Size" type="System.Drawing.Size, System.Drawing">
<value>90, 21</value>
@@ -298,7 +298,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;comboBoxComPort.ZOrder" xml:space="preserve">
<value>6</value>
<value>8</value>
</data>
<data name="label3.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -325,10 +325,10 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label3.ZOrder" xml:space="preserve">
<value>5</value>
<value>7</value>
</data>
<data name="txtGuideRate.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 159</value>
<value>86, 159</value>
</data>
<data name="txtGuideRate.Size" type="System.Drawing.Size, System.Drawing">
<value>46, 20</value>
@@ -349,13 +349,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;txtGuideRate.ZOrder" xml:space="preserve">
<value>4</value>
<value>6</value>
</data>
<data name="label4.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label4.Location" type="System.Drawing.Point, System.Drawing">
<value>129, 162</value>
<value>138, 162</value>
</data>
<data name="label4.Size" type="System.Drawing.Size, System.Drawing">
<value>122, 13</value>
@@ -376,13 +376,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label4.ZOrder" xml:space="preserve">
<value>3</value>
<value>5</value>
</data>
<data name="lblPercentOfSiderealRate.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="lblPercentOfSiderealRate.Location" type="System.Drawing.Point, System.Drawing">
<value>129, 175</value>
<value>138, 175</value>
</data>
<data name="lblPercentOfSiderealRate.Size" type="System.Drawing.Size, System.Drawing">
<value>105, 13</value>
@@ -403,7 +403,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblPercentOfSiderealRate.ZOrder" xml:space="preserve">
<value>2</value>
<value>4</value>
</data>
<data name="label5.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -430,7 +430,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label5.ZOrder" xml:space="preserve">
<value>1</value>
<value>3</value>
</data>
<data name="cboPrecision.Items" xml:space="preserve">
<value>Unchanged</value>
@@ -442,7 +442,7 @@
<value>High</value>
</data>
<data name="cboPrecision.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 191</value>
<value>86, 191</value>
</data>
<data name="cboPrecision.Size" type="System.Drawing.Size, System.Drawing">
<value>90, 21</value>
@@ -460,6 +460,66 @@
<value>$this</value>
</data>
<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>
</data>
<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>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>350, 288</value>
<value>350, 313</value>
</data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterScreen</value>
+11 -3
View File
@@ -139,7 +139,8 @@ namespace ASCOM.Meade.net
private const string TraceStateProfileName = "Trace Level";
private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second";
private const string PrecisionProfileName = "Precision";
private const string GuidingStyleProfileName = "Guiding Style";
public static void WriteProfile(ProfileProperties profileProperties)
{
lock (LockObject)
@@ -151,6 +152,7 @@ namespace ASCOM.Meade.net
driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort);
driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.InvariantCulture));
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 GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
private const string PrecisionDefault = "Unchanged";
private const string GuidingStyleDefault = "Auto";
public static ProfileProperties ReadProfile()
{
@@ -172,6 +176,7 @@ namespace ASCOM.Meade.net
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.Precision = driverProfile.GetValue(DriverId, PrecisionProfileName, string.Empty, PrecisionDefault);
profileProperties.GuidingStyle = driverProfile.GetValue(DriverId, GuidingStyleProfileName, string.Empty, GuidingStyleDefault);
}
return profileProperties;
@@ -238,7 +243,8 @@ namespace ASCOM.Meade.net
/// </summary>
/// <param name="deviceId"></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)
{
@@ -268,14 +274,16 @@ namespace ASCOM.Meade.net
ProductName = SendString(":GVP#");
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;
FirmwareVersion = "Unknown";
}
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.
SharedSerial.Connected = false;
+4 -3
View File
@@ -1,10 +1,11 @@
using System;
using ASCOM.Utilities.Interfaces;
namespace ASCOM.Meade.net.Wrapper
{
public interface ISharedResourcesWrapper
{
ConnectionInfo Connect(string deviceId, string driverId);
ConnectionInfo Connect(string deviceId, string driverId, ITraceLogger traceLogger);
void Disconnect(string deviceId, string driverId);
string ProductName { get; }
@@ -29,9 +30,9 @@ namespace ASCOM.Meade.net.Wrapper
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)