Added a config setting to be able to choose whether the telescope uses high or low precision. Set to Unchanged for the telescope settings to not be altered.

This commit is contained in:
2019-08-18 21:30:22 +01:00
parent b3dc507aff
commit 68928a2289
7 changed files with 203 additions and 17 deletions
@@ -31,6 +31,7 @@ namespace Meade.net.Telescope.UnitTests
_profileProperties.TraceLogger = false;
_profileProperties.ComPort = "TestCom1";
_profileProperties.GuideRateArcSecondsPerSecond = 1.23;
_profileProperties.Precision = "Unchanged";
_utilMock = new Mock<IUtil>();
_utilExtraMock = new Mock<IUtilExtra>();
@@ -734,6 +735,42 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(result, Is.True);
}
[Test]
public void Precision_Set_WhenConnectedAndPrecisionSetUnChanged_ThenDoesNotSetPrecision()
{
_telescope.Connected = true;
_sharedResourcesWrapperMock.Verify( x => x.SendString(":P#"), Times.Never);
}
[TestCase("High", false, true)]
[TestCase("High", true, true)]
[TestCase("Low", false, false)]
[TestCase("Low", true, false)]
public void Precision_Set_WhenConnectedAndPrecisionSetHighScopeIsLow_ThenTelescopePrecisionChanged(string desiredPresision, bool telescopePrecision, bool finalPrecision)
{
_profileProperties.Precision = desiredPresision;
var currentPrecision = telescopePrecision;
_sharedResourcesWrapperMock.Setup(x => x.SendString(":P#")).Returns(() =>
{
currentPrecision = !currentPrecision;
switch (currentPrecision)
{
case true:
return "HIGH PRECISION";
default:
return "LOW PRECISION";
}
});
_telescope.Connected = true;
Assert.That(currentPrecision, Is.EqualTo(finalPrecision));
_sharedResourcesWrapperMock.Verify(x => x.SendString(":P#"), Times.AtLeastOnce);
}
[Test]
public void CanSetPark_Get_ReturnsFalse()
{
+56
View File
@@ -243,6 +243,8 @@ namespace ASCOM.Meade.net
var parames = actionParameters.ToLower().Split(' ');
switch (parames[0])
{
case "count":
return "4";
case "select":
switch (parames[1])
{
@@ -391,6 +393,7 @@ namespace ASCOM.Meade.net
SetNewGuideRate( _guideRate, "Connect" );
}
SetTelescopePrecision("Connect");
}
catch (Exception)
{
@@ -412,6 +415,24 @@ namespace ASCOM.Meade.net
}
}
private void SetTelescopePrecision(string propertyName)
{
switch (_precision)
{
case "High":
TelescopePointingPrecision(true);
LogMessage(propertyName, $"High precision slewing selected");
break;
case "Low":
TelescopePointingPrecision(false);
LogMessage(propertyName, $"Low precision slewing selected");
break;
default:
LogMessage(propertyName, $"Precision slewing unchanged");
break;
}
}
public bool IsNewPulseGuidingSupported()
{
if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497)
@@ -466,6 +487,39 @@ namespace ASCOM.Meade.net
});
}
private bool TogglePrecision()
{
var result = _sharedResourcesWrapper.SendString(":P#");
//:P# Toggles High Precsion Pointing. When High precision pointing is enabled scope will first allow the operator to center a nearby bright star before moving to the actual target.
//Returns: <string>
//“HIGH PRECISION” Current setting after this command.
//“LOW PRECISION” Current setting after this command.
bool highPrecision = false;
switch (result)
{
case "HIGH PRECISION":
highPrecision = true;
break;
}
//Make sure that the buffers are cleared out.
_sharedResourcesWrapper.SendBlind("#");
return highPrecision;
}
public void TelescopePointingPrecision(bool high)
{
var currentPrecision = TogglePrecision();
while (currentPrecision != high)
{
currentPrecision = TogglePrecision();
}
}
public void SelectSite(int site)
{
CheckConnected("SelectSite");
@@ -1963,6 +2017,7 @@ namespace ASCOM.Meade.net
}
private DriveRates _trackingRate = DriveRates.driveSidereal;
private string _precision;
public DriveRates TrackingRate
{
@@ -2249,6 +2304,7 @@ namespace ASCOM.Meade.net
_tl.Enabled = profileProperties.TraceLogger;
_comPort = profileProperties.ComPort;
_guideRate = profileProperties.GuideRateArcSecondsPerSecond;
_precision = profileProperties.Precision;
LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}");
LogMessage("ReadProfile", $"Com Port: {_comPort}");
+1
View File
@@ -6,5 +6,6 @@ namespace ASCOM.Meade.net
public string ComPort { get; set; }
public bool TraceLogger { get; set; }
public double GuideRateArcSecondsPerSecond { get; set; }
public string Precision { get; set; }
}
}
+11 -2
View File
@@ -49,15 +49,24 @@ namespace ASCOM.Meade.net
}
txtGuideRate.Text = profileProperties.GuideRateArcSecondsPerSecond.ToString();
try
{
cboPrecision.SelectedItem = profileProperties.Precision;
}
catch (Exception e)
{
cboPrecision.SelectedItem = "Unchanged";
}
}
public ProfileProperties GetProfile()
public ProfileProperties GetProfile()
{
var profileProperties = new ProfileProperties
{
TraceLogger = chkTrace.Checked,
ComPort = comboBoxComPort.SelectedItem.ToString(),
GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim())
GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()),
Precision = cboPrecision.SelectedText
};
return profileProperties;
+22
View File
@@ -40,6 +40,8 @@ namespace ASCOM.Meade.net
this.txtGuideRate = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.lblPercentOfSiderealRate = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.cboPrecision = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit();
this.SuspendLayout();
//
@@ -112,10 +114,28 @@ namespace ASCOM.Meade.net
resources.ApplyResources(this.lblPercentOfSiderealRate, "lblPercentOfSiderealRate");
this.lblPercentOfSiderealRate.Name = "lblPercentOfSiderealRate";
//
// label5
//
resources.ApplyResources(this.label5, "label5");
this.label5.Name = "label5";
//
// cboPrecision
//
this.cboPrecision.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboPrecision.FormattingEnabled = true;
this.cboPrecision.Items.AddRange(new object[] {
resources.GetString("cboPrecision.Items"),
resources.GetString("cboPrecision.Items1"),
resources.GetString("cboPrecision.Items2")});
resources.ApplyResources(this.cboPrecision, "cboPrecision");
this.cboPrecision.Name = "cboPrecision";
//
// SetupDialogForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.cboPrecision);
this.Controls.Add(this.label5);
this.Controls.Add(this.lblPercentOfSiderealRate);
this.Controls.Add(this.label4);
this.Controls.Add(this.txtGuideRate);
@@ -152,5 +172,7 @@ namespace ASCOM.Meade.net
private System.Windows.Forms.TextBox txtGuideRate;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label lblPercentOfSiderealRate;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox cboPrecision;
}
}
+72 -15
View File
@@ -145,7 +145,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cmdOK.ZOrder" xml:space="preserve">
<value>10</value>
<value>12</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>9</value>
<value>11</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>8</value>
<value>10</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>7</value>
<value>9</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>6</value>
<value>8</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, 118</value>
<value>77, 136</value>
</data>
<data name="chkTrace.Size" type="System.Drawing.Size, System.Drawing">
<value>69, 17</value>
@@ -277,7 +277,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;chkTrace.ZOrder" xml:space="preserve">
<value>5</value>
<value>7</value>
</data>
<data name="comboBoxComPort.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 87</value>
@@ -298,13 +298,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;comboBoxComPort.ZOrder" xml:space="preserve">
<value>4</value>
<value>6</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>
<value>10, 162</value>
</data>
<data name="label3.Size" type="System.Drawing.Size, System.Drawing">
<value>61, 13</value>
@@ -325,10 +325,10 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label3.ZOrder" xml:space="preserve">
<value>3</value>
<value>5</value>
</data>
<data name="txtGuideRate.Location" type="System.Drawing.Point, System.Drawing">
<value>80, 222</value>
<value>77, 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>2</value>
<value>4</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>
<value>129, 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>1</value>
<value>3</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>
<value>129, 175</value>
</data>
<data name="lblPercentOfSiderealRate.Size" type="System.Drawing.Size, System.Drawing">
<value>105, 13</value>
@@ -403,6 +403,63 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblPercentOfSiderealRate.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="label5.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label5.Location" type="System.Drawing.Point, System.Drawing">
<value>13, 194</value>
</data>
<data name="label5.Size" type="System.Drawing.Size, System.Drawing">
<value>50, 13</value>
</data>
<data name="label5.TabIndex" type="System.Int32, mscorlib">
<value>12</value>
</data>
<data name="label5.Text" xml:space="preserve">
<value>Precision</value>
</data>
<data name="&gt;&gt;label5.Name" xml:space="preserve">
<value>label5</value>
</data>
<data name="&gt;&gt;label5.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;label5.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label5.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="cboPrecision.Items" xml:space="preserve">
<value>Unchanged</value>
</data>
<data name="cboPrecision.Items1" xml:space="preserve">
<value>Low</value>
</data>
<data name="cboPrecision.Items2" xml:space="preserve">
<value>High</value>
</data>
<data name="cboPrecision.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 191</value>
</data>
<data name="cboPrecision.Size" type="System.Drawing.Size, System.Drawing">
<value>69, 21</value>
</data>
<data name="cboPrecision.TabIndex" type="System.Int32, mscorlib">
<value>13</value>
</data>
<data name="&gt;&gt;cboPrecision.Name" xml:space="preserve">
<value>cboPrecision</value>
</data>
<data name="&gt;&gt;cboPrecision.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;cboPrecision.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;cboPrecision.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">
+4
View File
@@ -159,6 +159,7 @@ namespace ASCOM.Meade.net
private const string ComPortProfileName = "COM Port";
private const string TraceStateProfileName = "Trace Level";
private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second";
private const string PrecisionProfileName = "Precision";
public static void WriteProfile(ProfileProperties profileProperties)
{
@@ -170,6 +171,7 @@ namespace ASCOM.Meade.net
driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString());
driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort);
driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString());
driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision);
}
}
}
@@ -177,6 +179,7 @@ namespace ASCOM.Meade.net
private const string ComPortDefault = "COM1";
private const string TraceStateDefault = "false";
private const string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
private const string PrecisionDefault = "Unchanged";
public static ProfileProperties ReadProfile()
{
@@ -189,6 +192,7 @@ namespace ASCOM.Meade.net
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));
profileProperties.Precision = driverProfile.GetValue(DriverId, PrecisionProfileName, string.Empty, PrecisionDefault);
}
return profileProperties;