Skip to content

Commit

Permalink
1. Rearrange SetupDialogForm for better grouping.
Browse files Browse the repository at this point in the history
2. Fix the bug that Telescope.AxisRates() returns inappropriate range of rates.
3. Fix the bug that Starbook.GetRound() doesn't returns correct ROUND value.
  • Loading branch information
lkcheng89 committed May 10, 2020
1 parent b3973ae commit b9cfd81
Show file tree
Hide file tree
Showing 11 changed files with 413 additions and 290 deletions.
11 changes: 0 additions & 11 deletions CHANGES.html

This file was deleted.

14 changes: 0 additions & 14 deletions CHANGES.rst

This file was deleted.

45 changes: 45 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Changelog
=========

Starbook Driver v0.7
--------------------

* Add J2000 & JNow equatorial system options.
* Add Auto Meridian Flip feature.

Starbook Driver v0.6
--------------------

* Fix the bug that numeric parser gets wrong floating number under some locales.

Starbook Driver v0.5
--------------------

* Introduce multi-thread structure to overcome stuck problem in Stellarium.
* Add Slew & Sync under Alt/Az coordinate.
* Fix the problem that FindHome doesn't set AtHome to True.

Starbook Driver v0.4
--------------------

* Fix several bugs to pass ASCOM Conformance Checker.

Starbook Driver v0.3
--------------------

* Improve robustness with more defensive coding.
* Fix some UI state errors in SetupDialogForm
* Add SetPark and Park functions (Park will not stop tracking because of the limitation of Starbook)
* Add AtHome by XY encode values.

Starbook Driver v0.2
--------------------

* Add user input validation in setup dialog to prevent unexpected driver behaviour.
* Add GuideRateDeclination and GuideRateRightAscension setter for PulseGuide.
* Add MoveAxis and Park support.

Starbook Driver v0.1
--------------------

* First release.
4 changes: 2 additions & 2 deletions Driver.Starbook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,9 @@ public Response SetSpeed(int speed)
///
public Response GetRound(out int round)
{
round = 0; Response response = this.Handshake("GETROUND");
round = 0; Response response = this.Handshake("GETROUND", out Dictionary<string, string> dictionary);

if (response == Response.ErrorUnknown && int.TryParse(response.Reply, NumberStyles.Number, CultureInfo.InvariantCulture, out round))
if (response == Response.ErrorUnknown && dictionary.TryGetValue("ROUND", out string s) && int.TryParse(s, NumberStyles.Number, CultureInfo.InvariantCulture, out round))
{
response.Assign(Response.OK);
}
Expand Down
63 changes: 38 additions & 25 deletions Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public partial class Telescope : ITelescopeV3
/// <summary>
/// Private variable to hold an ASCOM Astrometry object to provide the Conversion method
/// </summary>
private ASCOM.Astrometry.Transform.Transform transform;
internal ASCOM.Astrometry.Transform.Transform transform;

/// <summary>
/// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify)
Expand Down Expand Up @@ -219,7 +219,7 @@ public void SetupDialog()
System.Windows.Forms.MessageBox.Show("Already connected, just press OK");
}

using (SetupDialogForm F = new SetupDialogForm())
using (SetupDialogForm F = new SetupDialogForm(this))
{
var result = F.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
Expand Down Expand Up @@ -878,21 +878,15 @@ public static double GuideRate(int guideRate)

public static int GuideRate(double guideRate)
{
double guideRateDifference = double.MaxValue;
int guideRateIndex = 0;

for (int index = 0; index <= 8; index++)
{
double difference = Math.Abs(guideRate - GuideRate(index));

if (guideRateDifference > difference)
if (guideRate == GuideRate(index))
{
guideRateDifference = difference;
guideRateIndex = index;
return index;
}
}

return guideRateIndex;
return -1;
}

public double GuideRateDeclination
Expand All @@ -907,15 +901,23 @@ public double GuideRateDeclination
{
CheckConnected("GuideRateDeclination_set");

Starbook.Response response = starbook.SetSpeed(Telescope.guideRate = GuideRate(value));
int guideRate = GuideRate(value);

if (guideRate < 0)
{
LogMessage("GuideRateDeclination_set", "InvalidValueException: {0}", value);
throw new ASCOM.InvalidValueException("GuideRateDeclination_set", "GuideRateDeclination", "AxisRates(axisSecondary)");
}

Starbook.Response response = starbook.SetSpeed(guideRate);

if (response != Starbook.Response.OK)
{
LogMessage("GuideRateDeclination_set", "InvalidOperationException: {0}, Starbook.SetSpeed({1})={2}", value, Telescope.guideRate, response);
LogMessage("GuideRateDeclination_set", "InvalidOperationException: {0}, Starbook.SetSpeed({1})={2}", value, guideRate, response);
throw new ASCOM.InvalidOperationException("GuideRateDeclination_set: Starbook.SetSpeed() is not working.");
}

LogMessage("GuideRateDeclination_set", "OK: {0}, GuideRate={1}", value, Telescope.guideRate);
LogMessage("GuideRateDeclination_set", "OK: {0}, GuideRate={1}", value, Telescope.guideRate = guideRate);
}
}

Expand All @@ -931,15 +933,23 @@ public double GuideRateRightAscension
{
CheckConnected("GuideRateRightAscension_set");

Starbook.Response response = starbook.SetSpeed(guideRate = GuideRate(value));
int guideRate = GuideRate(value);

if (guideRate < 0)
{
LogMessage("GuideRateRightAscension_set", "InvalidValueException: {0}", value);
throw new ASCOM.InvalidValueException("GuideRateRightAscension_set", "GuideRateRightAscension", "AxisRates(axisPrimary)");
}

Starbook.Response response = starbook.SetSpeed(guideRate);

if (response != Starbook.Response.OK)
{
LogMessage("GuideRateRightAscension_set", "InvalidOperationException: {0}, Starbook.SetSpeed({1})={2}", value, Telescope.guideRate, response);
LogMessage("GuideRateRightAscension_set", "InvalidOperationException: {0}, Starbook.SetSpeed({1})={2}", value, guideRate, response);
throw new ASCOM.InvalidOperationException("GuideRateRightAscension_set: Starbook.SetSpeed() is not working.");
}

LogMessage("GuideRateRightAscension_set", "OK: {0}, GuideRate={1}", value, Telescope.guideRate);
LogMessage("GuideRateRightAscension_set", "OK: {0}, GuideRate={1}", value, Telescope.guideRate = guideRate);
}
}

Expand Down Expand Up @@ -1001,17 +1011,14 @@ public void MoveAxis(TelescopeAxes Axis, double Rate)
}
else
{
double minRate = GuideRate(0);
double maxRate = GuideRate(8);
int guideRate = GuideRate(Math.Abs(Rate));

if (Math.Abs(Rate) < minRate || maxRate < Math.Abs(Rate))
if (guideRate < 0)
{
LogMessage("MoveAxis", "InvalidValueException: Rate={0}", Rate);
throw new ASCOM.InvalidValueException("MoveAxis", "Rate", string.Format(CultureInfo.InvariantCulture, "{0} to {1} or {2} to {3}", minRate, maxRate, -maxRate, -minRate));
LogMessage("MoveAxis", "InvalidValueException: {0}", Rate);
throw new ASCOM.InvalidValueException("MoveAxis", "Rate", string.Format("AxisRates({0})", Axis));
}

int guideRate = GuideRate(Math.Abs(Rate));

Starbook.Response response = starbook.SetSpeed(guideRate);

if (response != Starbook.Response.OK)
Expand Down Expand Up @@ -1348,7 +1355,13 @@ public double SiteElevation
{
get
{
double siteElevation = 0;
double siteElevation;

lock (transform)
{
siteElevation = transform.SiteElevation;
}

LogMessage("SiteElevation_get", "{0}", siteElevation);
return siteElevation;
}
Expand Down
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// by using the '*' as shown below:
//
// TODO - Set your driver's version here
[assembly: AssemblyVersion("0.6.0.0")]
[assembly: AssemblyVersion("0.7.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
21 changes: 0 additions & 21 deletions README.html

This file was deleted.

23 changes: 17 additions & 6 deletions Rates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public double Minimum
public class AxisRates : IAxisRates, IEnumerable
{
private TelescopeAxes axis;
private readonly Rate[] rates;
private List<Rate> rates;

//
// Constructor - Internal prevents public creation
Expand All @@ -84,6 +84,7 @@ public class AxisRates : IAxisRates, IEnumerable
internal AxisRates(TelescopeAxes axis)
{
this.axis = axis;
this.rates = new List<Rate>();
//
// This collection must hold zero or more Rate objects describing the
// rates of motion ranges for the Telescope.MoveAxis() method
Expand All @@ -98,21 +99,31 @@ internal AxisRates(TelescopeAxes axis)
{
case TelescopeAxes.axisPrimary:
case TelescopeAxes.axisSecondary:
double minimum = Telescope.GuideRate(0);
double maximum = Telescope.GuideRate(8);
this.rates = new Rate[] { new Rate(minimum, maximum) };
{
HashSet<double> rates = new HashSet<double>();
for (int index = 0; index <= 8; index++)
{
double rate = Telescope.GuideRate(index);
if (!rates.Contains(rate))
{
rates.Add(rate);
this.rates.Add(new Rate(rate, rate));
}
}
break;
}
case TelescopeAxes.axisTertiary:
this.rates = new Rate[0];
{
break;
}
}
}

#region IAxisRates Members

public int Count
{
get { return this.rates.Length; }
get { return this.rates.Count; }
}

public void Dispose()
Expand Down
Loading

0 comments on commit b9cfd81

Please sign in to comment.