Instrument Neutral Distributed Interface INDI
1.9.5
|
Go to the documentation of this file.
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...");
329 const struct timespec timeout = {0, 100000000L};
333 char RAStr[64] = {0}, DecStr[64] = {0};
378 nanosleep(&timeout,
nullptr);
395 LOGF_ERROR(
"Error Slewing to JNow RA %s - DEC %s", RAStr, DecStr);
404 LOGF_INFO(
"Slewing to RA: %s - DEC: %s", RAStr, DecStr);
411 char syncString[256] = {0};
430 LOG_INFO(
"Synchronization successful.");
441 const struct timespec timeout = {0, 100000000L};
472 nanosleep(&timeout,
nullptr);
484 LOG_INFO(
"Parking telescope in progress...");
497 LOG_ERROR(
"Error setting N/S motion direction.");
502 (current_move ==
LX200_NORTH) ?
"North" :
"South");
513 (current_move ==
LX200_NORTH) ?
"North" :
"South");
529 LOG_ERROR(
"Error setting W/E motion direction.");
544 (current_move ==
LX200_WEST) ?
"West" :
"East");
604 struct ln_zonedate ltm;
609 ln_date_to_zonedate(utc, <m, utc_offset * 3600.0);
611 JD = ln_get_julian_day(utc);
630 if (
setLocalDate(ltm.days, ltm.months, ltm.years) ==
false)
636 LOG_INFO(
"Time updated, updating planetary data...");
647 longitude = longitude - 360;
653 LOG_ERROR(
"Error setting site longitude coordinates");
659 LOG_ERROR(
"Error setting site latitude coordinates");
665 fs_sexa(l, latitude, 2, 36000);
666 fs_sexa(L, longitude, 2, 36000);
669 LOGF_INFO(
"Site location in the mount updated to Latitude %.12s (%g) Longitude %.12s (%g) (Longitude sign in carthography format)",
670 l, latitude, L, longitude);
703 if (strstr(
name,
"FOCUS_"))
711 LOGF_DEBUG(
"Trying to set track freq of: %04.1f", values[0]);
729 LOGF_DEBUG(
"Trying to set track freq of: %f\n", values[0]);
732 LOGF_DEBUG(
"Trying to set track freq of: %f\n", values[0]);
794 if (strstr(
name,
"FOCUS"))
833 char siteName[64] = {0};
1063 static struct timeval ltv;
1065 double dt = 0, da = 0, dx = 0;
1069 gettimeofday(&tv,
nullptr);
1071 if (ltv.tv_sec == 0 && ltv.tv_usec == 0)
1074 dt = tv.tv_sec - ltv.tv_sec + (tv.tv_usec - ltv.tv_usec) / 1e6;
1173 LOG_ERROR(
"Failed to retrieve time format from device.");
1189 char siteName[64] = {0};
1192 LOG_ERROR(
"Failed to get site name from device");
1205 LOG_ERROR(
"Failed to get tracking frequency from device.");
1222 else if (slewCode == 2)
1223 LOG_ERROR(
"Object below the minimum elevation limit.");
1265 time_t now = time (
nullptr);
1266 strftime(timeString,
MAXINDINAME,
"%T", localtime(&now));
1274 snprintf(timeString,
MAXINDINAME,
"%02d:%02d:%02d", h, m, s);
1284 time_t now = time (
nullptr);
1285 strftime(dateString,
MAXINDINAME,
"%F", localtime(&now));
1303 int lx200_utc_offset = 0;
1306 *offset = lx200_utc_offset * -1;
1321 char utcStr[8] = {0};
1322 snprintf(utcStr, 8,
"%.2f", offset);
1327 LOG_WARN(
"Could not obtain UTC offset from mount!");
1333 LOG_WARN(
"Could not obtain local time from mount!");
1339 LOG_WARN(
"Could not obtain local date from mount!");
1345 snprintf(datetime,
MAXINDINAME,
"%sT%s", cdate, ctime);
1348 if (strptime(datetime,
"%FT%T", <m) ==
nullptr)
1350 LOGF_WARN(
"Could not process mount date and time: %s", datetime);
1355 time_epoch = mktime(<m);
1358 time_epoch -=
static_cast<int>(offset * 3600.0);
1361 localtime_r(&time_epoch, &utm);
1364 strftime(cdate,
MAXINDINAME,
"%Y-%m-%dT%H:%M:%S", &utm);
1379 int lat_dd = 0, lat_mm = 0, long_dd = 0, long_mm = 0;
1380 double lat_ssf = 0.0, long_ssf = 0.0;
1396 LOG_WARN(
"Failed to get site latitude from device.");
1401 snprintf(lat_sexagesimal,
MAXINDIFORMAT,
"%02d:%02d:%02.1lf", lat_dd, lat_mm, lat_ssf);
1407 LOG_WARN(
"Failed to get site longitude from device.");
1412 snprintf(lng_sexagesimal,
MAXINDIFORMAT,
"%02d:%02d:%02.1lf", long_dd, long_mm, long_ssf);
1416 LOGF_INFO(
"Mount has Latitude %s (%g) Longitude %s (%g) (Longitude sign in carthography format)",
1433 LOG_ERROR(
"Cannot guide while slewing or parking in progress. Stop first.");
1440 LOG_ERROR(
"Cannot pulse guide while manually in motion. Stop first.");
1472 LOG_ERROR(
"Cannot guide while slewing or parking in progress. Stop first.");
1479 LOG_ERROR(
"Cannot pulse guide while manually in motion. Stop first.");
1511 LOG_ERROR(
"Cannot guide while slewing or parking in progress. Stop first.");
1518 LOG_ERROR(
"Cannot pulse guide while manually in motion. Stop first.");
1550 LOG_ERROR(
"Cannot guide while slewing or parking in progress. Stop first.");
1557 LOG_ERROR(
"Cannot pulse guide while manually in motion. Stop first.");
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
#define getUTCOffset(fd, x)
int setSiteLatitude(int fd, double Lat)
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...
void setLX200Debug(const char *deviceName, unsigned int debug_level)
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
int setSlewMode(int fd, int slewMode)
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
int SendPulseCmd(int fd, int direction, uint32_t duration_msec)
bool updateSlewRate(int index)
virtual void getBasicData()
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years)
char device[MAXINDIDEVICE]
virtual bool Sync(double ra, double dec) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
#define LOGF_ERROR(fmt,...)
int getSiteLatitude(int fd, int *dd, int *mm, double *ssf)
virtual bool checkConnection()
#define getLocalTime24(fd, x)
Implementations for common driver routines.
const char * MOTION_TAB
MOTION_TAB Where all the motion control properties of the device are located.
void IDSetText(const ITextVectorProperty *t, const char *msg,...) ATTRIBUTE_FORMAT_PRINTF(2
Tell client to update an existing text vector property.
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
void getSexComponents(double value, int *d, int *m, int *s)
int8_t guide_direction_we
static void guideTimeoutHelperWE(void *p)
ISwitchVectorProperty MovementNSSP
int f_scansexa(const char *str0, double *dp)
convert sexagesimal string str AxBxC to double.
virtual bool setUTCOffset(double offset)
INumberVectorProperty GuideWENP
void NewRaDec(double ra, double dec)
The child class calls this function when it has updates.
@ LX200_HAS_PRECISE_TRACKING_FREQ
bool isSimulation() const
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 defineProperty(INumberVectorProperty *property)
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
virtual bool SetSlewRate(int index) override
SetSlewRate Set desired slew rate index.
int selectSite(int fd, int siteNum)
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.
Provides interface to implement focuser functionality.
INumberVectorProperty LocationNP
int setSiteName(int fd, char *siteName, int siteNum)
virtual bool SetFocuserSpeed(int speed) override
SetFocuserSpeed Set Focuser speed.
@ FOCUSER_HAS_VARIABLE_SPEED
const char * GUIDE_TAB
GUIDE_TAB Where all the properties for guiding are located.
#define LX200_GENERIC_SLEWRATE
const char * SITE_TAB
SITE_TAB Where all site information setting are located.
#define getLX200DEC(fd, x)
const char * getDeviceName() const
int getSiteName(int fd, char *siteName, int siteNum)
virtual bool isSlewComplete()
int selectTrackingMode(int fd, int trackMode)
const char * FOCUS_TAB
FOCUS_TAB Where all the properties for focuser are located.
void initGuiderProperties(const char *deviceName, const char *groupName)
Initilize guider properties. It is recommended to call this function within initProperties() of your ...
int getCalendarDate(int fd, char *date)
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.
INumberVectorProperty EqNP
IGeographicCoordinates m_Location
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
virtual bool ReadScopeStatus() override
Read telescope status.
virtual bool sendScopeLocation()
void IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
virtual bool Goto(double ra, double dec) override
Move the scope to the supplied RA and DEC coordinates.
TelescopeStatus TrackState
virtual bool sendScopeTime()
ITextVectorProperty TimeTP
ISwitchVectorProperty AbortSP
virtual bool getUTFOffset(double *offset)
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
IText * IUFindText(const ITextVectorProperty *tvp, const char *name)
Find an IText member in a vector text property.
INumberVectorProperty GuideNSNP
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
int setSiteLongitude(int fd, double CartographicLongitude)
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 LOGF_DEBUG(fmt,...)
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
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.
int setFocuserSpeedMode(int fd, int speedMode)
static void updateFocusHelper(void *p)
int IUGetConfigText(const char *dev, const char *property, const char *member, char *value, int len)
IUGetConfigText Opens configuration file and reads single text property.
virtual bool getLocalDate(char *dateString)
bool saveConfigItems(FILE *fp)
saveConfigItems save focuser properties defined in the interface in config file
bool sendLocationOnStartup
virtual void slewError(int slewCode)
INumberVectorProperty FocusTimerNP
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
virtual uint16_t getDriverInterface() override
ISwitchVectorProperty TrackModeSP
#define LOGF_WARN(fmt,...)
#define setLocalTime(fd, x, y, z)
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.
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.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
ISwitchVectorProperty AlignmentSP
int getLX200EquatorialFormat()
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process focus number properties.
@ LX200_HAS_TRACKING_FREQ
ISwitchVectorProperty MovementWESP
virtual bool Handshake() override
perform handshake with device to check communication
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...
#define getLX200RA(fd, x)
int8_t guide_direction_ns
@ LX200_HAS_PULSE_GUIDING
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual const char * getDefaultName() override
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
int setObjectRA(int fd, double ra)
virtual bool setLocalTime24(uint8_t hour, uint8_t minute, uint8_t second)
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
int getTrackFreq(int fd, double *value)
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.
#define toggleTimeFormat(fd)
double get_local_sidereal_time(double longitude)
get_local_sidereal_time Returns local sideral time given longitude and system clock.
#define LOGF_INFO(fmt,...)
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...
int getSiteLongitude(int fd, int *ddd, int *mm, double *ssf)
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
int setCalenderDate(int fd, int dd, int mm, int yy)
void IUSaveText(IText *tp, const char *newtext)
Function to reliably save new text in a IText.
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
int setAlignmentMode(int fd, unsigned int alignMode)
int setPreciseTrackFreq(int fd, double trackF)
void initProperties(const char *groupName)
Initilize focuser properties. It is recommended to call this function within initProperties() of your...
virtual void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool saveConfig(bool silent=false, const char *property=nullptr)
Save the current properties in a configuration file.
ISwitchVectorProperty SlewRateSP
int setTrackFreq(int fd, double trackF)
static void guideTimeoutHelperNS(void *p)
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process focus switch properties.
#define TRACKRATE_SIDEREAL
int setFocuserMotion(int fd, int motionType)
int setObjectDEC(int fd, double dec)
int fs_sexa(char *out, double a, int w, int fracbase)
Converts a sexagesimal number to a string.
INumberVectorProperty TrackFreqNP
int checkLX200EquatorialFormat(int fd)
virtual int AddTrackMode(const char *name, const char *label, bool isDefault=false)
AddTrackMode.
@ LX200_HAS_ALIGNMENT_TYPE
int getTimeFormat(int fd, int *format)
int IUGetConfigOnSwitchIndex(const char *dev, const char *property, int *index)
IUGetConfigOnSwitchIndex Opens configuration file and reads single switch property to find ON switch ...
int IUFindOnSwitchIndex(const ISwitchVectorProperty *sp)
Returns the index of first ON switch it finds in the vector switch property.
virtual const char * getDriverName() override
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
void IUSaveConfigSwitch(FILE *fp, const ISwitchVectorProperty *svp)
Add a switch vector property value to the configuration file.
int MoveTo(int fd, int direction)
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
uint32_t GetTelescopeCapability() const
GetTelescopeCapability returns the capability of the Telescope.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
int check_lx200_connection(int fd)
ISwitchVectorProperty ParkSP
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
int HaltMovement(int fd, int direction)
void void void IDSetNumber(const INumberVectorProperty *n, const char *msg,...) ATTRIBUTE_FORMAT_PRINTF(2
Tell client to update an existing number vector property.
void void void void void IDSetSwitch(const ISwitchVectorProperty *s, const char *msg,...) ATTRIBUTE_FORMAT_PRINTF(2
Tell client to update an existing switch vector property.
ITextVectorProperty SiteNameTP
virtual int SendPulseCmd(int8_t direction, uint32_t duration_msec)
void setDriverInterface(uint16_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
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.
ISwitchVectorProperty UsePulseCmdSP
uint32_t genericCapability
void IERmTimer(int timerid)
Remove the timer with the given timerid, as returned from IEAddTimer() or IEAddPeriodicTimer().
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....
ISwitchVectorProperty SiteSP