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"};
305 LOG_INFO(
"Slew is complete. Tracking...");
330 const struct timespec timeout = {0, 100000000L};
334 char RAStr[64] = {0}, DecStr[64] = {0};
379 nanosleep(&timeout,
nullptr);
396 LOGF_ERROR(
"Error Slewing to JNow RA %s - DEC %s", RAStr, DecStr);
405 LOGF_INFO(
"Slewing to RA: %s - DEC: %s", RAStr, DecStr);
412 char syncString[256] = {0};
431 LOG_INFO(
"Synchronization successful.");
442 const struct timespec timeout = {0, 100000000L};
473 nanosleep(&timeout,
nullptr);
485 LOG_INFO(
"Parking telescope in progress...");
498 LOG_ERROR(
"Error setting N/S motion direction.");
503 (current_move ==
LX200_NORTH) ?
"North" :
"South");
514 (current_move ==
LX200_NORTH) ?
"North" :
"South");
530 LOG_ERROR(
"Error setting W/E motion direction.");
545 (current_move ==
LX200_WEST) ?
"West" :
"East");
605 struct ln_zonedate ltm;
610 ln_date_to_zonedate(utc, <m, utc_offset * 3600.0);
612 JD = ln_get_julian_day(utc);
631 if (
setLocalDate(ltm.days, ltm.months, ltm.years) ==
false)
637 LOG_INFO(
"Time updated, updating planetary data...");
648 longitude = longitude - 360;
654 LOG_ERROR(
"Error setting site longitude coordinates");
660 LOG_ERROR(
"Error setting site latitude coordinates");
666 fs_sexa(l, latitude, 2, 36000);
667 fs_sexa(L, longitude, 2, 36000);
670 LOGF_INFO(
"Site location in the mount updated to Latitude %.12s (%g) Longitude %.12s (%g) (Longitude sign in carthography format)",
671 l, latitude, L, longitude);
704 if (strstr(name,
"FOCUS_"))
712 LOGF_DEBUG(
"Trying to set track freq of: %04.1f", values[0]);
730 LOGF_DEBUG(
"Trying to set track freq of: %f\n", values[0]);
733 LOGF_DEBUG(
"Trying to set track freq of: %f\n", values[0]);
795 if (strstr(name,
"FOCUS"))
834 char siteName[64] = {0};
1064 static struct timeval ltv;
1066 double dt = 0, da = 0, dx = 0;
1070 gettimeofday(&tv,
nullptr);
1072 if (ltv.tv_sec == 0 && ltv.tv_usec == 0)
1075 dt = tv.tv_sec - ltv.tv_sec + (tv.tv_usec - ltv.tv_usec) / 1e6;
1174 LOG_ERROR(
"Failed to retrieve time format from device.");
1190 char siteName[64] = {0};
1193 LOG_ERROR(
"Failed to get site name from device");
1206 LOG_ERROR(
"Failed to get tracking frequency from device.");
1223 else if (slewCode == 2)
1224 LOG_ERROR(
"Object below the minimum elevation limit.");
1266 time_t now = time (
nullptr);
1267 strftime(timeString,
MAXINDINAME,
"%T", localtime(&now));
1275 snprintf(timeString,
MAXINDINAME,
"%02d:%02d:%02d", h, m, s);
1285 time_t now = time (
nullptr);
1286 strftime(dateString,
MAXINDINAME,
"%F", localtime(&now));
1304 int lx200_utc_offset = 0;
1307 *offset = lx200_utc_offset * -1;
1318 memset(<m, 0,
sizeof(ltm));
1319 memset(&utm, 0,
sizeof(utm));
1326 char utcStr[8] = {0};
1327 snprintf(utcStr, 8,
"%.2f", offset);
1332 LOG_WARN(
"Could not obtain UTC offset from mount!");
1338 LOG_WARN(
"Could not obtain local time from mount!");
1344 LOG_WARN(
"Could not obtain local date from mount!");
1350 snprintf(datetime,
MAXINDINAME,
"%sT%s", cdate, ctime);
1353 if (strptime(datetime,
"%FT%T", <m) ==
nullptr)
1355 LOGF_WARN(
"Could not process mount date and time: %s", datetime);
1367 ltm.tm_isdst = isdst;
1369 time_epoch = mktime(<m);
1372 time_epoch -=
static_cast<int>(offset * 3600.0);
1375 localtime_r(&time_epoch, &utm);
1378 strftime(cdate,
MAXINDINAME,
"%Y-%m-%dT%H:%M:%S", &utm);
1393 int lat_dd = 0, lat_mm = 0, long_dd = 0, long_mm = 0;
1394 double lat_ssf = 0.0, long_ssf = 0.0;
1410 LOG_WARN(
"Failed to get site latitude from device.");
1415 snprintf(lat_sexagesimal,
MAXINDIFORMAT,
"%02d:%02d:%02.1lf", lat_dd, lat_mm, lat_ssf);
1421 LOG_WARN(
"Failed to get site longitude from device.");
1426 snprintf(lng_sexagesimal,
MAXINDIFORMAT,
"%02d:%02d:%02.1lf", long_dd, long_mm, long_ssf);
1430 LOGF_INFO(
"Mount has Latitude %s (%g) Longitude %s (%g) (Longitude sign in carthography format)",
1447 LOG_ERROR(
"Cannot guide while slewing or parking in progress. Stop first.");
1454 LOG_ERROR(
"Cannot pulse guide while manually in motion. Stop first.");
1486 LOG_ERROR(
"Cannot guide while slewing or parking in progress. Stop first.");
1493 LOG_ERROR(
"Cannot pulse guide while manually in motion. Stop first.");
1525 LOG_ERROR(
"Cannot guide while slewing or parking in progress. Stop first.");
1532 LOG_ERROR(
"Cannot pulse guide while manually in motion. Stop first.");
1564 LOG_ERROR(
"Cannot guide while slewing or parking in progress. Stop first.");
1571 LOG_ERROR(
"Cannot pulse guide while manually in motion. Stop first.");
const char * getDeviceName() const
virtual bool saveConfig(bool silent=false, const char *property=nullptr)
Save the current properties in a configuration file.
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.
void setDriverInterface(uint16_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
uint16_t getDriverInterface() const
Provides interface to implement focuser functionality.
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
INumberVectorProperty FocusTimerNP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
void initProperties(const char *groupName)
Initilize focuser properties. It is recommended to call this function within initProperties() of your...
@ FOCUSER_HAS_VARIABLE_SPEED
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.
INumberVectorProperty GuideNSNP
void initGuiderProperties(const char *deviceName, const char *groupName)
Initilize guider properties. It is recommended to call this function within initProperties() of your ...
INumberVectorProperty GuideWENP
void processGuiderProperties(const char *name, double values[], char *names[], int n)
Call this function whenever client updates GuideNSNP or GuideWSP properties in the primary device....
TelescopeStatus TrackState
ISwitchVectorProperty MovementNSSP
ISwitchVectorProperty AbortSP
INumberVectorProperty LocationNP
virtual bool initProperties() override
Called to initialize basic properties required all the time.
ITextVectorProperty TimeTP
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.
ISwitchVectorProperty TrackModeSP
ISwitchVectorProperty SlewRateSP
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....
INumberVectorProperty EqNP
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
ISwitchVectorProperty ParkSP
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.
ISwitchVectorProperty MovementWESP
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)
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.
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.
@ LX200_HAS_PULSE_GUIDING
@ LX200_HAS_PRECISE_TRACKING_FREQ
@ LX200_HAS_ALIGNMENT_TYPE
@ LX200_HAS_TRACKING_FREQ
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.
#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)
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 sideral time given longitude and system clock.
#define TRACKRATE_SIDEREAL
void IUSaveConfigSwitch(FILE *fp, const ISwitchVectorProperty *svp)
Add a switch vector property value to the configuration file.
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.
IText * IUFindText(const ITextVectorProperty *tvp, const char *name)
Find an IText member in a vector text property.
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,...)
int setFocuserMotion(int fd, int motionType)
int setAlignmentMode(int fd, unsigned int alignMode)
int setSlewMode(int fd, int slewMode)
int SendPulseCmd(int fd, int direction, int duration_msec, bool wait_after_command, int max_wait_ms)
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
char device[MAXINDIDEVICE]