private void SlewToEquatorialCoordinate(double rightAscension, double declination) { lock (Controller) { TargetRightAscension = rightAscension; TargetDeclination = declination; LogMessage("SlewToCoordinates", "RA:{0}/Dec:{1}", _AscomToolsCurrentPosition.Util.HoursToHMS(rightAscension, "h", "m", "s"), _AscomToolsCurrentPosition.Util.DegreesToDMS(declination, ":", ":")); DateTime currentTime = DateTime.Now; Controller.MCAxisStop(AxisId.Both_Axes); // Stop the axes moving to get distances AxisPosition currentAxisPosition = _CurrentPosition.ObservedAxes; AxisPosition targetAxisPosition = _CurrentPosition.GetAxisPositionForRADec(rightAscension, declination, _AscomToolsCurrentPosition); double slewSeconds = Controller.MCGetSlewTimeEstimate(targetAxisPosition, Hemisphere); // Get a refined target position allowing for slew time. targetAxisPosition = _CurrentPosition.GetAxisPositionForRADec(rightAscension, declination, _AscomToolsCurrentPosition, slewSeconds); _TargetPosition = new MountCoordinate(targetAxisPosition, _AscomToolsTargetPosition, currentTime); System.Diagnostics.Debug.WriteLine($"Current Physical SOP: { currentAxisPosition.PhysicalSideOfPier}\t\tPointing SOP: {_CurrentPosition.GetPointingSideOfPier(false)}"); System.Diagnostics.Debug.WriteLine($" Target Physical SOP: { targetAxisPosition.PhysicalSideOfPier}\t\tPointing SOP: {_TargetPosition.GetPointingSideOfPier(false)}"); System.Diagnostics.Debug.WriteLine($" PreviousAxisPosition: { _previousAxisPosition}\t\tPrevious DecFlipped: {_previousAxisPosition.DecFlipped}"); System.Diagnostics.Debug.WriteLine($" Previous Pointing SOP: { _previousPointingSOP}\t\tPrevious DecFlipped: {_previousAxisPosition.DecFlipped}"); _IsSlewing = true; Controller.MCAxisSlewTo(targetAxisPosition, Hemisphere); } }
public void TakiExample5_4_4() { using (AscomTools tools = new AscomTools()) { Angle longitude = new Angle("-1°20'20.54\""); tools.Transform.SiteLatitude = new Angle("52°40'6.38\""); tools.Transform.SiteLongitude = longitude; tools.Transform.SiteElevation = 175.5; DateTime initialTime = new DateTime(2017, 03, 28, 21, 0, 0); DateTime observationTime = new DateTime(2017, 03, 28, 21, 27, 56); MountCoordinate star1 = new MountCoordinate(new EquatorialCoordinate("0h7m54.0s", "29.038°"), new AxisPosition(1.732239, 1.463808, true), tools, observationTime); observationTime = new DateTime(2017, 03, 28, 21, 37, 02); MountCoordinate star2 = new MountCoordinate(new EquatorialCoordinate("2h21m45.0s", "89.222°"), new AxisPosition(5.427625, 0.611563, true), tools, observationTime); TakiEQMountMapper taki = new TakiEQMountMapper(star1, star2, initialTime); EquatorialCoordinate bCet = new EquatorialCoordinate("0h43m07s", "-18.038°"); DateTime targetTime = new DateTime(2017, 03, 28, 21, 52, 12); AxisPosition bCetExpected = new AxisPosition(2.27695654215, 0.657465529226, true); // 130.46°, 37.67° AxisPosition bCetCalculated = taki.GetAxisPosition(bCet, targetTime); System.Diagnostics.Debug.WriteLine("Expected: {0}, calculated: {1}", bCetExpected, bCetCalculated); double tolerance = 0.5; // degrees. bool testResult = ((Math.Abs(bCetExpected.DecAxis - bCetCalculated.DecAxis) < tolerance) && (Math.Abs(bCetExpected.RAAxis - bCetCalculated.RAAxis) < tolerance)); Assert.IsTrue(testResult); } }
public void MountCoordinateTest() { using (AscomTools _AscomTools = new AscomTools()) { double siteLongitude = -1.333333; double siteLatitude = 52.666667; _AscomTools.Transform.SiteLatitude = siteLatitude; _AscomTools.Transform.SiteLongitude = siteLongitude; _AscomTools.Transform.SiteElevation = 192; DateTime testTime = new DateTime(2019, 1, 18, 21, 11, 00); AltAzCoordinate altAzPosition = new AltAzCoordinate(_AscomTools.Transform.SiteLatitude, 0.0); MountCoordinate currentPosition = new MountCoordinate(altAzPosition, new AxisPosition(0.0, 0.0), _AscomTools, testTime); double lst = currentPosition.LocalApparentSiderialTime; double ra = currentPosition.Equatorial.RightAscension.Value; double dec = currentPosition.Equatorial.Declination.Value; double alt = currentPosition.AltAzimuth.Altitude.Value; double az = currentPosition.AltAzimuth.Azimuth.Value; double lstExpected = 4.95996448153762; double raExpected = 10.9439120745406; double decExpected = 89.9999999983757; double azExpected = 8.03515690758855E-09; double altExpected = 52.6666669999972; Assert.AreEqual(lstExpected, lst, 0.001, "LST test failed"); Assert.AreEqual(raExpected, ra, 0.0001, "RA test failed"); Assert.AreEqual(decExpected, dec, 0.0001, "Dec test failed"); Assert.AreEqual(azExpected, az, 0.0001, "Az test failed"); Assert.AreEqual(altExpected, alt, 0.0001, "Alt test failed"); } }
public void GetNCPEquatorial() { MountCoordinate mount = new MountCoordinate(new AxisPosition(0.0, 0.0), _Tools, _Now); EquatorialCoordinate currentRaDec = mount.Equatorial; Assert.AreEqual(2.00536, currentRaDec.RightAscension.Value, 0.00001, "RA Value"); Assert.AreEqual(90.0, currentRaDec.Declination.Value, 0.001, "Declination value"); }
public void LASTTest() { DateTime now = DateTime.Now; MountCoordinate mount = new MountCoordinate(new AxisPosition(0.0, 0.0), _Tools, now); double ASCOMLast = (18.697374558 + 24.065709824419081 * (_Tools.Util.DateLocalToJulian(now) - 2451545.0) + (_Tools.Transform.SiteLongitude / 15.0)) % 24.0; Assert.AreEqual(ASCOMLast, mount.LocalApparentSiderialTime.Value, 1 / 3600.00); }
private PierSide GetDestinationSideOfPier(double rightAscension, double declination) { DateTime currentTime = DateTime.Now; AxisPosition targetAxisPosition = _CurrentPosition.GetAxisPositionForRADec(rightAscension, declination, _AscomToolsCurrentPosition); MountCoordinate targetPosition = new MountCoordinate(targetAxisPosition, _AscomToolsTargetPosition, currentTime); return(targetPosition.PointingSideOfPier); }
public void SlewDec(double slewAngle, double expectedDec) { MountCoordinate currentPosition = new MountCoordinate(new AxisPosition(0.0, 0.0), _Tools, _Now); currentPosition.MoveRADec(new AxisPosition(0.0, slewAngle), _Tools, _Now); EquatorialCoordinate expected = new EquatorialCoordinate(currentPosition.Equatorial.RightAscension.Value, expectedDec); Assert.AreEqual(expected, currentPosition.Equatorial, "Slewed DEC test"); }
public void TestCalculateTargetAxis(double targetRa, double targetDec, double expectedAxisRa, double expectedAxisDec, bool decFlipped) { EquatorialCoordinate target = _Tools.GetEquatorial(0.0, 0.0, _Now); MountCoordinate mount = new MountCoordinate(new AxisPosition(0.0, 0.0), _Tools, _Now); AxisPosition axisPosition = mount.GetAxisPositionForRADec(targetRa, targetDec, _Tools); Assert.AreEqual(expectedAxisRa, axisPosition.RAAxis, 0.000001, "RA Axis"); Assert.AreEqual(expectedAxisDec, axisPosition.DecAxis, 0.000001, "Dec Axis"); Assert.AreEqual(decFlipped, axisPosition.DecFlipped, "Dec flipped"); }
public void SlewRA(double slewAngle, double expectedRA) { MountCoordinate currentPosition = new MountCoordinate(new AxisPosition(0.0, 0.0), _Tools, _Now); double targetRA = AstroConvert.RangeRA(currentPosition.Equatorial.RightAscension.Value + expectedRA); double targetDec = currentPosition.Equatorial.Declination.Value; currentPosition.MoveRADec(new AxisPosition(slewAngle, 0.0), _Tools, _Now); EquatorialCoordinate expected = new EquatorialCoordinate(targetRA, targetDec); Assert.AreEqual(expected.RightAscension, currentPosition.Equatorial.RightAscension, 0.000001, "RA test"); Assert.AreEqual(expected.Declination, currentPosition.Equatorial.Declination, 0.000001, "DEc test"); }
public void GenerateTestData() { MountCoordinate mount = new MountCoordinate( new AltAzCoordinate(_Tools.Transform.SiteLatitude, 0.0), new AxisPosition(0.0, 0.0), _Tools, _Now); AxisPosition axes = mount.GetAxisPositionForRADec(17.0, 15, _Tools); for (double ra = 0.0; ra < 24.0; ra = ra + 3.0) { for (double dec = -90.0; dec <= 90.0; dec = dec + 30.0) { axes = mount.GetAxisPositionForRADec(ra, dec, _Tools); System.Diagnostics.Debug.WriteLine($"[DataRow({ra}, {dec}, {axes.RAAxis.Value}, {axes.DecAxis.Value}, {(axes.DecFlipped ? "true":"false")})]"); } } foreach (double ra in new double[] { 8.0, 9.0, 14.0, 21.0 }) { foreach (double dec in new double[] { 90.0, 45.0, 0.0, -45.0, -90.0 }) { axes = mount.GetAxisPositionForRADec(ra, dec, _Tools); System.Diagnostics.Debug.WriteLine($"[DataRow({ra}, {dec}, {axes.RAAxis.Value}, {axes.DecAxis.Value}, {(axes.DecFlipped ? "true" : "false")})]"); } } System.Diagnostics.Debug.WriteLine("// ASCOM_SOP Tests"); double sopRA = 23.0; double sopDec = 15.0; axes = mount.GetAxisPositionForRADec(sopRA, sopDec, _Tools); System.Diagnostics.Debug.WriteLine($"[DataRow({sopRA}, {sopDec}, {axes.RAAxis.Value}, {axes.DecAxis.Value}, {(axes.DecFlipped ? "true" : "false")})] // Point A (SE)"); sopRA = 11.0; sopDec = 60.0; axes = mount.GetAxisPositionForRADec(sopRA, sopDec, _Tools); System.Diagnostics.Debug.WriteLine($"[DataRow({sopRA}, {sopDec}, {axes.RAAxis.Value}, {axes.DecAxis.Value}, {(axes.DecFlipped ? "true" : "false")})] // Point B (NW)"); sopRA = 5.0; sopDec = 60.0; axes = mount.GetAxisPositionForRADec(sopRA, sopDec, _Tools); System.Diagnostics.Debug.WriteLine($"[DataRow({sopRA}, {sopDec}, {axes.RAAxis.Value}, {axes.DecAxis.Value}, {(axes.DecFlipped ? "true" : "false")})] // Point C (NE)"); sopRA = 17.0; sopDec = 15.0; axes = mount.GetAxisPositionForRADec(sopRA, sopDec, _Tools); System.Diagnostics.Debug.WriteLine($"[DataRow({sopRA}, {sopDec}, {axes.RAAxis.Value}, {axes.DecAxis.Value}, {(axes.DecFlipped ? "true" : "false")})] // Point D (SW)"); Assert.IsTrue(true); }
public void TestGetDec(double expectedRA, double expectedDec, double RAAxis, double DecAxis, bool decFlipped) { EquatorialCoordinate target = _Tools.GetEquatorial(0.0, 0.0, _Now); MountCoordinate mount = new MountCoordinate( new AltAzCoordinate(_Tools.Transform.SiteLatitude, 0.0), new AxisPosition(0.0, 0.0), _Tools, _Now); AxisPosition axisPosition = new AxisPosition(RAAxis, DecAxis); Angle testDec = mount.GetDec(axisPosition); Assert.AreEqual(expectedDec, testDec, 0.000001, "Dec Value"); }
public void NorthHorizonAltAz() { EquatorialCoordinate target = _Tools.GetEquatorial(0.0, 0.0, _Now); MountCoordinate mount = new MountCoordinate(new AxisPosition(0.0, 0.0), _Tools, _Now); AxisPosition targetAxisPosition = mount.GetAxisPositionForRADec(target.RightAscension, target.Declination, _Tools); mount.MoveRADec(targetAxisPosition, _Tools, _Now); EquatorialCoordinate testRaDec = mount.Equatorial; // Assert.AreEqual(PierSide.pierEast, mount.GetPointingSideOfPier(false), "Pointing side of pier"); Assert.AreEqual(7.98608, testRaDec.RightAscension.Value, 0.00001, "RA Value"); Assert.AreEqual(37.333, testRaDec.Declination.Value, 0.001, "Declination value"); Assert.AreEqual(307.333, mount.ObservedAxes[1], 0.001, "Declination axis value"); }
public void SouthEastHorizonAltAz() { EquatorialCoordinate target = _Tools.GetEquatorial(0.0, 135.0, _Now); MountCoordinate mount = new MountCoordinate(new AxisPosition(0.0, 0.0), _Tools, _Now); AxisPosition targetAxisPosition = mount.GetAxisPositionForRADec(target.RightAscension, target.Declination, _Tools); mount.MoveRADec(targetAxisPosition, _Tools, _Now); EquatorialCoordinate testRaDec = mount.Equatorial; // Assert.AreEqual(PierSide.pierWest, mount.GetPointingSideOfPier(false), "Pointing side of pier"); Assert.AreEqual(23.42014, testRaDec.RightAscension.Value, 0.00001, "RA Value"); Assert.AreEqual(-25.39285, testRaDec.Declination.Value, 0.001, "Declination value"); Assert.AreEqual(244.60715, mount.ObservedAxes[1], 0.001, "Declination axis value"); }
private void RelocateMounts(double latitude, double longitude, double elevation) { _AscomToolsCurrentPosition.Transform.SiteLongitude = longitude; _AscomToolsTargetPosition.Transform.SiteLongitude = longitude; _AscomToolsCurrentPosition.Transform.SiteLatitude = latitude; _AscomToolsTargetPosition.Transform.SiteLatitude = latitude; _AscomToolsCurrentPosition.Transform.SiteElevation = elevation; _AscomToolsTargetPosition.Transform.SiteElevation = elevation; // Refresh the current positiona using the new longitude _CurrentPosition = new MountCoordinate(_CurrentPosition.ObservedAxes, _AscomToolsCurrentPosition, _CurrentPosition.SyncTime); if (_TargetPosition != null) { _TargetPosition = new MountCoordinate(_TargetPosition.ObservedAxes, _AscomToolsTargetPosition, _TargetPosition.SyncTime); } RefreshCurrentPosition(); }
public void TestGetRA(double expectedRa, double expectedDec, double RAAxis, double DecAxis, bool flippedDec) { EquatorialCoordinate target = _Tools.GetEquatorial(0.0, 0.0, _Now); MountCoordinate mount = new MountCoordinate( new AltAzCoordinate(_Tools.Transform.SiteLatitude, 0.0), new AxisPosition(0.0, 0.0), _Tools, _Now); AxisPosition axisPosition = new AxisPosition(RAAxis, DecAxis, flippedDec); System.Diagnostics.Debug.Write($"\nFlipped:{(flippedDec ? "Y" : "N")} Expecting: {expectedRa} ->"); HourAngle testRa = mount.GetRA(axisPosition); //if (Math.Abs(expectedRa-testRa)> 0.000001) //{ // System.Diagnostics.Debug.Write(" - FAIL"); //} Assert.AreEqual(expectedRa, testRa, 0.000001, "RA Value"); }
public void CalculateSlewAngles() { MountCoordinate currentPosition = new MountCoordinate(new AxisPosition(0.0, 0.0), _Tools, _Now); double ha = currentPosition.LocalApparentSiderialTime; System.Diagnostics.Debug.WriteLine("\nPoint A (SE)"); System.Diagnostics.Debug.WriteLine("============"); AxisPosition targetAxes = currentPosition.GetAxisPositionForRADec(AstroConvert.RangeRA(ha - 3.0), 10.0, _Tools); Angle[] deltaAngles = currentPosition.ObservedAxes.GetSlewAnglesTo(targetAxes); System.Diagnostics.Debug.WriteLine($"Slewing through: {deltaAngles[0]} / {deltaAngles[1]}"); currentPosition.MoveRADec(targetAxes, _Tools, _Now); currentPosition.DumpDebugInfo(); Assert.AreEqual(PierSide.pierWest, currentPosition.GetPointingSideOfPier(false), "Point A"); System.Diagnostics.Debug.WriteLine("\nPoint B (NW)"); System.Diagnostics.Debug.WriteLine("============"); targetAxes = currentPosition.GetAxisPositionForRADec(AstroConvert.RangeRA(ha + 9.0), 60.0, _Tools); deltaAngles = currentPosition.ObservedAxes.GetSlewAnglesTo(targetAxes); System.Diagnostics.Debug.WriteLine($"Slewing through: {deltaAngles[0]} / {deltaAngles[1]}"); currentPosition.MoveRADec(targetAxes, _Tools, _Now); currentPosition.DumpDebugInfo(); Assert.AreEqual(PierSide.pierEast, currentPosition.GetPointingSideOfPier(false), "Point B"); System.Diagnostics.Debug.WriteLine("\nPoint C (NE)"); System.Diagnostics.Debug.WriteLine("============"); targetAxes = currentPosition.GetAxisPositionForRADec(AstroConvert.RangeRA(ha - 9.0), 60.0, _Tools); deltaAngles = currentPosition.ObservedAxes.GetSlewAnglesTo(targetAxes); System.Diagnostics.Debug.WriteLine($"Slewing through: {deltaAngles[0]} / {deltaAngles[1]}"); currentPosition.MoveRADec(targetAxes, _Tools, _Now); currentPosition.DumpDebugInfo(); Assert.AreEqual(PierSide.pierWest, currentPosition.GetPointingSideOfPier(false), "Point C"); System.Diagnostics.Debug.WriteLine("\nPoint D (SW)"); System.Diagnostics.Debug.WriteLine("============"); targetAxes = currentPosition.GetAxisPositionForRADec(AstroConvert.RangeRA(ha + 3.0), 10.0, _Tools); deltaAngles = currentPosition.ObservedAxes.GetSlewAnglesTo(targetAxes); System.Diagnostics.Debug.WriteLine($"Slewing through: {deltaAngles[0]} / {deltaAngles[1]}"); currentPosition.MoveRADec(targetAxes, _Tools, _Now); currentPosition.DumpDebugInfo(); Assert.AreEqual(PierSide.pierEast, currentPosition.GetPointingSideOfPier(false), "Point D"); }
private void InitialiseCurrentPosition(bool firstConnection) { lock (Controller) { DateTime now = DateTime.Now; // This method is only called if this is the first connection to the mount // so override saved ParkStatus and always start off parked. _ParkedAxisPosition = Settings.AxisParkPosition; if (firstConnection) { _CurrentPosition = new MountCoordinate(_ParkedAxisPosition, _AscomToolsCurrentPosition, now); _previousAxisPosition = _ParkedAxisPosition; Controller.MCSetAxisPosition(_ParkedAxisPosition); } else { _previousAxisPosition = Controller.MCGetAxisPositions(); _CurrentPosition = new MountCoordinate(_previousAxisPosition, _AscomToolsCurrentPosition, now); } //if (Settings.ParkStatus != ParkStatus.Parked) //{ // Settings.ParkStatus = ParkStatus.Parked; // SaveSettings(); //} // Get the MoveAxis value limits. InitialiseAxisRates(); // Get the controllers current axis states and see if we need to // start tracking. _AxisState = Controller.MCGetAxesStates(); if (TrackingState != TrackingStatus.Off) { if ((!_AxisState[RA_AXIS].Slewing && !_AxisState[DEC_AXIS].Slewing)) { StartTracking(); } } } }
public void ASCOM_SOP() { MountCoordinate currentPosition = new MountCoordinate(new AxisPosition(0.0, 0.0), _Tools, _Now); double ha = currentPosition.LocalApparentSiderialTime; AxisPosition targetAxisPosition = currentPosition.GetAxisPositionForRADec(AstroConvert.RangeRA(ha - 3.0), 10.0, _Tools); MountCoordinate targetCoordinate = new MountCoordinate(targetAxisPosition, _Tools, _Now); // currentPosition.MoveRADec(targetAxisPosition, _Tools, _Now); Assert.AreEqual(PierSide.pierWest, targetCoordinate.GetPointingSideOfPier(false), "Point A"); targetAxisPosition = currentPosition.GetAxisPositionForRADec(AstroConvert.RangeRA(ha + 9.0), 60.0, _Tools); currentPosition.MoveRADec(targetAxisPosition, _Tools, _Now); Assert.AreEqual(PierSide.pierEast, currentPosition.GetPointingSideOfPier(false), "Point B"); targetAxisPosition = currentPosition.GetAxisPositionForRADec(AstroConvert.RangeRA(ha - 9.0), 60.0, _Tools); currentPosition.MoveRADec(targetAxisPosition, _Tools, _Now); Assert.AreEqual(PierSide.pierWest, currentPosition.GetPointingSideOfPier(false), "Point C"); targetAxisPosition = currentPosition.GetAxisPositionForRADec(AstroConvert.RangeRA(ha + 3.0), 10.0, _Tools); currentPosition.MoveRADec(targetAxisPosition, _Tools, _Now); Assert.AreEqual(PierSide.pierEast, currentPosition.GetPointingSideOfPier(false), "Point D"); }
public void GetTheoreticalFromEquatorial() { using (AscomTools tools = new AscomTools()) { Angle longitude = new Angle("-1°20'20.54\""); tools.Transform.SiteLatitude = new Angle("52°40'6.38\""); tools.Transform.SiteLongitude = longitude; tools.Transform.SiteElevation = 175.5; MountCoordinate mirphac = new MountCoordinate(new EquatorialCoordinate("3h25m34.77s", "49°55'12.0\""), new AxisPosition(1.04551212078025, 0.882804566344625, true), tools, _localTime); MountCoordinate almaak = new MountCoordinate(new EquatorialCoordinate("2h04m58.83s", "42°24'41.1\""), new AxisPosition(0.597795712351665, 0.817146830684098, true), tools, _localTime); MountCoordinate ruchbah = new MountCoordinate(new EquatorialCoordinate("1h26m58.39s", "60°19'33.3\""), new AxisPosition(0.506260233480349, 1.09753088667021, true), tools, _localTime); TakiEQMountMapper taki = new TakiEQMountMapper(mirphac, almaak, ruchbah, _localTime); EquatorialCoordinate gPer = new EquatorialCoordinate("2h03m28.89s", "54°34'10.9\""); AxisPosition gPerExpected = new AxisPosition(0.649384407012042, 0.998796900509728, true); AxisPosition gPerCalculated = taki.GetAxisPosition(gPer, _localTime); System.Diagnostics.Debug.WriteLine("Calculated: {0}, expected: {1}", gPerExpected, gPerCalculated); double tolerance = 0.25; // degrees. bool testResult = ((Math.Abs(gPerExpected.DecAxis - gPerCalculated.DecAxis) < tolerance) && (Math.Abs(gPerExpected.RAAxis - gPerCalculated.RAAxis) < tolerance)); Assert.IsTrue(testResult); } }