Instrument Neutral Distributed Interface INDI 2.2.5
indicom.h
Go to the documentation of this file.
1
38#pragma once
39
40// All constants and conversion macros are now in indimacros.h
41#include "indimacros.h"
42
43extern const char *Direction[];
44extern const char *SolarSystem[];
45
46struct ln_date;
47struct ln_equ_posn;
48struct ln_lnlat_posn;
49struct ln_hrz_posn;
50
51/* TTY Error Codes */
65
66#ifdef __cplusplus
67extern "C" {
68#endif
69
74/* @{ */
75
84int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read);
85
99int tty_read_expanded(int fd, char *buf, int nbytes, long timeout_seconds, long timeout_microseconds, int *nbytes_read);
100
109int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read);
110
125int tty_read_section_expanded(int fd, char *buf, char stop_char, long timeout_seconds, long timeout_microseconds,
126int *nbytes_read);
127
137int tty_nread_section(int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read);
138
152int tty_nread_section_expanded(int fd, char *buf, int nsize, char stop_char, long timeout_seconds,
153long timeout_microseconds,
154int *nbytes_read);
155
163int tty_write(int fd, const char *buffer, int nbytes, int *nbytes_written);
164
171int tty_write_string(int fd, const char *buffer, int *nbytes_written);
172
183int tty_connect(const char *device, int bit_rate, int word_size, int parity, int stop_bits, int *fd);
184
189int tty_disconnect(int fd);
190
196void tty_error_msg(int err_code, char *err_msg, int err_msg_len);
197
201void tty_set_debug(int debug);
202void tty_set_gemini_udp_format(int enabled);
203void tty_set_generic_udp_format(int enabled);
204void tty_clr_trailing_read_lf(int enabled);
205
206int tty_timeout(int fd, int timeout);
207
208int tty_timeout_microseconds(int fd, long timeout_seconds, long timeout_microseconds);
209
210
220void tty_reset_udp_session(int fd, int only_if_timeout_happened);
221
229void tty_set_auto_reset_udp_session(int flag);
230
231
232/* @} */
233
238/* @{ */
239
253int fs_sexa(char *out, double a, int w, int fracbase);
254
261int f_scansexa(const char *str0, double *dp);
262
268#ifndef _WIN32
269int extractISOTime(const char *timestr, struct ln_date *iso_date);
270#endif
271
272 void getSexComponents(double value, int *d, int *m, int *s);
273 void getSexComponentsIID(double value, int *d, int *m, double *s);
274
282 int numberFormat(char *buf, const char *format, double value);
283
287 double time_ns();
288
292 const char *indi_timestamp();
293
298 double rangeHA(double r);
299
304 double range24(double r);
305
310 double range360(double r);
311
317 double range180(double r);
318
323 double rangeDec(double r);
324
329 double get_local_sidereal_time(double longitude);
330
336 double get_local_hour_angle(double local_sidereal_time, double ra);
337
338
346 void get_hrz_from_equ(struct ln_equ_posn *object, struct ln_lnlat_posn *observer, double JD, struct ln_hrz_posn *position);
347
355 void get_equ_from_hrz(struct ln_hrz_posn *object, struct ln_lnlat_posn *observer, double JD,
356 struct ln_equ_posn *position);
364 void get_alt_az_coordinates(double hour_angle, double dec, double latitude, double* alt, double *az);
365
371 double estimate_geocentric_elevation(double latitude, double sea_level_elevation);
372
379 double estimate_field_rotation_rate(double Alt, double Az, double latitude);
380
386 double estimate_field_rotation(double hour_angle, double field_rotation_rate);
387
392 double as2rad(double as);
393
398 double rad2as(double rad);
399
404 double estimate_distance(double parsecs, double parallax_radius);
405
410 double m2au(double m);
411
419 double calc_delta_magnitude(double mag_ratio, double *spectrum, double *ref_spectrum, int spectrum_size);
420
428 double calc_photon_flux(double rel_magnitude, double filter_bandwidth, double wavelength, double steradian);
429
437 double calc_rel_magnitude(double photon_flux, double filter_bandwidth, double wavelength, double steradian);
438
444 double estimate_absolute_magnitude(double dist, double delta_mag);
445
450 double estimate_star_mass(double delta_mag, double ref_mass);
451
457 double estimate_orbit_radius(double obs_lambda, double ref_lambda, double period);
458
464 double estimate_secondary_mass(double star_mass, double star_drift, double orbit_radius);
465
470 double estimate_secondary_size(double star_size, double dropoff_ratio);
471
479 void baseline_2d_projection(double alt, double az, double baseline[3], double wavelength, double uvresult[2]);
480
488 double baseline_delay(double alt, double az, double baseline[3]);
489
490 /* @} */
491
492#ifdef __cplusplus
493 }
494#endif
hid_device * device
double ra
double dec
double estimate_secondary_size(double star_size, double dropoff_ratio)
estimate the size of an object occulting a star in star_size units.
Definition indicom.c:1474
int tty_write_string(int fd, const char *buffer, int *nbytes_written)
Writes a null terminated string to fd.
Definition indicom.c:473
void tty_set_generic_udp_format(int enabled)
Definition indicom.c:364
double estimate_geocentric_elevation(double latitude, double sea_level_elevation)
estimate_geocentric_elevation Returns an estimation of the actual geocentric elevation
Definition indicom.c:1401
double rangeDec(double r)
rangeDec Limits declination value to be in -90 to 90 range.
Definition indicom.c:1341
double calc_rel_magnitude(double photon_flux, double filter_bandwidth, double wavelength, double steradian)
calc_rel_magnitude Returns the relative magnitude of the object with the given photon flux measured a...
Definition indicom.c:1484
double estimate_secondary_mass(double star_mass, double star_drift, double orbit_radius)
estimate the mass of an object with known mass orbiting around a star.
Definition indicom.c:1469
TTY_ERROR
Definition indicom.h:53
@ TTY_PORT_FAILURE
Definition indicom.h:59
@ TTY_OK
Definition indicom.h:54
@ TTY_READ_ERROR
Definition indicom.h:55
@ TTY_SELECT_ERROR
Definition indicom.h:57
@ TTY_TIME_OUT
Definition indicom.h:58
@ TTY_PORT_BUSY
Definition indicom.h:63
@ TTY_PARAM_ERROR
Definition indicom.h:60
@ TTY_OVERFLOW
Definition indicom.h:62
@ TTY_WRITE_ERROR
Definition indicom.h:56
@ TTY_ERRNO
Definition indicom.h:61
void baseline_2d_projection(double alt, double az, double baseline[3], double wavelength, double uvresult[2])
baseline_2d_projection Returns the coordinates of the projection of a single baseline targeting the o...
Definition indicom.c:1494
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
Definition indicom.c:653
void getSexComponentsIID(double value, int *d, int *m, double *s)
Definition indicom.c:266
int f_scansexa(const char *str0, double *dp)
convert sexagesimal string str AxBxC to double. x can be anything non-numeric. Any missing A,...
Definition indicom.c:194
double get_local_hour_angle(double local_sidereal_time, double ra)
get_local_hour_angle Returns local hour angle of an object
Definition indicom.c:1379
int tty_connect(const char *device, int bit_rate, int word_size, int parity, int stop_bits, int *fd)
Establishes a tty connection to a terminal device.
Definition indicom.c:1022
double calc_photon_flux(double rel_magnitude, double filter_bandwidth, double wavelength, double steradian)
calc_photon_flux Returns the photon flux of the object with the given magnitude observed at a determi...
Definition indicom.c:1479
void tty_set_debug(int debug)
tty_set_debug Enable or disable debug which prints verbose information.
Definition indicom.c:349
void get_alt_az_coordinates(double hour_angle, double dec, double latitude, double *alt, double *az)
get_alt_az_coordinates Returns alt-azimuth coordinates of an object
Definition indicom.c:1385
double estimate_field_rotation_rate(double Alt, double Az, double latitude)
estimate_field_rotation_rate Returns an estimation of the field rotation rate of the object
Definition indicom.c:1409
double estimate_distance(double parsecs, double parallax_radius)
estimate_distance Convert parallax arcseconds into meters
Definition indicom.c:1439
double estimate_orbit_radius(double obs_lambda, double ref_lambda, double period)
estimate the orbit radius of an object with known mass orbiting around a star.
Definition indicom.c:1464
double get_local_sidereal_time(double longitude)
get_local_sidereal_time Returns local sidereal time given longitude and system clock.
int tty_disconnect(int fd)
Closes a tty connection and flushes the bus.
Definition indicom.c:1224
const char * SolarSystem[]
void tty_set_auto_reset_udp_session(int flag)
automatically reset UDP session on write
Definition indicom.c:354
int tty_timeout_microseconds(int fd, long timeout_seconds, long timeout_microseconds)
Definition indicom.c:379
double rangeHA(double r)
rangeHA Limits the hour angle value to be between -12 —> 12
Definition indicom.c:1301
void getSexComponents(double value, int *d, int *m, int *s)
Definition indicom.c:243
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
Definition indicom.c:548
double estimate_absolute_magnitude(double dist, double delta_mag)
estimate_absolute_magnitude Returns an estimation of the absolute magnitude of an object given its di...
Definition indicom.c:1489
double range180(double r)
range180 Limits an angle to be between -180 to +180 degrees
Definition indicom.c:1331
double m2au(double m)
m2au Convert meters into astronomical units
Definition indicom.c:1444
double range24(double r)
range24 Limits a number to be between 0-24 range.
Definition indicom.c:1311
int tty_read_section_expanded(int fd, char *buf, char stop_char, long timeout_seconds, long timeout_microseconds, int *nbytes_read)
read buffer from terminal with a delimiter
Definition indicom.c:658
void get_hrz_from_equ(struct ln_equ_posn *object, struct ln_lnlat_posn *observer, double JD, struct ln_hrz_posn *position)
get_hrz_from_equ Calculate horizontal coordinates from equatorial coordinates.
double estimate_field_rotation(double hour_angle, double field_rotation_rate)
estimate_field_rotation Returns an estimation of the field rotation rate of the object
Definition indicom.c:1419
const char * indi_timestamp()
Create an ISO 8601 formatted time stamp. The format is YYYY-MM-DDTHH:MM:SS.
Definition indicom.c:337
int tty_timeout(int fd, int timeout)
Definition indicom.c:374
double as2rad(double as)
as2rad Convert arcseconds into radians
Definition indicom.c:1429
double estimate_star_mass(double delta_mag, double ref_mass)
estimate the star mass in ref_size units e.g. sun masses or kgs
double range360(double r)
range360 Limits an angle to be between 0-360 degrees.
Definition indicom.c:1321
double baseline_delay(double alt, double az, double baseline[3])
baseline_delay Returns the delay in meters of a single baseline targeting the object by coordinates
Definition indicom.c:1504
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
Definition indicom.c:1243
int tty_write(int fd, const char *buffer, int nbytes, int *nbytes_written)
Writes a buffer to fd.
Definition indicom.c:418
void tty_reset_udp_session(int fd, int only_if_timeout_happened)
create new UDP session to prevent packet conflict
Definition indicom.c:481
double time_ns()
Get a unix timestamp with nanosecond precision.
Definition indicom.c:315
double calc_delta_magnitude(double mag_ratio, double *spectrum, double *ref_spectrum, int spectrum_size)
calc_delta_magnitude Returns the difference of magnitudes given two spectra
Definition indicom.c:1449
int extractISOTime(const char *timestr, struct ln_date *iso_date)
Extract ISO 8601 time and store it in a tm struct.
void get_equ_from_hrz(struct ln_hrz_posn *object, struct ln_lnlat_posn *observer, double JD, struct ln_equ_posn *position)
ln_get_equ_from_hrz Calculate Equatorial EOD Coordinates from horizontal coordinates
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[].
Definition indicom.c:130
int numberFormat(char *buf, const char *format, double value)
Fill buffer with properly formatted INumber string.
Definition indicom.c:277
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
Definition indicom.c:759
int tty_read_expanded(int fd, char *buf, int nbytes, long timeout_seconds, long timeout_microseconds, int *nbytes_read)
read buffer from terminal with a delimiter
Definition indicom.c:553
void tty_clr_trailing_read_lf(int enabled)
Definition indicom.c:369
void tty_set_gemini_udp_format(int enabled)
Definition indicom.c:359
int tty_nread_section_expanded(int fd, char *buf, int nsize, char stop_char, long timeout_seconds, long timeout_microseconds, int *nbytes_read)
read buffer from terminal with a delimiter
Definition indicom.c:764
double rad2as(double rad)
rad2as Convert radians into arcseconds
Definition indicom.c:1434
const char * Direction[]
int fd
std::vector< uint8_t > buffer