Alignment: add TransformCelestialToTelescopeJD / TransformTelescopeToCelestialJD#2387
Alignment: add TransformCelestialToTelescopeJD / TransformTelescopeToCelestialJD#2387ckemper67 wants to merge 2 commits into
Conversation
…CelestialJD Add new *JD variants to MathPlugin and all built-in plugins (BasicMathPlugin, NearestMathPlugin, SPKMathPlugin, DummyMathPlugin) that accept an absolute Julian Date instead of reading the system clock internally. The old TransformCelestialToTelescope / TransformTelescopeToCelestial methods become thin shims (resolving ln_get_julian_from_sys() + JulianOffset) to preserve binary ABI compatibility with external DSO plugins. MathPluginManagement gains matching *JD dispatch methods; its old methods are also reduced to shims. Test suite migrated from the joff = fixedJD - ln_get_julian_from_sys() hack to direct *JD calls with a static constexpr fixedJD, making all tests deterministic and clock-independent.
248f5bd to
642a9ca
Compare
Fix MathPlugin default TransformCelestialToTelescopeJD/TransformTelescopeToCelestialJD fallback to pass JulianDate - ln_get_julian_from_sys() as the offset, so legacy external plugins that add ln_get_julian_from_sys() internally recover the correct absolute JD. Add override keyword to *JD method declarations in BasicMathPlugin, NearestMathPlugin, and DummyMathPlugin for consistency with SPKMathPlugin and compiler-enforced signature checking. Remove dead pTransformCelestialToTelescope and pTransformTelescopeToCelestial function pointer members from MathPluginManagement (dispatch now goes through direct virtual calls on pLoadedMathPlugin). Remove stale commented-out ln_get_julian_from_sys() lines from BasicMathPlugin.cpp and the trivial JDD alias variables from NearestMathPlugin.cpp. Add two regression tests (LegacyPlugin_JD_Fallback_*) that verify the fallback offset computation is correct for legacy external plugins.
642a9ca to
8911f90
Compare
|
Great work! I agree this would make all the testing and simulation deterministic now. You can mark the shim functions as deprecated. At the same time, another PR for all affected drivers should be prepared to migrate them to the new functions. |
|
Yes I will send the follow-up PRs once we have this submitted. Do you want the depreciation as part of this pull request or in a follow up as well? |
|
Sure you can add it to this PR as well. |
|
On second thought, I would prefer to combine the deprecation declaration with the PR that fixes the drivers. That way we don't introduce deprecation warnings/errors into the build. What do you think? #2388 is the followup. I based it on master, so it contains this PR as well. The last commit are the deprecation changes and the cleanups. |
Reviewer note
This PR changes a core alignment subsystem API (
MathPlugin,MathPluginManagement)that is used by multiple drivers inside this repo and by third-party drivers in
indi-3rdparty(notablyindi-celestronauxandindi-eqmod). Would appreciatearchitectural feedback before merge.
Summary
Refactors the INDI alignment subsystem so that the core transform methods no longer read
the system clock internally. Two new methods are added to
MathPluginthat accept anabsolute Julian Date directly:
TransformCelestialToTelescopeJD(RA, Dec, JulianDate, TDV)TransformTelescopeToCelestialJD(TDV, RA, Dec, JulianDate)All built-in plugins (
BasicMathPlugin/SVDMathPlugin,NearestMathPlugin,SPKMathPlugin,DummyMathPlugin) implement the new methods as their primaryimplementation. The old
TransformCelestialToTelescope/TransformTelescopeToCelestialmethods become thin compat shims that resolve
ln_get_julian_from_sys() + JulianOffsetand delegate to the new JD variants.
MathPluginManagementgains matching*JDdispatchmethods; its old public methods are similarly shimmed.
Motivation
The old interface forced every plugin to call
ln_get_julian_from_sys()internally.This had two consequences:
Tests were non-deterministic. The test suite worked around this with a
joff = fixedJD - ln_get_julian_from_sys()hack to re-anchor transforms to a fixedpoint in time. This was fragile and obscured intent.
Simulated time was impossible. Any future support for injected/simulated time
(e.g. KStars time simulation) requires callers to supply the JD — the plugins cannot
intercept
ln_get_julian_from_sys()from the outside.Backward compatibility
External plugins that have not yet adopted the new interface are unaffected at the
source and binary level. The new
*JDmethods are non-pure virtual. The base-classdefault computes
JulianOffset = JulianDate - ln_get_julian_from_sys()and calls theold pure-virtual, so an unmodified external plugin recovers the correct absolute JD
when it adds
ln_get_julian_from_sys()internally.All existing drivers that call the old
TransformCelestialToTelescope/TransformTelescopeToCelestialinterface — includingskywatcherAPIMount,indi-celestronaux,eqmod,telescope_simulator,astrotrac,temmadriver,dsc—continue to work unchanged through the compat shims. Non-zero
JulianOffsetcalls(e.g. bracket tracking in
skywatcherAPIMountandcelestronaux) are correctlyhandled: the shim resolves the absolute JD before dispatching.
Changes
libs/alignment/MathPlugin.h/.cppTransformCelestialToTelescopeJDandTransformTelescopeToCelestialJDasnon-pure virtual methods with default fallback implementations.
libs/alignment/BasicMathPlugin.h/.cpp,NearestMathPlugin,SPKMathPlugin,DummyMathPlugin*JDmethods as the primary implementation (clock-free).Transform*overrides to one-liner shims.libs/alignment/MathPluginManagement.h/.cppTransformCelestialToTelescopeJD/TransformTelescopeToCelestialJDdispatch methods (direct virtual call on
pLoadedMathPlugin).Transform*methods to compat shims.pTransformCelestialToTelescope/pTransformTelescopeToCelestialfunction pointer members (dispatch goes through direct virtual calls).
test/alignment/test_alignment_plugins.cppjoff = fixedJD - ln_get_julian_from_sys()workaround from all testblocks; replace with direct
*JDcalls usingstatic constexpr double fixedJD.LegacyPlugin_JD_Fallback_CelestialToTelescopeandLegacyPlugin_JD_Fallback_TelescopeToCelestial) that verify the base-class fallbackcorrectly converts an absolute JD to the offset expected by legacy external plugins.
Test results
Follow-up (not in this PR)
Phase 2 — Deprecate: Mark the old
Transform*pure-virtual methods[[deprecated]]to produce compiler warnings for external plugins that haven't migrated.
Phase 3 — Driver API: Thread a
JDparameter (with default= ln_get_julian_from_sys())through the six public methods of
AlignmentSubsystemForDrivers(
SkyToTelescopeEquatorial,TelescopeEquatorialToSky, etc.) and update the internalcall sites to use
*JDdirectly. Migrate directMathPluginManagementcallers(
skywatcherAPIMount,indi-celestronaux) to use*JDwith explicit JD values.Phase 4 — Remove: Once no callers use the old interface, make
*JDpure virtual andremove the compat layer entirely.