Skip to content

Commit

Permalink
Merge branch 'libastro_refactor'
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed May 24, 2021
2 parents 9e7af7e + feb2e56 commit 6cf3eea
Show file tree
Hide file tree
Showing 57 changed files with 2,488 additions and 3,393 deletions.
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ SET(indiclient_C_SRC
${CMAKE_CURRENT_SOURCE_DIR}/base64.c)

SET(indiclient_CXX_SRC
${CMAKE_CURRENT_SOURCE_DIR}/libs/libastro.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/basedevice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/baseclient.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/property/indiproperty.cpp
Expand All @@ -198,8 +199,7 @@ IF (UNITY_BUILD)
ENABLE_UNITY_BUILD(indiclient_cxx indiclient_CXX_SRC 10 cpp)
ENDIF ()

SET(indiclient_C_SRC ${indiclient_C_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/libs/libastro.cpp
SET(indiclient_C_SRC ${indiclient_C_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/libs/indicom.c)

add_library(indiclient STATIC ${indiclient_C_SRC} ${indiclient_CXX_SRC})
Expand Down Expand Up @@ -253,6 +253,7 @@ SET(indiclientqt_C_SRC
${CMAKE_CURRENT_SOURCE_DIR}/libs/indiuserio.c
${CMAKE_CURRENT_SOURCE_DIR}/base64.c)
SET(indiclientqt_CXX_SRC
${CMAKE_CURRENT_SOURCE_DIR}/libs/libastro.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/basedevice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/baseclientqt.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/property/indiproperty.cpp
Expand All @@ -270,8 +271,7 @@ IF (UNITY_BUILD)
ENABLE_UNITY_BUILD(indiclientqt_cxx indiclientqt_CXX_SRC 10 cpp)
ENDIF ()

SET(indiclientqt_C_SRC ${indiclientqt_C_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/libs/libastro.cpp
SET(indiclientqt_C_SRC ${indiclientqt_C_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/libs/indicom.c)

add_library(indiclientqt STATIC ${indiclientqt_C_SRC} ${indiclientqt_CXX_SRC})
Expand Down Expand Up @@ -429,6 +429,7 @@ SET(indidriver_C_SRC
)

SET(indidriver_CXX_SRC
${CMAKE_CURRENT_SOURCE_DIR}/libs/libastro.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/basedevice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/defaultdevice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/property/indiproperty.cpp
Expand Down Expand Up @@ -477,7 +478,7 @@ SET(indidriver_CXX_SRC
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/dsp/dspinterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/dsp/transforms.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/dsp/convolution.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/pid/pid.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/pid/pid.cpp
)

IF (UNITY_BUILD)
Expand All @@ -488,8 +489,7 @@ ENDIF ()
SET(indidriver_C_SRC
${indidriver_C_SRC}
${libdsp_C_SRC}
${fpack_C_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/libs/libastro.cpp
${fpack_C_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/libs/indicom.c)

##################################################
Expand Down
31 changes: 15 additions & 16 deletions drivers/ccd/ccd_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,22 +636,22 @@ int CCDSim::DrawCcdFrame(INDI::CCDChip * targetChip)
currentRA = RA;
currentDE = Dec;

ln_equ_posn epochPos { 0, 0 }, J2000Pos { 0, 0 };
INDI::IEquatorialCoordinates epochPos { 0, 0 }, J2000Pos { 0, 0 };

double jd = ln_get_julian_from_sys();

epochPos.ra = currentRA * 15.0;
epochPos.dec = currentDE;
epochPos.rightascension = currentRA;
epochPos.declination = currentDE;

// Convert from JNow to J2000
LibAstro::ObservedToJ2000(&epochPos, jd, &J2000Pos);
INDI::ObservedToJ2000(&epochPos, jd, &J2000Pos);

currentRA = J2000Pos.ra / 15.0;
currentDE = J2000Pos.dec;
currentRA = J2000Pos.rightascension;
currentDE = J2000Pos.declination;

//LOGF_DEBUG("DrawCcdFrame JNow %f, %f J2000 %f, %f", epochPos.ra, epochPos.dec, J2000Pos.ra, J2000Pos.dec);
//ln_equ_posn jnpos;
//LibAstro::J2000toObserved(&J2000Pos, jd, &jnpos);
//INDI::IEquatorialCoordinates jnpos;
//INDI::J2000toObserved(&J2000Pos, jd, &jnpos);
//LOGF_DEBUG("J2000toObserved JNow %f, %f J2000 %f, %f", jnpos.ra, jnpos.dec, J2000Pos.ra, J2000Pos.dec);

currentDE += guideNSOffset;
Expand Down Expand Up @@ -1105,17 +1105,16 @@ bool CCDSim::ISNewNumber(const char * dev, const char * name, double values[], c
IUUpdateNumber(&EqPENP, values, names, n);
EqPENP.s = IPS_OK;

ln_equ_posn epochPos { 0, 0 }, J2000Pos { 0, 0 };
epochPos.ra = EqPEN[AXIS_RA].value * 15.0;
epochPos.dec = EqPEN[AXIS_DE].value;
INDI::IEquatorialCoordinates epochPos { 0, 0 }, J2000Pos { 0, 0 };
epochPos.rightascension = EqPEN[AXIS_RA].value;
epochPos.declination = EqPEN[AXIS_DE].value;

RA = EqPEN[AXIS_RA].value;
Dec = EqPEN[AXIS_DE].value;

LibAstro::ObservedToJ2000(&epochPos, ln_get_julian_from_sys(), &J2000Pos);
//ln_get_equ_prec2(&epochPos, ln_get_julian_from_sys(), JD2000, &J2000Pos);
currentRA = J2000Pos.ra / 15.0;
currentDE = J2000Pos.dec;
INDI::ObservedToJ2000(&epochPos, ln_get_julian_from_sys(), &J2000Pos);
currentRA = J2000Pos.rightascension;
currentDE = J2000Pos.declination;
usePE = true;

IDSetNumber(&EqPENP, nullptr);
Expand Down Expand Up @@ -1309,7 +1308,7 @@ bool CCDSim::ISSnoopDevice(XMLEle * root)

if (rc_ra == 0 && rc_de == 0 && ((newra != raPE) || (newdec != decPE)))
{
ln_equ_posn epochPos { 0, 0 }, J2000Pos { 0, 0 };
INDI::IEquatorialCoordinates epochPos { 0, 0 }, J2000Pos { 0, 0 };
epochPos.ra = newra * 15.0;
epochPos.dec = newdec;
ln_get_equ_prec2(&epochPos, ln_get_julian_from_sys(), JD2000, &J2000Pos);
Expand Down
36 changes: 10 additions & 26 deletions drivers/ccd/guide_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,18 +574,11 @@ int GuideSim::DrawCcdFrame(INDI::CCDChip * targetChip)
currentRA = RA;
currentDE = Dec;

ln_equ_posn epochPos { 0, 0 }, J2000Pos { 0, 0 };

epochPos.ra = currentRA * 15.0;
epochPos.dec = currentDE;

INDI::IEquatorialCoordinates epochPos { currentRA, currentDE }, J2000Pos { 0, 0 };
// Convert from JNow to J2000
LibAstro::ObservedToJ2000(&epochPos, ln_get_julian_from_sys(), &J2000Pos);
//ln_get_equ_prec2(&epochPos, ln_get_julian_from_sys(), JD2000, &J2000Pos);

currentRA = J2000Pos.ra / 15.0;
currentDE = J2000Pos.dec;

INDI::ObservedToJ2000(&epochPos, ln_get_julian_from_sys(), &J2000Pos);
currentRA = J2000Pos.rightascension;
currentDE = J2000Pos.declination;
currentDE += guideNSOffset;
currentRA += guideWEOffset;
#ifdef USE_EQUATORIAL_PE
Expand Down Expand Up @@ -661,7 +654,7 @@ int GuideSim::DrawCcdFrame(INDI::CCDChip * targetChip)
// tra, tdec are at the center of the projection center for the simulated
// images
//double J2ra = J2000Pos.ra; // J2000Pos: 0,360, RA: 0,24
double J2dec = J2000Pos.dec;
double J2dec = J2000Pos.declination;

//double J2rar = J2ra * 0.0174532925;
double J2decr = J2dec * 0.0174532925;
Expand Down Expand Up @@ -1137,23 +1130,14 @@ bool GuideSim::ISNewNumber(const char * dev, const char * name, double values[],
IUUpdateNumber(&EqPENP, values, names, n);
EqPENP.s = IPS_OK;

ln_equ_posn epochPos { 0, 0 }, J2000Pos { 0, 0 };
epochPos.ra = EqPEN[AXIS_RA].value * 15.0;
epochPos.dec = EqPEN[AXIS_DE].value;

RA = EqPEN[AXIS_RA].value;
Dec = EqPEN[AXIS_DE].value;

LibAstro::ObservedToJ2000(&epochPos, ln_get_julian_from_sys(), &J2000Pos);
//ln_get_equ_prec2(&epochPos, ln_get_julian_from_sys(), JD2000, &J2000Pos);
currentRA = J2000Pos.ra / 15.0;
currentDE = J2000Pos.dec;
INDI::IEquatorialCoordinates epochPos { EqPEN[AXIS_RA].value, EqPEN[AXIS_DE].value }, J2000Pos { 0, 0 };
INDI::ObservedToJ2000(&epochPos, ln_get_julian_from_sys(), &J2000Pos);
currentRA = J2000Pos.rightascension;
currentDE = J2000Pos.declination;
usePE = true;

IDSetNumber(&EqPENP, nullptr);
return true;
}

}

return INDI::CCD::ISNewNumber(dev, name, values, names, n);
Expand Down Expand Up @@ -1251,7 +1235,7 @@ bool GuideSim::ISSnoopDevice(XMLEle * root)

if (rc_ra == 0 && rc_de == 0 && ((newra != raPE) || (newdec != decPE)))
{
ln_equ_posn epochPos { 0, 0 }, J2000Pos { 0, 0 };
INDI::IEquatorialCoordinates epochPos { 0, 0 }, J2000Pos { 0, 0 };
epochPos.ra = newra * 15.0;
epochPos.dec = newdec;
ln_get_equ_prec2(&epochPos, ln_get_julian_from_sys(), JD2000, &J2000Pos);
Expand Down
2 changes: 1 addition & 1 deletion drivers/skeleton/mount_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class MountDriver : public INDI::Telescope, public INDI::GuiderInterface
///////////////////////////////////////////////////////////////////////////////
/// Class Variables
///////////////////////////////////////////////////////////////////////////////
ln_lnlat_posn m_GeographicLocation { 0, 0 };
IGeographicCoordinates m_GeographicLocation { 0, 0 };

/////////////////////////////////////////////////////////////////////////////
/// Static Helper Values
Expand Down
8 changes: 4 additions & 4 deletions drivers/telescope/celestrongps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,25 +595,25 @@ bool CelestronGPS::GotoAzAlt(double az, double alt)
{
if (isSimulation())
{
ln_hrz_posn horizontalPos;
INDI::IHorizontalCoordinates horizontalPos;
// Libnova south = 0, west = 90, north = 180, east = 270
horizontalPos.az = az + 180;
if (horizontalPos.az >= 360)
horizontalPos.az -= 360;
horizontalPos.alt = alt;
ln_lnlat_posn observer;
IGeographicCoordinates observer;
observer.lat = LocationN[LOCATION_LATITUDE].value;
observer.lng = LocationN[LOCATION_LONGITUDE].value;
if (observer.lng > 180)
observer.lng -= 360;
ln_equ_posn equatorialPos;
INDI::IEquatorialCoordinates equatorialPos;
ln_get_equ_from_hrz(&horizontalPos, &observer, ln_get_julian_from_sys(), &equatorialPos);
targetRA = equatorialPos.ra/15.0;
targetRA = equatorialPos.rightascension/15.0;
targetDEC = equatorialPos.dec;
}
Expand Down
Loading

0 comments on commit 6cf3eea

Please sign in to comment.