25#include <libnova/sidereal_time.h>
26#include <libnova/transform.h>
37#define MOUNTINFO_TAB "Mount Info"
42static std::unique_ptr<IEQPro> scope(
new IEQPro());
48 driver.reset(
new Base());
198void IEQPro::getStartupData()
202 firmwareInfo = driver->getFirmwareInfo();
220 double raGuideRate = 0, deGuideRate = 0;
221 if (driver->getGuideRate(&raGuideRate, &deGuideRate))
223 GuideRateN[
RA_AXIS].value = raGuideRate;
224 GuideRateN[
DEC_AXIS].value = deGuideRate;
229 int yy, dd, mm, hh, minute, ss;
230 if (driver->getUTCDateTime(&utc_offset, &yy, &mm, &dd, &hh, &minute, &ss))
232 char isoDateTime[32] = {0};
233 char utcOffset[8] = {0};
235 snprintf(isoDateTime, 32,
"%04d-%02d-%02dT%02d:%02d:%02d", yy, mm, dd, hh, minute, ss);
236 snprintf(utcOffset, 8,
"%4.2f", utc_offset);
241 LOGF_INFO(
"Mount UTC offset is %s. UTC time is %s", utcOffset, isoDateTime);
248 double longitude = 0, latitude = 0;
249 if (driver->getStatus(&scopeInfo))
258 LOGF_INFO(
"Mount Longitude %g Latitude %g", longitude, latitude);
321 if (!strcmp(name, GuideRateNP.
name))
325 if (driver->setGuideRate(GuideRateN[
RA_AXIS].value, GuideRateN[
DEC_AXIS].value))
343 bool rc = driver->getStatus(&newInfo);
403 LOG_INFO(
"Mount arrived at home position.");
417 LOG_INFO(
"Mount arrived at home position.");
433 LOG_INFO(
"Manual parking complete. Shut the mount down.");
446 LOG_INFO(
"Slew complete, tracking...");
448 LOG_INFO(
"Meridian flip complete, tracking...");
463 if (driver->getPierSide(&pierSide))
483 rc = driver->getCoords(¤tRA, ¤tDEC);
495 char RAStr[64] = {0}, DecStr[64] = {0};
497 fs_sexa(RAStr, targetRA, 2, 3600);
498 fs_sexa(DecStr, targetDEC, 2, 3600);
500 if (driver->setRA(r) ==
false || driver->setDE(d) ==
false)
506 if (driver->slew() ==
false)
516 for (
int i = 0; i < 5; i++)
518 bool rc = driver->getStatus(&newInfo);
521 std::this_thread::sleep_for(std::chrono::milliseconds(100));
527 LOGF_INFO(
"Slewing to RA: %s - DEC: %s", RAStr, DecStr);
532 LOG_ERROR(
"Mount status failed to update to slewing.");
539 if (driver->setRA(
ra) ==
false || driver->setDE(
dec) ==
false)
545 if (driver->sync() ==
false)
562 return driver->abort();
579 LOG_ERROR(
"Failed to slew tp parking position.");
583 char RAStr[64] = {0}, DecStr[64] = {0};
584 fs_sexa(RAStr, targetRA, 2, 3600);
585 fs_sexa(DecStr, targetDEC, 2, 3600);
588 LOGF_INFO(
"Telescope parking in progress to RA: %s DEC: %s", RAStr, DecStr);
596 char AzStr[16], AltStr[16];
597 fs_sexa(AzStr, parkAz, 2, 3600);
598 fs_sexa(AltStr, parkAlt, 2, 3600);
599 LOGF_DEBUG(
"Parking to Az (%s) Alt (%s)...", AzStr, AltStr);
604 if (driver->setParkAz(parkAz) && driver->setParkAlt(parkAlt))
609 LOG_INFO(
"Parking is in progress...");
621 horizontalPos.
azimuth = parkAz;
630 LOG_INFO(
"Parking is in progress...");
644 if (canParkNatively && driver->unpark() ==
false)
664 if (driver->initCommunication(
PortFD) ==
false)
667 canParkNatively = driver->isCommandSupported(
"MP1",
true);
668 canFindHome = driver->isCommandSupported(
"MSH",
true);
669 canGuideRate = driver->isCommandSupported(
"RG",
true);
676 struct ln_zonedate ltm;
678 ln_date_to_zonedate(utc, <m, utc_offset * 3600.0);
681 if (driver->setLocalTime(ltm.hours, ltm.minutes, ltm.seconds) ==
false)
691 if (driver->setLocalDate(ltm.years, ltm.months, ltm.days) ==
false)
698 if (driver->setUTCOffset(utc_offset) ==
false)
716 if (driver->setLongitude(longitude) ==
false)
722 if (driver->setLatitude(latitude) ==
false)
728 char l[32] = {0}, L[32] = {0};
730 fs_sexa(L, longitude, 4, 3600);
732 LOGF_INFO(
"Site location updated to Lat %.32s - Long %.32s", l, L);
739 driver->setDebugEnabled(enable);
752 LOG_ERROR(
"Please unpark the mount before issuing any motion commands.");
761 LOG_ERROR(
"Error setting N/S motion direction.");
786 LOG_ERROR(
"Please unpark the mount before issuing any motion commands.");
795 LOG_ERROR(
"Error setting N/S motion direction.");
818 bool rc = driver->startGuide(
IEQ_N, ms);
824 bool rc = driver->startGuide(
IEQ_S, ms);
830 bool rc = driver->startGuide(
IEQ_E, ms);
836 bool rc = driver->startGuide(
IEQ_W, ms);
843 return driver->setSlewRate(rate);
946 double parkAZ = horizontalCoords.azimuth;
947 double parkAlt = horizontalCoords.altitude;
948 char AzStr[16], AltStr[16];
949 fs_sexa(AzStr, parkAZ, 2, 3600);
950 fs_sexa(AltStr, parkAlt, 2, 3600);
951 LOGF_DEBUG(
"Setting current parking position to coordinates Az (%s) Alt (%s)...", AzStr, AltStr);
973 if (driver->setTrackMode(rate))
981 static bool deRateWarning =
true;
985 if (deRate != 0 && deRateWarning)
988 deRateWarning =
false;
989 LOG_WARN(
"Custom Declination tracking rate is not implemented yet.");
992 if (driver->setCustomRATrackRate(ieqRARate))
1009 return driver->setTrackEnabled(enabled);
1017 if (!canFindHome && (firmwareInfo.
Model.find(
"CEM") == std::string::npos &&
1018 firmwareInfo.
Model.find(
"GEM45") == std::string::npos &&
1019 firmwareInfo.
Model.find(
"HAE") == std::string::npos &&
1020 firmwareInfo.
Model.find(
"HAZ") == std::string::npos &&
1021 firmwareInfo.
Model.find(
"HEM") == std::string::npos))
1023 LOG_WARN(
"Home search is not supported in this model.");
1027 if (driver->findHome() ==
false)
1032 LOG_INFO(
"Searching for home position...");
1036 if (driver->setCurrentHome() ==
false)
1041 LOG_INFO(
"Home position set to current coordinates.");
1045 if (driver->gotoHome() ==
false)
1050 LOG_INFO(
"Slewing to home position...");
void setDefaultBaudRate(BaudRate newRate)
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by t...
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool Goto(double, double) override
Move the scope to the supplied RA and DEC coordinates.
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 IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool Handshake() override
perform handshake with device to check communication
virtual bool UnPark() override
Unpark the telescope if already parked.
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 IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
virtual bool SetSlewRate(int index) override
SetSlewRate Set desired slew rate index.
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
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.
virtual const char * getDefaultName() override
virtual bool ReadScopeStatus() override
Read telescope status.
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate Set custom tracking rates.
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override
Execute a homing action.
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 updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool saveConfig(bool silent=false, const char *property=nullptr)
Save the current properties in a configuration file.
void setDriverInterface(uint32_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
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)
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
uint32_t getDriverInterface() const
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
void initProperties(const char *groupName)
Initialize guider properties. It is recommended to call this function within initProperties() of your...
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Call this function whenever client updates GuideNSNP or GuideWSP properties in the primary device....
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
void setLabel(const char *label)
int findOnSwitchIndex() const
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.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
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.
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....
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
IGeographicCoordinates m_Location
@ TELESCOPE_CAN_HOME_FIND
@ TELESCOPE_HAS_TRACK_RATE
@ TELESCOPE_HAS_PIER_SIDE
@ TELESCOPE_HAS_TRACK_MODE
@ TELESCOPE_CAN_CONTROL_TRACK
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.
void setPierSide(TelescopePierSide side)
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....
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.
The BaseFirmware class provides control for iOptron version 2014 v2.0 protocol.
const char * MOTION_TAB
MOTION_TAB Where all the motion control properties of the device are located.
INDI::PropertyNumber TrackRateNP
INDI::PropertyNumber EqNP
INDI::PropertySwitch HomeSP
INDI::PropertySwitch SlewRateSP
INDI::PropertySwitch TrackModeSP
INDI::PropertyText TimeTP
INDI::PropertyNumber LocationNP
bool set_ieqpro_dec(int fd, double dec)
bool set_ieqpro_ra(int fd, double ra)
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 sidereal time given longitude and system clock.
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 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.
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...
#define TRACKRATE_SIDEREAL
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.
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.
std::string MainBoardFirmware
std::string ControllerFirmware
SystemStatus systemStatus