31#include <libnova/sidereal_time.h>
40#define LX200_GENERIC_SLEWRATE 5
41#define SIDRATE 0.004178
60 return static_cast<const char *
>(
"Standard LX200");
114 int selectedSite = 0;
120 IUFillSwitchVector(&
SiteSP,
SiteS, 4,
getDeviceName(),
"Sites",
"",
SITE_TAB,
IP_RW,
ISR_1OFMANY, 0,
IPS_IDLE);
122 char siteName[64] = {
"NA"};
304 LOG_INFO(
"Slew is complete. Tracking...");
330 const struct timespec timeout = {0, 100000000L};
334 char RAStr[64] = {0}, DecStr[64] = {0};
381 nanosleep(&timeout,
nullptr);
399 LOGF_ERROR(
"Error Slewing to JNow RA %s - DEC %s", RAStr, DecStr);
408 LOGF_INFO(
"Slewing to RA: %s - DEC: %s", RAStr, DecStr);
415 char syncString[256] = {0};
420 LOG_ERROR(
"Error setting RA/DEC. Unable to Sync.");
436 LOG_INFO(
"Synchronization successful.");
447 const struct timespec timeout = {0, 100000000L};
480 nanosleep(&timeout,
nullptr);
493 LOG_INFO(
"Parking telescope in progress...");
506 LOG_ERROR(
"Error setting N/S motion direction.");
511 (current_move ==
LX200_NORTH) ?
"North" :
"South");
522 (current_move ==
LX200_NORTH) ?
"North" :
"South");
538 LOG_ERROR(
"Error setting W/E motion direction.");
553 (current_move ==
LX200_WEST) ?
"West" :
"East");
616 struct ln_zonedate ltm;
621 ln_date_to_zonedate(utc, <m, utc_offset * 3600.0);
623 JD = ln_get_julian_day(utc);
642 if (
setLocalDate(ltm.days, ltm.months, ltm.years) ==
false)
648 LOG_INFO(
"Time updated, updating planetary data...");
659 longitude = longitude - 360;
665 LOG_ERROR(
"Error setting site longitude coordinates");
671 LOG_ERROR(
"Error setting site latitude coordinates");
677 fs_sexa(l, latitude, 2, 36000);
678 fs_sexa(L, longitude, 2, 36000);
681 LOGF_INFO(
"Site location in the mount updated to Latitude %.12s (%g) Longitude %.12s (%g) (Longitude sign in carthography format)",
682 l, latitude, L, longitude);
726 LOGF_DEBUG(
"Trying to set track freq of: %04.1f", values[0]);
744 LOGF_DEBUG(
"Trying to set track freq of: %f\n", values[0]);
747 LOGF_DEBUG(
"Trying to set track freq of: %f\n", values[0]);
827 char siteName[64] = {0};
985 static struct timeval ltv;
987 double dt = 0, da = 0, dx = 0;
991 gettimeofday(&tv,
nullptr);
993 if (ltv.tv_sec == 0 && ltv.tv_usec == 0)
996 dt = tv.tv_sec - ltv.tv_sec + (tv.tv_usec - ltv.tv_usec) / 1e6;
1095 LOG_ERROR(
"Failed to retrieve time format from device.");
1111 char siteName[64] = {0};
1114 LOG_ERROR(
"Failed to get site name from device");
1127 LOG_ERROR(
"Failed to get tracking frequency from device.");
1144 else if (slewCode == 2)
1145 LOG_ERROR(
"Object below the minimum elevation limit.");
1187 time_t now = time (
nullptr);
1188 strftime(timeString,
MAXINDINAME,
"%T", localtime(&now));
1197 snprintf(timeString,
MAXINDINAME,
"%02d:%02d:%02d", h, m, s);
1207 time_t now = time (
nullptr);
1208 strftime(dateString,
MAXINDINAME,
"%F", localtime(&now));
1227 int lx200_utc_offset = 0;
1231 *offset = lx200_utc_offset * -1;
1242 memset(<m, 0,
sizeof(ltm));
1243 memset(&utm, 0,
sizeof(utm));
1250 LOG_WARN(
"Could not obtain UTC offset from mount!");
1256 LOG_WARN(
"Could not obtain local time from mount!");
1262 LOG_WARN(
"Could not obtain local date from mount!");
1268 snprintf(datetime,
MAXINDINAME,
"%sT%s", cdate, ctime);
1271 if (strptime(datetime,
"%FT%T", <m) ==
nullptr)
1273 LOGF_WARN(
"Could not process mount date and time: %s", datetime);
1285 ltm.tm_isdst = isdst;
1292 LOGF_WARN(
"Mount clock is not set (%s local). Waiting for time to be set by the client.", datetime);
1299 time_epoch = mktime(<m);
1302 time_epoch -=
static_cast<int>(offset * 3600.0);
1305 localtime_r(&time_epoch, &utm);
1308 strftime(cdate,
MAXINDINAME,
"%Y-%m-%dT%H:%M:%S", &utm);
1311 char utcStr[8] = {0};
1312 snprintf(utcStr, 8,
"%.2f", offset);
1327 int lat_dd = 0, lat_mm = 0, long_dd = 0, long_mm = 0;
1328 double lat_ssf = 0.0, long_ssf = 0.0;
1344 LOG_WARN(
"Failed to get site latitude from device.");
1350 snprintf(lat_sexagesimal,
MAXINDIFORMAT,
"%02d:%02d:%02.1lf", lat_dd, lat_mm, lat_ssf);
1357 LOG_WARN(
"Failed to get site longitude from device.");
1363 snprintf(lng_sexagesimal,
MAXINDIFORMAT,
"%02d:%02d:%02.1lf", long_dd, long_mm, long_ssf);
1370 LOGF_INFO(
"Mount has Latitude %s (%g) Longitude (0 to +360 Eastwards) %s (%g)",
1387 LOG_ERROR(
"Cannot guide while slewing or parking in progress. Stop first.");
1394 LOG_ERROR(
"Cannot pulse guide while manually in motion. Stop first.");
1426 LOG_ERROR(
"Cannot guide while slewing or parking in progress. Stop first.");
1433 LOG_ERROR(
"Cannot pulse guide while manually in motion. Stop first.");
1465 LOG_ERROR(
"Cannot guide while slewing or parking in progress. Stop first.");
1472 LOG_ERROR(
"Cannot pulse guide while manually in motion. Stop first.");
1504 LOG_ERROR(
"Cannot guide while slewing or parking in progress. Stop first.");
1511 LOG_ERROR(
"Cannot pulse guide while manually in motion. Stop first.");
1541 return ::SendPulseCmd(
PortFD, direction, duration_msec);
INDI::PropertyText getText(const char *name) const
virtual bool saveConfig(bool silent=false, const char *property=nullptr)
Save the current properties in a configuration file.
void setDriverInterface(uint32_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
bool isSimulation() const
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
uint32_t getDriverInterface() const
Provides interface to implement focuser functionality.
INDI::PropertySwitch FocusReverseSP
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
@ FOCUSER_HAS_VARIABLE_SPEED
INDI::PropertyNumber FocusSpeedNP
INDI::PropertyNumber FocusTimerNP
void initProperties(const char *groupName)
Initialize focuser properties. It is recommended to call this function within initProperties() of you...
bool saveConfigItems(FILE *fp)
saveConfigItems save focuser properties defined in the interface in config file
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process focus number properties.
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process focus switch properties.
INDI::PropertyNumber GuideNSNP
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
INDI::PropertyNumber GuideWENP
void initProperties(const char *groupName)
Initialize guider properties. It is recommended to call this function within initProperties() of your...
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Call this function whenever client updates GuideNSNP or GuideWSP properties in the primary device....
void setState(IPState state)
const char * getDeviceName() const
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
const char * getName() const
int findOnSwitchIndex() const
TelescopeStatus TrackState
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual int AddTrackMode(const char *name, const char *label, bool isDefault=false)
AddTrackMode.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
IGeographicCoordinates m_Location
uint32_t GetTelescopeCapability() const
GetTelescopeCapability returns the capability of the Telescope.
void NewRaDec(double ra, double dec)
The child class calls this function when it has updates.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool Sync(double ra, double dec) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
uint32_t genericCapability
int8_t guide_direction_we
static void guideTimeoutHelperNS(void *p)
@ LX200_HAS_PULSE_GUIDING
@ LX200_HAS_PRECISE_TRACKING_FREQ
@ LX200_HAS_ALIGNMENT_TYPE
@ LX200_HAS_TRACKING_FREQ
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
ITextVectorProperty SiteNameTP
virtual void slewError(int slewCode)
bool updateSlewRate(int index)
virtual bool SetSlewRate(int index) override
SetSlewRate Set desired slew rate index.
static void updateFocusHelper(void *p)
virtual bool getLocalDate(char *dateString)
virtual bool Park() override
Park the telescope to its home position.
virtual bool updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
static constexpr int MIN_VALID_MOUNT_YEAR
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
ISwitchVectorProperty AlignmentSP
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
virtual bool getUTFOffset(double *offset)
virtual bool sendScopeLocation()
bool sendLocationOnStartup
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool isSlewComplete()
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual const char * getDefaultName() override
static void guideTimeoutHelperWE(void *p)
virtual bool ReadScopeStatus() override
Read telescope status.
virtual bool getLocalTime(char *timeString)
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
INumberVectorProperty TrackFreqNP
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool checkConnection()
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool sendScopeTime()
virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years)
virtual bool setLocalTime24(uint8_t hour, uint8_t minute, uint8_t second)
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
virtual void getBasicData()
virtual bool Goto(double ra, double dec) override
Move the scope to the supplied RA and DEC coordinates.
virtual bool setUTCOffset(double offset)
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override
MoveFocuser the focuser in a particular direction with a specific speed for a finite duration.
virtual bool SetFocuserSpeed(int speed) override
SetFocuserSpeed Set Focuser speed.
virtual bool Handshake() override
perform handshake with device to check communication
virtual int SendPulseCmd(int8_t direction, uint32_t duration_msec)
ISwitchVectorProperty SiteSP
virtual const char * getDriverName() override
int8_t guide_direction_ns
ISwitchVectorProperty UsePulseCmdSP
const char * GUIDE_TAB
GUIDE_TAB Where all the properties for guiding are located.
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
const char * MOTION_TAB
MOTION_TAB Where all the motion control properties of the device are located.
const char * SITE_TAB
SITE_TAB Where all site information setting are located.
const char * FOCUS_TAB
FOCUS_TAB Where all the properties for focuser are located.
void IERmTimer(int timerid)
Remove the timer with the given timerid, as returned from IEAddTimer() or IEAddPeriodicTimer().
int IEAddTimer(int millisecs, IE_TCF *fp, void *p)
Register a new single-shot timer function, fp, to be called with ud as argument after ms.
INDI::PropertySwitch ParkSP
INDI::PropertySwitch AbortSP
INDI::PropertyNumber TrackRateNP
INDI::PropertySwitch MovementNSSP
INDI::PropertyNumber EqNP
INDI::PropertySwitch SlewRateSP
INDI::PropertySwitch TrackModeSP
INDI::PropertyText TimeTP
INDI::PropertySwitch MovementWESP
INDI::PropertyNumber LocationNP
#define setLocalTime(fd, x, y, z)
int f_scansexa(const char *str0, double *dp)
convert sexagesimal string str AxBxC to double. x can be anything non-numeric. Any missing A,...
void getSexComponents(double value, int *d, int *m, int *s)
double range360(double r)
range360 Limits an angle to be between 0-360 degrees.
int fs_sexa(char *out, double a, int w, int fracbase)
Converts a sexagesimal number to a string. sprint the variable a in sexagesimal format into out[].
Implementations for common driver routines.
double get_local_sidereal_time(double longitude)
get_local_sidereal_time Returns local sidereal time given longitude and system clock.
void IUSaveConfigSwitch(FILE *fp, const ISwitchVectorProperty *svp)
Add a switch vector property value to the configuration file.
IText * IUFindText(const ITextVectorProperty *tvp, const char *name)
Find an IText member in a vector text property.
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
int IUFindOnSwitchIndex(const ISwitchVectorProperty *svp)
Returns the index of first ON switch it finds in the vector switch property.
void IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
void IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
void IUSaveText(IText *tp, const char *newtext)
Function to reliably save new text in a IText.
void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s)
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
void IUFillText(IText *tp, const char *name, const char *label, const char *initialText)
Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
void IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max, double step, double value)
Assign attributes for a number property. The number's auxiliary elements will be set to NULL.
void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name, const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s)
Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
void IDSetSwitch(const ISwitchVectorProperty *svp, const char *fmt,...)
int IUGetConfigText(const char *dev, const char *property, const char *member, char *value, int len)
IUGetConfigText Opens configuration file and reads single text property.
int IUGetConfigOnSwitchIndex(const char *dev, const char *property, int *index)
IUGetConfigOnSwitchIndex Opens configuration file and reads single switch property to find ON switch ...
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)
#define LOGF_INFO(fmt,...)
#define LOGF_WARN(fmt,...)
#define LOGF_DEBUG(fmt,...)
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
#define LOGF_ERROR(fmt,...)
#define TRACKRATE_SIDEREAL
int setFocuserMotion(int fd, int motionType)
int setAlignmentMode(int fd, unsigned int alignMode)
int setSlewMode(int fd, int slewMode)
int getSiteLongitude(int fd, int *ddd, int *mm, double *ssf)
int selectTrackingMode(int fd, int trackMode)
int getSiteName(int fd, char *siteName, int siteNum)
int selectSite(int fd, int siteNum)
int setObjectRA(int fd, double ra, bool addSpace)
int getLX200EquatorialFormat()
int setSiteLongitude(int fd, double CartographicLongitude, bool addSpace)
int setObjectDEC(int fd, double dec, bool addSpace)
int checkLX200EquatorialFormat(int fd)
int setSiteLatitude(int fd, double Lat, bool addSpace)
int setTrackFreq(int fd, double trackF)
int setFocuserSpeedMode(int fd, int speedMode)
int setCalenderDate(int fd, int dd, int mm, int yy, bool addSpace)
int getCalendarDate(int fd, char *date)
int MoveTo(int fd, int direction)
int getTimeFormat(int fd, int *format)
int getTrackFreq(int fd, double *value)
int setPreciseTrackFreq(int fd, double trackF)
int setSiteName(int fd, char *siteName, int siteNum)
void setLX200Debug(const char *deviceName, unsigned int debug_level)
int check_lx200_connection(int in_fd)
int HaltMovement(int fd, int direction)
int getSiteLatitude(int fd, int *dd, int *mm, double *ssf)
#define getUTCOffset(fd, x)
#define getLX200DEC(fd, x)
#define getLX200RA(fd, x)
#define getLocalTime24(fd, x)
#define toggleTimeFormat(fd)
#define LX200_GENERIC_SLEWRATE