Merged in develop (pull request #11)

Next release
This commit is contained in:
2019-07-26 10:47:59 +00:00
17 changed files with 790 additions and 96 deletions
@@ -30,6 +30,7 @@ namespace Meade.net.Telescope.UnitTests
_profileProperties = new ProfileProperties();
_profileProperties.TraceLogger = false;
_profileProperties.ComPort = "TestCom1";
_profileProperties.GuideRateArcSecondsPerSecond = 1.23;
_utilMock = new Mock<IUtil>();
_utilExtraMock = new Mock<IUtilExtra>();
@@ -37,10 +38,8 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
_sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MMSS");
_sharedResourcesWrapperMock.Setup(x => x.Autostar497).Returns(() => "AUTOSTAR");
_sharedResourcesWrapperMock.Setup(x => x.Autostar49731Ee).Returns(() => "31Ee");
_sharedResourcesWrapperMock.Setup(x => x.Autostar49743Eg) .Returns(() => "43Eg");
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(_profileProperties);
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Action>())).Callback<Action>(action => { action(); });
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Func<ASCOM.Meade.net.Telescope.TelescopeDateDetails>>())).Returns<Func<ASCOM.Meade.net.Telescope.TelescopeDateDetails>>( (func) => func());
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Func<AltitudeData>>())).Returns<Func<AltitudeData>>((func) => func());
@@ -56,8 +55,8 @@ namespace Meade.net.Telescope.UnitTests
private void ConnectTelescope()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.Autostar49731Ee);
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
_telescope.Connected = true;
}
@@ -90,8 +89,9 @@ namespace Meade.net.Telescope.UnitTests
var supportedActions = _telescope.SupportedActions;
Assert.That(supportedActions, Is.Not.Null);
Assert.That(supportedActions.Count, Is.EqualTo(1));
Assert.That(supportedActions.Count, Is.EqualTo(2));
Assert.That(supportedActions.Contains("handbox"), Is.True);
Assert.That(supportedActions.Contains("site"), Is.True);
}
[Test]
@@ -135,7 +135,7 @@ namespace Meade.net.Telescope.UnitTests
[TestCase("back", ":EK87#")]
[TestCase("forward", ":EK69#")]
[TestCase("?", ":EK63#")]
public void Action_Handbox_blindCommands(string action, string expectedString)
public void Action_Handbox_WhenCalling_ThenSendsAppropriateBlindCommands(string action, string expectedString)
{
ConnectTelescope();
@@ -144,6 +144,100 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(expectedString), Times.Once);
}
[TestCase("1")]
[TestCase("2")]
[TestCase("3")]
[TestCase("4")]
public void Action_Site_WhenCallingWithValidValues_ThenSelectsCorrectSite(string site)
{
ConnectTelescope();
string parameters = $"select {site}";
_telescope.Action("site", parameters);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":W{site}#"), Times.Once);
}
[TestCase("0")]
[TestCase("5")]
public void Action_Site_WhenCallingWithInCorrectValues_ThenThrowsException(string site)
{
ConnectTelescope();
string parameters = $"select {site}";
var exception = Assert.Throws<InvalidValueException>(() => { _telescope.Action("site", parameters); });
Assert.That(exception.Message, Is.EqualTo($"Site {parameters} not allowed, must be between 1 and 4"));
}
[TestCase("1", ":GM#", "Home")]
[TestCase("2", ":GN#", "Club")]
[TestCase("3", ":GO#", "GPS")]
[TestCase("4", ":GP#", "Parents")]
public void Action_Site_GetName_WhenCallingWithValidValues_ThenSelectsCorrectSite(string site, string telescopeCommand, string siteName)
{
ConnectTelescope();
_sharedResourcesWrapperMock.Setup(x => x.SendString(telescopeCommand)).Returns(siteName);
string parameters = $"GetName {site}";
var result = _telescope.Action("site", parameters);
_sharedResourcesWrapperMock.Verify(x => x.SendString(telescopeCommand), Times.Once);
Assert.That(result, Is.EqualTo(siteName));
}
[TestCase("0")]
[TestCase("5")]
public void Action_Site_GetName_WhenCallingWithInCorrectValues_ThenThrowsException(string site)
{
ConnectTelescope();
string parameters = $"GetName {site}";
var exception = Assert.Throws<InvalidValueException>(() => { _telescope.Action("site", parameters); });
Assert.That(exception.Message, Is.EqualTo($"Site {parameters} not allowed, must be between 1 and 4"));
}
[TestCase("1", ":SMHome#", "Home")]
[TestCase("2", ":SNClub#", "Club")]
[TestCase("3", ":SOGPS Site#", "GPS Site")]
[TestCase("4", ":SPParents#", "Parents")]
public void Action_Site_SetName_WhenCallingWithValidValues_ThenSelectsCorrectSite(string site, string telescopeCommand, string siteName)
{
ConnectTelescope();
_sharedResourcesWrapperMock.Setup(x => x.SendChar(telescopeCommand)).Returns("1");
string parameters = $"SetName {site} {siteName}";
_telescope.Action("site", parameters);
_sharedResourcesWrapperMock.Verify(x => x.SendChar(telescopeCommand), Times.Once);
}
[TestCase("0")]
[TestCase("5")]
public void Action_Site_SetName_WhenCallingWithInCorrectValues_ThenThrowsException(string site)
{
ConnectTelescope();
string parameters = $"SetName {site}";
var exception = Assert.Throws<InvalidValueException>(() => { _telescope.Action("site", parameters); });
Assert.That(exception.Message, Is.EqualTo($"Site {parameters} not allowed, must be between 1 and 4"));
}
[Test]
public void Action_Site_WhenCallingUnknownParam_ThenThrowsException()
{
ConnectTelescope();
string parameters = $"unknown";
var exception = Assert.Throws<InvalidValueException>(() => { _telescope.Action("site", parameters); });
Assert.That(exception.Message, Is.EqualTo($"Site parameters {parameters} not known"));
}
[Test]
public void Action_Handbox_nonExistantAction()
{
@@ -238,13 +332,29 @@ namespace Meade.net.Telescope.UnitTests
[TestCase(false)]
public void Connected_Get_ReturnsExpectedValue(bool expectedConnected)
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.Autostar49731Ee);
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
_telescope.Connected = expectedConnected;
Assert.That(_telescope.Connected, Is.EqualTo(expectedConnected));
}
[Test]
public void Connected_Set_WhenConnecting_Then()
{
var productName = "LX2001";
var firmware = string.Empty;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware);
_telescope.Connected = true;
_sharedResourcesWrapperMock.Verify( x => x.Connect("Serial"), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#"), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"),Times.Once);
}
[Test]
public void Connected_Set_SettingTrueWhenTrue_ThenDoesNothing()
@@ -275,8 +385,8 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void Connected_Set_WhenFailsToConnect_ThenDisconnects()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.Autostar49731Ee);
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
_sharedResourcesWrapperMock.Setup(x => x.SendString(It.IsAny<string>())).Throws(new Exception("TestFailed"));
@@ -287,10 +397,11 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Verify(x => x.Disconnect(It.IsAny<string>()), Times.Once());
}
[TestCase("AUTOSTAR", "30Ab", false)]
[TestCase("AUTOSTAR","31Ee", true)]
[TestCase("AUTOSTAR", "43Eg", true)]
[TestCase("AUTOSTAR II", "", false)]
[TestCase("Autostar", "30Ab", false)]
[TestCase("Autostar", "31Ee", true)]
[TestCase("Autostar", "43Eg", true)]
[TestCase("Autostar II", "", false)]
[TestCase("LX2001", "", true)]
public void IsNewPulseGuidingSupported_ThenIsSupported_ThenReturnsTrue(string productName, string firmware, bool isSupported)
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
@@ -337,9 +448,18 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":U#"), Times.Once);
}
[Test]
public void SelectSite_Get_WhenNotConnected_ThrowsException()
{
var exception = Assert.Throws<NotConnectedException>(() => { _telescope.SelectSite(1); });
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SelectSite"));
}
[Test]
public void SelectSite_WhenNewSiteToLow_ThenThrowsException()
{
ConnectTelescope();
var site = 0;
var result = Assert.Throws<ArgumentOutOfRangeException>(() => { _telescope.SelectSite(site); });
@@ -349,6 +469,8 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void SelectSite_WhenNewSiteToHigh_ThenThrowsException()
{
ConnectTelescope();
var site = 5;
var result = Assert.Throws<ArgumentOutOfRangeException>(() => { _telescope.SelectSite(site); });
@@ -361,6 +483,8 @@ namespace Meade.net.Telescope.UnitTests
[TestCase(4)]
public void SelectSite_WhenNewSiteToHigh_ThenThrowsException(int site)
{
ConnectTelescope();
_telescope.SelectSite(site);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":W{site}#"), Times.Once);
@@ -381,7 +505,7 @@ namespace Meade.net.Telescope.UnitTests
{
Version version = System.Reflection.Assembly.GetAssembly(typeof(ASCOM.Meade.net.Telescope)).GetName().Version;
string exptectedDriverInfo = $"{version.Major}.{version.Minor}.{version.Revision}.{version.Build}";
string exptectedDriverInfo = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
var driverVersion = _telescope.DriverVersion;
@@ -582,13 +706,34 @@ namespace Meade.net.Telescope.UnitTests
}
[Test]
public void CanSetGuideRates_Get_ReturnsFalse()
public void CanSetGuideRates_Get_WhenNotConnected_ThenThrowsException()
{
var exception = Assert.Throws<NotConnectedException>(() => { var result = _telescope.CanSetGuideRates; });
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: CanSetGuideRates Get"));
}
[Test]
public void CanSetGuideRates_Get_WhenConnectedToAutostar_ThenReturnsFalse()
{
ConnectTelescope();
var result = _telescope.CanSetGuideRates;
Assert.That(result, Is.False);
}
[Test]
public void CanSetGuideRates_Get_WhenConnectedToLX200GPS_ThenReturnsTrue()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.LX200GPS_42G);
_telescope.Connected = true;
var result = _telescope.CanSetGuideRates;
Assert.That(result, Is.True);
}
[Test]
public void CanSetPark_Get_ReturnsFalse()
{
@@ -769,15 +914,16 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void GuideRateDeclination_Get_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.GuideRateDeclination; });
var result = _telescope.GuideRateDeclination;
Assert.That(excpetion.Property, Is.EqualTo("GuideRateDeclination"));
Assert.That(excpetion.AccessorSet, Is.False);
Assert.That(result, Is.EqualTo(0.00034166666666666666));
}
[Test]
public void GuideRateDeclination_Set_ThenThrowsException()
public void GuideRateDeclination_Set_WhenNotSupported_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.GuideRateDeclination = 0; });
Assert.That(excpetion.Property, Is.EqualTo("GuideRateDeclination"));
@@ -785,23 +931,52 @@ namespace Meade.net.Telescope.UnitTests
}
[Test]
public void GuideRateRightAscension_Get_ThenThrowsException()
public void GuideRateDeclination_Set_WhenIsSupported_ThenSetsNewGuideRate()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.GuideRateRightAscension; });
var newGuideRate = 0.00034166666666666666;
Assert.That(excpetion.Property, Is.EqualTo("GuideRateRightAscension"));
Assert.That(excpetion.AccessorSet, Is.False);
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS);
_telescope.GuideRateDeclination = newGuideRate;
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Rg01.2#"), Times.Once);
Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate));
}
[Test]
public void GuideRateRightAscension_Set_ThenThrowsException()
public void GuideRateRightAscension_Get_ThenThrowsException()
{
var result = _telescope.GuideRateRightAscension;
Assert.That(result, Is.EqualTo(0.00034166666666666666));
}
[Test]
public void GuideRateRightAscension_Set_WhenNotSupported_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.GuideRateRightAscension = 0; });
Assert.That(excpetion.Property, Is.EqualTo("GuideRateRightAscension"));
Assert.That(excpetion.AccessorSet, Is.True);
}
[Test]
public void GuideRateRightAscension_Set_WhenIsSupported_ThenSetsNewGuideRate()
{
var newGuideRate = 0.00034166666666666666;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS);
_telescope.GuideRateRightAscension = newGuideRate;
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Rg01.2#"), Times.Once);
Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate));
}
[Test]
public void IsPulseGuiding_Get_ReturnsFalse()
{
@@ -969,7 +1144,7 @@ namespace Meade.net.Telescope.UnitTests
var duration = 0;
ConnectTelescope();
_telescope.PulseGuide(direction, 0);
_telescope.PulseGuide(direction, duration);
string d = string.Empty;
switch (direction)
@@ -999,11 +1174,47 @@ namespace Meade.net.Telescope.UnitTests
public void PulseGuide_WhenConnectedAndNewerPulseGuidingNotAvailable_ThenSendsOldCommandsAndWaits(GuideDirections direction)
{
var duration = 0;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => "31Ed");
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee);
_telescope.Connected = true;
_telescope.PulseGuide(direction, 0);
_telescope.PulseGuide(direction, duration);
string d = string.Empty;
switch (direction)
{
case GuideDirections.guideEast:
d = "e";
break;
case GuideDirections.guideWest:
d = "w";
break;
case GuideDirections.guideNorth:
d = "n";
break;
case GuideDirections.guideSouth:
d = "s";
break;
}
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":RG#"));
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":M{d}#"));
_utilMock.Verify(x => x.WaitForMilliseconds(duration), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Q{d}#"));
}
[TestCase(GuideDirections.guideEast)]
[TestCase(GuideDirections.guideWest)]
[TestCase(GuideDirections.guideNorth)]
[TestCase(GuideDirections.guideSouth)]
public void PulseGuide_WhenConnectedAndNewerPulseGuidingAvailableButDurationTooLong_ThenSendsOldCommandsAndWaits(GuideDirections direction)
{
var duration = 10000;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee);
_telescope.Connected = true;
_telescope.PulseGuide(direction, duration);
string d = string.Empty;
switch (direction)
@@ -1294,8 +1505,6 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void SyncToAltAz_WhenConnected_ThenSendsExpectedMessage()
{
string expectedMessage = "test blind Message";
ConnectTelescope();
var exception = Assert.Throws<MethodNotImplementedException>(() => { _telescope.SyncToAltAz(0,0); });
+14
View File
@@ -0,0 +1,14 @@
namespace ASCOM.Meade.net
{
public static class DoubleExtensions
{
public static bool InRange(this double value, double low, double high)
{
if (value < low)
return false;
if (value > high)
return false;
return true;
}
}
}
@@ -118,6 +118,7 @@
<Compile Include="AstroMaths\EquatorialCoordinates.cs" />
<Compile Include="AstroMaths\HorizonCoordinates.cs" />
<Compile Include="AstroMaths\IAstroMaths.cs" />
<Compile Include="DoubleExtensions.cs" />
<Compile Include="StringExtensions.cs" />
<Compile Include="Telescope.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+23
View File
@@ -6,5 +6,28 @@ namespace ASCOM.Meade.net
{
return int.Parse(str);
}
public static double ToDouble(this string str)
{
return double.Parse(str);
}
public static int Position(this string str, char find, int instance)
{
var currentInstance = 0;
for (var i = 0; i < str.Length; i++)
{
if (str[i] == find)
{
currentInstance++;
if (currentInstance == instance)
{
return i;
}
}
}
return -1;
}
}
}
+268 -26
View File
@@ -97,17 +97,20 @@ namespace ASCOM.Meade.net
Initialise();
}
private double _guideRate;
private const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second
private void Initialise()
{
//todo move the TraceLogger out to a factory class.
_tl = new TraceLogger("", "Meade.net.Telescope");
LogMessage("Telescope", "Starting initialisation");
_tl = new TraceLogger("", "Meade.Generic.Telescope");
ReadProfile(); // Read device configuration from the ASCOM Profile store
IsConnected = false; // Initialise connected to false
LogMessage("Telescope", "Completed initialisation");
LogMessage("Telescope", $"Driver version: {DriverVersion}");
}
@@ -151,6 +154,7 @@ namespace ASCOM.Meade.net
LogMessage("SupportedActions Get", "Returning empty arraylist");
var supportedActions = new ArrayList();
supportedActions.Add("handbox");
supportedActions.Add("site");
return supportedActions;
}
}
@@ -233,7 +237,71 @@ namespace ASCOM.Meade.net
LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters);
throw new ActionNotImplementedException($"{actionName}({actionParameters})");
}
break;
case "site":
var parames = actionParameters.ToLower().Split(' ');
switch (parames[0])
{
case "select":
switch (parames[1])
{
case "1":
case "2":
case "3":
case "4":
SelectSite(parames[1].ToInteger());
break;
default:
LogMessage("", "Action {0}, parameters {1} not implemented", actionName,
actionParameters);
throw new InvalidValueException(
$"Site {actionParameters} not allowed, must be between 1 and 4");
}
break;
case "getname":
switch (parames[1])
{
case "1":
case "2":
case "3":
case "4":
return GetSiteName(parames[1].ToInteger());
default:
LogMessage("", "Action {0}, parameters {1} not implemented", actionName,
actionParameters);
throw new InvalidValueException(
$"Site {actionParameters} not allowed, must be between 1 and 4");
}
break;
case "setname":
switch (parames[1])
{
case "1":
case "2":
case "3":
case "4":
var sitename = actionParameters.Substring(actionParameters.Position(' ', 2)).Trim();
SetSiteName(parames[1].ToInteger(), sitename);
break;
default:
LogMessage("", "Action {0}, parameters {1} not implemented", actionName,
actionParameters);
throw new InvalidValueException(
$"Site {actionParameters} not allowed, must be between 1 and 4");
}
break;
default:
throw new InvalidValueException(
$"Site parameters {actionParameters} not known");
}
break;
default:
LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters);
throw new ActionNotImplementedException($"{actionName}");
@@ -299,9 +367,11 @@ namespace ASCOM.Meade.net
if (value)
{
LogMessage("Connected Set", "Connecting to port {0}", _comPort);
try
{
ReadProfile();
LogMessage("Connected Set", "Connecting to port {0}", _comPort);
_sharedResourcesWrapper.Connect("Serial");
try
{
@@ -315,6 +385,12 @@ namespace ASCOM.Meade.net
LogMessage("Connected Set", $"New Pulse Guiding Supported: {_userNewerPulseGuiding}");
IsConnected = true;
if (CanSetGuideRates)
{
SetNewGuideRate( _guideRate, "Connect" );
}
}
catch (Exception)
{
@@ -338,11 +414,25 @@ namespace ASCOM.Meade.net
public bool IsNewPulseGuidingSupported()
{
if (_sharedResourcesWrapper.ProductName == _sharedResourcesWrapper.Autostar497)
if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497)
{
return FirmwareIsGreaterThan(_sharedResourcesWrapper.Autostar49731Ee);
return FirmwareIsGreaterThan(TelescopeList.Autostar497_31Ee);
}
if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
{
return true;
}
return false;
}
private bool IsGuideRateSettingSupported()
{
if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
{
return true;
}
return false;
}
@@ -376,9 +466,10 @@ namespace ASCOM.Meade.net
});
}
//todo hook this up to a custom action
public void SelectSite(int site)
{
CheckConnected("SelectSite");
if (site < 1)
throw new ArgumentOutOfRangeException("site",site,"Site cannot be lower than 1");
else if (site > 4)
@@ -390,6 +481,96 @@ namespace ASCOM.Meade.net
//Returns: Nothing
}
private void SetSiteName(int site, string sitename)
{
CheckConnected("SetSiteName");
if (site < 1)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1");
else if (site > 4)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4");
string command = String.Empty;
switch (site)
{
case 1:
command = $":SM{sitename}#";
//:SM<string>#
//Set site 1s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
// Returns:
//0 Invalid
//1 - Valid
break;
case 2:
command = $":SN{sitename}#";
//:SN<string>#
//Set site 2s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
// Returns:
//0 Invalid
//1 - Valid
break;
case 3:
command = $":SO{sitename}#";
//:SO<string>#
//Set site 3s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
// Returns:
//0 Invalid
//1 - Valid
break;
case 4:
command = $":SP{sitename}#";
//:SP<string>#
//Set site 4s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
// Returns:
//0 Invalid
//1 - Valid
break;
}
var result = _sharedResourcesWrapper.SendChar(command);
if (result != "1")
{
throw new InvalidOperationException("Failed to set site name.");
}
}
private string GetSiteName(int site)
{
CheckConnected("GetSiteName");
if (site < 1)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1");
else if (site > 4)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4");
switch (site)
{
case 1:
return _sharedResourcesWrapper.SendString(":GM#");
//:GM# Get Site 1 Name
//Returns: <string>#
//A # terminated string with the name of the requested site.
case 2:
return _sharedResourcesWrapper.SendString(":GN#");
//:GN# Get Site 2 Name
//Returns: <string>#
//A # terminated string with the name of the requested site.
case 3:
return _sharedResourcesWrapper.SendString(":GO#");
//:GO# Get Site 3 Name
//Returns: <string>#
//A # terminated string with the name of the requested site.
case 4:
return _sharedResourcesWrapper.SendString(":GP#");
//:GP# Get Site 4 Name
//Returns: <string>#
//A # terminated string with the name of the requested site.
}
throw new ArgumentOutOfRangeException("site", site, "Site out of range");
}
public string Description
{
// TODO customise this device description
@@ -416,7 +597,7 @@ namespace ASCOM.Meade.net
get
{
Version version = Assembly.GetExecutingAssembly().GetName().Version;
string driverVersion = $"{version.Major}.{version.Minor}.{version.Revision}.{version.Build}";
string driverVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
LogMessage("DriverVersion Get", driverVersion);
return driverVersion;
}
@@ -489,7 +670,7 @@ namespace ASCOM.Meade.net
//P If scope in Polar Mode
//todo implement GW Command - Supported in Autostar 43Eg and above
//if FirmwareIsGreaterThan(_sharedResourcesWrapper.AUTOSTAR497_43EG)
//if FirmwareIsGreaterThan(TelescopeList.Autostar497_43EG)
//{
//var alignmentString = SerialPort.CommandTerminated(":GW#", "#");
//:GW# Get Scope Alignment Status
@@ -525,7 +706,7 @@ namespace ASCOM.Meade.net
CheckConnected("AlignmentMode Set");
//todo tidy this up into a better solution that means can :GW#, :AL#, :AA#, & :AP# and checked for Autostar properly
if (!FirmwareIsGreaterThan(_sharedResourcesWrapper.Autostar49743Eg))
if (!FirmwareIsGreaterThan(TelescopeList.Autostar497_43Eg))
throw new PropertyNotImplementedException("AlignmentMode",true );
//todo make this only try with Autostar 43Eg and above.
@@ -716,8 +897,12 @@ namespace ASCOM.Meade.net
{
get
{
LogMessage("CanSetGuideRates", "Get - " + false.ToString());
return false;
CheckConnected("CanSetGuideRates Get");
var canSetGuideRate = IsGuideRateSettingSupported();
LogMessage("CanSetGuideRates", "Get - " + canSetGuideRate.ToString());
return canSetGuideRate;
}
}
@@ -898,31 +1083,71 @@ namespace ASCOM.Meade.net
}
}
private void SetNewGuideRate(double value, string propertyName)
{
if (!IsGuideRateSettingSupported())
{
LogMessage($"{propertyName} Set", "Not implemented");
throw new PropertyNotImplementedException(propertyName, true);
}
if (!value.InRange(0, 15.0417))
{
throw new InvalidValueException(propertyName, value.ToString(), "0 to 15.0417”/sec");
}
LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString()} arc seconds/second ({value.ToString()} degrees/second)");
_sharedResourcesWrapper.SendBlind($":Rg{value:00.0}#");
//:RgSS.S#
//Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking
//Rates when the CCD guider or handbox guider buttons are pressed when the guide rate is selected.Rate shall not exceed
//sidereal speed(approx 15.0417”/sec)[Autostar II only]
//Returns: Nothing
//info from RickB says that 15.04107 is a better value for
_guideRate = value;
WriteProfile();
}
private double DegreesPerSecondToArcSecondPerSecond(double value)
{
return value * 3600.0;
}
private double ArcSecondPerSecondToDegreesPerSecond(double value)
{
return value / 3600.0;
}
public double GuideRateDeclination
{
get
{
LogMessage("GuideRateDeclination Get", "Not implemented");
throw new PropertyNotImplementedException("GuideRateDeclination", false);
var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate);
LogMessage("GuideRateDeclination Get", $"{_guideRate} arc seconds / second = {degreesPerSecond} degrees per second");
return degreesPerSecond;
}
set
{
LogMessage("GuideRateDeclination Set", "Not implemented");
throw new PropertyNotImplementedException("GuideRateDeclination", true);
var newValue = DegreesPerSecondToArcSecondPerSecond(value);
SetNewGuideRate(newValue, "GuideRateDeclination");
}
}
public double GuideRateRightAscension
{
get
{
LogMessage("GuideRateRightAscension Get", "Not implemented");
throw new PropertyNotImplementedException("GuideRateRightAscension", false);
double degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate);
LogMessage("GuideRateRightAscension Get", $"{_guideRate} arc seconds / second = {degreesPerSecond} degrees per second");
return degreesPerSecond;
}
set
{
LogMessage("GuideRateRightAscension Set", "Not implemented");
throw new PropertyNotImplementedException("GuideRateRightAscension", true);
var newValue = DegreesPerSecondToArcSecondPerSecond(value);
SetNewGuideRate(newValue, "GuideRateRightAscension");
}
}
@@ -1075,8 +1300,9 @@ namespace ASCOM.Meade.net
break;
}
if (_userNewerPulseGuiding)
if (_userNewerPulseGuiding && duration < 10000)
{
LogMessage("PulseGuide", $"Using new pulse guiding technique");
_sharedResourcesWrapper.SendBlind($":Mg{d}{duration:0000}#");
//:MgnDDDD#
//:MgsDDDD#
@@ -1086,12 +1312,11 @@ namespace ASCOM.Meade.net
//passed in the command.These commands support serial port driven guiding.
//Returns Nothing
//LX200 Not Supported
//todo implement IsPulseGuiding if WaitForMilliseconds is not needed
_utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed
}
else
{
LogMessage("PulseGuide", $"Using old pulse guiding technique");
_sharedResourcesWrapper.Lock(() =>
{
_sharedResourcesWrapper.SendBlind(":RG#"); //Make sure we are at guide rate
@@ -2020,11 +2245,28 @@ namespace ASCOM.Meade.net
/// </summary>
internal void ReadProfile()
{
var profileProperties = _sharedResourcesWrapper.ReadProfile();
ProfileProperties profileProperties = _sharedResourcesWrapper.ReadProfile();
_tl.Enabled = profileProperties.TraceLogger;
_comPort = profileProperties.ComPort;
_guideRate = profileProperties.GuideRateArcSecondsPerSecond;
LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}");
LogMessage("ReadProfile", $"Com Port: {_comPort}");
LogMessage("ReadProfile", $"Guide Rate: {_guideRate}");
}
internal void WriteProfile()
{
var profileProperties = new ProfileProperties
{
TraceLogger = _tl.Enabled,
ComPort = _comPort,
GuideRateArcSecondsPerSecond = _guideRate
};
_sharedResourcesWrapper.WriteProfile(profileProperties);
}
/// <summary>
/// Log helper function that takes formatted strings and arguments
/// </summary>
+8 -3
View File
@@ -74,14 +74,15 @@ namespace ASCOM.Meade.net
private void Initialise()
{
Tl = new TraceLogger("", "Meade.net.focusser");
//todo move the TraceLogger out to a factory class.
Tl = new TraceLogger("", "Meade.Generic.focusser");
Tl.LogMessage("Focuser", "Starting initialisation");
ReadProfile(); // Read device configuration from the ASCOM Profile store
IsConnected = false; // Initialise connected to false
Tl.LogMessage("Focuser", "Completed initialisation");
LogMessage("Focuser", "Completed initialisation");
LogMessage("Focuser", $"Driver version: {DriverVersion}");
}
@@ -177,6 +178,7 @@ namespace ASCOM.Meade.net
{
try
{
ReadProfile();
_sharedResourcesWrapper.Connect("Serial");
try
{
@@ -578,6 +580,9 @@ namespace ASCOM.Meade.net
var profileProperties = _sharedResourcesWrapper.ReadProfile();
Tl.Enabled = profileProperties.TraceLogger;
_comPort = profileProperties.ComPort;
LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}");
LogMessage("ReadProfile", $"Com Port: {_comPort}");
}
/// <summary>
-1
View File
@@ -112,7 +112,6 @@ namespace ASCOM.Meade.net
private readonly Type _mClassType;
private Guid _mClassId;
private readonly ArrayList _mInterfaceTypes;
private UInt32 _mLocked = 0;
private uint _mCookie;
private readonly string _mProgid;
-2
View File
@@ -9,14 +9,12 @@ namespace ASCOM.Meade.net
class GarbageCollection
{
private bool _mbContinueThread;
private bool _mGcWatchStopped;
private readonly int _miInterval;
private readonly ManualResetEvent _mEventThreadEnded;
public GarbageCollection(int iInterval)
{
_mbContinueThread = true;
_mGcWatchStopped = false;
_miInterval = iInterval;
_mEventThreadEnded = new ManualResetEvent(false);
}
+1
View File
@@ -133,6 +133,7 @@
<Compile Include="LocalServer.cs" />
<Compile Include="ProfileProperties.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TelescopeList.cs" />
<Compile Include="Wrapper\SharedResourcesWrapper.cs" />
<EmbeddedResource Include="frmMain.resx">
<SubType>Designer</SubType>
+1
View File
@@ -5,5 +5,6 @@ namespace ASCOM.Meade.net
// properies that are part of the profile
public string ComPort { get; set; }
public bool TraceLogger { get; set; }
public double GuideRateArcSecondsPerSecond { get; set; }
}
}
+42 -4
View File
@@ -5,7 +5,7 @@ using System.Windows.Forms;
namespace ASCOM.Meade.net
{
[ComVisible(false)] // Form not registered for COM!
[ComVisible(false)] // Form not registered for COM!
public partial class SetupDialogForm : Form
{
public SetupDialogForm()
@@ -33,19 +33,22 @@ namespace ASCOM.Meade.net
{
MessageBox.Show(other.Message);
}
}
}
public void SetProfile(ProfileProperties profileProperties)
{
chkTrace.Checked = profileProperties.TraceLogger;
// set the list of com ports to those that are currently available
comboBoxComPort.Items.Clear();
comboBoxComPort.Items.AddRange(System.IO.Ports.SerialPort.GetPortNames()); // use System.IO because it's static
comboBoxComPort.Items.AddRange(System.IO.Ports.SerialPort
.GetPortNames()); // use System.IO because it's static
// select the current port if possible
if (comboBoxComPort.Items.Contains(profileProperties.ComPort))
{
comboBoxComPort.SelectedItem = profileProperties.ComPort;
}
txtGuideRate.Text = profileProperties.GuideRateArcSecondsPerSecond.ToString();
}
public ProfileProperties GetProfile()
@@ -53,7 +56,8 @@ namespace ASCOM.Meade.net
var profileProperties = new ProfileProperties
{
TraceLogger = chkTrace.Checked,
ComPort = comboBoxComPort.SelectedItem.ToString()
ComPort = comboBoxComPort.SelectedItem.ToString(),
GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim())
};
return profileProperties;
@@ -63,5 +67,39 @@ namespace ASCOM.Meade.net
{
Activate();
}
private bool _guideRateValid = true;
private void TextBox1_TextChanged(object sender, EventArgs e)
{
//const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second
try
{
double newGuideRate = double.Parse(txtGuideRate.Text.Trim());
const double siderealArcSecondsPerSecond = 15.041;
var percentOfSideReal = (newGuideRate / siderealArcSecondsPerSecond * 100);
lblPercentOfSiderealRate.Text = $"({percentOfSideReal:00.0}% of sidereal rate)";
_guideRateValid = true;
}
catch (Exception exception)
{
//Surpressing this exception as if the value is not valid then it's not useful.
_guideRateValid = false;
}
UpdateOKButton();
}
private void UpdateOKButton()
{
cmdOK.Enabled = _guideRateValid && (comboBoxComPort.SelectedItem != null);
}
private void ComboBoxComPort_SelectedValueChanged(object sender, EventArgs e)
{
UpdateOKButton();
}
}
}
+34
View File
@@ -36,6 +36,10 @@ namespace ASCOM.Meade.net
this.label2 = new System.Windows.Forms.Label();
this.chkTrace = new System.Windows.Forms.CheckBox();
this.comboBoxComPort = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.txtGuideRate = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.lblPercentOfSiderealRate = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit();
this.SuspendLayout();
//
@@ -85,11 +89,37 @@ namespace ASCOM.Meade.net
this.comboBoxComPort.FormattingEnabled = true;
resources.ApplyResources(this.comboBoxComPort, "comboBoxComPort");
this.comboBoxComPort.Name = "comboBoxComPort";
this.comboBoxComPort.SelectedValueChanged += new System.EventHandler(this.ComboBoxComPort_SelectedValueChanged);
//
// label3
//
resources.ApplyResources(this.label3, "label3");
this.label3.Name = "label3";
//
// txtGuideRate
//
resources.ApplyResources(this.txtGuideRate, "txtGuideRate");
this.txtGuideRate.Name = "txtGuideRate";
this.txtGuideRate.TextChanged += new System.EventHandler(this.TextBox1_TextChanged);
//
// label4
//
resources.ApplyResources(this.label4, "label4");
this.label4.Name = "label4";
//
// lblPercentOfSiderealRate
//
resources.ApplyResources(this.lblPercentOfSiderealRate, "lblPercentOfSiderealRate");
this.lblPercentOfSiderealRate.Name = "lblPercentOfSiderealRate";
//
// SetupDialogForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.lblPercentOfSiderealRate);
this.Controls.Add(this.label4);
this.Controls.Add(this.txtGuideRate);
this.Controls.Add(this.label3);
this.Controls.Add(this.comboBoxComPort);
this.Controls.Add(this.chkTrace);
this.Controls.Add(this.label2);
@@ -118,5 +148,9 @@ namespace ASCOM.Meade.net
private System.Windows.Forms.Label label2;
private System.Windows.Forms.CheckBox chkTrace;
private System.Windows.Forms.ComboBox comboBoxComPort;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtGuideRate;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label lblPercentOfSiderealRate;
}
}
+114 -9
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, 112</value>
<value>281, 225</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>6</value>
<value>10</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, 142</value>
<value>281, 255</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>5</value>
<value>9</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>4</value>
<value>8</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>3</value>
<value>7</value>
</data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -250,7 +250,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>2</value>
<value>6</value>
</data>
<data name="chkTrace.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -277,7 +277,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;chkTrace.ZOrder" xml:space="preserve">
<value>1</value>
<value>5</value>
</data>
<data name="comboBoxComPort.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 87</value>
@@ -298,6 +298,111 @@
<value>$this</value>
</data>
<data name="&gt;&gt;comboBoxComPort.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="label3.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label3.Location" type="System.Drawing.Point, System.Drawing">
<value>13, 225</value>
</data>
<data name="label3.Size" type="System.Drawing.Size, System.Drawing">
<value>61, 13</value>
</data>
<data name="label3.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="label3.Text" xml:space="preserve">
<value>Guide Rate</value>
</data>
<data name="&gt;&gt;label3.Name" xml:space="preserve">
<value>label3</value>
</data>
<data name="&gt;&gt;label3.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;label3.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label3.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="txtGuideRate.Location" type="System.Drawing.Point, System.Drawing">
<value>80, 222</value>
</data>
<data name="txtGuideRate.Size" type="System.Drawing.Size, System.Drawing">
<value>46, 20</value>
</data>
<data name="txtGuideRate.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="txtGuideRate.Text" xml:space="preserve">
<value>10.0</value>
</data>
<data name="&gt;&gt;txtGuideRate.Name" xml:space="preserve">
<value>txtGuideRate</value>
</data>
<data name="&gt;&gt;txtGuideRate.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;txtGuideRate.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;txtGuideRate.ZOrder" xml:space="preserve">
<value>2</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>132, 225</value>
</data>
<data name="label4.Size" type="System.Drawing.Size, System.Drawing">
<value>122, 13</value>
</data>
<data name="label4.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
</data>
<data name="label4.Text" xml:space="preserve">
<value>Arc seconds per second</value>
</data>
<data name="&gt;&gt;label4.Name" xml:space="preserve">
<value>label4</value>
</data>
<data name="&gt;&gt;label4.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;label4.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label4.ZOrder" xml:space="preserve">
<value>1</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>132, 238</value>
</data>
<data name="lblPercentOfSiderealRate.Size" type="System.Drawing.Size, System.Drawing">
<value>105, 13</value>
</data>
<data name="lblPercentOfSiderealRate.TabIndex" type="System.Int32, mscorlib">
<value>11</value>
</data>
<data name="lblPercentOfSiderealRate.Text" xml:space="preserve">
<value>(67% of sidereal rate)</value>
</data>
<data name="&gt;&gt;lblPercentOfSiderealRate.Name" xml:space="preserve">
<value>lblPercentOfSiderealRate</value>
</data>
<data name="&gt;&gt;lblPercentOfSiderealRate.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;lblPercentOfSiderealRate.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;lblPercentOfSiderealRate.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">
@@ -307,7 +412,7 @@
<value>6, 13</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>350, 175</value>
<value>350, 288</value>
</data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterScreen</value>
+6 -4
View File
@@ -158,6 +158,7 @@ namespace ASCOM.Meade.net
// Constants used for Profile persistence
private const string ComPortProfileName = "COM Port";
private const string TraceStateProfileName = "Trace Level";
private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second";
public static void WriteProfile(ProfileProperties profileProperties)
{
@@ -168,12 +169,14 @@ namespace ASCOM.Meade.net
driverProfile.DeviceType = "Telescope";
driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString());
driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort);
driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString());
}
}
}
private const string ComPortDefault = "COM1";
private const string TraceStateDefault = "false";
private const string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
public static ProfileProperties ReadProfile()
{
@@ -183,10 +186,9 @@ namespace ASCOM.Meade.net
using (Profile driverProfile = new Profile())
{
driverProfile.DeviceType = "Telescope";
profileProperties.ComPort =
driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault);
profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId,
TraceStateProfileName, string.Empty, TraceStateDefault));
profileProperties.ComPort = driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault);
profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault));
profileProperties.GuideRateArcSecondsPerSecond = double.Parse(driverProfile.GetValue(DriverId, GuideRateProfileName, string.Empty, GuideRateProfileNameDefault));
}
return profileProperties;
+30
View File
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
namespace ASCOM.Meade.net
{
public static class TelescopeList
{
#region Autostar 497/Audiostar
public readonly static string Autostar497 = "Autostar";
//Autostar/Audiostar firmware revisions
public readonly static string Autostar497_30Ee = "30Ee";
public readonly static string Autostar497_31Ee = "31Ee";
public readonly static string Autostar497_43Eg = "43Eg";
#endregion
#region LX200GPS
public readonly static string LX200GPS = "LX2001";
public readonly static string LX200GPS_42G = "4.2G";
#endregion
}
}
+6 -14
View File
@@ -4,11 +4,6 @@ namespace ASCOM.Meade.net.Wrapper
{
public interface ISharedResourcesWrapper
{
string Autostar497 { get; }
string Autostar49731Ee { get; }
string Autostar49743Eg { get;}
void Connect(string deviceId);
void Disconnect(string deviceId);
@@ -28,19 +23,11 @@ namespace ASCOM.Meade.net.Wrapper
ProfileProperties ReadProfile();
void SetupDialog();
void WriteProfile(ProfileProperties profileProperties);
}
public class SharedResourcesWrapper : ISharedResourcesWrapper
{
#region AutostarProducts
public string Autostar497 => "Autostar";
public string Autostar49731Ee => "31Ee";
public string Autostar49743Eg => "43Eg";
#endregion
public void Connect(string deviceId)
{
SharedResources.Connect( deviceId);
@@ -94,5 +81,10 @@ namespace ASCOM.Meade.net.Wrapper
{
SharedResources.SetupDialog();
}
public void WriteProfile(ProfileProperties profileProperties)
{
SharedResources.WriteProfile(profileProperties);
}
}
}
@@ -16,7 +16,7 @@
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>