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}};
73 for (uint8_t i = 0; i < SLEW_MODES; i++)
81 int configMountType = MOUNT_GEM;
83 MountTypeSP[MOUNT_GEM].
fill(
"MOUNT_GEM",
"GEM",
85 MountTypeSP[MOUNT_SINGLE_ARM].
fill(
"MOUNT_SINGLE_ARM",
"Single ARM",
90 AccelerationNP[
AXIS_RA].
fill(
"AXIS_RA",
"RA arcsec/sec^2",
"%.2f", 0, 3600, 100, 0);
91 AccelerationNP[
AXIS_DE].
fill(
"AXIS_DE",
"DE arcsec/sec^2",
"%.2f", 0, 3600, 100, 0);
95 EncoderNP[
AXIS_RA].
fill(
"AXIS_RA",
"Hour Angle",
"%.2f", -3600, 3600, 100, 0);
96 EncoderNP[
AXIS_DE].
fill(
"AXIS_DE",
"Declination",
"%.2f", -3600, 3600, 100, 0);
102 GuideRateNP[
AXIS_RA].
fill(
"GUIDE_RATE_WE",
"W/E Rate",
"%g", 0, 1, 0.1, 0.1);
103 GuideRateNP[
AXIS_DE].
fill(
"GUIDE_RATE_NS",
"N/S Rate",
"%g", 0, 1, 0.1, 0.1);
201bool AstroTrac::getVersion()
203 char response[DRIVER_LEN] = {0};
204 if (sendCommand(
"<1zv?>", response))
206 FirmwareTP[0].setText(response + 4, 4);
218 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
219 snprintf(command, DRIVER_LEN,
"<%da?>", axis + 1);
220 if (sendCommand(command, response))
226 std::regex(
"<.a(\\d+)>"),
234 LOGF_DEBUG(
"Failed to parse acceleration (%s)", response);
244bool AstroTrac::setAcceleration(
INDI_EQ_AXIS axis, uint32_t a)
246 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
248 snprintf(command, DRIVER_LEN,
"<%da%u>", axis + 1, a);
249 if (sendCommand(command, response))
250 return response[3] ==
'#';
258bool AstroTrac::getVelocity(
INDI_EQ_AXIS axis,
double &value)
260 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
261 snprintf(command, DRIVER_LEN,
"<%dv?>", axis + 1);
262 if (sendCommand(command, response))
266 std::string
velocity = std::regex_replace(
268 std::regex(
"<.v([+-]?[0-9]+\\.[0-9]+?)>"),
276 LOGF_DEBUG(
"Failed to parse velocity (%s)", response);
301bool AstroTrac::setVelocity(
INDI_EQ_AXIS axis,
double value)
303 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
306 snprintf(command, DRIVER_LEN,
"<%dve%f>", axis + 1, value * (
m_Location.
latitude >= 0 ? 1 : -1));
307 if (sendCommand(command, response))
308 return response[4] ==
'#';
318 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
320 snprintf(command, DRIVER_LEN,
"<%dx>", axis + 1);
321 if (sendCommand(command, response))
322 return response[3] ==
'#';
330bool AstroTrac::isSlewComplete()
332 char HAResponse[DRIVER_LEN] = {0}, DEResponse[DRIVER_LEN] = {0};
333 if (sendCommand(
"<1t?>", HAResponse) && sendCommand(
"<2t?>", DEResponse))
335 return (HAResponse[3] ==
'0' && DEResponse[3] ==
'0');
344bool AstroTrac::syncEncoder(
INDI_EQ_AXIS axis,
double value)
346 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
348 snprintf(command, DRIVER_LEN,
"<%dy%f>", axis + 1, value);
349 if (sendCommand(command, response))
350 return response[3] ==
'#';
358bool AstroTrac::slewEncoder(
INDI_EQ_AXIS axis,
double value)
360 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
362 snprintf(command, DRIVER_LEN,
"<%dp%f>", axis + 1, value);
363 if (sendCommand(command, response))
364 return response[3] ==
'#';
377 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
378 snprintf(command, DRIVER_LEN,
"<%dp?>", axis + 1);
379 if (sendCommand(command, response))
383 char regex_str[64] = {0};
384 snprintf(regex_str, 64,
"<%dp([+-]?[0-9]+\\.[0-9]+?)>", axis + 1);
385 std::string position = std::regex_replace(
387 std::regex(regex_str),
390 EncoderNP[axis].setValue(std::stod(position));
399 char regex_str[64] = {0};
400 snprintf(regex_str, 64,
"<%dp([+-]?[0-9]+\\.[0-9]+?)>", other + 1);
401 std::string position = std::regex_replace(
403 std::regex(regex_str),
406 EncoderNP[other].setValue(std::stod(position));
411 LOGF_DEBUG(
"Failed to parse position (%s)", response);
426void AstroTrac::getRADEFromEncoders(
double haEncoder,
double deEncoder,
double &
ra,
double &de, TelescopePierSide &pierSide)
428 static const double jitter = 0.0005;
432 if (haEncoder > jitter * -1 && haEncoder < jitter)
434 if (deEncoder > jitter * -1 && deEncoder < jitter)
443 de = std::min(90 - deEncoder, 90.0);
444 ha = -6.0 + (haEncoder / 360.0) * 24.0;
451 ha = 6.0 + (haEncoder / 360.0) * 24.0;
461 de = std::max(-90 - deEncoder, -90.0);
462 ha = -6.0 - (haEncoder / 360.0) * 24.0;
468 de = -90 + deEncoder;
469 ha = 6.0 - (haEncoder / 360.0) * 24.0;
477 char RAStr[32] = {0}, DecStr[32] = {0};
480 LOGF_DEBUG(
"Encoders HA: %.4f DE: %.4f Processed: HA: %.4f DE: %.4f (%s) LST: %.4f RA: %.4f (%s)",
481 haEncoder, deEncoder, ha, de, DecStr, lst,
ra, RAStr);
490void AstroTrac::getEncodersFromRADE(
double ra,
double de,
double &haEncoder,
double &deEncoder)
500 deEncoder = -(de - 90.0);
501 haEncoder = (dHA + 6.0) * 360.0 / 24.0;
506 deEncoder = de - 90.0;
507 haEncoder = (dHA - 6.0) * 360.0 / 24.0;
515 deEncoder = -(de + 90.0);
516 haEncoder = -(dHA + 6.0) * 360.0 / 24.0;
521 deEncoder = (de + 90.0);
522 haEncoder = -(dHA - 6.0) * 360 / 24.0;
551 char RAStr[32], DecStr[32];
554 LOGF_INFO(
"Syncing to JNOW RA %s - DEC %s", RAStr, DecStr);
559 LOGF_DEBUG(
"Sync - duplicate entry RA: %lf(%lf) DEC: %lf",
ra * 360.0 / 24.0,
ra,
dec);
568 double haEncoder = 0, deEncoder = 0;
570 if (getTelescopeFromSkyCoordinates(
ra,
dec, telescopeCoordinates))
572 char mountRAString[32] = {0}, mountDEString[32] = {0}, skyRAString[32] = {0}, skyDEString[32] = {0};
578 LOGF_DEBUG(
"GOTO Sky RA: %s DE: %s ---> Mount RA: %s DE: %s", skyRAString, skyDEString, mountRAString, mountDEString);
584 double tHA = calculateSlewTime(haEncoder - EncoderNP[
AXIS_RA].getValue());
588 LOGF_DEBUG(
"GOTO Encoders HA: %.4f (%.4f + %.4f) DE: %.4f", haEncoder + tHA, haEncoder, tHA, deEncoder);
591 bool rc1 = slewEncoder(
AXIS_RA, haEncoder + tHA);
592 bool rc2 = slewEncoder(
AXIS_DE, deEncoder);
598 char RAStr[32], DecStr[32];
601 LOGF_INFO(
"Slewing to JNOW RA %s - DEC %s", RAStr, DecStr);
614double AstroTrac::calculateSlewTime(
double distance)
617 distance = fabs(distance) * 3600.0;
620 double accelerate_decelerate = MAX_SLEW_VELOCITY * MAX_SLEW_VELOCITY / AccelerationNP[
AXIS_RA].getValue();
623 if (distance < accelerate_decelerate)
625 return (2 * sqrt(distance / AccelerationNP[
AXIS_RA].getValue()));
630 return (2.0 * MAX_SLEW_VELOCITY / AccelerationNP[
AXIS_RA].getValue() + (distance - accelerate_decelerate) /
641 double ra = 0, de = 0, skyRA = 0, skyDE = 0;
647 double lastHAEncoder = EncoderNP[
AXIS_RA].getValue();
648 double lastDEEncoder = EncoderNP[
AXIS_DE].getValue();
651 getRADEFromEncoders(EncoderNP[
AXIS_RA].getValue(), EncoderNP[
AXIS_DE].getValue(),
ra, de, side);
653 if (std::fabs(lastHAEncoder - EncoderNP[
AXIS_RA].getValue()) > 0
654 || std::fabs(lastDEEncoder - EncoderNP[
AXIS_DE].getValue()) > 0)
664 if (isSlewComplete())
668 LOG_INFO(
"Slew complete, tracking...");
691 char mountRAString[32] = {0}, mountDEString[32] = {0}, skyRAString[32] = {0}, skyDEString[32] = {0};
693 fs_sexa(mountDEString, de, 2, 3600);
694 fs_sexa(skyRAString, skyRA, 2, 3600);
695 fs_sexa(skyDEString, skyDE, 2, 3600);
697 LOGF_DEBUG(
"Mount RA: %s DE: %s ---> Sky RA: %s DE: %s", mountRAString, mountDEString, skyRAString, skyDEString);
703 LOG_ERROR(
"TransformTelescopeToCelestial failed in ReadScopeStatus");
716 LOGF_DEBUG(
"TransformCelestialToTelescope: RA=%lf DE=%lf, TDV (x :%lf, y: %lf, z: %lf), local hour RA %lf DEC %lf",
732 LOG_INFO(
"Parking is in progress...");
776 GuideRateNP.
update(values, names, n);
785 AccelerationNP.
update(values, names, n);
793 AccelerationNP.
apply();
800 if (slewEncoder(
AXIS_RA, values[0]) && slewEncoder(
AXIS_DE, values[1]))
829 MountTypeSP.
update(states, names, n);
846 char *formats[],
char *names[],
int n)
875 LOG_ERROR(
"Please unpark the mount before issuing any motion commands.");
902 LOG_ERROR(
"Please unpark the mount before issuing any motion commands.");
978 LOG_INFO(
"Please start tracking to set guide pulse");
984 double lastRARate(0), lastDERate(0);
985 getVelocity(
AXIS_RA, lastRARate);
986 getVelocity(
AXIS_DE, lastDERate);
989 lastRARate = std::fabs(lastRARate);
990 double rate = std::fabs(lastDERate) > 0 ? lastDERate : (lastRARate > 0 ? lastRARate :
TRACKRATE_SIDEREAL);
993 double dDE = std::fabs(GuideRateNP.
at(
AXIS_DE)->
getValue() * rate * ms / 1000.0);
996 setVelocity(
AXIS_DE, rate + dDE);
1022 LOG_INFO(
"Please start tracking to set guide pulse");
1028 double lastRARate(0), lastDERate(0);
1029 getVelocity(
AXIS_RA, lastRARate);
1030 getVelocity(
AXIS_DE, lastDERate);
1033 lastRARate = std::fabs(lastRARate);
1034 double rate = std::fabs(lastDERate) > 0 ? lastDERate : (lastRARate > 0 ? -lastRARate : -
TRACKRATE_SIDEREAL);
1037 double dDE = std::fabs(GuideRateNP.
at(
AXIS_DE)->
getValue() * rate * ms / 1000.0);
1040 setVelocity(
AXIS_DE, rate - dDE);
1066 LOG_INFO(
"Please start tracking to set guide pulse");
1072 double lastRARate(0);
1073 getVelocity(
AXIS_RA, lastRARate);
1079 double dRA = std::fabs(GuideRateNP.
at(
AXIS_RA)->
getValue() * rate * ms / 1000.0);
1092 setVelocity(
AXIS_RA, rate + dRA);
1119 LOG_INFO(
"Please start tracking to set guide pulse");
1125 double lastRARate(0);
1126 getVelocity(
AXIS_RA, lastRARate);
1132 double dRA = std::fabs(GuideRateNP.
at(
AXIS_RA)->
getValue() * rate * ms / 1000.0);
1145 setVelocity(
AXIS_RA, rate - dRA);
1163 return setVelocity(
AXIS_RA, raRate) && setVelocity(
AXIS_DE, deRate);
1171 double dRA = 0, dDE = 0;
1210 MountTypeSP.
save(fp);
1218void AstroTrac::simulateMount()
1221 uint32_t elapsed = m_SimulationTimer.
elapsed();
1241 double elapsedDistanceHA = (elapsed / 1000.0 * haVelocity) / 3600.0;
1242 double elapsedDistanceDE = (elapsed / 1000.0 * deVelocity) / 3600.0;
1245 SimData.currentMechanicalHA += elapsedDistanceHA;
1246 if (
SimData.currentMechanicalHA > 180)
1247 SimData.currentMechanicalHA -= 360;
1248 else if (
SimData.currentMechanicalHA < -180)
1249 SimData.currentMechanicalHA += 360;
1251 SimData.currentMechanicalDE += elapsedDistanceDE;
1252 if (
SimData.currentMechanicalDE > 180)
1253 SimData.currentMechanicalDE -= 360;
1254 else if (
SimData.currentMechanicalDE < -180)
1255 SimData.currentMechanicalDE += 360;
1269 double elapsedDistance = (elapsed / 1000.0 * MAX_SLEW_VELOCITY) / 3600.0;
1272 double dHA =
SimData.targetMechanicalHA -
SimData.currentMechanicalHA;
1273 if (std::abs(dHA) <= elapsedDistance)
1276 SimData.currentMechanicalHA += elapsedDistance;
1278 SimData.currentMechanicalHA -= elapsedDistance;
1281 double dDE =
SimData.targetMechanicalDE -
SimData.currentMechanicalDE;
1282 if (std::abs(dDE) <= elapsedDistance)
1285 SimData.currentMechanicalDE += elapsedDistance;
1287 SimData.currentMechanicalDE -= elapsedDistance;
1295 if (
SimData.currentMechanicalHA > 180)
1296 SimData.currentMechanicalHA = 180;
1297 else if (
SimData.currentMechanicalHA < -180)
1298 SimData.currentMechanicalHA = -180;
1313 m_SimulationTimer.
start();
1319bool AstroTrac::handleSimulationCommand(
const char *
cmd,
char *res,
int cmd_len,
int res_len)
1324 if (strstr(
cmd,
"zv?"))
1326 snprintf(res, res_len,
"<%czvSIMU>",
cmd[1]);
1329 else if (strstr(
cmd,
"p?"))
1334 else if (strstr(
cmd,
"p"))
1337 sscanf(
cmd,
"<%*cp%lf", &value);
1339 SimData.targetMechanicalHA = value;
1341 SimData.targetMechanicalDE = value;
1342 snprintf(res, res_len,
"<%cp#>",
cmd[1]);
1345 else if (strstr(
cmd,
"a?"))
1347 snprintf(res, res_len,
"<%ca%u>",
cmd[1],
SimData.acceleration[
cmd[1] -
'1']);
1350 else if (strstr(
cmd,
"a"))
1353 sscanf(
cmd,
"<%*ca%u", &value);
1355 snprintf(res, res_len,
"<%ca#>",
cmd[1]);
1358 else if (strstr(
cmd,
"v?"))
1360 snprintf(res, res_len,
"<%cv%.6f>",
cmd[1],
SimData.velocity[
cmd[1] -
'1']);
1363 else if (strstr(
cmd,
"ve"))
1366 sscanf(
cmd,
"<%*cve%lf", &value);
1368 snprintf(res, res_len,
"<%cve#>",
cmd[1]);
1371 else if (strstr(
cmd,
"t"))
1375 result = std::abs(
SimData.currentMechanicalHA -
SimData.targetMechanicalHA) <= DIFF_THRESHOLD ?
'0' :
'1';
1377 result = std::abs(
SimData.currentMechanicalDE -
SimData.targetMechanicalDE) <= DIFF_THRESHOLD ?
'0' :
'1';
1378 snprintf(res, res_len,
"<%ct%c#>",
cmd[1], result);
1381 else if (strstr(
cmd,
"x"))
1383 snprintf(res, res_len,
"<%cx#>",
cmd[1]);
1392bool AstroTrac::sendCommand(
const char *
cmd,
char *res,
int cmd_len,
int res_len)
1394 int nbytes_written = 0, nbytes_read = 0, rc = -1;
1397 return handleSimulationCommand(
cmd, res, cmd_len, res_len);
1399 tcflush(
PortFD, TCIOFLUSH);
1403 char hex_cmd[DRIVER_LEN * 3] = {0};
1404 hexDump(hex_cmd,
cmd, cmd_len);
1418 LOGF_ERROR(
"Serial write error: %s.", errstr);
1429 rc =
tty_read(
PortFD, res, res_len, DRIVER_TIMEOUT, &nbytes_read);
1437 LOGF_ERROR(
"Serial read error: %s.", errstr);
1443 char hex_res[DRIVER_LEN * 3] = {0};
1444 hexDump(hex_res, res, res_len);
1452 tcflush(
PortFD, TCIOFLUSH);
1460void AstroTrac::hexDump(
char *buf,
const char *data,
int size)
1462 for (
int i = 0; i < size; i++)
1463 sprintf(buf + 3 * i,
"%02X ",
static_cast<uint8_t
>(data[i]));
1466 buf[3 * size - 1] =
'\0';
1472std::vector<std::string> AstroTrac::split(
const std::string &input,
const std::string ®ex)
1475 std::regex re(regex);
1476 std::sregex_token_iterator
1477 first{input.begin(), input.end(), re, -1},
1479 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.
double currentMechanicalDE
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 void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
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 setDefaultHost(const char *addressHost)
void setDefaultPort(uint32_t addressPort)
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.
void start()
Starts this timer. Once started, a timer value can be checked with elapsed().
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)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
void save(FILE *f) const
save Save property to configuration file.
void setLabel(const char *label)
bool isNameMatch(const char *otherName) const
const WidgetView< T > * at(size_t index) const
bool update(const double values[], const char *const names[], int n)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
bool update(const ISState states[], const char *const names[], int n)
int findOnSwitchIndex() const
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, double timeout, IPState state)
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.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
double GetAxis1Park() const
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
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
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_HAS_TRACK_RATE
@ TELESCOPE_HAS_PIER_SIDE
@ TELESCOPE_HAS_TRACK_MODE
@ TELESCOPE_CAN_CONTROL_TRACK
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....
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.
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 * 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.
INDI::PropertyNumber TrackRateNP
INDI::PropertySwitch MovementNSSP
INDI::PropertySwitch SlewRateSP
INDI::PropertySwitch TrackModeSP
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 ...
#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)