Merged in develop (pull request #26)

Version 1.0.0
This commit is contained in:
2021-03-02 20:31:32 +00:00
17 changed files with 459 additions and 83 deletions
-1
View File
@@ -218,5 +218,4 @@ _Pvt_Extensions
# nCrunch items
*.ncrunchsolution
*.DotSettings
*.ncrunchproject
@@ -1,4 +1,5 @@
using System;
using System.Globalization;
using System.Reflection;
using ASCOM;
using ASCOM.Astrometry.AstroUtils;
@@ -22,6 +23,7 @@ namespace Meade.net.Telescope.UnitTests
private Mock<IAstroUtils> _astroUtilsMock;
private Mock<ISharedResourcesWrapper> _sharedResourcesWrapperMock;
private Mock<IAstroMaths> _astroMathsMock;
private Mock<IClock> _clockMock;
private ProfileProperties _profileProperties;
private ConnectionInfo _connectionInfo;
@@ -63,8 +65,10 @@ namespace Meade.net.Telescope.UnitTests
_astroMathsMock = new Mock<IAstroMaths>();
_clockMock = new Mock<IClock>();
_telescope = new ASCOM.Meade.net.Telescope(_utilMock.Object, _utilExtraMock.Object, _astroUtilsMock.Object,
_sharedResourcesWrapperMock.Object, _astroMathsMock.Object);
_sharedResourcesWrapperMock.Object, _astroMathsMock.Object, _clockMock.Object);
}
private void ConnectTelescope(string productName = TelescopeList.Autostar497, string firmwareVersion = TelescopeList.Autostar497_31Ee)
@@ -1459,6 +1463,53 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Q{d}#"));
}
[TestCase(GuideDirections.guideEast)]
[TestCase(GuideDirections.guideWest)]
[TestCase(GuideDirections.guideNorth)]
[TestCase(GuideDirections.guideSouth)]
public void PulseGuide_WhenConnectedAndNewerPulseGuidingNotAvailable_ThenSendsOldCommandsAndDoesNotWaitForExtraSettleTime(GuideDirections direction)
{
short slewSettleTime = 10;
_profileProperties.SettleTime = slewSettleTime;
var telescopeDecResult = "s12*3456";
var dmsResult = 1.2;
var telescopeRaResult = "HH:MM:SS";
var hmsResult = 1.3;
_sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#")).Returns(telescopeDecResult);
_sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
_utilMock.Setup(x => x.DMSToDegrees(telescopeDecResult)).Returns(dmsResult);
_utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
var duration = 0;
_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)
{
case GuideDirections.guideEast:
d = "e";
break;
case GuideDirections.guideWest:
d = "w";
break;
case GuideDirections.guideNorth:
d = "n";
break;
case GuideDirections.guideSouth:
d = "s";
break;
}
_clockMock.Verify(x => x.UtcNow, Times.Never);
}
[TestCase(GuideDirections.guideEast)]
[TestCase(GuideDirections.guideWest)]
[TestCase(GuideDirections.guideNorth)]
@@ -1633,25 +1684,51 @@ namespace Meade.net.Telescope.UnitTests
}
[Test]
public void SlewSettleTime_Get_ThenThrowsException()
public void SlewSettleTime_Get_WhenNotConnected_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() =>
var exception = Assert.Throws<NotConnectedException>(() =>
{
var result = _telescope.SlewSettleTime;
Assert.Fail($"{result} should not have returned");
});
Assert.That(excpetion.Property, Is.EqualTo("SlewSettleTime"));
Assert.That(excpetion.AccessorSet, Is.False);
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SlewSettleTime Get"));
}
[Test]
public void SlewSettleTime_Set_ThenThrowsException()
public void SlewSettleTime_Set_WhenNotConnected_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.SlewSettleTime = 0; });
var exception = Assert.Throws<NotConnectedException>(() =>
{
_telescope.SlewSettleTime = 13;
Assert.Fail($"should not have returned");
});
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SlewSettleTime Set"));
}
Assert.That(excpetion.Property, Is.EqualTo("SlewSettleTime"));
Assert.That(excpetion.AccessorSet, Is.True);
[Test]
public void SlewSettleTime_Get_ReturnsExpectedValue()
{
ConnectTelescope();
var result = _telescope.SlewSettleTime;
Assert.That(result, Is.EqualTo(0));
}
[TestCase(8)]
[TestCase(12)]
[TestCase(3)]
public void SlewSettleTime_Set_ThenReturnsNewSettleTime(short settleTime)
{
_profileProperties.SettleTime = 0;
ConnectTelescope();
_telescope.SlewSettleTime = settleTime;
var result = _telescope.SlewSettleTime;
Assert.That(result, Is.EqualTo(settleTime));
}
[Test]
@@ -2310,6 +2387,64 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Verify(x => x.SendString(":D#"),Times.Once);
}
[TestCase(0, 0, "2021-10-03T20:36:00", "2021-10-03T20:36:01", false)]
[TestCase(5, 0, "2021-10-03T20:36:00", "2021-10-03T20:36:01", true)]
[TestCase(5, 0, "2021-10-03T20:36:00", "2021-10-03T20:36:06", false)]
[TestCase(10, 0, "2021-10-03T20:36:00", "2021-10-03T20:36:06", true)]
[TestCase(10, 0, "2021-10-03T20:36:00", "2021-10-03T20:36:09", true)]
[TestCase(10, 0, "2021-10-03T20:36:00", "2021-10-03T20:36:10", false)]
[TestCase(0, 5, "2021-10-03T20:36:00", "2021-10-03T20:36:01", true)]
[TestCase(0, 5, "2021-10-03T20:36:00", "2021-10-03T20:36:05", false)]
[TestCase(0, 10, "2021-10-03T20:36:00", "2021-10-03T20:36:05", true)]
[TestCase(0, 10, "2021-10-03T20:36:00", "2021-10-03T20:36:10", false)]
[TestCase(15, 10, "2021-10-03T20:36:00", "2021-10-03T20:36:10", true)]
[TestCase(15, 10, "2021-10-03T20:36:00", "2021-10-03T20:36:24", true)]
[TestCase(15, 10, "2021-10-03T20:36:00", "2021-10-03T20:36:25", false)]
public void Slewing_WhenTelescopeIsSlewing_ThenReturnsExpectedValueForSettleTime( short settleTime, short profileSettleTime, string startSlewing, string endSlewing, bool isSlewing)
{
_profileProperties.SettleTime = profileSettleTime;
var timescalled = 0;
DateTime startSlewingDateTime = DateTime.ParseExact(startSlewing, "yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture);
DateTime endSlewingDatetime = DateTime.ParseExact(endSlewing, "yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture);
_clockMock.Setup(x => x.UtcNow).Returns(() =>
{
if (timescalled == 0)
{
timescalled++;
return startSlewingDateTime;
}
return endSlewingDatetime;
});
var slewingText = "|";
var notSlewingText = String.Empty;
_sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns( () =>
{
if (timescalled == 0)
{
return slewingText;
}
return notSlewingText;
});
ConnectTelescope();
_telescope.SlewSettleTime = settleTime;
var result = _telescope.Slewing;
Assert.That(result, Is.EqualTo(true));
result = _telescope.Slewing;
Assert.That(result, Is.EqualTo(isSlewing));
}
[TestCase(TelescopeList.LX200CLASSIC,"","|", true)]
[TestCase(TelescopeList.LX200CLASSIC, "", "||||||||", true)]
[TestCase(TelescopeList.LX200CLASSIC, "", "", false)]
@@ -2351,6 +2486,60 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Verify(x => x.SendString(":D#"), Times.Never);
}
[TestCase(1, TelescopeAxes.axisPrimary, 0, 0, false, false)]
[TestCase(-1, TelescopeAxes.axisPrimary, 0, 0, false, false)]
[TestCase(1, TelescopeAxes.axisSecondary, 0, 0, false, false)]
[TestCase(-1, TelescopeAxes.axisSecondary, 0, 0, false, false)]
[TestCase(1, TelescopeAxes.axisPrimary, 10, 0, true, false)]
[TestCase(-1, TelescopeAxes.axisPrimary, 10, 0, true, false)]
[TestCase(1, TelescopeAxes.axisSecondary, 10, 0, true, false)]
[TestCase(-1, TelescopeAxes.axisSecondary, 10, 0, true, false)]
[TestCase(1, TelescopeAxes.axisPrimary, 10, 20, true, true)]
[TestCase(-1, TelescopeAxes.axisPrimary, 10, 20, true, true)]
[TestCase(1, TelescopeAxes.axisSecondary, 10, 20, true, true)]
[TestCase(-1, TelescopeAxes.axisSecondary, 10, 20, true, true)]
public void Slewing_WhenTelescopeStops_ThenWaitsForSettleTime(int rate, TelescopeAxes axis, short profileSettleTime, short driverSettleTime, bool expectedResultInWaitingPeriod, bool afterProfileSettleTimeUp)
{
_profileProperties.SettleTime = profileSettleTime;
DateTime currentTime = MakeTime("2021-01-23T22:02:10");
_clockMock.Setup(x => x.UtcNow).Returns(() => currentTime );
ConnectTelescope();
_telescope.SlewSettleTime = driverSettleTime;
_telescope.MoveAxis(axis, rate);
var result = _telescope.Slewing;
Assert.That(result, Is.True);
_telescope.MoveAxis(axis, 0);
currentTime = currentTime + TimeSpan.FromSeconds(profileSettleTime / 2);
result = _telescope.Slewing;
Assert.That(result, Is.EqualTo(expectedResultInWaitingPeriod));
currentTime = currentTime + TimeSpan.FromSeconds(profileSettleTime / 2);
result = _telescope.Slewing;
Assert.That(result, Is.EqualTo(afterProfileSettleTimeUp));
currentTime = currentTime + TimeSpan.FromSeconds(driverSettleTime);
result = _telescope.Slewing;
Assert.That(result, Is.False);
}
private DateTime MakeTime( string dateTimeString )
{
return DateTime.ParseExact(dateTimeString, "yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture);
}
[Test]
public void SlewToTargetAsync_WhenNotConnected_ThenThrowsException()
@@ -58,7 +58,7 @@ namespace ASCOM.Meade.net.AstroMaths
t0 -= 24;
}
var ut = DateTimeToDecimalHours(utcDateTime);
var ut = utcDateTime.DateTimeToDecimalHours();
var a = ut * 1.002737909;
var t1 = t0 + a;
+9
View File
@@ -0,0 +1,9 @@
using System;
namespace ASCOM.Meade.net
{
public class Clock : IClock
{
public DateTime UtcNow => DateTime.UtcNow;
}
}
+9
View File
@@ -0,0 +1,9 @@
using System;
namespace ASCOM.Meade.net
{
public interface IClock
{
DateTime UtcNow { get; }
}
}
@@ -124,8 +124,10 @@
<Compile Include="AstroMaths\EquatorialCoordinates.cs" />
<Compile Include="AstroMaths\HorizonCoordinates.cs" />
<Compile Include="AstroMaths\IAstroMaths.cs" />
<Compile Include="Clock.cs" />
<Compile Include="ComparisonResult.cs" />
<Compile Include="DoubleExtensions.cs" />
<Compile Include="IClock.cs" />
<Compile Include="StringExtensions.cs" />
<Compile Include="Telescope.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+57 -28
View File
@@ -60,16 +60,20 @@ namespace ASCOM.Meade.net
private readonly IAstroMaths _astroMaths;
private readonly IClock _clock;
/// <summary>
/// Private variable to hold number of decimals for RA
/// </summary>
private int _digitsRa = 2;
/// <summary>
/// Private variable to hold number of decimals for DE
/// Private variable to hold number of decimals for Dec
/// </summary>
private int _digitsDe = 2;
private short _settleTime;
/// <summary>
/// Initializes a new instance of the <see cref="Meade.net"/> class.
/// Must be public for COM registration.
@@ -84,6 +88,7 @@ namespace ASCOM.Meade.net
_utilitiesExtra = util; //Initialise util object
_astroUtilities = new AstroUtils(); // Initialise astro utilities object
_astroMaths = new AstroMaths.AstroMaths();
_clock = new Clock();
Initialise(nameof(Telescope));
}
@@ -116,8 +121,9 @@ namespace ASCOM.Meade.net
sb.AppendLine();
}
public Telescope( IUtil util, IUtilExtra utilExtra, IAstroUtils astroUtilities, ISharedResourcesWrapper sharedResourcesWrapper, IAstroMaths astroMaths) : base(sharedResourcesWrapper)
public Telescope( IUtil util, IUtilExtra utilExtra, IAstroUtils astroUtilities, ISharedResourcesWrapper sharedResourcesWrapper, IAstroMaths astroMaths, IClock clock) : base(sharedResourcesWrapper)
{
_clock = clock;
_utilities = util; //Initialise util object
_utilitiesExtra = utilExtra; //Initialise util object
_astroUtilities = astroUtilities; // Initialise astro utilities object
@@ -813,6 +819,7 @@ namespace ASCOM.Meade.net
_movingPrimary = false;
_movingSecondary = false;
SetSlewingMinEndTime();
}
public AlignmentModes AlignmentMode
@@ -1377,6 +1384,11 @@ namespace ASCOM.Meade.net
switch (rate.Compare(0))
{
case ComparisonResult.Equals:
if (!_isGuiding)
{
SetSlewingMinEndTime();
}
_movingPrimary = false;
SharedResourcesWrapper.SendBlind(":Qe#");
//:Qe# Halt eastward Slews
@@ -1386,7 +1398,6 @@ namespace ASCOM.Meade.net
//Returns: Nothing
break;
case ComparisonResult.Greater:
SharedResourcesWrapper.SendBlind(":Me#");
//:Me# Move Telescope East at current slew rate
//Returns: Nothing
@@ -1404,6 +1415,10 @@ namespace ASCOM.Meade.net
switch (rate.Compare(0))
{
case ComparisonResult.Equals:
if (!_isGuiding)
{
SetSlewingMinEndTime();
}
_movingSecondary = false;
SharedResourcesWrapper.SendBlind(":Qn#");
//:Qn# Halt northward Slews
@@ -1424,9 +1439,7 @@ namespace ASCOM.Meade.net
//Returns: Nothing
_movingSecondary = true;
break;
}
break;
default:
throw new InvalidValueException("Can not move this axis.");
@@ -1554,7 +1567,7 @@ namespace ASCOM.Meade.net
/// <summary>
/// convert a HH:MM.T (classic LX200 RA Notation) string to a double hours. T is the decimal part of minutes which is converted into seconds
/// </summary>
public double HMToHours(string hm)
public double HmToHours(string hm)
{
var token = hm.Split('.');
if (token.Length != 2)
@@ -1575,7 +1588,7 @@ namespace ASCOM.Meade.net
//Returns: HH:MM.T# or HH:MM:SS#
//Depending which precision is set for the telescope
double rightAscension = HMToHours(result);
double rightAscension = HmToHours(result);
LogMessage("RightAscension", $"Get - {result} convert to {rightAscension} {_utilitiesExtra.HoursToHMS(rightAscension)}");
return rightAscension;
@@ -1660,7 +1673,7 @@ namespace ASCOM.Meade.net
CheckConnected("SiteElevation Set");
LogMessage("SiteElevation", $"Set: {value}");
if (value == base.SiteElevation)
if (Math.Abs(value - base.SiteElevation) < 0.1)
{
LogMessage("SiteElevation", $"Set: no change detected");
return;
@@ -1774,14 +1787,15 @@ namespace ASCOM.Meade.net
{
get
{
LogMessage("SlewSettleTime Get", "Not implemented");
throw new PropertyNotImplementedException("SlewSettleTime", false);
CheckConnected("SlewSettleTime Get");
LogMessage("SlewSettleTime Get", $"{_settleTime} Seconds");
return _settleTime;
}
// ReSharper disable once ValueParameterNotUsed
set
{
LogMessage("SlewSettleTime Set", "Not implemented");
throw new PropertyNotImplementedException("SlewSettleTime", true);
CheckConnected("SlewSettleTime Set");
LogMessage("SlewSettleTime Set", $"Setting from {_settleTime} to {value}");
_settleTime = value;
}
}
@@ -1859,6 +1873,7 @@ namespace ASCOM.Meade.net
case "0":
//We're slewing everything should be working just fine.
LogMessage("DoSlewAsync", "Slewing to target");
SetSlewingMinEndTime();
break;
case "1":
//Below Horizon
@@ -1894,7 +1909,7 @@ namespace ASCOM.Meade.net
{
throw new InvalidOperationException("fault");
}
SetSlewingMinEndTime();
break;
}
});
@@ -1962,16 +1977,34 @@ namespace ASCOM.Meade.net
return _movingPrimary || _movingSecondary;
}
private DateTime _earliestNonSlewingTime = DateTime.MinValue;
public bool Slewing
{
get
{
var isSlewing = GetSlewing();
if (isSlewing)
SetSlewingMinEndTime();
else if (_clock.UtcNow < _earliestNonSlewingTime)
isSlewing = true;
LogMessage("Slewing", $"Result = {isSlewing}");
return isSlewing;
}
}
private void SetSlewingMinEndTime()
{
_earliestNonSlewingTime = _clock.UtcNow + GetTotalSlewingSettleTime();
}
private TimeSpan GetTotalSlewingSettleTime()
{
return TimeSpan.FromSeconds( SlewSettleTime + ProfileSettleTime );
}
private bool GetSlewing()
{
if (!Connected) return false;
@@ -1999,8 +2032,9 @@ namespace ASCOM.Meade.net
bool isSlewing = false;
try
{
if (string.IsNullOrWhiteSpace(result))
if (string.IsNullOrEmpty(result))
{
// ReSharper disable once RedundantAssignment
isSlewing = false;
return isSlewing;
}
@@ -2073,14 +2107,14 @@ namespace ASCOM.Meade.net
// At least the classic LX200 low precision might not slew to the exact target position
// This Requires to retrieve the aimed target ra de from the telescope
double ra = RightAscension;
if (_targetRightAscension != InvalidParameter &&
if (Math.Abs(_targetRightAscension - InvalidParameter) > 0.1 &&
_utilities.HoursToHMS(ra, ":", ":", ":", _digitsRa) != _utilities.HoursToHMS(_targetRightAscension, ":", ":", ":", _digitsRa))
{
LogMessage("SyncToTarget", $"differ RA real {ra} targeted {_targetRightAscension}");
_targetRightAscension = ra;
}
double de = Declination;
if (_targetDeclination != InvalidParameter &&
if (Math.Abs(_targetDeclination - InvalidParameter) > 0.1 &&
_utilities.DegreesToDMS(de, "*", ":", ":", _digitsDe) != _utilities.DegreesToDMS(_targetDeclination, "*", ":", ":", _digitsDe))
{
LogMessage("SyncToTarget", $"differ DE real {de} targeted {_targetDeclination}");
@@ -2120,11 +2154,9 @@ namespace ASCOM.Meade.net
if (value < -90)
throw new InvalidValueException("Declination cannot be less than -90.");
var dms = "";
if (IsLongFormat)
dms = _utilities.DegreesToDMS(value, "*", ":", ":", _digitsDe);
else
dms = _utilities.DegreesToDM(value, "*", "", _digitsDe);
var dms = IsLongFormat ?
_utilities.DegreesToDMS(value, "*", ":", ":", _digitsDe) :
_utilities.DegreesToDM(value, "*", "", _digitsDe);
var s = value < 0 ? string.Empty : "+";
@@ -2177,12 +2209,9 @@ namespace ASCOM.Meade.net
if (value >= 24)
throw new InvalidValueException("Right ascension value cannot be greater than 23:59:59");
var hms = "";
if(IsLongFormat)
hms = _utilities.HoursToHMS(value, ":", ":", ":", _digitsRa);
else
//meade protocol defines H:MM.T format
hms = _utilities.HoursToHM(value, ":", "", _digitsRa).Replace(',','.');
var hms = IsLongFormat ?
_utilities.HoursToHMS(value, ":", ":", ":", _digitsRa) :
_utilities.HoursToHM(value, ":", "", _digitsRa).Replace(',','.');
var command = $":Sr{hms}#";
LogMessage("TargetRightAscension Set", $"{command}");
+6
View File
@@ -0,0 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/Housekeeping/ExcludedProjects/ProjectMasksToIgnore/=_002A_002A_005C_002A_002EUnitTests/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/Housekeeping/ExcludedProjects/ProjectMasksToIgnore/=_002A_002A_005C_002A_002EUnitTests/@EntryIndexRemoved">True</s:Boolean>
<s:Boolean x:Key="/Default/Housekeeping/ExcludedProjects/ProjectMasksToIgnore/=_002A_002EUnitTests_002E_002A/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ASCOM/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Autostar/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
+16 -11
View File
@@ -337,18 +337,23 @@ namespace ASCOM.Meade.net
{
key?.SetValue(null, progid); // Could be assyTitle/Desc??, but .NET components show ProgId here
key?.SetValue("AppId", _sAppId);
using (RegistryKey key2 = key.CreateSubKey("Implemented Categories"))
if (key != null)
{
key2?.CreateSubKey("{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}");
}
using (RegistryKey key2 = key.CreateSubKey("ProgId"))
{
key2?.SetValue(null, progid);
}
key.CreateSubKey("Programmable");
using (RegistryKey key2 = key.CreateSubKey("LocalServer32"))
{
key2?.SetValue(null, Application.ExecutablePath);
using (RegistryKey key2 = key.CreateSubKey("Implemented Categories"))
{
key2?.CreateSubKey("{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}");
}
using (RegistryKey key2 = key.CreateSubKey("ProgId"))
{
key2?.SetValue(null, progid);
}
key.CreateSubKey("Programmable");
using (RegistryKey key2 = key.CreateSubKey("LocalServer32"))
{
key2?.SetValue(null, Application.ExecutablePath);
}
}
}
//
+3
View File
@@ -27,6 +27,7 @@ namespace ASCOM.Meade.net
protected string Precision;
protected string GuidingStyle;
protected double SiteElevation;
protected short ProfileSettleTime;
protected readonly ISharedResourcesWrapper SharedResourcesWrapper;
@@ -67,6 +68,7 @@ namespace ASCOM.Meade.net
Precision = profileProperties.Precision;
GuidingStyle = profileProperties.GuidingStyle.ToLower();
SiteElevation = profileProperties.SiteElevation;
ProfileSettleTime = profileProperties.SettleTime;
LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}");
LogMessage("ReadProfile", $"Com Port: {ComPort}");
@@ -76,6 +78,7 @@ namespace ASCOM.Meade.net
LogMessage("ReadProfile", $"Precision: {Precision}");
LogMessage("ReadProfile", $"Guiding Style: {GuidingStyle}");
LogMessage("ReadProfile", $"Site Elevation: {SiteElevation}");
LogMessage("ReadProfile", $"Settle Time after slew: {ProfileSettleTime}");
}
/// <summary>
+1
View File
@@ -13,5 +13,6 @@ namespace ASCOM.Meade.net
public bool DynamicBreaking { get; set; }
public bool RtsDtrEnabled { get; set; }
public double SiteElevation { get; set; }
public short SettleTime { get; set; }
}
}
+9
View File
@@ -135,5 +135,14 @@ namespace ASCOM.Meade.net.Properties {
return ResourceManager.GetString("SetupDialogForm_TextBox1_TextChanged___0_00_0___of_sidereal_rate_", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Please enter only numbers..
/// </summary>
internal static string SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_ {
get {
return ResourceManager.GetString("SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_", resourceCulture);
}
}
}
}
+3
View File
@@ -144,4 +144,7 @@ Valid are : -register, -unregister and -embedding</value>
<data name="SetupDialogForm_SetupDialogForm__0__Settings___1__" xml:space="preserve">
<value>{0} Settings ({1})</value>
</data>
<data name="SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_" xml:space="preserve">
<value>Please enter only numbers.</value>
</data>
</root>
+6 -4
View File
@@ -88,6 +88,7 @@ namespace ASCOM.Meade.net
cbxReverseDirection.Checked = profileProperties.ReverseFocusDirection;
cbxDynamicBreaking.Checked = profileProperties.DynamicBreaking;
nudSettleTime.Value = profileProperties.SettleTime;
}
public ProfileProperties GetProfile()
@@ -103,8 +104,9 @@ namespace ASCOM.Meade.net
BacklashCompensation = int.Parse(txtBacklashSteps.Text),
ReverseFocusDirection = cbxReverseDirection.Checked,
DynamicBreaking = cbxDynamicBreaking.Checked,
SiteElevation = double.Parse(txtElevation.Text)
};
SiteElevation = double.Parse(txtElevation.Text),
SettleTime = Convert.ToInt16(nudSettleTime.Value)
};
return profileProperties;
}
@@ -167,7 +169,7 @@ namespace ASCOM.Meade.net
{
if (System.Text.RegularExpressions.Regex.IsMatch(txtElevation.Text, "[^0-9]"))
{
MessageBox.Show("Please enter only numbers.");
MessageBox.Show(Resources.SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_);
txtElevation.Text = txtElevation.Text.Remove(txtElevation.Text.Length - 1);
}
}
@@ -176,7 +178,7 @@ namespace ASCOM.Meade.net
{
if (System.Text.RegularExpressions.Regex.IsMatch(txtBacklashSteps.Text, "[^0-9]"))
{
MessageBox.Show("Please enter only numbers.");
MessageBox.Show(Resources.SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_);
txtBacklashSteps.Text = txtElevation.Text.Remove(txtBacklashSteps.Text.Length - 1);
}
}
+31
View File
@@ -61,7 +61,11 @@ namespace ASCOM.Meade.net
this.label12 = new System.Windows.Forms.Label();
this.txtElevation = new System.Windows.Forms.TextBox();
this.label13 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.nudSettleTime = new System.Windows.Forms.NumericUpDown();
this.label15 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudSettleTime)).BeginInit();
this.SuspendLayout();
//
// cmdOK
@@ -231,10 +235,33 @@ namespace ASCOM.Meade.net
resources.ApplyResources(this.label13, "label13");
this.label13.Name = "label13";
//
// label14
//
resources.ApplyResources(this.label14, "label14");
this.label14.Name = "label14";
//
// nudSettleTime
//
resources.ApplyResources(this.nudSettleTime, "nudSettleTime");
this.nudSettleTime.Maximum = new decimal(new int[] {
32767,
0,
0,
0});
this.nudSettleTime.Name = "nudSettleTime";
//
// label15
//
resources.ApplyResources(this.label15, "label15");
this.label15.Name = "label15";
//
// SetupDialogForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label15);
this.Controls.Add(this.nudSettleTime);
this.Controls.Add(this.label14);
this.Controls.Add(this.label13);
this.Controls.Add(this.txtElevation);
this.Controls.Add(this.label12);
@@ -270,6 +297,7 @@ namespace ASCOM.Meade.net
this.TopMost = true;
this.Shown += new System.EventHandler(this.SetupDialogForm_Shown);
((System.ComponentModel.ISupportInitialize)(this.picASCOM)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudSettleTime)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -305,5 +333,8 @@ namespace ASCOM.Meade.net
private Label label12;
private TextBox txtElevation;
private Label label13;
private Label label14;
private NumericUpDown nudSettleTime;
private Label label15;
}
}
+101 -26
View File
@@ -145,7 +145,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cmdOK.ZOrder" xml:space="preserve">
<value>26</value>
<value>29</value>
</data>
<data name="cmdCancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
@@ -172,7 +172,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cmdCancel.ZOrder" xml:space="preserve">
<value>25</value>
<value>28</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>24</value>
<value>27</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>23</value>
<value>26</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>22</value>
<value>25</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>21</value>
<value>24</value>
</data>
<data name="comboBoxComPort.Location" type="System.Drawing.Point, System.Drawing">
<value>97, 87</value>
@@ -298,7 +298,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;comboBoxComPort.ZOrder" xml:space="preserve">
<value>20</value>
<value>23</value>
</data>
<data name="label3.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -325,7 +325,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label3.ZOrder" xml:space="preserve">
<value>19</value>
<value>22</value>
</data>
<data name="txtGuideRate.Location" type="System.Drawing.Point, System.Drawing">
<value>97, 275</value>
@@ -349,7 +349,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;txtGuideRate.ZOrder" xml:space="preserve">
<value>18</value>
<value>21</value>
</data>
<data name="label4.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -376,7 +376,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label4.ZOrder" xml:space="preserve">
<value>17</value>
<value>20</value>
</data>
<data name="lblPercentOfSiderealRate.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -403,7 +403,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblPercentOfSiderealRate.ZOrder" xml:space="preserve">
<value>16</value>
<value>19</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>15</value>
<value>18</value>
</data>
<data name="cboPrecision.Items" xml:space="preserve">
<value>Unchanged</value>
@@ -460,7 +460,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cboPrecision.ZOrder" xml:space="preserve">
<value>14</value>
<value>17</value>
</data>
<data name="label6.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -490,7 +490,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label6.ZOrder" xml:space="preserve">
<value>13</value>
<value>16</value>
</data>
<data name="cboGuidingStyle.Items" xml:space="preserve">
<value>Auto</value>
@@ -520,7 +520,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cboGuidingStyle.ZOrder" xml:space="preserve">
<value>12</value>
<value>15</value>
</data>
<data name="label7.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -550,7 +550,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label7.ZOrder" xml:space="preserve">
<value>11</value>
<value>14</value>
</data>
<data name="label8.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -583,7 +583,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label8.ZOrder" xml:space="preserve">
<value>10</value>
<value>13</value>
</data>
<data name="txtBacklashSteps.Location" type="System.Drawing.Point, System.Drawing">
<value>97, 411</value>
@@ -607,7 +607,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;txtBacklashSteps.ZOrder" xml:space="preserve">
<value>8</value>
<value>11</value>
</data>
<data name="label9.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -637,7 +637,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label9.ZOrder" xml:space="preserve">
<value>9</value>
<value>12</value>
</data>
<data name="label10.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -667,7 +667,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label10.ZOrder" xml:space="preserve">
<value>7</value>
<value>10</value>
</data>
<data name="label11.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -700,7 +700,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label11.ZOrder" xml:space="preserve">
<value>6</value>
<value>9</value>
</data>
<data name="cbxReverseDirection.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -727,7 +727,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cbxReverseDirection.ZOrder" xml:space="preserve">
<value>5</value>
<value>8</value>
</data>
<data name="cbxDynamicBreaking.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -754,7 +754,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cbxDynamicBreaking.ZOrder" xml:space="preserve">
<value>4</value>
<value>7</value>
</data>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
@@ -790,7 +790,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cbxRtsDtr.ZOrder" xml:space="preserve">
<value>3</value>
<value>6</value>
</data>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
@@ -820,7 +820,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label12.ZOrder" xml:space="preserve">
<value>2</value>
<value>5</value>
</data>
<data name="txtElevation.Location" type="System.Drawing.Point, System.Drawing">
<value>97, 202</value>
@@ -841,7 +841,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;txtElevation.ZOrder" xml:space="preserve">
<value>1</value>
<value>4</value>
</data>
<data name="label13.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -868,6 +868,81 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label13.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="label14.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label14.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 236</value>
</data>
<data name="label14.Size" type="System.Drawing.Size, System.Drawing">
<value>56, 13</value>
</data>
<data name="label14.TabIndex" type="System.Int32, mscorlib">
<value>25</value>
</data>
<data name="label14.Text" xml:space="preserve">
<value>Settle time</value>
</data>
<data name="&gt;&gt;label14.Name" xml:space="preserve">
<value>label14</value>
</data>
<data name="&gt;&gt;label14.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;label14.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label14.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="nudSettleTime.Location" type="System.Drawing.Point, System.Drawing">
<value>97, 234</value>
</data>
<data name="nudSettleTime.Size" type="System.Drawing.Size, System.Drawing">
<value>120, 20</value>
</data>
<data name="nudSettleTime.TabIndex" type="System.Int32, mscorlib">
<value>26</value>
</data>
<data name="&gt;&gt;nudSettleTime.Name" xml:space="preserve">
<value>nudSettleTime</value>
</data>
<data name="&gt;&gt;nudSettleTime.Type" xml:space="preserve">
<value>System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;nudSettleTime.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;nudSettleTime.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="label15.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label15.Location" type="System.Drawing.Point, System.Drawing">
<value>223, 236</value>
</data>
<data name="label15.Size" type="System.Drawing.Size, System.Drawing">
<value>47, 13</value>
</data>
<data name="label15.TabIndex" type="System.Int32, mscorlib">
<value>27</value>
</data>
<data name="label15.Text" xml:space="preserve">
<value>seconds</value>
</data>
<data name="&gt;&gt;label15.Name" xml:space="preserve">
<value>label15</value>
</data>
<data name="&gt;&gt;label15.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;label15.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label15.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">
+5 -1
View File
@@ -146,6 +146,7 @@ namespace ASCOM.Meade.net
private const string ReverseFocusDirectionName = "Reverse Focuser Direction";
private const string DynamicBreakingName = "Dynamic Breaking";
private const string SiteElevationName = "Site Elevation";
private const string SettleTimeName = "Settle Time";
public static void WriteProfile(ProfileProperties profileProperties)
{
@@ -163,7 +164,8 @@ namespace ASCOM.Meade.net
driverProfile.WriteValue(DriverId, BacklashCompensationName, profileProperties.BacklashCompensation.ToString());
driverProfile.WriteValue(DriverId, ReverseFocusDirectionName, profileProperties.ReverseFocusDirection.ToString());
driverProfile.WriteValue(DriverId, DynamicBreakingName, profileProperties.DynamicBreaking.ToString());
driverProfile.WriteValue(DriverId, SiteElevationName, profileProperties.SiteElevation.ToString());
driverProfile.WriteValue(DriverId, SiteElevationName, profileProperties.SiteElevation.ToString(CultureInfo.InvariantCulture));
driverProfile.WriteValue(DriverId, SettleTimeName, profileProperties.SettleTime.ToString());
}
}
}
@@ -178,6 +180,7 @@ namespace ASCOM.Meade.net
private const string ReverseFocuserDiectionDefault = "true";
private const string DynamicBreakingDefault = "true";
private const string SiteElevationDefault = "0";
private const string SettleTimeDefault = "2";
public static ProfileProperties ReadProfile()
{
@@ -197,6 +200,7 @@ namespace ASCOM.Meade.net
profileProperties.ReverseFocusDirection = Convert.ToBoolean(driverProfile.GetValue(DriverId, ReverseFocusDirectionName, string.Empty, ReverseFocuserDiectionDefault));
profileProperties.DynamicBreaking = Convert.ToBoolean(driverProfile.GetValue(DriverId, DynamicBreakingName, string.Empty, DynamicBreakingDefault));
profileProperties.SiteElevation = Convert.ToInt32(driverProfile.GetValue(DriverId, SiteElevationName, string.Empty, SiteElevationDefault));
profileProperties.SettleTime = Convert.ToInt16(driverProfile.GetValue(DriverId, SettleTimeName, string.Empty, SettleTimeDefault));
}
return profileProperties;