29 #include <libnova/transform.h>
35 const int LX200SS2000PC::ShortTimeOut = 2;
36 const int LX200SS2000PC::LongTimeOut = 10;
56 IUFillNumber(&SlewAccuracyN[0],
"SlewRA",
"RA (arcmin)",
"%10.6m", 0., 60., 1., 3.0);
57 IUFillNumber(&SlewAccuracyN[1],
"SlewDEC",
"Dec (arcmin)",
"%10.6m", 0., 60., 1., 3.0);
86 if (!strcmp(name, SlewAccuracyNP.
name))
93 if (SlewAccuracyN[0].value < 3 || SlewAccuracyN[1].value < 3)
94 IDSetNumber(&SlewAccuracyNP,
"Warning: Setting the slew accuracy too low may result in a dead lock");
115 return const_cast<const char *
>(
"SkySensor2000PC");
128 struct ln_zonedate ltm;
129 ln_date_to_zonedate(utc, <m,
static_cast<long>(utc_offset * 3600.0 + 0.5));
130 LOGF_DEBUG(
"New zonetime is %04d-%02d-%02d %02d:%02d:%06.3f (offset=%ld)", ltm.years,
131 ltm.months, ltm.days, ltm.hours, ltm.minutes, ltm.seconds, ltm.gmtoff);
132 JD = ln_get_julian_day(utc);
134 if (
setLocalTime(
PortFD, ltm.hours, ltm.minutes,
static_cast<int>(ltm.seconds + 0.5)) < 0)
169 return fabs(dx) <= (SlewAccuracyN[0].value / (900.0)) && fabs(dy) <= (SlewAccuracyN[1].value / 60.0);
172 bool LX200SS2000PC::getCalendarDate(
int &year,
int &month,
int &day)
176 LOGF_DEBUG(
"LX200SS2000PC::getCalendarDate():: Date string from telescope: %s", date);
179 result = (sscanf(date,
"%d%*c%d%*c%d", &month, &day, &year) == 3);
180 LOGF_DEBUG(
"setCalenderDate: Date retrieved from telescope: %02d/%02d/%02d.", month, day,
190 bool LX200SS2000PC::setCalenderDate(
int year,
int month,
int day)
198 int ss_year = 0, ss_month = 0, ss_day = 0;
199 const bool send_to_skysensor =
200 (!
getCalendarDate(ss_year, ss_month, ss_day) || year != ss_year || month != ss_month || day != ss_day);
201 LOGF_DEBUG(
"LX200SS2000PC::setCalenderDate(): Driver date %02d/%02d/%02d, SS2000PC date %02d/%02d/%02d.", month, day,
202 year, ss_month, ss_day, ss_year);
203 if (send_to_skysensor)
206 int nbytes_written = 0;
208 snprintf(
buffer,
sizeof(
buffer),
":SC %02d/%02d/%02d#", month, day, (year % 100));
214 && nbytes_read == 1 &&
219 strncmp(
buffer,
"Updating planetary data#", 24) != 0)
222 "LX200SS2000PC::setCalenderDate(): Received unexpected first line '%s'.",
buffer);
226 strncmp(
buffer,
" #", 24) != 0)
229 "LX200SS2000PC::setCalenderDate(): Received unexpected second line '%s'.",
buffer);
242 const bool send_to_skysensor = (
getUTCOffset(
PortFD, &ss_timezone) != 0 || offset != ss_timezone);
243 if (send_to_skysensor)
246 snprintf(temp_string,
sizeof(temp_string),
":SG %+03d#",
static_cast<int>(offset));
259 if (latitude == 0.0 && longitude == 0.0)
264 LOG_ERROR(
"Error setting site latitude coordinates");
269 LOG_ERROR(
"Error setting site longitude coordinates");
274 fs_sexa(slat, latitude, 3, 3600);
275 fs_sexa(slong, longitude, 4, 3600);
277 LOGF_INFO(
"Site location updated to Latitude: %.32s - Longitude: %.32s", slat, slong);
285 int LX200SS2000PC::setSiteLatitude(
int fd,
double Lat)
298 snprintf(temp_string,
sizeof(temp_string),
":St %c%03d*%02d#", sign, d, m);
306 int LX200SS2000PC::setSiteLongitude(
int fd,
double Long)
313 snprintf(temp_string,
sizeof(temp_string),
":Sg %03d*%02d#", d, m);
323 char AzStr[16], AltStr[16];
324 fs_sexa(AzStr, parkAz, 2, 3600);
325 fs_sexa(AltStr, parkAlt, 2, 3600);
326 LOGF_DEBUG(
"Parking to Az (%s) Alt (%s)...", AzStr, AltStr);
334 Goto(equatorialCoords.rightascension, equatorialCoords.declination);
349 LOGF_ERROR(
"Error Slewing to Az %s - Alt %s", AzStr, AltStr);
357 LOG_INFO(
"Parking is in progress...");
378 char AzStr[16], AltStr[16];
379 fs_sexa(AzStr, parkAz, 2, 3600);
380 fs_sexa(AltStr, parkAlt, 2, 3600);
381 LOGF_DEBUG(
"Syncing to parked coordinates Az (%s) Alt (%s)...", AzStr, AltStr);
388 currentRA = equatorialCoords.rightascension;
399 char syncString[256];
416 double parkAZ = horizontalCoords.azimuth;
417 double parkAlt = horizontalCoords.altitude;
419 char AzStr[16], AltStr[16];
420 fs_sexa(AzStr, parkAZ, 2, 3600);
421 fs_sexa(AltStr, parkAlt, 2, 3600);
423 LOGF_DEBUG(
"Setting current parking position to coordinates Az (%s) Alt (%s)...", AzStr, AltStr);
467 LOG_INFO(
"Slew is complete. Tracking...");
const char * getDeviceName() const
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
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
ISwitchVectorProperty SlewRateSP
virtual void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
INumberVectorProperty EqNP
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 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 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.
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...
@ LX200_HAS_PULSE_GUIDING
virtual bool sendScopeTime()
virtual bool Goto(double ra, double dec) override
Move the scope to the supplied RA and DEC coordinates.
void setLX200Capability(uint32_t cap)
const char * OPTIONS_TAB
OPTIONS_TAB Where all the driver's options are located. Those may include auxiliary controls,...
#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 IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
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,...)
void IDSetSwitch(const ISwitchVectorProperty *svp, 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 setStandardProcedure(int fd, const char *data)
int setSiteLongitude(int fd, double CartographicLongitude, 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.