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());
53 scopeInfo.slewRate =
SR_1;
198void IEQPro::getStartupData()
202 firmwareInfo = driver->getFirmwareInfo();
208 const std::string &model = firmwareInfo.
Model;
209 const bool altAz = (model.size() >= 3 && model.compare(model.size() - 3, 3,
" AA") == 0) ||
210 model.find(
"AZ Mount") != std::string::npos;
214 IUSaveText(&FirmwareT[1], firmwareInfo.MainBoardFirmware.c_str());
218 const bool controllerReported = !firmwareInfo.ControllerFirmware.empty() &&
219 firmwareInfo.ControllerFirmware.find_first_not_of(
'x') != std::string::npos;
220 IUSaveText(&FirmwareT[2], controllerReported ? firmwareInfo.ControllerFirmware.c_str() :
"N/A");
221 IUSaveText(&FirmwareT[3], firmwareInfo.RAFirmware.c_str());
222 IUSaveText(&FirmwareT[4], firmwareInfo.DEFirmware.c_str());
229 double raGuideRate = 0, deGuideRate = 0;
230 if (driver->getGuideRate(&raGuideRate, &deGuideRate))
232 GuideRateN[
RA_AXIS].value = raGuideRate;
233 GuideRateN[
DEC_AXIS].value = deGuideRate;
238 int yy, dd, mm, hh, minute, ss;
239 if (driver->getUTCDateTime(&utc_offset, &yy, &mm, &dd, &hh, &minute, &ss))
241 char isoDateTime[32] = {0};
242 char utcOffset[8] = {0};
244 snprintf(isoDateTime, 32,
"%04d-%02d-%02dT%02d:%02d:%02d", yy, mm, dd, hh, minute, ss);
245 snprintf(utcOffset, 8,
"%4.2f", utc_offset);
250 LOGF_INFO(
"Mount UTC offset is %s. UTC time is %s", utcOffset, isoDateTime);
257 double longitude = 0, latitude = 0;
258 if (driver->getStatus(&scopeInfo))
260 longitude = scopeInfo.longitude;
261 latitude = scopeInfo.latitude;
267 LOGF_INFO(
"Mount Longitude %g Latitude %g", longitude, latitude);
330 if (!strcmp(name, GuideRateNP.name))
334 if (driver->setGuideRate(GuideRateN[
RA_AXIS].value, GuideRateN[
DEC_AXIS].value))
352 bool rc = driver->getStatus(&newInfo);
412 LOG_INFO(
"Mount arrived at home position.");
426 LOG_INFO(
"Mount arrived at home position.");
442 LOG_INFO(
"Manual parking complete. Shut the mount down.");
455 LOG_INFO(
"Slew complete, tracking...");
457 LOG_INFO(
"Meridian flip complete, tracking...");
472 if (driver->getPierSide(&pierSide))
492 rc = driver->getCoords(¤tRA, ¤tDEC);
504 char RAStr[64] = {0}, DecStr[64] = {0};
506 fs_sexa(RAStr, targetRA, 2, 3600);
507 fs_sexa(DecStr, targetDEC, 2, 3600);
509 if (driver->setRA(r) ==
false || driver->setDE(d) ==
false)
515 if (driver->slew() ==
false)
525 for (
int i = 0; i < 5; i++)
527 bool rc = driver->getStatus(&newInfo);
530 std::this_thread::sleep_for(std::chrono::milliseconds(100));
536 LOGF_INFO(
"Slewing to RA: %s - DEC: %s", RAStr, DecStr);
541 LOG_ERROR(
"Mount status failed to update to slewing.");
548 if (driver->setRA(
ra) ==
false || driver->setDE(
dec) ==
false)
554 if (driver->sync() ==
false)
571 return driver->abort();
588 LOG_ERROR(
"Failed to slew tp parking position.");
592 char RAStr[64] = {0}, DecStr[64] = {0};
593 fs_sexa(RAStr, targetRA, 2, 3600);
594 fs_sexa(DecStr, targetDEC, 2, 3600);
597 LOGF_INFO(
"Telescope parking in progress to RA: %s DEC: %s", RAStr, DecStr);
605 char AzStr[16], AltStr[16];
606 fs_sexa(AzStr, parkAz, 2, 3600);
607 fs_sexa(AltStr, parkAlt, 2, 3600);
608 LOGF_DEBUG(
"Parking to Az (%s) Alt (%s)...", AzStr, AltStr);
613 if (driver->setParkAz(parkAz) && driver->setParkAlt(parkAlt))
618 LOG_INFO(
"Parking is in progress...");
630 horizontalPos.
azimuth = parkAz;
639 LOG_INFO(
"Parking is in progress...");
653 if (canParkNatively && driver->unpark() ==
false)
673 if (driver->initCommunication(
PortFD) ==
false)
676 canParkNatively = driver->isCommandSupported(
"MP1",
true);
677 canFindHome = driver->isCommandSupported(
"MSH",
true);
678 canGuideRate = driver->isCommandSupported(
"RG",
true);
685 struct ln_zonedate ltm;
687 ln_date_to_zonedate(utc, <m, utc_offset * 3600.0);
690 if (driver->setLocalTime(ltm.hours, ltm.minutes, ltm.seconds) ==
false)
700 if (driver->setLocalDate(ltm.years, ltm.months, ltm.days) ==
false)
707 if (driver->setUTCOffset(utc_offset) ==
false)
725 if (driver->setLongitude(longitude) ==
false)
731 if (driver->setLatitude(latitude) ==
false)
737 char l[32] = {0}, L[32] = {0};
739 fs_sexa(L, longitude, 4, 3600);
741 LOGF_INFO(
"Site location updated to Lat %.32s - Long %.32s", l, L);
748 driver->setDebugEnabled(enable);
761 LOG_ERROR(
"Please unpark the mount before issuing any motion commands.");
770 LOG_ERROR(
"Error setting N/S motion direction.");
795 LOG_ERROR(
"Please unpark the mount before issuing any motion commands.");
804 LOG_ERROR(
"Error setting N/S motion direction.");
827 bool rc = driver->startGuide(
IEQ_N, ms);
833 bool rc = driver->startGuide(
IEQ_S, ms);
839 bool rc = driver->startGuide(
IEQ_E, ms);
845 bool rc = driver->startGuide(
IEQ_W, ms);
852 return driver->setSlewRate(rate);
955 double parkAZ = horizontalCoords.
azimuth;
956 double parkAlt = horizontalCoords.
altitude;
957 char AzStr[16], AltStr[16];
958 fs_sexa(AzStr, parkAZ, 2, 3600);
959 fs_sexa(AltStr, parkAlt, 2, 3600);
960 LOGF_DEBUG(
"Setting current parking position to coordinates Az (%s) Alt (%s)...", AzStr, AltStr);
982 if (driver->setTrackMode(rate))
990 static bool deRateWarning =
true;
994 if (deRate != 0 && deRateWarning)
997 deRateWarning =
false;
998 LOG_WARN(
"Custom Declination tracking rate is not implemented yet.");
1001 if (driver->setCustomRATrackRate(ieqRARate))
1018 return driver->setTrackEnabled(enabled);
1026 if (!canFindHome && (firmwareInfo.Model.find(
"CEM") == std::string::npos &&
1027 firmwareInfo.Model.find(
"GEM45") == std::string::npos &&
1028 firmwareInfo.Model.find(
"HAE") == std::string::npos &&
1029 firmwareInfo.Model.find(
"HAZ") == std::string::npos &&
1030 firmwareInfo.Model.find(
"HEM") == std::string::npos))
1032 LOG_WARN(
"Home search is not supported in this model.");
1036 if (driver->findHome() ==
false)
1041 LOG_INFO(
"Searching for home position...");
1045 if (driver->setCurrentHome() ==
false)
1050 LOG_INFO(
"Home position set to current coordinates.");
1054 if (driver->gotoHome() ==
false)
1059 LOG_INFO(
"Slewing to home position...");
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....
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.
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
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 setMountType(TelescopeMountType type)
setMountType Report the mount type in TELESCOPE_MOUNT_TYPE. Drivers call it when the type is fixed by...
void SetParkDataType(TelescopeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
@ TELESCOPE_CAN_HOME_FIND
@ TELESCOPE_HAS_TRACK_RATE
@ TELESCOPE_HAS_PIER_SIDE
@ TELESCOPE_HAS_TRACK_MODE
@ TELESCOPE_CAN_CONTROL_TRACK
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,...)
*brief user defined string literal for JSON values *sa std::size_t n
#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.
SystemStatus systemStatus