25 #include <libnova/sidereal_time.h>
26 #include <libnova/transform.h>
35 #define MOUNTINFO_TAB "Mount Info"
38 static std::unique_ptr<IEQProLegacy> scope(
new IEQProLegacy());
129 IUFillSwitchVector(&HomeSP, HomeS, 3,
getDeviceName(),
"HOME",
"Home",
MAIN_CONTROL_TAB,
IP_RW,
ISR_ATMOST1, 0,
133 IUFillNumber(&GuideRateN[
RA_AXIS],
"RA_GUIDE_RATE",
"x Sidereal",
"%.2f", 0.01, 0.9, 0.1, 0.5);
134 IUFillNumber(&GuideRateN[
DEC_AXIS],
"DE_GUIDE_RATE",
"x Sidereal",
"%.2f", 0.1, 0.99, 0.1, 0.5);
195 void IEQProLegacy::getStartupData()
211 double raGuideRate = 0, deGuideRate = 0;
214 GuideRateN[
RA_AXIS].value = raGuideRate;
215 GuideRateN[
DEC_AXIS].value = deGuideRate;
220 int yy, dd, mm, hh, minute, ss;
223 char isoDateTime[32] = {0};
224 char utcOffset[8] = {0};
226 snprintf(isoDateTime, 32,
"%04d-%02d-%02dT%02d:%02d:%02d", yy, mm, dd, hh, minute, ss);
227 snprintf(utcOffset, 8,
"%4.2f", utc_offset);
232 LOGF_INFO(
"Mount UTC offset is %s. UTC time is %s", utcOffset, isoDateTime);
239 double longitude = 0, latitude = 0;
246 LOGF_INFO(
"Mount Longitude %g Latitude %g", longitude, latitude);
295 if (!strcmp(name, GuideRateNP.
name))
323 if (!strcmp(name, HomeSP.
name))
334 if (firmwareInfo.
Model.find(
"CEM") == std::string::npos)
338 LOG_WARN(
"Home search is not supported in this model.");
351 LOG_INFO(
"Searching for home position...");
364 LOG_INFO(
"Home position set to current coordinates.");
377 LOG_INFO(
"Slewing to home position...");
467 LOG_INFO(
"Slew complete, tracking...");
469 LOG_INFO(
"Meridian flip complete, tracking...");
493 char RAStr[64] = {0}, DecStr[64] = {0};
495 fs_sexa(RAStr, targetRA, 2, 3600);
496 fs_sexa(DecStr, targetDEC, 2, 3600);
512 LOGF_INFO(
"Slewing to RA: %s - DEC: %s", RAStr, DecStr);
558 LOG_ERROR(
"Failed to slew tp parking position.");
562 char RAStr[64] = {0}, DecStr[64] = {0};
563 fs_sexa(RAStr, targetRA, 2, 3600);
564 fs_sexa(DecStr, targetDEC, 2, 3600);
567 LOGF_INFO(
"Telescope parking in progress to RA: %s DEC: %s", RAStr, DecStr);
575 char AzStr[16], AltStr[16];
576 fs_sexa(AzStr, parkAz, 2, 3600);
577 fs_sexa(AltStr, parkAlt, 2, 3600);
578 LOGF_DEBUG(
"Parking to Az (%s) Alt (%s)...", AzStr, AltStr);
584 if (
Goto(equatorialCoords.rightascension, equatorialCoords.declination))
587 LOG_INFO(
"Parking is in progress...");
627 struct ln_zonedate ltm;
629 ln_date_to_zonedate(utc, <m, utc_offset * 3600.0);
679 char l[32] = {0}, L[32] = {0};
681 fs_sexa(L, longitude, 4, 3600);
683 LOGF_INFO(
"Site location updated to Lat %.32s - Long %.32s", l, L);
702 LOG_ERROR(
"Please unpark the mount before issuing any motion commands.");
711 LOG_ERROR(
"Error setting N/S motion direction.");
736 LOG_ERROR(
"Please unpark the mount before issuing any motion commands.");
745 LOG_ERROR(
"Error setting N/S motion direction.");
805 static struct timeval ltv;
811 gettimeofday(&tv,
nullptr);
813 if (ltv.tv_sec == 0 && ltv.tv_usec == 0)
816 dt = tv.tv_sec - ltv.tv_sec + (tv.tv_usec - ltv.tv_usec) / 1e6;
896 double parkAZ = horizontalCoords.azimuth;
897 double parkAlt = horizontalCoords.altitude;
899 char AzStr[16], AltStr[16];
900 fs_sexa(AzStr, parkAZ, 2, 3600);
901 fs_sexa(AltStr, parkAlt, 2, 3600);
903 LOGF_DEBUG(
"Setting current parking position to coordinates Az (%s) Alt (%s)...", AzStr,
935 static bool deRateWarning =
true;
939 if (deRate != 0 && deRateWarning)
942 deRateWarning =
false;
943 LOG_WARN(
"Custom Declination tracking rate is not implemented yet.");
void setDefaultBaudRate(BaudRate newRate)
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by t...
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
virtual bool ReadScopeStatus() override
Read telescope status.
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
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 SetSlewRate(int index) override
SetSlewRate Set desired slew rate index.
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate Set custom tracking rates.
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
virtual bool Park() override
Park the telescope to its home position.
virtual bool Handshake() override
perform handshake with device to check communication
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
virtual bool Goto(double, double) override
Move the scope to the supplied RA and DEC coordinates.
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual const char * getDefaultName() override
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
virtual void simulationTriggered(bool enable) override
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
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.
const char * getDeviceName() const
virtual bool saveConfig(bool silent=false, const char *property=nullptr)
Save the current properties in a configuration file.
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 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
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
void SetAxis1Park(double value)
SetRAPark Set current RA/AZ parking position. The data park file (stored in ~/.indi/ParkData....
void SetAxis1ParkDefault(double steps)
SetRAPark Set default RA/AZ parking position.
void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount)
SetTelescopeCapability sets the Telescope capabilities. All capabilities must be initialized.
INumberVectorProperty LocationNP
virtual bool initProperties() override
Called to initialize basic properties required all the time.
ITextVectorProperty TimeTP
double GetAxis1Park() const
double GetAxis2Park() const
bool isParked()
isParked is mount currently parked?
virtual int AddTrackMode(const char *name, const char *label, bool isDefault=false)
AddTrackMode.
ISwitchVectorProperty TrackModeSP
ISwitchVectorProperty SlewRateSP
Connection::Serial * serialConnection
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
@ TELESCOPE_HAS_TRACK_RATE
@ TELESCOPE_HAS_TRACK_MODE
@ TELESCOPE_CAN_CONTROL_TRACK
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
IGeographicCoordinates m_Location
void NewRaDec(double ra, double dec)
The child class calls this function when it has updates.
bool InitPark()
InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status and parking...
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
void SetAxis2Park(double steps)
SetDEPark Set current DEC/ALT parking position. The data park file (stored in ~/.indi/ParkData....
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
void SetParkDataType(TelescopeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
void SetAxis2ParkDefault(double steps)
SetDEParkDefault Set default DEC/ALT parking position.
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.
bool goto_ieqpro_home(int fd)
bool set_ieqpro_latitude(int fd, double latitude)
bool set_ieqpro_current_home(int fd)
void set_sim_gps_status(IEQ_GPS_STATUS value)
bool start_ieqpro_guide(int fd, IEQ_DIRECTION dir, uint32_t ms)
void set_sim_dec(double dec)
bool find_ieqpro_home(int fd)
void set_sim_hemisphere(IEQ_HEMISPHERE value)
bool set_ieqpro_local_date(int fd, int yy, int mm, int dd)
bool get_ieqpro_utc_date_time(int fd, double *utc_hours, int *yy, int *mm, int *dd, int *hh, int *minute, int *ss)
bool get_ieqpro_status(int fd, IEQInfo *info)
bool set_ieqpro_local_time(int fd, int hh, int mm, int ss)
void set_ieqpro_debug(bool enable)
bool get_ieqpro_coords(int fd, double *ra, double *dec)
void set_ieqpro_device(const char *name)
void set_ieqpro_simulation(bool enable)
bool get_ieqpro_firmware(int fd, FirmwareInfo *info)
bool set_ieqpro_custom_ra_track_rate(int fd, double rate)
bool set_ieqpro_dec(int fd, double dec)
bool set_ieqpro_guide_rate(int fd, double raRate, double deRate)
bool abort_ieqpro(int fd)
bool unpark_ieqpro(int fd)
bool set_ieqpro_track_mode(int fd, IEQ_TRACK_RATE rate)
void set_sim_system_status(IEQ_SYSTEM_STATUS value)
void set_sim_slew_rate(IEQ_SLEW_RATE value)
bool get_ieqpro_latitude(int fd, double *latitude)
bool check_ieqpro_connection(int fd)
bool set_ieqpro_ra(int fd, double ra)
bool set_ieqpro_slew_rate(int fd, IEQ_SLEW_RATE rate)
bool get_ieqpro_guide_rate(int fd, double *raRate, double *deRate)
bool start_ieqpro_motion(int fd, IEQ_DIRECTION dir)
void set_sim_time_source(IEQ_TIME_SOURCE value)
bool set_ieqpro_utc_offset(int fd, double offset)
bool set_ieqpro_longitude(int fd, double longitude)
bool get_ieqpro_longitude(int fd, double *longitude)
void set_sim_ra(double ra)
bool set_ieqpro_track_enabled(int fd, bool enabled)
bool stop_ieqpro_motion(int fd, IEQ_DIRECTION dir)
void set_sim_track_rate(IEQ_TRACK_RATE value)
double range24(double r)
range24 Limits a number to be between 0-24 range.
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 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 IUGetConfigNumber(const char *dev, const char *property, const char *member, double *value)
IUGetConfigNumber Opens configuration file and reads single number property.
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)
#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...
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.
std::string ControllerFirmware
std::string MainBoardFirmware
IEQ_TIME_SOURCE timeSource
IEQ_SYSTEM_STATUS systemStatus
IEQ_HEMISPHERE hemisphere
static Logger & getInstance()
Method to get a reference to the object (i.e., Singleton) It is a static method.
int addDebugLevel(const char *debugLevelName, const char *LoggingLevelName)
Adds a new debugging level to the driver.