30#include <libnova/transform.h>
36const int LX200SS2000PC::ShortTimeOut = 2;
37const int LX200SS2000PC::LongTimeOut = 10;
57 IUFillNumber(&SlewAccuracyN[0],
"SlewRA",
"RA (arcmin)",
"%10.6m", 0., 60., 1., 3.0);
58 IUFillNumber(&SlewAccuracyN[1],
"SlewDEC",
"Dec (arcmin)",
"%10.6m", 0., 60., 1., 3.0);
87 if (!strcmp(name, SlewAccuracyNP.
name))
94 if (SlewAccuracyN[0].value < 3 || SlewAccuracyN[1].value < 3)
95 IDSetNumber(&SlewAccuracyNP,
"Warning: Setting the slew accuracy too low may result in a dead lock");
116 return const_cast<const char *
>(
"SkySensor2000PC");
129 struct ln_zonedate ltm;
130 ln_date_to_zonedate(utc, <m,
static_cast<long>(utc_offset * 3600.0 + 0.5));
131 LOGF_DEBUG(
"New zonetime is %04d-%02d-%02d %02d:%02d:%06.3f (offset=%ld)", ltm.years,
132 ltm.months, ltm.days, ltm.hours, ltm.minutes, ltm.seconds, ltm.gmtoff);
133 JD = ln_get_julian_day(utc);
135 if (
setLocalTime(
PortFD, ltm.hours, ltm.minutes,
static_cast<int>(ltm.seconds + 0.5),
true))
170 return fabs(dx) <= (SlewAccuracyN[0].value / (900.0)) && fabs(dy) <= (SlewAccuracyN[1].value / 60.0);
173bool LX200SS2000PC::getCalendarDate(
int &year,
int &month,
int &day)
177 LOGF_DEBUG(
"LX200SS2000PC::getCalendarDate():: Date string from telescope: %s", date);
180 result = (sscanf(date,
"%d%*c%d%*c%d", &month, &day, &year) == 3);
181 LOGF_DEBUG(
"setCalenderDate: Date retrieved from telescope: %02d/%02d/%02d.", month, day,
191bool LX200SS2000PC::setCalenderDate(
int year,
int month,
int day)
199 int ss_year = 0, ss_month = 0, ss_day = 0;
200 const bool send_to_skysensor =
201 (!
getCalendarDate(ss_year, ss_month, ss_day) || year != ss_year || month != ss_month || day != ss_day);
202 LOGF_DEBUG(
"LX200SS2000PC::setCalenderDate(): Driver date %02d/%02d/%02d, SS2000PC date %02d/%02d/%02d.", month, day,
203 year, ss_month, ss_day, ss_year);
204 if (send_to_skysensor)
207 int nbytes_written = 0;
209 snprintf(buffer,
sizeof(buffer),
":SC %02d/%02d/%02d#", month, day, (year % 100));
215 && nbytes_read == 1 &&
220 strncmp(buffer,
"Updating planetary data#", 24) != 0)
223 "LX200SS2000PC::setCalenderDate(): Received unexpected first line '%s'.", buffer);
227 strncmp(buffer,
" #", 24) != 0)
230 "LX200SS2000PC::setCalenderDate(): Received unexpected second line '%s'.", buffer);
243 const bool send_to_skysensor = (
getUTCOffset(
PortFD, &ss_timezone) != 0 || offset != ss_timezone);
244 if (send_to_skysensor)
247 snprintf(temp_string,
sizeof(temp_string),
":SG %+03d#",
static_cast<int>(offset));
260 if (latitude == 0.0 && longitude == 0.0)
265 LOG_ERROR(
"Error setting site latitude coordinates");
270 LOG_ERROR(
"Error setting site longitude coordinates");
275 fs_sexa(slat, latitude, 3, 3600);
276 fs_sexa(slong, longitude, 4, 3600);
278 LOGF_INFO(
"Site location updated to Latitude: %.32s - Longitude: %.32s", slat, slong);
286int LX200SS2000PC::setSiteLatitude(
int fd,
double Lat)
299 snprintf(temp_string,
sizeof(temp_string),
":St %c%03d*%02d#", sign, d, m);
307int LX200SS2000PC::setSiteLongitude(
int fd,
double Long)
314 snprintf(temp_string,
sizeof(temp_string),
":Sg %03d*%02d#", d, m);
324 char AzStr[16], AltStr[16];
325 fs_sexa(AzStr, parkAz, 2, 3600);
326 fs_sexa(AltStr, parkAlt, 2, 3600);
327 LOGF_DEBUG(
"Parking to Az (%s) Alt (%s)...", AzStr, AltStr);
335 Goto(equatorialCoords.rightascension, equatorialCoords.declination);
350 LOGF_ERROR(
"Error Slewing to Az %s - Alt %s", AzStr, AltStr);
358 LOG_INFO(
"Parking is in progress...");
379 char AzStr[16], AltStr[16];
380 fs_sexa(AzStr, parkAz, 2, 3600);
381 fs_sexa(AltStr, parkAlt, 2, 3600);
382 LOGF_DEBUG(
"Syncing to parked coordinates Az (%s) Alt (%s)...", AzStr, AltStr);
389 currentRA = equatorialCoords.rightascension;
400 char syncString[256];
417 double parkAZ = horizontalCoords.azimuth;
418 double parkAlt = horizontalCoords.altitude;
420 char AzStr[16], AltStr[16];
421 fs_sexa(AzStr, parkAZ, 2, 3600);
422 fs_sexa(AltStr, parkAlt, 2, 3600);
424 LOGF_DEBUG(
"Setting current parking position to coordinates Az (%s) Alt (%s)...", AzStr, AltStr);
445 const struct timespec timeout = {0, 100000000L};
449 char RAStr[64] = {0}, DecStr[64] = {0};
496 nanosleep(&timeout,
nullptr);
514 LOGF_ERROR(
"Error Slewing to JNow RA %s - DEC %s", RAStr, DecStr);
523 LOGF_INFO(
"Slewing to RA: %s - DEC: %s", RAStr, DecStr);
530 char syncString[256] = {0};
535 LOG_ERROR(
"Error setting RA/DEC. Unable to Sync.");
551 LOG_INFO(
"Synchronization successful.");
585 LOG_INFO(
"Slew is complete. Tracking...");
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
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 setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
TelescopeStatus TrackState
void SetAxis1Park(double value)
SetRAPark Set current RA/AZ parking position. The data park file (stored in ~/.indi/ParkData....
void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount)
SetTelescopeCapability sets the Telescope capabilities. All capabilities must be initialized.
double GetAxis1Park() const
double GetAxis2Park() const
virtual void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
IGeographicCoordinates m_Location
void NewRaDec(double ra, double dec)
The child class calls this function when it has updates.
void SetAxis2Park(double steps)
SetDEPark Set current DEC/ALT parking position. The data park file (stored in ~/.indi/ParkData....
void SetParkDataType(TelescopeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual void getBasicData(void) override
virtual const char * getDefaultName(void) override
virtual bool setUTCOffset(double offset) override
virtual bool Goto(double ra, double dec) override
Move the scope to the supplied RA and DEC coordinates.
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
virtual bool updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual bool Park() override
Park the telescope to its home position.
virtual bool ReadScopeStatus() override
Read telescope status.
virtual bool isSlewComplete(void) override
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
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.
@ LX200_HAS_PULSE_GUIDING
virtual void slewError(int slewCode)
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool sendScopeLocation()
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool sendScopeTime()
void setLX200Capability(uint32_t cap)
const char * OPTIONS_TAB
OPTIONS_TAB Where all the driver's options are located. Those may include auxiliary controls,...
INDI::PropertySwitch AbortSP
INDI::PropertySwitch MovementNSSP
INDI::PropertyNumber EqNP
INDI::PropertySwitch SlewRateSP
INDI::PropertySwitch MovementWESP
INDI::PropertyNumber LocationNP
#define setLocalTime(fd, x, y, z)
#define NARRAY(a)
Handy macro to find the number of elements in array a[]. Must be used with actual array,...
void getSexComponents(double value, int *d, int *m, int *s)
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
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[].
int tty_nread_section(int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
Implementations for common driver routines.
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.
void IUSaveConfigNumber(FILE *fp, const INumberVectorProperty *nvp)
Add a number vector property value to the configuration file.
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 IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
#define LOGF_INFO(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 setAlignmentMode(int fd, unsigned int alignMode)
int setObjAlt(int fd, double alt)
int setObjAz(int fd, double az)
int setObjectRA(int fd, double ra, bool addSpace)
int getLX200EquatorialFormat()
int setStandardProcedure(int fd, const char *data)
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 setCalenderDate(int fd, int dd, int mm, int yy, bool addSpace)
int getCalendarDate(int fd, char *date)
int getCommandString(int fd, char *data, const char *cmd)
#define getUTCOffset(fd, x)
#define getLX200DEC(fd, x)
#define getLX200RA(fd, x)
std::vector< uint8_t > buffer
void EquatorialToHorizontal(IEquatorialCoordinates *object, IGeographicCoordinates *observer, double JD, IHorizontalCoordinates *position)
EquatorialToHorizontal Calculate horizontal coordinates from equatorial coordinates.
void HorizontalToEquatorial(IHorizontalCoordinates *object, IGeographicCoordinates *observer, double JD, IEquatorialCoordinates *position)
HorizontalToEquatorial Calculate Equatorial EOD Coordinates from horizontal coordinates.