33#define AXIS_TAB "Axis Settings"
48 return (
const char *)
"Digital Setting Circle";
56 IUFillNumber(&EncoderN[AXIS1_ENCODER],
"AXIS1_ENCODER",
"Axis 1",
"%0.f", 0, 1e6, 0, 0);
57 IUFillNumber(&EncoderN[AXIS2_ENCODER],
"AXIS2_ENCODER",
"Axis 2",
"%0.f", 0, 1e6, 0, 0);
58 IUFillNumber(&EncoderN[AXIS1_RAW_ENCODER],
"AXIS1_RAW_ENCODER",
"RAW Axis 1",
"%0.f", -1e6, 1e6, 0, 0);
59 IUFillNumber(&EncoderN[AXIS2_RAW_ENCODER],
"AXIS2_RAW_ENCODER",
"RAW Axis 2",
"%0.f", -1e6, 1e6, 0, 0);
64 IUFillNumber(&AxisSettingsN[AXIS1_TICKS],
"AXIS1_TICKS",
"#1 ticks/rev",
"%g", 256, 1e6, 0, 4096);
65 IUFillNumber(&AxisSettingsN[AXIS1_DEGREE_OFFSET],
"AXIS1_DEGREE_OFFSET",
"#1 Degrees Offset",
"%g", -180, 180, 30,
67 IUFillNumber(&AxisSettingsN[AXIS2_TICKS],
"AXIS2_TICKS",
"#2 ticks/rev",
"%g", 256, 1e6, 0, 4096);
68 IUFillNumber(&AxisSettingsN[AXIS2_DEGREE_OFFSET],
"AXIS2_DEGREE_OFFSET",
"#2 Degrees Offset",
"%g", -180, 180, 30,
92 IUFillNumber(&EncoderOffsetN[OFFSET_AXIS1_SCALE],
"OFFSET_AXIS1_SCALE",
"#1 Ticks Scale",
"%g", 0, 1e6, 0, 1);
93 IUFillNumber(&EncoderOffsetN[OFFSET_AXIS1_OFFSET],
"OFFSET_AXIS1_OFFSET",
"#1 Ticks Offset",
"%g", -1e6, 1e6, 0, 0);
94 IUFillNumber(&EncoderOffsetN[AXIS1_DEGREE_OFFSET],
"AXIS1_DEGREE_OFFSET",
"#1 Degrees Offset",
"%g", -180, 180, 30, 0);
95 IUFillNumber(&EncoderOffsetN[OFFSET_AXIS2_SCALE],
"OFFSET_AIXS2_SCALE",
"#2 Ticks Scale",
"%g", 0, 1e6, 0, 1);
96 IUFillNumber(&EncoderOffsetN[OFFSET_AXIS2_OFFSET],
"OFFSET_AXIS2_OFFSET",
"#2 Ticks Offset",
"%g", -1e6, 1e6, 0, 0);
97 IUFillNumber(&EncoderOffsetN[AXIS2_DEGREE_OFFSET],
"AXIS2_DEGREE_OFFSET",
"#2 Degrees Offset",
"%g", -180, 180, 30, 0);
103 IUFillNumber(&SimEncoderN[AXIS1_ENCODER],
"AXIS1_ENCODER",
"Axis 1",
"%0.f", -1e6, 1e6, 0, 0);
104 IUFillNumber(&SimEncoderN[AXIS2_ENCODER],
"AXIS2_ENCODER",
"Axis 2",
"%0.f", -1e6, 1e6, 0, 0);
160bool DSC::ISNewText(
const char *dev,
const char *name,
char *texts[],
char *names[],
int n)
167bool DSC::ISNewNumber(
const char *dev,
const char *name,
double values[],
char *names[],
int n)
171 if (strcmp(name, AxisSettingsNP.
name) == 0)
187 if (strcmp(name, SimEncoderNP.
name) == 0)
205 if (strcmp(name, ReverseSP.
name) == 0)
221 if (strcmp(name, AxisRangeSP.
name) == 0)
226 if (AxisRangeS[AXIS_FULL_STEP].s ==
ISS_ON)
228 LOGF_INFO(
"Axis range is from 0 to %.f", AxisSettingsN[AXIS1_TICKS].value);
232 LOGF_INFO(
"Axis range is from -%.f to %.f",
233 AxisSettingsN[AXIS1_TICKS].value / 2, AxisSettingsN[AXIS1_TICKS].value / 2);
253 char CR[1] = { 0x51 };
255 char response[18] = { 0 };
256 int rc = 0, nbytes_read = 0, nbytes_written = 0;
262 snprintf(response, 18,
"%06.f\t%06.f", SimEncoderN[AXIS1_ENCODER].value, SimEncoderN[AXIS2_ENCODER].value);
266 tcflush(
PortFD, TCIFLUSH);
272 LOGF_ERROR(
"Error writing to device %s (%d)", errmsg, rc);
281 if (nbytes_read < 12)
285 LOGF_ERROR(
"Error reading from device %s (%d)", errmsg, rc);
293 double Axis1Encoder = 0, Axis2Encoder = 0;
294 std::regex rgx(R
"((\+?\-?\d+)\s(\+?\-?\d+))");
296 std::string input(response);
298 if (std::regex_search(input, match, rgx))
300 Axis1Encoder = atof(match.str(1).c_str());
301 Axis2Encoder = atof(match.str(2).c_str());
305 LOGF_ERROR(
"Error processing response: %s", response);
311 LOGF_DEBUG(
"Raw Axis encoders. Axis1: %g Axis2: %g", Axis1Encoder, Axis2Encoder);
313 EncoderN[AXIS1_RAW_ENCODER].value = Axis1Encoder;
314 EncoderN[AXIS2_RAW_ENCODER].value = Axis2Encoder;
317 if (AxisRangeS[AXIS_HALF_STEP].s ==
ISS_ON)
319 if (Axis1Encoder < 0)
320 Axis1Encoder += AxisSettingsN[AXIS1_TICKS].value;
322 if (Axis2Encoder < 0)
323 Axis2Encoder += AxisSettingsN[AXIS2_TICKS].value;
327 double Axis1 = Axis1Encoder;
328 if (ReverseS[AXIS1_ENCODER].s ==
ISS_ON)
329 Axis1 = AxisSettingsN[AXIS1_TICKS].value - Axis1;
333 Axis1Diff += AxisSettingsN[AXIS1_TICKS].value;
334 else if (Axis1Diff > AxisSettingsN[AXIS1_TICKS].value)
335 Axis1Diff -= AxisSettingsN[AXIS1_TICKS].value;
338 double Axis2 = Axis2Encoder;
339 if (ReverseS[AXIS2_ENCODER].s ==
ISS_ON)
340 Axis2 = AxisSettingsN[AXIS2_TICKS].value - Axis2;
342 LOGF_DEBUG(
"Axis encoders after reverse. Axis1: %g Axis2: %g", Axis1, Axis2);
352 EncoderN[AXIS1_ENCODER].value = Axis1;
353 EncoderN[AXIS2_ENCODER].value = Axis2;
357 double Axis1Degrees = (Axis1 / AxisSettingsN[AXIS1_TICKS].value * 360.0) + AxisSettingsN[AXIS1_DEGREE_OFFSET].value;
358 double Axis2Degrees = (Axis2 / AxisSettingsN[AXIS2_TICKS].value * 360.0) + AxisSettingsN[AXIS2_DEGREE_OFFSET].value;
360 Axis1Degrees =
range360(Axis1Degrees);
361 Axis2Degrees =
range360(Axis2Degrees);
372 encoderEquatorialCoordinates.
rightascension = Axis1Degrees / 15.0;
380 eq = TelescopeEquatorialToSky();
384 encoderHorizontalCoordinates.
azimuth = Axis1Degrees;
385 encoderHorizontalCoordinates.
azimuth += 180;
388 encoderHorizontalCoordinates.
altitude = Axis2Degrees;
391 eq = TelescopeHorizontalToSky();
393 char AzStr[64], AltStr[64];
394 fs_sexa(AzStr, Axis1Degrees, 2, 3600);
395 fs_sexa(AltStr, Axis2Degrees, 2, 3600);
396 LOGF_DEBUG(
"Current Az: %s Current Alt: %s", AzStr, AltStr);
414 RaDec.declination = encoderEquatorialCoordinates.
declination;
418 AltAz.azimuth = encoderHorizontalCoordinates.
azimuth;
419 AltAz.altitude = encoderHorizontalCoordinates.
altitude;
454 double RightAscension, Declination;
466 lha = lha * 360 / 24;
467 eq.rightascension = lha;
474 Declination = encoderEquatorialCoordinates.
declination;
482 Declination = encoderEquatorialCoordinates.
declination;
485 eq.rightascension = RightAscension;
486 eq.declination = Declination;
494 double RightAscension, Declination;
522 RightAscension = EquatorialCoordinates.rightascension;
523 Declination = EquatorialCoordinates.declination;
526 eq.rightascension = RightAscension;
527 eq.declination = Declination;
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.
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 ReadScopeStatus() override
Read telescope status.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual const char * getDefaultName() override
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool Handshake() override
perform handshake with device to check communication
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual void simulationTriggered(bool enable) override
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
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 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 Initialise(InMemoryDatabase *pInMemoryDatabase)
Initialise or re-initialise the math plugin. Re-reading the in memory database as necessary.
MountAlignment_t GetApproximateMountAlignment()
Get the approximate alignment of the mount.
void SetAlignmentSubsystemActive(bool enable)
SetAlignmentSubsystemActive Enable or Disable alignment subsystem.
const TelescopeDirectionVector TelescopeDirectionVectorFromAltitudeAzimuth(INDI::IHorizontalCoordinates HorizontalCoordinates)
Calculates a normalised direction vector from the supplied altitude and azimuth.
const TelescopeDirectionVector TelescopeDirectionVectorFromLocalHourAngleDeclination(INDI::IEquatorialCoordinates EquatorialCoordinates)
Calculates a telescope direction vector from the supplied local hour angle and declination.
void AltitudeAzimuthFromTelescopeDirectionVector(const TelescopeDirectionVector TelescopeDirectionVector, INDI::IHorizontalCoordinates &HorizontalCoordinates)
Calculates an altitude and azimuth from the supplied normalised direction vector and declination.
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 setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
void save(FILE *f) const
save Save property to configuration file.
bool isNameMatch(const char *otherName) const
bool update(const ISState states[], const char *const names[], int n)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, double timeout, IPState state)
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.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
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.
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 * 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.
std::unique_ptr< DSC > dsc(new DSC())
INDI::PropertySwitch MountTypeSP
INDI::PropertyNumber LocationNP
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
double range24(double r)
range24 Limits a number to be between 0-24 range.
double range360(double r)
range360 Limits an angle to be between 0-360 degrees.
double rangeDec(double decdegrees)
rangeDec Limits declination value to be in -90 to 90 range.
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[].
double get_local_hour_angle(double sideral_time, double ra)
get_local_hour_angle Returns local hour angle of an object
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 IUSaveConfigSwitch(FILE *fp, const ISwitchVectorProperty *svp)
Add a switch vector property value to the configuration file.
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 IUSaveConfigNumber(FILE *fp, const INumberVectorProperty *nvp)
Add a number vector property value to the configuration file.
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 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.
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 IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
#define LOGF_INFO(fmt,...)
#define LOGF_DEBUG(fmt,...)
#define LOGF_ERROR(fmt,...)
#define DEBUGF(priority, msg,...)
Namespace to encapsulate the INDI Alignment Subsystem classes. For more information see "INDI Alignme...
void HorizontalToEquatorial(IHorizontalCoordinates *object, IGeographicCoordinates *observer, double JD, IEquatorialCoordinates *position)
HorizontalToEquatorial Calculate Equatorial EOD Coordinates from horizontal coordinates.
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)