Files
MeadeGeneric/MeadeAutostar497/AscomClasses/Rates.cs
T
ColinD 777adb260a Merged in develop (pull request #3)
Develop

* 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.
2019-05-08 17:23:13 +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.MeadeAutostar497
{
#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.MeadeAutostar497.Rate
// The ClassInterface/None addribute prevents an empty interface called
// _Rate from being created and used as the [default] interface
//
[Guid("20c14d35-a61b-4c6a-a6ab-cb9f27997c45")]
[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.MeadeAutostar497.AxisRates
// The ClassInterface/None addribute prevents an empty interface called
// _AxisRates from being created and used as the [default] interface
//
[Guid("ac703603-bcfc-4d98-9de3-c2b9a165756f")]
[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.MeadeAutostar497.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("cb732953-8e5a-4bf0-b3b7-451edb74b5d5")]
[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 };
// 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
}