28#include <libnova/sidereal_time.h>
29#include <libnova/transform.h>
39const std::array<uint32_t, AstroTrac::SLEW_MODES> AstroTrac::SLEW_SPEEDS = {{1, 2, 4, 8, 32, 64, 128, 600, 700, 800}};
74 for (uint8_t i = 0; i < SLEW_MODES; i++)
76 SlewRateSP[i].setLabel(std::to_string(SLEW_SPEEDS[i]) +
"x");
91 AccelerationNP[
AXIS_RA].fill(
"AXIS_RA",
"RA arcsec/sec^2",
"%.2f", 0, 3600, 100, 0);
92 AccelerationNP[
AXIS_DE].fill(
"AXIS_DE",
"DE arcsec/sec^2",
"%.2f", 0, 3600, 100, 0);
96 EncoderNP[
AXIS_RA].fill(
"AXIS_RA",
"Hour Angle",
"%.2f", -3600, 3600, 100, 0);
97 EncoderNP[
AXIS_DE].fill(
"AXIS_DE",
"Declination",
"%.2f", -3600, 3600, 100, 0);
103 GuideRateNP[
AXIS_RA].fill(
"GUIDE_RATE_WE",
"W/E Rate",
"%g", 0, 1, 0.1, 0.1);
104 GuideRateNP[
AXIS_DE].fill(
"GUIDE_RATE_NS",
"N/S Rate",
"%g", 0, 1, 0.1, 0.1);
192bool AstroTrac::getVersion()
194 char response[DRIVER_LEN] = {0};
195 if (sendCommand(
"<1zv?>", response))
197 FirmwareTP[0].setText(response + 4, 4);
209 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
210 snprintf(command, DRIVER_LEN,
"<%da?>", axis + 1);
211 if (sendCommand(command, response))
217 std::regex(
"<.a(\\d+)>"),
225 LOGF_DEBUG(
"Failed to parse acceleration (%s)", response);
235bool AstroTrac::setAcceleration(
INDI_EQ_AXIS axis, uint32_t a)
237 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
239 snprintf(command, DRIVER_LEN,
"<%da%u>", axis + 1, a);
240 if (sendCommand(command, response))
241 return response[3] ==
'#';
249bool AstroTrac::getVelocity(
INDI_EQ_AXIS axis,
double &value)
251 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
252 snprintf(command, DRIVER_LEN,
"<%dv?>", axis + 1);
253 if (sendCommand(command, response))
257 std::string
velocity = std::regex_replace(
259 std::regex(
"<.v([+-]?[0-9]+\\.[0-9]+?)>"),
267 LOGF_DEBUG(
"Failed to parse velocity (%s)", response);
292bool AstroTrac::setVelocity(
INDI_EQ_AXIS axis,
double value)
294 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
297 snprintf(command, DRIVER_LEN,
"<%dve%f>", axis + 1, value * (
m_Location.latitude >= 0 ? 1 : -1));
298 if (sendCommand(command, response))
299 return response[4] ==
'#';
309 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
311 snprintf(command, DRIVER_LEN,
"<%dx>", axis + 1);
312 if (sendCommand(command, response))
313 return response[3] ==
'#';
321bool AstroTrac::isSlewComplete()
323 char HAResponse[DRIVER_LEN] = {0}, DEResponse[DRIVER_LEN] = {0};
324 if (sendCommand(
"<1t?>", HAResponse) && sendCommand(
"<2t?>", DEResponse))
326 return (HAResponse[3] ==
'0' && DEResponse[3] ==
'0');
335bool AstroTrac::syncEncoder(
INDI_EQ_AXIS axis,
double value)
337 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
339 snprintf(command, DRIVER_LEN,
"<%dy%f>", axis + 1, value);
340 if (sendCommand(command, response))
341 return response[3] ==
'#';
349bool AstroTrac::slewEncoder(
INDI_EQ_AXIS axis,
double value)
351 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
353 snprintf(command, DRIVER_LEN,
"<%dp%f>", axis + 1, value);
354 if (sendCommand(command, response))
355 return response[3] ==
'#';
368 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
369 snprintf(command, DRIVER_LEN,
"<%dp?>", axis + 1);
370 if (sendCommand(command, response))
374 char regex_str[64] = {0};
375 snprintf(regex_str, 64,
"<%dp([+-]?[0-9]+\\.[0-9]+?)>", axis + 1);
376 std::string position = std::regex_replace(
378 std::regex(regex_str),
381 EncoderNP[axis].setValue(std::stod(position));
390 char regex_str[64] = {0};
391 snprintf(regex_str, 64,
"<%dp([+-]?[0-9]+\\.[0-9]+?)>", other + 1);
392 std::string position = std::regex_replace(
394 std::regex(regex_str),
397 EncoderNP[other].setValue(std::stod(position));
402 LOGF_DEBUG(
"Failed to parse position (%s)", response);
417void AstroTrac::getRADEFromEncoders(
double haEncoder,
double deEncoder,
double &
ra,
double &de, TelescopePierSide &pierSide)
419 static const double jitter = 0.0005;
423 if (haEncoder > jitter * -1 && haEncoder < jitter)
425 if (deEncoder > jitter * -1 && deEncoder < jitter)
434 de = std::min(90 - deEncoder, 90.0);
435 ha = -6.0 + (haEncoder / 360.0) * 24.0;
442 ha = 6.0 + (haEncoder / 360.0) * 24.0;
452 de = std::max(-90 - deEncoder, -90.0);
453 ha = -6.0 - (haEncoder / 360.0) * 24.0;
459 de = -90 + deEncoder;
460 ha = 6.0 - (haEncoder / 360.0) * 24.0;
468 char RAStr[32] = {0}, DecStr[32] = {0};
471 LOGF_DEBUG(
"Encoders HA: %.4f DE: %.4f Processed: HA: %.4f DE: %.4f (%s) LST: %.4f RA: %.4f (%s)",
472 haEncoder, deEncoder, ha, de, DecStr, lst,
ra, RAStr);
481void AstroTrac::getEncodersFromRADE(
double ra,
double de,
double &haEncoder,
double &deEncoder)
491 deEncoder = -(de - 90.0);
492 haEncoder = (dHA + 6.0) * 360.0 / 24.0;
497 deEncoder = de - 90.0;
498 haEncoder = (dHA - 6.0) * 360.0 / 24.0;
506 deEncoder = -(de + 90.0);
507 haEncoder = -(dHA + 6.0) * 360.0 / 24.0;
512 deEncoder = (de + 90.0);
513 haEncoder = -(dHA - 6.0) * 360 / 24.0;
542 char RAStr[32], DecStr[32];
545 LOGF_INFO(
"Syncing to JNOW RA %s - DEC %s", RAStr, DecStr);
550 LOGF_DEBUG(
"Sync - duplicate entry RA: %lf(%lf) DEC: %lf",
ra * 360.0 / 24.0,
ra,
dec);
559 double haEncoder = 0, deEncoder = 0;
561 if (getTelescopeFromSkyCoordinates(
ra,
dec, telescopeCoordinates))
563 char mountRAString[32] = {0}, mountDEString[32] = {0}, skyRAString[32] = {0}, skyDEString[32] = {0};
569 LOGF_DEBUG(
"GOTO Sky RA: %s DE: %s ---> Mount RA: %s DE: %s", skyRAString, skyDEString, mountRAString, mountDEString);
575 double tHA = calculateSlewTime(haEncoder - EncoderNP[
AXIS_RA].getValue());
579 LOGF_DEBUG(
"GOTO Encoders HA: %.4f (%.4f + %.4f) DE: %.4f", haEncoder + tHA, haEncoder, tHA, deEncoder);
582 bool rc1 = slewEncoder(
AXIS_RA, haEncoder + tHA);
583 bool rc2 = slewEncoder(
AXIS_DE, deEncoder);
589 char RAStr[32], DecStr[32];
592 LOGF_INFO(
"Slewing to JNOW RA %s - DEC %s", RAStr, DecStr);
605double AstroTrac::calculateSlewTime(
double distance)
608 distance = fabs(distance) * 3600.0;
611 double accelerate_decelerate = MAX_SLEW_VELOCITY * MAX_SLEW_VELOCITY / AccelerationNP[
AXIS_RA].getValue();
614 if (distance < accelerate_decelerate)
616 return (2 * sqrt(distance / AccelerationNP[
AXIS_RA].getValue()));
621 return (2.0 * MAX_SLEW_VELOCITY / AccelerationNP[
AXIS_RA].getValue() + (distance - accelerate_decelerate) /
632 double ra = 0, de = 0, skyRA = 0, skyDE = 0;
638 double lastHAEncoder = EncoderNP[
AXIS_RA].getValue();
639 double lastDEEncoder = EncoderNP[
AXIS_DE].getValue();
642 getRADEFromEncoders(EncoderNP[
AXIS_RA].getValue(), EncoderNP[
AXIS_DE].getValue(),
ra, de, side);
644 if (std::fabs(lastHAEncoder - EncoderNP[
AXIS_RA].getValue()) > 0
645 || std::fabs(lastDEEncoder - EncoderNP[
AXIS_DE].getValue()) > 0)
655 if (isSlewComplete())
659 LOG_INFO(
"Slew complete, tracking...");
672 m_MountInternalCoordinates.rightascension =
ra;
673 m_MountInternalCoordinates.declination = de;
682 char mountRAString[32] = {0}, mountDEString[32] = {0}, skyRAString[32] = {0}, skyDEString[32] = {0};
684 fs_sexa(mountDEString, de, 2, 3600);
685 fs_sexa(skyRAString, skyRA, 2, 3600);
686 fs_sexa(skyDEString, skyDE, 2, 3600);
688 LOGF_DEBUG(
"Mount RA: %s DE: %s ---> Sky RA: %s DE: %s", mountRAString, mountDEString, skyRAString, skyDEString);
694 LOG_ERROR(
"TransformTelescopeToCelestial failed in ReadScopeStatus");
707 LOGF_DEBUG(
"TransformCelestialToTelescope: RA=%lf DE=%lf, TDV (x :%lf, y: %lf, z: %lf), local hour RA %lf DEC %lf",
723 LOG_INFO(
"Parking is in progress...");
765 if (GuideRateNP.isNameMatch(name))
767 GuideRateNP.update(values, names,
n);
768 GuideRateNP.setState(
IPS_OK);
774 if (AccelerationNP.isNameMatch(name))
776 AccelerationNP.update(values, names,
n);
780 AccelerationNP.setState(
IPS_OK);
784 AccelerationNP.apply();
789 if (EncoderNP.isNameMatch(name))
791 if (slewEncoder(
AXIS_RA, values[0]) && slewEncoder(
AXIS_DE, values[1]))
794 EncoderNP.setState(
IPS_OK);
828 char *formats[],
char *names[],
int n)
857 LOG_ERROR(
"Please unpark the mount before issuing any motion commands.");
884 LOG_ERROR(
"Please unpark the mount before issuing any motion commands.");
911 LOG_ERROR(
"AstroTrac supports GEM and single arm (Fork) setups only.");
973 LOG_INFO(
"Please start tracking to set guide pulse");
979 double lastRARate(0), lastDERate(0);
980 getVelocity(
AXIS_RA, lastRARate);
981 getVelocity(
AXIS_DE, lastDERate);
984 lastRARate = std::fabs(lastRARate);
985 double rate = std::fabs(lastDERate) > 0 ? lastDERate : (lastRARate > 0 ? lastRARate :
TRACKRATE_SIDEREAL);
988 double dDE = std::fabs(GuideRateNP.at(
AXIS_DE)->getValue() * rate * ms / 1000.0);
991 setVelocity(
AXIS_DE, rate + dDE);
1017 LOG_INFO(
"Please start tracking to set guide pulse");
1023 double lastRARate(0), lastDERate(0);
1024 getVelocity(
AXIS_RA, lastRARate);
1025 getVelocity(
AXIS_DE, lastDERate);
1028 lastRARate = std::fabs(lastRARate);
1029 double rate = std::fabs(lastDERate) > 0 ? lastDERate : (lastRARate > 0 ? -lastRARate : -
TRACKRATE_SIDEREAL);
1032 double dDE = std::fabs(GuideRateNP.at(
AXIS_DE)->getValue() * rate * ms / 1000.0);
1035 setVelocity(
AXIS_DE, rate - dDE);
1061 LOG_INFO(
"Please start tracking to set guide pulse");
1067 double lastRARate(0);
1068 getVelocity(
AXIS_RA, lastRARate);
1074 double dRA = std::fabs(GuideRateNP.at(
AXIS_RA)->getValue() * rate * ms / 1000.0);
1087 setVelocity(
AXIS_RA, rate + dRA);
1114 LOG_INFO(
"Please start tracking to set guide pulse");
1120 double lastRARate(0);
1121 getVelocity(
AXIS_RA, lastRARate);
1127 double dRA = std::fabs(GuideRateNP.at(
AXIS_RA)->getValue() * rate * ms / 1000.0);
1140 setVelocity(
AXIS_RA, rate - dRA);
1158 return setVelocity(
AXIS_RA, raRate) && setVelocity(
AXIS_DE, deRate);
1166 double dRA = 0, dDE = 0;
1212void AstroTrac::simulateMount()
1215 uint32_t elapsed = m_SimulationTimer.
elapsed();
1235 double elapsedDistanceHA = (elapsed / 1000.0 * haVelocity) / 3600.0;
1236 double elapsedDistanceDE = (elapsed / 1000.0 * deVelocity) / 3600.0;
1239 SimData.currentMechanicalHA += elapsedDistanceHA;
1240 if (SimData.currentMechanicalHA > 180)
1241 SimData.currentMechanicalHA -= 360;
1242 else if (SimData.currentMechanicalHA < -180)
1243 SimData.currentMechanicalHA += 360;
1245 SimData.currentMechanicalDE += elapsedDistanceDE;
1246 if (SimData.currentMechanicalDE > 180)
1247 SimData.currentMechanicalDE -= 360;
1248 else if (SimData.currentMechanicalDE < -180)
1249 SimData.currentMechanicalDE += 360;
1263 double elapsedDistance = (elapsed / 1000.0 * MAX_SLEW_VELOCITY) / 3600.0;
1266 double dHA = SimData.targetMechanicalHA - SimData.currentMechanicalHA;
1267 if (std::abs(dHA) <= elapsedDistance)
1268 SimData.currentMechanicalHA = SimData.targetMechanicalHA;
1270 SimData.currentMechanicalHA += elapsedDistance;
1272 SimData.currentMechanicalHA -= elapsedDistance;
1275 double dDE = SimData.targetMechanicalDE - SimData.currentMechanicalDE;
1276 if (std::abs(dDE) <= elapsedDistance)
1277 SimData.currentMechanicalDE = SimData.targetMechanicalDE;
1279 SimData.currentMechanicalDE += elapsedDistance;
1281 SimData.currentMechanicalDE -= elapsedDistance;
1288 SimData.currentMechanicalHA += (elapsed / 1000.0 *
TrackRateNP[
AXIS_RA].getValue()) / 3600.0;
1289 if (SimData.currentMechanicalHA > 180)
1290 SimData.currentMechanicalHA = 180;
1291 else if (SimData.currentMechanicalHA < -180)
1292 SimData.currentMechanicalHA = -180;
1298 m_SimulationTimer.restart();
1307 m_SimulationTimer.start();
1313bool AstroTrac::handleSimulationCommand(
const char *
cmd,
char *res,
int cmd_len,
int res_len)
1318 if (strstr(
cmd,
"zv?"))
1320 snprintf(res, res_len,
"<%czvSIMU>",
cmd[1]);
1323 else if (strstr(
cmd,
"p?"))
1325 snprintf(res, res_len,
"<%cp%.6f>",
cmd[1],
cmd[1] ==
'1' ? SimData.currentMechanicalHA : SimData.currentMechanicalDE);
1328 else if (strstr(
cmd,
"p"))
1331 sscanf(
cmd,
"<%*cp%lf", &value);
1333 SimData.targetMechanicalHA =
value;
1335 SimData.targetMechanicalDE =
value;
1336 snprintf(res, res_len,
"<%cp#>",
cmd[1]);
1339 else if (strstr(
cmd,
"a?"))
1341 snprintf(res, res_len,
"<%ca%u>",
cmd[1], SimData.acceleration[
cmd[1] -
'1']);
1344 else if (strstr(
cmd,
"a"))
1347 sscanf(
cmd,
"<%*ca%u", &value);
1348 SimData.acceleration[
cmd[1] -
'1'] =
value;
1349 snprintf(res, res_len,
"<%ca#>",
cmd[1]);
1352 else if (strstr(
cmd,
"v?"))
1354 snprintf(res, res_len,
"<%cv%.6f>",
cmd[1], SimData.velocity[
cmd[1] -
'1']);
1357 else if (strstr(
cmd,
"ve"))
1360 sscanf(
cmd,
"<%*cve%lf", &value);
1361 SimData.velocity[
cmd[1] -
'1'] =
value;
1362 snprintf(res, res_len,
"<%cve#>",
cmd[1]);
1365 else if (strstr(
cmd,
"t"))
1369 result = std::abs(SimData.currentMechanicalHA - SimData.targetMechanicalHA) <= DIFF_THRESHOLD ?
'0' :
'1';
1371 result = std::abs(SimData.currentMechanicalDE - SimData.targetMechanicalDE) <= DIFF_THRESHOLD ?
'0' :
'1';
1372 snprintf(res, res_len,
"<%ct%c#>",
cmd[1], result);
1375 else if (strstr(
cmd,
"x"))
1377 snprintf(res, res_len,
"<%cx#>",
cmd[1]);
1386bool AstroTrac::sendCommand(
const char *
cmd,
char *res,
int cmd_len,
int res_len)
1388 int nbytes_written = 0, nbytes_read = 0, rc = -1;
1391 return handleSimulationCommand(
cmd, res, cmd_len, res_len);
1393 tcflush(
PortFD, TCIOFLUSH);
1397 char hex_cmd[DRIVER_LEN * 3] = {0};
1398 hexDump(hex_cmd,
cmd, cmd_len);
1412 LOGF_ERROR(
"Serial write error: %s.", errstr);
1423 rc =
tty_read(
PortFD, res, res_len, DRIVER_TIMEOUT, &nbytes_read);
1431 LOGF_ERROR(
"Serial read error: %s.", errstr);
1437 char hex_res[DRIVER_LEN * 3] = {0};
1438 hexDump(hex_res, res, res_len);
1446 tcflush(
PortFD, TCIOFLUSH);
1454void AstroTrac::hexDump(
char *buf,
const char *data,
int size)
1456 for (
int i = 0; i < size; i++)
1457 sprintf(buf + 3 * i,
"%02X ",
static_cast<uint8_t
>(data[i]));
1460 buf[3 * size - 1] =
'\0';
1466std::vector<std::string> AstroTrac::split(
const std::string &input,
const std::string ®ex)
1469 std::regex re(regex);
1470 std::sregex_token_iterator
1471 first{input.begin(), input.end(), re, -1},
1473 return {first, last};
std::unique_ptr< AstroTrac > AstroTrac_mount(new AstroTrac())
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual const char * getDefaultName() override
virtual bool Handshake() override
perform handshake with device to check communication
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate Set custom tracking rates.
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
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 SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual void simulationTriggered(bool enable) override
Handle Simulation Trigger.
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 SetMountType(TelescopeMountType type) override
SetMountType Called when the user selects a different mount type in TELESCOPE_MOUNT_TYPE....
virtual bool saveConfigItems(FILE *fp) override
Config Items.
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) override
Process the client newBLOB command.
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion 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 Park() override
Park the telescope to its home position.
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool ReadScopeStatus() override
Read telescope status.
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 initProperties() override
Called to initialize basic properties required all the time.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
virtual bool updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
virtual bool Goto(double ra, double dec) override
Move the scope to the supplied RA and DEC coordinates.
void ProcessAlignmentNumberProperties(Telescope *pTelescope, const char *name, double values[], char *names[], int n)
Call this function from within the ISNewNumber processing path. The function will handle any alignmen...
void ProcessAlignmentSwitchProperties(Telescope *pTelescope, const char *name, ISState *states, char *names[], int n)
Call this function from within the ISNewSwitch processing path. The function will handle any alignmen...
void InitAlignmentProperties(Telescope *pTelescope)
Initialize alignment subsystem properties. It is recommended to call this function within initPropert...
void ProcessAlignmentBLOBProperties(Telescope *pTelescope, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
Call this function from within the ISNewBlob processing path. The function will handle any alignment ...
void SaveAlignmentConfigProperties(FILE *fp)
Call this function to save persistent alignment related properties. This function should be called fr...
void ProcessAlignmentTextProperties(Telescope *pTelescope, const char *name, char *texts[], char *names[], int n)
Call this function from within the ISNewText processing path. The function will handle any alignment ...
bool CheckForDuplicateSyncPoint(const AlignmentDatabaseEntry &CandidateEntry, double Tolerance=0.1) const
Check if a entry already exists in the database.
AlignmentDatabaseType & GetAlignmentDatabase()
Get a reference to the in memory database.
void UpdateLocation(double latitude, double longitude, double elevation)
Call this function from within the updateLocation processing path.
void UpdateSize()
Call this function when the number of entries in the database changes.
bool TransformTelescopeToCelestialJD(const TelescopeDirectionVector &ApparentTelescopeDirectionVector, double &RightAscension, double &Declination, double JulianDate)
TransformTelescopeToCelestialJD Transforms Mount Coords to Celestial (Sky) Coordinates.
bool TransformCelestialToTelescopeJD(double RightAscension, double Declination, double JulianDate, TelescopeDirectionVector &ApparentTelescopeDirectionVector)
TransformCelestialToTelescopeJD Transforms Celestial (Sky) Coords to Mount Coordinates.
bool Initialise(InMemoryDatabase *pInMemoryDatabase)
Initialise or re-initialise the math plugin. Re-reading the in memory database as necessary.
void SetApproximateMountAlignmentFromMountType(MountType_t Type)
Call this function to set the ApproximateMountAlignment property of the current Math Plugin....
void EquatorialCoordinatesFromTelescopeDirectionVector(const TelescopeDirectionVector TelescopeDirectionVector, INDI::IEquatorialCoordinates &EquatorialCoordinates)
Calculates equatorial coordinates from the supplied telescope direction vector and declination.
const TelescopeDirectionVector TelescopeDirectionVectorFromEquatorialCoordinates(INDI::IEquatorialCoordinates EquatorialCoordinates)
Calculates a telescope direction vector from the supplied equatorial coordinates.
INDI::PropertySwitch getSwitch(const char *name) const
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)
bool isSimulation() const
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
uint32_t getDriverInterface() const
virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
Process the client newBLOB command.
int64_t elapsed() const
Returns the number of milliseconds since this ElapsedTimer was last started.
int64_t restart()
Restarts the timer and returns the number of milliseconds elapsed since the previous start.
INDI::PropertyNumber GuideNSNP
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
INDI::PropertyNumber GuideWENP
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)
TelescopeStatus TrackState
void SetAxis1Park(double value)
SetRAPark Set current RA/AZ parking position. The data park file (stored in ~/.indi/ParkData....
TelescopeMountType getMountType() const
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.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
double GetAxis1Park() const
void setTelescopeConnection(const uint8_t &value)
setTelescopeConnection Set telescope connection mode. Child class should call this in the constructor...
double GetAxis2Park() const
virtual int AddTrackMode(const char *name, const char *label, bool isDefault=false)
AddTrackMode.
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....
Connection::TCP * tcpConnection
TelescopeMountType
Mount geometry reported in the standard TELESCOPE_MOUNT_TYPE property. The values are the indices of ...
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.
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...
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.
@ TELESCOPE_HAS_TRACK_RATE
@ TELESCOPE_HAS_PIER_SIDE
@ TELESCOPE_CAN_SET_MOUNT_TYPE
@ TELESCOPE_HAS_TRACK_MODE
@ TELESCOPE_CAN_CONTROL_TRACK
void SetAxis2ParkDefault(double steps)
SetDEParkDefault Set default DEC/ALT parking position.
static void singleShot(int msec, const std::function< void()> &callback)
This static function calls a the given function after a given time interval.
const char * MOTION_TAB
MOTION_TAB Where all the motion control properties of the device are located.
INDI::PropertyNumber TrackRateNP
INDI::PropertySwitch MovementNSSP
INDI::PropertySwitch SlewRateSP
INDI::PropertySwitch TrackModeSP
INDI::PropertySwitch MountTypeSP
Standard TELESCOPE_MOUNT_TYPE property, indexed by TelescopeMountType. Writable if the driver sets TE...
INDI::PropertySwitch MovementWESP
INDI::PropertyNumber LocationNP
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
double rangeHA(double r)
rangeHA Limits the hour angle value to be between -12 ---> 12
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
double range24(double r)
range24 Limits a number to be between 0-24 range.
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
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.
double get_local_sidereal_time(double longitude)
get_local_sidereal_time Returns local sidereal time given longitude and system clock.
int IUGetConfigOnSwitchIndex(const char *dev, const char *property, int *index)
IUGetConfigOnSwitchIndex Opens configuration file and reads single switch property to find ON switch ...
*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 LOGF_ERROR(fmt,...)
#define TRACKRATE_SIDEREAL
Namespace to encapsulate the INDI Alignment Subsystem classes. For more information see "INDI Alignme...
Entry in the in memory alignment database.
double RightAscension
Right ascension in decimal hours. N.B. libnova works in decimal degrees so conversion is always neede...
double ObservationJulianDate
TelescopeDirectionVector TelescopeDirection
Normalised vector giving telescope pointing direction. This is referred to elsewhere as the "apparent...
double Declination
Declination in decimal degrees.
int PrivateDataSize
This size in bytes of any private data.
Holds a normalised direction vector (direction cosines).