Added explicit locks around all sequences of commands.
This commit is contained in:
@@ -561,6 +561,9 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
Thread.Sleep(duration); //todo figure out if this is really needed
|
Thread.Sleep(duration); //todo figure out if this is really needed
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
SerialPort.Lock();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
_serialPort.Command(":RG#"); //Make sure we are at guide rate
|
_serialPort.Command(":RG#"); //Make sure we are at guide rate
|
||||||
_serialPort.Command($":M{d}#");
|
_serialPort.Command($":M{d}#");
|
||||||
@@ -571,6 +574,11 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
Thread.Sleep(200);
|
Thread.Sleep(200);
|
||||||
_serialPort.Command($":Q{d}#");
|
_serialPort.Command($":Q{d}#");
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
SerialPort.Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Park()
|
public void Park()
|
||||||
@@ -593,12 +601,20 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void SlewToCoordinatesAsync(double rightAscension, double declination)
|
public void SlewToCoordinatesAsync(double rightAscension, double declination)
|
||||||
|
{
|
||||||
|
SerialPort.Lock();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
TargetRightAscension = rightAscension;
|
TargetRightAscension = rightAscension;
|
||||||
TargetDeclination = declination;
|
TargetDeclination = declination;
|
||||||
|
|
||||||
DoSlewAsync(true);
|
DoSlewAsync(true);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
SerialPort.Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SlewToAltAz(double azimuth, double altitude)
|
public void SlewToAltAz(double azimuth, double altitude)
|
||||||
{
|
{
|
||||||
@@ -662,12 +678,20 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void SlewToAltAzAsync(double azimuth, double altitude)
|
public void SlewToAltAzAsync(double azimuth, double altitude)
|
||||||
|
{
|
||||||
|
SerialPort.Lock();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
TargetAltitude = altitude;
|
TargetAltitude = altitude;
|
||||||
TargetAzimuth = azimuth;
|
TargetAzimuth = azimuth;
|
||||||
|
|
||||||
DoSlewAsync(false);
|
DoSlewAsync(false);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
SerialPort.Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SyncToTarget()
|
public void SyncToTarget()
|
||||||
{
|
{
|
||||||
@@ -707,10 +731,13 @@ 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();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var absrate = Math.Abs(rate);
|
var absrate = Math.Abs(rate);
|
||||||
|
|
||||||
switch(absrate)
|
switch (absrate)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
//do nothing, it's ok this time as we're halting the slew.
|
//do nothing, it's ok this time as we're halting the slew.
|
||||||
@@ -767,6 +794,7 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
//Returns: Nothing
|
//Returns: Nothing
|
||||||
_movingPrimary = true;
|
_movingPrimary = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case TelescopeAxes.axisSecondary:
|
case TelescopeAxes.axisSecondary:
|
||||||
if (rate == 0)
|
if (rate == 0)
|
||||||
@@ -799,6 +827,11 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
throw new ASCOM.MethodNotImplementedException("Can not move this axis.");
|
throw new ASCOM.MethodNotImplementedException("Can not move this axis.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
SerialPort.Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void FocuserHalt()
|
public void FocuserHalt()
|
||||||
{
|
{
|
||||||
@@ -809,6 +842,9 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
|
|
||||||
//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)
|
||||||
|
{
|
||||||
|
SerialPort.Lock();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
switch (polar)
|
switch (polar)
|
||||||
{
|
{
|
||||||
@@ -837,6 +873,7 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
throw new ASCOM.DriverException("This error should not happen");
|
throw new ASCOM.DriverException("This error should not happen");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
var maResponse = SerialPort.CommandChar(":MA#");
|
var maResponse = SerialPort.CommandChar(":MA#");
|
||||||
@@ -850,9 +887,15 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
{
|
{
|
||||||
throw new ASCOM.InvalidOperationException("fault");
|
throw new ASCOM.InvalidOperationException("fault");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
SerialPort.Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool UserNewerPulseGuiding { get; set; } = true; //todo make this a device setting
|
public bool UserNewerPulseGuiding { get; set; } = true; //todo make this a device setting
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user