Modified the implementation of side of pier support detection. Hopefully will now,

Added extra checking to ensure that a slew cannot be started whilst a slew is in progress.
This commit is contained in:
2021-12-11 19:10:18 +00:00
parent a5a3bd5bd4
commit df7dfb7c04
6 changed files with 221 additions and 215 deletions
@@ -42,8 +42,6 @@ namespace Meade.net.Focuser.UnitTests
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Action>())).Callback<Action>(action => { action(); });
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() => _profileProperties);
_focuser = new ASCOM.Meade.net.Focuser(_utilMock.Object, _sharedResourcesWrapperMock.Object);
@@ -422,8 +420,6 @@ namespace Meade.net.Focuser.UnitTests
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Once);
}
_sharedResourcesWrapperMock.Verify(x => x.Lock(It.IsAny<Action>()), Times.Once);
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once);
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Never);
_utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Once());
@@ -455,8 +451,6 @@ namespace Meade.net.Focuser.UnitTests
_utilMock.Verify(x => x.WaitForMilliseconds(_profileProperties.BacklashCompensation), Times.Once);
_utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(2));
}
_sharedResourcesWrapperMock.Verify(x => x.Lock(It.IsAny<Action>()), Times.Once);
}
[Test]
@@ -95,9 +95,6 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Setup(x => x.SendString("GZ", false)).Returns("DDD*MMSS");
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() =>_profileProperties);
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Action>())).Callback<Action>(action => { action(); });
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Func<ASCOM.Meade.net.Telescope.TelescopeDateDetails>>())).Returns<Func<ASCOM.Meade.net.Telescope.TelescopeDateDetails>>( func => func());
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Func<AltitudeData>>())).Returns<Func<AltitudeData>>(func => func());
_connectionInfo = new ConnectionInfo
{
@@ -1930,11 +1927,12 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(excpetion.Method, Is.EqualTo("SetPark"));
}
[Test]
public void SideOfPier_Get_WhenMeridianFlipNotSupported_ThenThrowsException()
[TestCase(TelescopeList.LX200CLASSIC, null)]
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_31Ee)]
[TestCase(TelescopeList.LX200GPS, TelescopeList.LX200GPS_42F)]
public void SideOfPier_Get_WhenMeridianFlipNotSupported_ThenThrowsException(string model, string firmware)
{
// LX200 classic is a fork mounted scope so it does not support meridian flips
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(TelescopeList.LX200CLASSIC);
ConnectTelescope(model, firmware);
var excpetion = Assert.Throws<PropertyNotImplementedException>(() =>
{
@@ -1946,6 +1944,41 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(excpetion.AccessorSet, Is.False);
}
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg)]
[TestCase(TelescopeList.LX200GPS, TelescopeList.LX200GPS_42G)]
public void SideOfPier_Get_WhenMeridianFlipSupported_ThenReturnsResult(string model, string firmware)
{
ConnectTelescope(model, firmware);
Assert.DoesNotThrow(() => { var result = _telescope.SideOfPier; });
}
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algAltAz, 'A')]
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algPolar, 'P')]
public void SideOfPier_Get_WhenMeridianFlipNotSupportedByAlignementMode_ThenThrowsException(string model, string firmware, AlignmentModes alignmode, char alignmentStatus)
{
ConnectTelescope(model, firmware);
_testProperties.AlignmentStatus = new[] { alignmentStatus, 'T', '1' };
var excpetion = Assert.Throws<PropertyNotImplementedException>(() =>
{
var result = _telescope.SideOfPier;
Assert.Fail($"{result} should not have returned");
});
Assert.That(excpetion.Property, Is.EqualTo("SideOfPier"));
Assert.That(excpetion.AccessorSet, Is.False);
}
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algGermanPolar, 'G')]
public void SideOfPier_Get_WhenMeridianFlipSupportedByAlignementMode_ThenDoesNotThrow(string model, string firmware, AlignmentModes alignmode, char alignmentStatus)
{
ConnectTelescope(model, firmware);
_testProperties.AlignmentStatus = new[] { alignmentStatus, 'T', '1' };
Assert.DoesNotThrow(() => { var result = _telescope.SideOfPier; });
}
[Test]
public void SideOfPier_Set_ThenThrowsException()
{
@@ -2119,7 +2152,7 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Verify(x => x.SendString("Gg", false), Times.Exactly(3));
_sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Exactly(2));
_sharedResourcesWrapperMock.Verify(x => x.SendString("D", false), Times.Exactly(3));
_sharedResourcesWrapperMock.Verify(x => x.SendString("D", false), Times.AtLeast(3));
}
[Test]
@@ -3272,12 +3305,15 @@ namespace Meade.net.Telescope.UnitTests
{
_sharedResourcesWrapperMock.Setup(x => x.SendChar("MS", false)).Returns("0");
var preTestItterations = 1;
var slewCounter = 0;
var iterations = 10;
_sharedResourcesWrapperMock.Setup(x => x.SendString("D", false)).Returns(() =>
{
slewCounter++;
if (slewCounter <= iterations)
if (slewCounter <= preTestItterations)
return "";
else if (slewCounter <= iterations)
return "|";
return "";
});
@@ -3289,7 +3325,7 @@ namespace Meade.net.Telescope.UnitTests
_telescope.SlewToTarget();
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations));
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations - preTestItterations));
}
[Test]
@@ -3366,12 +3402,15 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Setup(x => x.SendChar("MS", false)).Returns("0");
var preTestItterations = 1;
var slewCounter = 0;
var iterations = 10;
_sharedResourcesWrapperMock.Setup(x => x.SendString("D", false)).Returns(() =>
{
slewCounter++;
if (slewCounter <= iterations)
if (slewCounter <= preTestItterations)
return "";
else if (slewCounter <= iterations)
return "|";
return "";
});
@@ -3383,7 +3422,7 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(_telescope.TargetDeclination, Is.EqualTo(dmsResult));
_sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Once);
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations));
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations - preTestItterations));
}
[Test]
@@ -3486,12 +3525,15 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Setup(x => x.SendChar("MS", false)).Returns("0");
var preTestItterations = 1;
var slewCounter = 0;
var iterations = 10;
_sharedResourcesWrapperMock.Setup(x => x.SendString("D", false)).Returns(() =>
{
slewCounter++;
if (slewCounter <= iterations)
if (slewCounter <= preTestItterations)
return "";
else if (slewCounter <= iterations)
return "|";
return "";
});
@@ -3503,7 +3545,7 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(_telescope.TargetRightAscension, Is.EqualTo(_testProperties.rightAscension));
Assert.That(_telescope.TargetDeclination, Is.EqualTo(_testProperties.declination));
_sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Once);
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations));
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations - preTestItterations));
}
[Test]
+145 -160
View File
@@ -649,7 +649,7 @@ namespace ASCOM.Meade.net
// According to "A User's Guide to the Meade LXD55 and LXD75 Telescopes" Autostar supports meridian flip so
// we assume that for any telescope that supports the GW command and is not in Alt-Az mode then
// meridian flip on slew is supported
private bool IsMeridianFlipOnSlewSupported() => IsGwCommandSupported() && AlignmentMode != AlignmentModes.algAltAz;
private bool IsMeridianFlipOnSlewSupported() => IsGwCommandSupported() && AlignmentMode == AlignmentModes.algGermanPolar;
private bool FirmwareIsGreaterThan(string minVersion)
{
@@ -734,39 +734,36 @@ namespace ASCOM.Meade.net
{
LogMessage("SetLongFormat", "Long coordinate format not supported for this mount");
SharedResourcesWrapper.Lock(() => SharedResourcesWrapper.IsLongFormat = false);
SharedResourcesWrapper.IsLongFormat = false;
return;
}
SharedResourcesWrapper.Lock(() =>
var result = SharedResourcesWrapper.SendString("GZ");
LogMessage("SetLongFormat", $"Get - Azimuth {result}");
//:GZ# Get telescope azimuth
//Returns: DDD*MM.T or DDD*MM'SS#
//The current telescope Azimuth depending on the selected precision.
SharedResourcesWrapper.IsLongFormat = result.Length > 6;
if (SharedResourcesWrapper.IsLongFormat != setLongFormat)
{
var result = SharedResourcesWrapper.SendString("GZ");
LogMessage("SetLongFormat", $"Get - Azimuth {result}");
//:GZ# Get telescope azimuth
//Returns: DDD*MM.T or DDD*MM'SS#
//The current telescope Azimuth depending on the selected precision.
_utilities.WaitForMilliseconds(500);
SharedResourcesWrapper.SendBlind("U");
//:U# Toggle between low/hi precision positions
//Low - RA displays and messages HH:MM.T sDD*MM
//High - Dec / Az / El displays and messages HH:MM: SS sDD*MM:SS
// Returns Nothing
result = SharedResourcesWrapper.SendString("GZ");
SharedResourcesWrapper.IsLongFormat = result.Length > 6;
if (SharedResourcesWrapper.IsLongFormat != setLongFormat)
{
_utilities.WaitForMilliseconds(500);
SharedResourcesWrapper.SendBlind("U");
//:U# Toggle between low/hi precision positions
//Low - RA displays and messages HH:MM.T sDD*MM
//High - Dec / Az / El displays and messages HH:MM: SS sDD*MM:SS
// Returns Nothing
result = SharedResourcesWrapper.SendString("GZ");
SharedResourcesWrapper.IsLongFormat = result.Length > 6;
LogMessage("SetLongFormat", $"Get - Azimuth {result}");
if (SharedResourcesWrapper.IsLongFormat == setLongFormat)
LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} ");
}
else
{
LogMessage("SetLongFormat", $"Get - Azimuth {result}");
if (SharedResourcesWrapper.IsLongFormat == setLongFormat)
LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} ");
}
});
}
else
{
LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} ");
}
LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} ");
}
@@ -1001,8 +998,8 @@ namespace ASCOM.Meade.net
alignmentMode = AlignmentModes.algPolar;
break;
//case "G":
// alignmentMode = AlignmentModes.algGermanPolar;
// break;
//alignmentMode = AlignmentModes.algGermanPolar;
//break;
default:
throw new InvalidValueException(
$"unknown alignment returned from telescope: {alignmentString}");
@@ -1135,13 +1132,13 @@ namespace ASCOM.Meade.net
private HorizonCoordinates CalcAltAzFromTelescopeEqData()
{
var altitudeData = SharedResourcesWrapper.Lock(() => new AltitudeData
var altitudeData = new AltitudeData
{
UtcDateTime = UTCDate,
SiteLongitude = SiteLongitude,
SiteLatitude = SiteLatitude,
EquatorialCoordinates = GetTelescopeRaAndDec()
});
};
double hourAngle = _astroMaths.RightAscensionToHourAngle(altitudeData.UtcDateTime,
altitudeData.SiteLongitude,
@@ -2175,98 +2172,94 @@ namespace ASCOM.Meade.net
LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude}");
HorizonCoordinates altAz = new HorizonCoordinates {Azimuth = azimuth, Altitude = altitude};
HorizonCoordinates altAz = new HorizonCoordinates { Azimuth = azimuth, Altitude = altitude };
var utcDateTime = UTCDate;
var latitude = SiteLatitude;
var longitude = SiteLongitude;
SharedResourcesWrapper.Lock(() =>
{
var raDec = _astroMaths.ConvertHozToEq(utcDateTime, latitude, longitude, altAz);
var raDec = _astroMaths.ConvertHozToEq(utcDateTime, latitude, longitude, altAz);
TargetRightAscension = raDec.RightAscension;
TargetDeclination = raDec.Declination;
TargetRightAscension = raDec.RightAscension;
TargetDeclination = raDec.Declination;
DoSlewAsync(true);
//TargetAltitude = altitude;
//TargetAzimuth = azimuth;
//DoSlewAsync(false);
});
DoSlewAsync(true);
}
private void DoSlewAsync(bool polar)
{
CheckConnected("DoSlewAsync");
CheckParked();
SharedResourcesWrapper.Lock(() =>
if (Slewing)
{
switch (polar)
{
case true:
var response = SharedResourcesWrapper.SendChar("MS");
//:MS# Slew to Target Object
//Returns:
//0 Slew is Possible
//1<string># Object Below Horizon w/string message
//2<string># Object Below Higher w/string message
LogMessage("DoSlewAsync", "Cannot start a slew whilst slew is in progress.");
throw new ASCOM.InvalidOperationException("Cannot start a slew whilst slew is in progress.");
}
switch (response)
{
case "0":
//We're slewing everything should be working just fine.
LogMessage("DoSlewAsync", "Slewing to target");
switch (polar)
{
case true:
var response = SharedResourcesWrapper.SendChar("MS");
//:MS# Slew to Target Object
//Returns:
//0 Slew is Possible
//1<string># Object Below Horizon w/string message
//2<string># Object Below Higher w/string message
if (IsMeridianFlipOnSlewSupported())
{
// Update side of pier to destination side of pier
// Assumption: Mount will do meridian flip if required
SharedResourcesWrapper.SideOfPier = DestinationSideOfPier(TargetRightAscension, TargetDeclination);
}
switch (response)
{
case "0":
//We're slewing everything should be working just fine.
LogMessage("DoSlewAsync", "Slewing to target");
SetSlewingMinEndTime();
break;
case "1":
//Below Horizon
string belowHorizonMessage = SharedResourcesWrapper.ReadTerminated();
LogMessage("DoSlewAsync", $"Slew failed \"{belowHorizonMessage}\"");
throw new InvalidOperationException(belowHorizonMessage);
case "2":
//Below minimum elevation
string belowMinimumElevationMessage = SharedResourcesWrapper.ReadTerminated();
LogMessage("DoSlewAsync", $"Slew failed \"{belowMinimumElevationMessage}\"");
throw new InvalidOperationException(belowMinimumElevationMessage);
case "3":
//Telescope can hit the mount
string canHitMountMessage = SharedResourcesWrapper.ReadTerminated();
LogMessage("DoSlewAsync", $"Slew failed \"{canHitMountMessage}\"");
throw new InvalidOperationException(canHitMountMessage);
default:
LogMessage("DoSlewAsync", $"Slew failed - unknown response \"{response}\"");
throw new DriverException("This error should not happen");
if (IsMeridianFlipOnSlewSupported())
{
// Update side of pier to destination side of pier
// Assumption: Mount will do meridian flip if required
SharedResourcesWrapper.SideOfPier =
DestinationSideOfPier(TargetRightAscension, TargetDeclination);
}
}
SetSlewingMinEndTime();
break;
case "1":
//Below Horizon
string belowHorizonMessage = SharedResourcesWrapper.ReadTerminated();
LogMessage("DoSlewAsync", $"Slew failed \"{belowHorizonMessage}\"");
throw new InvalidOperationException(belowHorizonMessage);
case "2":
//Below minimum elevation
string belowMinimumElevationMessage = SharedResourcesWrapper.ReadTerminated();
LogMessage("DoSlewAsync", $"Slew failed \"{belowMinimumElevationMessage}\"");
throw new InvalidOperationException(belowMinimumElevationMessage);
case "3":
//Telescope can hit the mount
string canHitMountMessage = SharedResourcesWrapper.ReadTerminated();
LogMessage("DoSlewAsync", $"Slew failed \"{canHitMountMessage}\"");
throw new InvalidOperationException(canHitMountMessage);
default:
LogMessage("DoSlewAsync", $"Slew failed - unknown response \"{response}\"");
throw new DriverException("This error should not happen");
break;
case false:
var maResponse = SharedResourcesWrapper.SendChar("MA");
//:MA# Autostar, LX 16", Autostar II - Slew to target Alt and Az
//Returns:
//0 - No fault
//1 - Fault
//LX200 - Not supported
}
if (maResponse == "1")
{
throw new InvalidOperationException("fault");
}
SetSlewingMinEndTime();
break;
}
});
break;
case false:
var maResponse = SharedResourcesWrapper.SendChar("MA");
//:MA# Autostar, LX 16", Autostar II - Slew to target Alt and Az
//Returns:
//0 - No fault
//1 - Fault
//LX200 - Not supported
if (maResponse == "1")
{
throw new InvalidOperationException("fault");
}
SetSlewingMinEndTime();
break;
}
}
public void SlewToCoordinates(double rightAscension, double declination)
@@ -2450,17 +2443,15 @@ namespace ASCOM.Meade.net
public void SyncToCoordinates(double rightAscension, double declination)
{
LogMessage("SyncToCoordinates", $"RA={rightAscension} Dec={declination}");
LogMessage("SyncToCoordinates", $"RA={_utilitiesExtra.HoursToHMS(rightAscension)} Dec={_utilitiesExtra.HoursToHMS(declination)}");
LogMessage("SyncToCoordinates",
$"RA={_utilitiesExtra.HoursToHMS(rightAscension)} Dec={_utilitiesExtra.HoursToHMS(declination)}");
CheckConnected("SyncToCoordinates");
CheckParked();
SharedResourcesWrapper.Lock(() =>
{
TargetRightAscension = rightAscension;
TargetDeclination = declination;
TargetRightAscension = rightAscension;
TargetDeclination = declination;
SyncToTarget();
});
SyncToTarget();
}
public void SyncToTarget()
@@ -2612,13 +2603,15 @@ namespace ASCOM.Meade.net
get
{
LogMessage("Tracking", "Get");
bool isTracking = true;
if (IsGwCommandSupported())
{
var alignmentStatus = GetScopeAlignmentStatus();
return alignmentStatus.Tracking;
isTracking = alignmentStatus.Tracking;
}
return true;
LogMessage("Tracking", $"Get = {isTracking}");
return isTracking;
}
set
{
@@ -2731,23 +2724,18 @@ namespace ASCOM.Meade.net
{
CheckParked();
var telescopeDateDetails = SharedResourcesWrapper.Lock(() =>
var telescopeDateDetails = new TelescopeDateDetails
{
var tdd = new TelescopeDateDetails
{
TelescopeDate = SharedResourcesWrapper.SendString("GC"),
//:GC# Get current date.
//Returns: MM/DD/YY#
//The current local calendar date for the telescope.
TelescopeTime = SharedResourcesWrapper.SendString("GL"),
//:GL# Get Local Time in 24 hour format
//Returns: HH:MM:SS#
//The Local Time in 24 - hour Format
UtcCorrection = GetUtcCorrection()
};
return tdd;
});
TelescopeDate = SharedResourcesWrapper.SendString("GC"),
//:GC# Get current date.
//Returns: MM/DD/YY#
//The current local calendar date for the telescope.
TelescopeTime = SharedResourcesWrapper.SendString("GL"),
//:GL# Get Local Time in 24 hour format
//Returns: HH:MM:SS#
//The Local Time in 24 - hour Format
UtcCorrection = GetUtcCorrection()
};
int month = telescopeDateDetails.TelescopeDate.Substring(0, 2).ToInteger();
int day = telescopeDateDetails.TelescopeDate.Substring(3, 2).ToInteger();
@@ -2783,40 +2771,37 @@ namespace ASCOM.Meade.net
CheckConnected("UTCDate Set");
SharedResourcesWrapper.Lock(() =>
var utcCorrection = GetUtcCorrection();
var localDateTime = value - utcCorrection;
string localStingCommand = $"SL{localDateTime:HH:mm:ss}";
var timeResult = SharedResourcesWrapper.SendChar(localStingCommand);
//:SLHH:MM:SS#
//Set the local Time
//Returns:
//0 - Invalid
//1 - Valid
if (timeResult != "1")
{
var utcCorrection = GetUtcCorrection();
var localDateTime = value - utcCorrection;
throw new InvalidOperationException("Failed to set local time");
}
string localStingCommand = $"SL{localDateTime:HH:mm:ss}";
var timeResult = SharedResourcesWrapper.SendChar(localStingCommand);
//:SLHH:MM:SS#
//Set the local Time
//Returns:
//0 - Invalid
//1 - Valid
if (timeResult != "1")
{
throw new InvalidOperationException("Failed to set local time");
}
string localDateCommand = $"SC{localDateTime:MM/dd/yy}";
var dateResult = SharedResourcesWrapper.SendChar(localDateCommand);
//:SCMM/DD/YY#
//Change Handbox Date to MM/DD/YY
//Returns: <D><string>
//D = '0' if the date is invalid. The string is the null string.
//D = '1' for valid dates and the string is "Updating Planetary Data# #"
//Note: For Autostar II this is the UTC data!
if (dateResult != "1")
{
throw new InvalidOperationException("Failed to set local date");
}
string localDateCommand = $"SC{localDateTime:MM/dd/yy}";
var dateResult = SharedResourcesWrapper.SendChar(localDateCommand);
//:SCMM/DD/YY#
//Change Handbox Date to MM/DD/YY
//Returns: <D><string>
//D = '0' if the date is invalid. The string is the null string.
//D = '1' for valid dates and the string is "Updating Planetary Data# #"
//Note: For Autostar II this is the UTC data!
if (dateResult != "1")
{
throw new InvalidOperationException("Failed to set local date");
}
//throwing away these two strings which represent
SharedResourcesWrapper.ReadTerminated(); //Updating Planetary Data#
SharedResourcesWrapper.ReadTerminated(); // #
});
//throwing away these two strings which represent
SharedResourcesWrapper.ReadTerminated(); //Updating Planetary Data#
SharedResourcesWrapper.ReadTerminated(); // #
}
}
+18 -21
View File
@@ -297,30 +297,27 @@ namespace ASCOM.Meade.net
var direction = position > 0;
if (ReverseFocusDirection)
direction = !direction;
//backlash compensation.
var backlashCompensationSteps = direction ? Math.Abs(BacklashCompensation) : 0;
SharedResourcesWrapper.Lock(() =>
var steps = Math.Abs(position) + backlashCompensationSteps;
MoveFocuser(direction, steps);
//todo refactor the backlash compensation to combine the commands into as few moves as practicle.
//ApplyBacklashCompensation(direction);
if (direction & backlashCompensationSteps != 0)
{
//backlash compensation.
var backlashCompensationSteps = direction ? Math.Abs(BacklashCompensation) : 0;
Tl.LogMessage("Move", "Applying backlash compensation");
MoveFocuser(!direction, backlashCompensationSteps);
}
var steps = Math.Abs(position) + backlashCompensationSteps;
MoveFocuser(direction, steps);
//todo refactor the backlash compensation to combine the commands into as few moves as practicle.
//ApplyBacklashCompensation(direction);
if (direction & backlashCompensationSteps != 0)
{
Tl.LogMessage("Move", "Applying backlash compensation");
MoveFocuser(!direction, backlashCompensationSteps);
}
DynamicBreaking(direction);
//todo implement dynamic braking
//dynamic breaking is sending the command to move in the opposite direction immediatly followed by the command to stop.
});
DynamicBreaking(direction);
//todo implement dynamic braking
//dynamic breaking is sending the command to move in the opposite direction immediatly followed by the command to stop.
}
private void DynamicBreaking(bool directionOut)
+1
View File
@@ -23,6 +23,7 @@
// ReSharper disable once InconsistentNaming
public const string LX200GPS = "LX2001";
public const string LX200GPS_42F = "4.2F";
// ReSharper disable once InconsistentNaming
public const string LX200GPS_42G = "4.2G";
#endregion
+1 -14
View File
@@ -12,10 +12,7 @@ namespace ASCOM.Meade.net.Wrapper
string ProductName { get; }
string FirmwareVersion { get; }
void Lock(Action action);
T Lock<T>(Func<T> func);
string SendString(string message, bool raw = false);
void SendBlind(string message, bool raw = false);
bool SendBool(string command, bool raw = false);
@@ -69,16 +66,6 @@ namespace ASCOM.Meade.net.Wrapper
public string FirmwareVersion => SharedResources.FirmwareVersion;
public void Lock(Action action)
{
SharedResources.Lock(action);
}
public T Lock<T>(Func<T> func)
{
return SharedResources.Lock(func);
}
public string SendString(string message, bool raw = false)
{
return SharedResources.SendString(message, raw);