Files
MeadeGeneric/Meade.net.Telescope/Rates.cs
T
ColinD 58ba1e6ee3 Merged in develop (pull request #6)
Release 0.5.0.0

* Removed unwanted files

* Adding git ignore file

* Started working on getting the basic communications with the scope working.
    Working on routines to get and set the date and time in the handbox.

* Switched the serial port over to using the .net frameworks serial port.
    Extracted the serial port into it's own class and created a simpler command processing mechanism.

* Implemented AbortSlew and did some code tidy up.

* Forced all code to 64-bit only, will make this 32/64 bit before release.
    Fixed issue in the SerialProcessor when setting the time, makes sure that there's no chance of thread stealing when pulling out the junk messages
    Added ConformanceResult.txt to show the progress of the driver development

* Added code for the site latitude
    and started work on the longitude.

* Added unit tests for reading and writing the utcDate.
    Fixed a couple of defects in the code that was setting the utcDate.

* Corrected Longitude value range

* Added support for UTC offset.

* Pulse guiding support added

* Added SiteLatitude unit tests

* Added unit tests for SiteLongitude

* Added unit tests for the new Pulse guide implementation.

* Added support for AlignmentMode

* Added support for AtPark and Park

* Added support for parking the scope
    Added support for reading the scope Azimuth

* Added support for reading Declination

* Added 5 second timeout for the serial port.
    Fixed problem with the GW command not working on the Autostar 497.

* Fixed broken unit test

* Added support for altitude

* Tidying up resharper warinings

* Implemented RightAscension
    TargetRightAscension
    TargetDec
    SlewToCoord
    and SlewToCoordAsync

* Sorted out the target RA and Dec exceptions to be compliant with ascom.

* Implemented SlewToAltAz and SlewToAltAzAsync

* Implemented SyncToTarget functionality

* Implemented slew to target

* Added support for MoveAxis

* Added support for tracking rate

* Added IFocuserV3 to the driver and made sure that it's registered for ASCOM as a focuser as well.

* Fixed issue with Target RA and Dec loosing precision

* Telescope driver now passes the Ascom conformance.

* Upgraded driver version to 0.1

* Added explicit locks around all sequences of commands.

* Basic implementation of the IFocusserV3

* Focuser passes validation, this makes the code V0.2

* Added support for CommandBlind and CommandString
    Modified the tracking rates to be setable.  However, the get is now simulated.

* Merged in feature/LocalServer (pull request #5)

    Feature/LocalServer

    * Major refactor.  Switching over to a local server hub style driver allowing multiple programs to control the telescope at one time without the need for the POTH Hub

    * Unified the setup dialog

    * Implemented shared serial port, Both Telescope and Driver can connect at the same time.

    * Ported the focuser implementation from the non server based version.

    * Ported the telescope driver code.

    * Fixed problem with # not being stripped from the returned string ends. Fixed issue with RA being returned as degress rather than hours.

    * Telescope passes validation

    * Added a lock around the focuser move.

    * Reimplemented CommandBlind and CommandString

    * Corrected version information

    * Removed the Altitude support as there's a bug in the Autostar and Audiostar firmware

* Added comments for all meade commands.
    Fixed the Site Lat and Long setters

* Re instated the Altitude value and ran conformance for both the telescope and focuser.

* Redesigned the Altitude and Azimuth readings to use the Right Ascension and Declination co-ordinates and perform the transformation using the date and site details from the scope.   This will correct the problem of the Altitude reading from the handset being incorrect.

* Added code to make sure that the scope returns values in high precision mode.

* Fixed problem where SlewToAltAz didn't work correctly.  Now uses the RA/Dec slew for everything, and converts the values as needed.

* Upgraded the error handling to ensure that all serial commands are executed after checking that there is a connection open.

* Added some code to the focuser connect to make it consistent with the telescope connect in that it will now test that the connection is to an Autostar.

    Upgraded the move code to make it less unreliable.

* Added localisation support

* First draft of the installer

* Sorted out the registry settings needed to get the driver working properly on install.

* Modified the solution to be able to create as 32-bit install that works on 64bit windows 10.

* Added a call to activate when the setup dialog is shown.
2019-06-04 19:06:57 +00:00

245 lines
7.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using ASCOM.DeviceInterface;
using System.Collections;
using System.Threading;
namespace ASCOM.Meade.net
{
#region Rate class
//
// The Rate class implements IRate, and is used to hold values
// for AxisRates. You do not need to change this class.
//
// The Guid attribute sets the CLSID for ASCOM.Meade.net.Rate
// The ClassInterface/None addribute prevents an empty interface called
// _Rate from being created and used as the [default] interface
//
[Guid("288838d1-bbf9-4ce0-9ee1-86ecf38b45c9")]
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
public class Rate : ASCOM.DeviceInterface.IRate
{
private double maximum = 0;
private double minimum = 0;
//
// Default constructor - Internal prevents public creation
// of instances. These are values for AxisRates.
//
internal Rate(double minimum, double maximum)
{
this.maximum = maximum;
this.minimum = minimum;
}
#region Implementation of IRate
public void Dispose()
{
// TODO Add any required object cleanup here
}
public double Maximum
{
get { return this.maximum; }
set { this.maximum = value; }
}
public double Minimum
{
get { return this.minimum; }
set { this.minimum = value; }
}
#endregion
}
#endregion
#region AxisRates
//
// AxisRates is a strongly-typed collection that must be enumerable by
// both COM and .NET. The IAxisRates and IEnumerable interfaces provide
// this polymorphism.
//
// The Guid attribute sets the CLSID for ASCOM.Meade.net.AxisRates
// The ClassInterface/None addribute prevents an empty interface called
// _AxisRates from being created and used as the [default] interface
//
[Guid("436de2dd-a77a-41ad-8a9e-14c3695f18f2")]
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
public class AxisRates : IAxisRates, IEnumerable
{
private TelescopeAxes axis;
private readonly Rate[] rates;
//
// Constructor - Internal prevents public creation
// of instances. Returned by Telescope.AxisRates.
//
internal AxisRates(TelescopeAxes axis)
{
this.axis = axis;
//
// This collection must hold zero or more Rate objects describing the
// rates of motion ranges for the Telescope.MoveAxis() method
// that are supported by your driver. It is OK to leave this
// array empty, indicating that MoveAxis() is not supported.
//
// Note that we are constructing a rate array for the axis passed
// to the constructor. Thus we switch() below, and each case should
// initialize the array for the rate for the selected axis.
//
switch (axis)
{
case TelescopeAxes.axisPrimary:
// TODO Initialize this array with any Primary axis rates that your driver may provide
// Example: m_Rates = new Rate[] { new Rate(10.5, 30.2), new Rate(54.0, 43.6) }
//this.rates = new Rate[0];
this.rates = new Rate[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) };
break;
case TelescopeAxes.axisSecondary:
// TODO Initialize this array with any Secondary axis rates that your driver may provide
//this.rates = new Rate[0];
this.rates = new Rate[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) };
break;
case TelescopeAxes.axisTertiary:
// TODO Initialize this array with any Tertiary axis rates that your driver may provide
this.rates = new Rate[0];
break;
}
}
#region IAxisRates Members
public int Count
{
get { return this.rates.Length; }
}
public void Dispose()
{
// TODO Add any required object cleanup here
}
public IEnumerator GetEnumerator()
{
return rates.GetEnumerator();
}
public IRate this[int index]
{
get { return this.rates[index - 1]; } // 1-based
}
#endregion
}
#endregion
#region TrackingRates
//
// TrackingRates is a strongly-typed collection that must be enumerable by
// both COM and .NET. The ITrackingRates and IEnumerable interfaces provide
// this polymorphism.
//
// The Guid attribute sets the CLSID for ASCOM.Meade.net.TrackingRates
// The ClassInterface/None addribute prevents an empty interface called
// _TrackingRates from being created and used as the [default] interface
//
// This class is implemented in this way so that applications based on .NET 3.5
// will work with this .NET 4.0 object. Changes to this have proved to be challenging
// and it is strongly suggested that it isn't changed.
//
[Guid("8e9aa30e-ab24-4a20-8af3-4a057defb1ff")]
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
public class TrackingRates : ITrackingRates, IEnumerable, IEnumerator
{
private readonly DriveRates[] trackingRates;
// this is used to make the index thread safe
private readonly ThreadLocal<int> pos = new ThreadLocal<int>(() => { return -1; });
private static readonly object lockObj = new object();
//
// Default constructor - Internal prevents public creation
// of instances. Returned by Telescope.AxisRates.
//
internal TrackingRates()
{
//
// This array must hold ONE or more DriveRates values, indicating
// the tracking rates supported by your telescope. The one value
// (tracking rate) that MUST be supported is driveSidereal!
//
this.trackingRates = new[] { DriveRates.driveSidereal, DriveRates.driveLunar };
// TODO Initialize this array with any additional tracking rates that your driver may provide
}
#region ITrackingRates Members
public int Count
{
get { return this.trackingRates.Length; }
}
public IEnumerator GetEnumerator()
{
pos.Value = -1;
return this as IEnumerator;
}
public void Dispose()
{
// TODO Add any required object cleanup here
}
public DriveRates this[int index]
{
get { return this.trackingRates[index - 1]; } // 1-based
}
#endregion
#region IEnumerable members
public object Current
{
get
{
lock (lockObj)
{
if (pos.Value < 0 || pos.Value >= trackingRates.Length)
{
throw new System.InvalidOperationException();
}
return trackingRates[pos.Value];
}
}
}
public bool MoveNext()
{
lock (lockObj)
{
if (++pos.Value >= trackingRates.Length)
{
return false;
}
return true;
}
}
public void Reset()
{
pos.Value = -1;
}
#endregion
}
#endregion
}