Basic implementation of the IFocusserV3
This commit is contained in:
@@ -949,8 +949,8 @@ namespace ASCOM.MeadeAutostar497
|
|||||||
|
|
||||||
#region IFocuser Implementation
|
#region IFocuser Implementation
|
||||||
|
|
||||||
private int focuserPosition = 0; // Class level variable to hold the current focuser position
|
//private int focuserPosition = 0; // Class level variable to hold the current focuser position
|
||||||
private const int focuserSteps = 10000;
|
//private const int focuserSteps = 10000;
|
||||||
|
|
||||||
public bool Absolute
|
public bool Absolute
|
||||||
{
|
{
|
||||||
@@ -994,8 +994,9 @@ namespace ASCOM.MeadeAutostar497
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
tl.LogMessage("MaxIncrement Get", focuserSteps.ToString());
|
var maxIncrement = _telescopeController.FocuserMaxIncrement;
|
||||||
return focuserSteps; // Maximum change in one move
|
tl.LogMessage("MaxIncrement Get", maxIncrement.ToString());
|
||||||
|
return maxIncrement; // Maximum change in one move
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1003,22 +1004,25 @@ namespace ASCOM.MeadeAutostar497
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
tl.LogMessage("MaxStep Get", focuserSteps.ToString());
|
var maxStep = _telescopeController.FocuserMaxStep;
|
||||||
return focuserSteps; // Maximum extent of the focuser, so position range is 0 to 10,000
|
tl.LogMessage("MaxStep Get", maxStep.ToString());
|
||||||
|
return maxStep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Move(int Position)
|
public void Move(int Position)
|
||||||
{
|
{
|
||||||
tl.LogMessage("Move", Position.ToString());
|
tl.LogMessage("Move", Position.ToString());
|
||||||
focuserPosition = Position; // Set the focuser position
|
_telescopeController.FocuserMove(Position);
|
||||||
|
//focuserPosition = Position; // Set the focuser position
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Position
|
public int Position
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return focuserPosition; // Return the focuser position
|
throw new ASCOM.PropertyNotImplementedException("Position", false);
|
||||||
|
//return focuserPosition; // Return the focuser position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
double TargetRightAscension { get; set; }
|
double TargetRightAscension { get; set; }
|
||||||
double TargetDeclination { get; set; }
|
double TargetDeclination { get; set; }
|
||||||
DriveRates TrackingRate { get; }
|
DriveRates TrackingRate { get; }
|
||||||
|
int FocuserMaxIncrement { get; set; }
|
||||||
|
int FocuserMaxStep { get; set; }
|
||||||
void AbortSlew();
|
void AbortSlew();
|
||||||
void PulseGuide(GuideDirections direction, int duration);
|
void PulseGuide(GuideDirections direction, int duration);
|
||||||
void Park();
|
void Park();
|
||||||
@@ -33,5 +35,6 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
void SlewToTargetAsync();
|
void SlewToTargetAsync();
|
||||||
void MoveAxis(TelescopeAxes axis, double rate);
|
void MoveAxis(TelescopeAxes axis, double rate);
|
||||||
void FocuserHalt();
|
void FocuserHalt();
|
||||||
|
void FocuserMove(int position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,6 +97,7 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
SerialPort.Open();
|
SerialPort.Open();
|
||||||
|
|
||||||
TestConnectionActive();
|
TestConnectionActive();
|
||||||
|
SetFocuserSpeedFastest();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@@ -520,6 +521,10 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int FocuserMaxIncrement { get; set; } = 7000;
|
||||||
|
|
||||||
|
public int FocuserMaxStep { get; set; } = 7000;
|
||||||
|
|
||||||
public double Altitude {
|
public double Altitude {
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -730,6 +735,7 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
|
|
||||||
private bool _movingPrimary;
|
private bool _movingPrimary;
|
||||||
private bool _movingSecondary;
|
private bool _movingSecondary;
|
||||||
|
|
||||||
public void MoveAxis(TelescopeAxes axis, double rate)
|
public void MoveAxis(TelescopeAxes axis, double rate)
|
||||||
{
|
{
|
||||||
SerialPort.Lock();
|
SerialPort.Lock();
|
||||||
@@ -840,6 +846,74 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
//Returns: Nothing
|
//Returns: Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void FocuserMove(int newPosition)
|
||||||
|
{
|
||||||
|
//todo implement backlash compensation
|
||||||
|
//todo implement direction reverse
|
||||||
|
//todo implement dynamic braking
|
||||||
|
|
||||||
|
if (newPosition < -FocuserMaxIncrement || newPosition > FocuserMaxIncrement)
|
||||||
|
{
|
||||||
|
throw new ASCOM.InvalidValueException($"position out of range {-FocuserMaxIncrement} < {newPosition} < {FocuserMaxIncrement}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newPosition == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (newPosition > 0)
|
||||||
|
{
|
||||||
|
//desired move direction is out
|
||||||
|
MoveFocuser(true, Math.Abs(newPosition));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//desired move direction is in
|
||||||
|
MoveFocuser(false, Math.Abs(newPosition));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MoveFocuser(bool directionOut, int steps)
|
||||||
|
{
|
||||||
|
SerialPort.Command(directionOut ? ":F+#" : ":F-#");
|
||||||
|
//:F+# Start Focuser moving inward (toward objective)
|
||||||
|
//Returns: None
|
||||||
|
|
||||||
|
//:F-# Start Focuser moving outward (away from objective)
|
||||||
|
//Returns: None
|
||||||
|
|
||||||
|
Util.WaitForMilliseconds(steps);
|
||||||
|
|
||||||
|
FocuserHalt();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetFocuserSpeedFastest()
|
||||||
|
{
|
||||||
|
SerialPort.Command(":FF#");
|
||||||
|
//:FF# Set Focus speed to fastest setting
|
||||||
|
//Returns: Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetFocuserSpeedSlowest()
|
||||||
|
{
|
||||||
|
SerialPort.Command(":FS#");
|
||||||
|
//:FS# Set Focus speed to slowest setting
|
||||||
|
//Returns: Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetFocuserSpeed( int speed)
|
||||||
|
{
|
||||||
|
if (speed < 1)
|
||||||
|
throw new ArgumentOutOfRangeException("speed is too low");
|
||||||
|
|
||||||
|
if (speed > 4)
|
||||||
|
throw new ArgumentOutOfRangeException("speed is too high");
|
||||||
|
|
||||||
|
SerialPort.Command($":F{speed}#");
|
||||||
|
//:F<n># Autostar, Autostar II – set focuser speed to <n> where <n> is an ASCII digit 1..4
|
||||||
|
//Returns: Nothing
|
||||||
|
//All others – Not Supported
|
||||||
|
}
|
||||||
|
|
||||||
//todo remove the polar parameter and split method into two.
|
//todo remove the polar parameter and split method into two.
|
||||||
private void DoSlewAsync( bool polar)
|
private void DoSlewAsync( bool polar)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user