Instrument Neutral Distributed Interface INDI
1.9.5
|
Go to the documentation of this file.
40 #define PRODUCT_TAB "Product"
41 #define ALIGNMENT_TAB "Alignment"
42 #define LX200_TIMEOUT 5
45 #define REFRACTION_MODEL_TEMPERATURE "REFRACTION_MODEL_TEMPERATURE"
46 #define REFRACTION_MODEL_PRESSURE "REFRACTION_MODEL_PRESSURE"
47 #define MODEL_COUNT "MODEL_COUNT"
48 #define ALIGNMENT_POINTS "ALIGNMENT_POINTS"
49 #define ALIGNMENT_STATE "Alignment"
50 #define MINIMAL_NEW_ALIGNMENT_POINT_RO "MINIMAL_NEW_ALIGNMENT_POINT_RO"
51 #define MINIMAL_NEW_ALIGNMENT_POINT "MINIMAL_NEW_ALIGNMENT_POINT"
52 #define NEW_ALIGNMENT_POINT "NEW_ALIGNMENT_POINT"
53 #define NEW_ALIGNMENT_POINTS "NEW_ALIGNMENT_POINTS"
54 #define NEW_MODEL_NAME "NEW_MODEL_NAME"
55 #define PRODUCT_INFO "PRODUCT_INFO"
56 #define TLE_TEXT "TLE_TEXT"
57 #define TLE_NUMBER "TLE_NUMBER"
58 #define TRAJECTORY_TIME "TRAJECTORY_TIME"
59 #define SAT_TRACKING_STAT "SAT_TRACKING_STAT"
60 #define UNATTENDED_FLIP "UNATTENDED_FLIP"
102 LOG_INFO(
"Setting Ultra Precision Mode.");
110 LOG_ERROR(
"Failed to set Ultra Precision Mode.");
227 LOGF_INFO(
"Unattended Flip from config and mount are %s",
232 LOGF_INFO(
"Read Unattended Flip %s from config while mount has %s, updating mount",
240 LOG_INFO(
"Did not find an Unattended Flip setting in the config file. Specify desired behaviour in Motion Control tab and save config in Options tab.");
279 LOG_WARN(
"Failed to get tracking frequency from device.");
287 char RefractionModelTemperature[80];
290 sscanf(RefractionModelTemperature,
"%f#", &rmtemp);
295 char RefractionModelPressure[80];
298 sscanf(RefractionModelPressure,
"%f#", &rmpres);
319 LOG_INFO(
"Unattended Flip is disabled.");
325 LOG_INFO(
"Unattended Flip is enabled.");
333 LOG_INFO(
"sendLocationOnStartup is enabled, call sendScopeLocation.");
338 LOG_INFO(
"sendLocationOnStartup is disabled, do not call sendScopeLocation.");
342 LOG_INFO(
"sendTimeOnStartup is enabled, call sendScopeTime.");
347 LOG_INFO(
"sendTimeOnStartup is disabled, do not call sendScopeTime.");
352 bool LX200_10MICRON::getMountInfo()
354 char ProductName[80];
358 char FirmwareVersion[80];
360 char FirmwareDate1[80];
362 char FirmwareDate2[80];
365 sscanf(FirmwareDate1,
"%s %02d %04d", mon, &dd, &yyyy);
367 char FirmwareDate[80];
368 snprintf(FirmwareDate, 80,
"%04d-%02d-%02dT%s", yyyy,
monthToNumber(mon), dd, FirmwareDate2);
370 LOGF_INFO(
"Product:%s Control box:%s Firmware:%s of %s", ProductName, ControlBox, FirmwareVersion, FirmwareDate);
420 char cmd[] =
"#:Ginfo#";
424 int nbytes_write = 0, nbytes_read = 0;
431 tcflush(
fd, TCIFLUSH);
436 term = strchr(data,
'#');
449 nbytes_read = sscanf(data,
"%g,%g,%c,%g,%g,%g,%d,%d#", &Ginfo.RA_JNOW, &Ginfo.DEC_JNOW, &Ginfo.SideOfPier,
450 &Ginfo.AZ, &Ginfo.ALT, &Ginfo.Jdate, &Ginfo.Gstat, &Ginfo.SlewStatus);
456 if (Ginfo.Gstat != OldGstat)
460 LOGF_INFO(
"Gstat changed from %d to %d", OldGstat, Ginfo.Gstat);
464 LOGF_INFO(
"Gstat initialized at %d", Ginfo.Gstat);
518 OldGstat = Ginfo.Gstat;
519 NewRaDec(Ginfo.RA_JNOW, Ginfo.DEC_JNOW);
522 char LocalSiderealTimeS[80];
524 f_scansexa(LocalSiderealTimeS, &Ginfo.SiderealTime);
586 return '1' == guaf[0];
598 snprintf(data,
sizeof(data),
"#:Suaf%d#", (setting ==
false) ? 0 : 1);
601 if (setting ==
false)
626 snprintf(data,
sizeof(data),
"#:FLIP#");
661 snprintf(data,
sizeof(data),
":SC%04d-%02d-%02d#", years, months, days);
683 LOGF_INFO(
"The function is called with TLE %s", tle);
684 if (strlen(tle) > 230)
690 std::string sep =
"$0a";
691 std::string search =
"\n";
692 tle_str = (std::string) tle;
693 for(
size_t pos = 0; ; pos += sep.length() )
696 pos = tle_str.find( search, pos );
697 if( pos == std::string::npos )
break;
699 tle_str.erase( pos, search.length() );
700 tle_str.insert( pos, sep );
703 snprintf(command,
sizeof(command),
":TLEL0%s#", tle_str.c_str());
714 if (response[0] ==
'E')
716 LOG_ERROR(
"Invalid formatting of TLE, trying to split:");
717 char *pch = strtok ((
char*) tle,
"\n");
718 while (pch !=
nullptr)
721 pch = strtok (
nullptr,
"\n");
728 char *pch = strtok ((
char*) tle,
"\n");
729 while (pch !=
nullptr)
732 pch = strtok (
nullptr,
"\n");
749 snprintf(command,
sizeof(command),
":TLEDL%d#", tleN);
751 LOG_INFO(
"Setting TLE from Database");
761 if (response[0] ==
'E')
783 struct ln_date start_pass;
784 if (
extractISOTime(start_pass_isodatetime.c_str(), &start_pass) == -1)
786 LOGF_ERROR(
"Date/Time is invalid: %s.", start_pass_isodatetime.c_str());
790 struct ln_date end_pass;
791 if (
extractISOTime(end_pass_isodatetime.c_str(), &end_pass) == -1)
793 LOGF_ERROR(
"Date/Time is invalid: %s.", end_pass_isodatetime.c_str());
799 JD_start = ln_get_julian_day(&start_pass);
800 JD_end = ln_get_julian_day(&end_pass);
801 int nextPassInMinutes =
static_cast<int>(ceil((JD_end - JD_start) * 24 * 60));
802 int nextPassinMinutesUpTo1440 =
std::min(nextPassInMinutes, 1440);
803 int nextPassinMinutesBetween1and1440 =
std::max(nextPassinMinutesUpTo1440, 1);
806 snprintf(command,
sizeof(command),
":TLEP%7.8f,%01d#", JD_start, nextPassinMinutesBetween1and1440);
808 LOGF_INFO(
"For the next %01d minutes", nextPassinMinutesBetween1and1440);
819 if (response[0] ==
'E')
821 LOG_ERROR(
"TLE not loaded or invalid command");
824 if (response[0] ==
'N')
845 snprintf(command,
sizeof(command),
":TLES#");
855 if (response[0] ==
'E')
860 if (response[0] ==
'F')
865 if (response[0] ==
'V')
867 LOG_INFO(
"Slewing to start of transit");
870 if (response[0] ==
'S')
872 LOG_INFO(
"Slewing to transiting satellite");
875 if (response[0] ==
'Q')
893 snprintf(data, 16,
"#:SRTMP%0+6.1f#", temperature);
907 snprintf(data, 16,
"#:SRPRS%06.1f#", pressure);
930 char MRa_str[32], MDec_str[32];
931 fs_sexa(MRa_str, MRa, 0, 36000);
932 fs_sexa(MDec_str, MDec, 0, 3600);
935 (
static_cast<int>(MSide) == 0) ? MSide_char =
'E' : MSide_char =
'W';
937 char PRa_str[32], PDec_str[32];
938 fs_sexa(PRa_str, PRa, 0, 36000);
939 fs_sexa(PDec_str, PDec, 0, 3600);
941 char SidTime_str[32];
942 fs_sexa(SidTime_str, SidTime, 0, 36000);
945 snprintf(command, 80,
"#:newalpt%s,%s,%c,%s,%s,%s#", MRa_str, MDec_str, MSide_char, PRa_str, PDec_str, SidTime_str);
956 int nbytes_read = sscanf(response,
"%3d#", &points);
959 LOGF_ERROR(
"AddSyncPoint response error %d", nbytes_read);
962 LOGF_INFO(
"AddSyncPoint responded [%4s], there are now %d new alignment points", response, points);
971 double MSide = (toupper(Ginfo.SideOfPier) ==
'E') ? 0 : 1;
972 return AddSyncPoint(Ginfo.RA_JNOW, Ginfo.DEC_JNOW, MSide, PRa, PDec, Ginfo.SiderealTime);
984 LOG_ERROR(
"SetRefractionModelTemperature error");
999 LOG_ERROR(
"SetRefractionModelPressure error");
1028 LOG_ERROR(
"Cannot add alignment points yet, need to start a new alignment first");
1048 LOG_ERROR(
"Cannot add alignment points yet, need to start a new alignment first");
1073 if (strcmp(
name,
"TLE_NUMBER") == 0)
1075 LOG_INFO(
"I am trying to set from Database");
1111 LOG_INFO(
"Alignment state is IDLE");
1158 LOG_ERROR(
"Delete current alignment error");
1163 LOG_INFO(
"Current Alignment deleted");
1226 LOG_ERROR(
"Setting unattended flip failed");
1231 LOG_INFO(
"Unattended flip disabled");
1236 LOG_ERROR(
"Setting unattended flip failed");
1241 LOG_INFO(
"Unattended flip enabled");
1269 if (strcmp(
name,
"SAT_TLE_TEXT") == 0)
1288 LOG_ERROR(
"TLE was not correctly uploaded");
1292 if (strcmp(
name,
"SAT_PASS_WINDOW") == 0)
1306 LOG_ERROR(
"Trajectory could not be calculated");
1322 entry month_table[] = { {
"Jan", 1 }, {
"Feb", 2 }, {
"Mar", 3 }, {
"Apr", 4 }, {
"May", 5 },
1323 {
"Jun", 6 }, {
"Jul", 7 }, {
"Aug", 8 }, {
"Sep", 9 }, {
"Oct", 10 },
1324 {
"Nov", 11 }, {
"Dec", 12 }, {
nullptr, 0 }
1326 entry *p = month_table;
1327 while (p->name !=
nullptr)
1329 if (strcasecmp(p->name, monthName) == 0)
1339 int nbytes_write = 0;
1346 tcflush(
fd, TCIFLUSH);
1351 char bool_return[2];
1353 int nbytes_write = 0, nbytes_read = 0;
1357 tcflush(
fd, TCIFLUSH);
1364 tcflush(
fd, TCIFLUSH);
1366 if (nbytes_read < 1)
1369 if (bool_return[0] != expect[0])
1383 int nbytes_write = 0, nbytes_read = 0;
1387 tcflush(
fd, TCIFLUSH);
1394 tcflush(
fd, TCIFLUSH);
1396 if (nbytes_read < 1)
ITextVectorProperty ProductTP
bool CalculateSatTrajectory(std::string start_pass_isodatetime, std::string end_pass_isodatetime)
INumber NewAlpN[ALP_COUNT]
@ TELESCOPE_HAS_TRACK_RATE
int IUGetConfigSwitch(const char *dev, const char *property, const char *member, ISState *value)
IUGetConfigSwitch Opens configuration file and reads single switch property.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
@ SAT_PASS_WINDOW_START
Index for start of the window.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
INumberVectorProperty RefractionModelTemperatureNP
int monthToNumber(const char *monthName)
#define LOGF_ERROR(fmt,...)
@ UNATTENDED_FLIP_ENABLED
ISwitchVectorProperty AlignmentStateSP
bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
void setPierSide(TelescopePierSide side)
@ GSTAT_FOLLOWING_SATELLITE
Implementations for common driver routines.
const char * MOTION_TAB
MOTION_TAB Where all the motion control properties of the device are located.
INumberVectorProperty AlignmentPointsNP
void IDSetText(const ITextVectorProperty *t, const char *msg,...) ATTRIBUTE_FORMAT_PRINTF(2
Tell client to update an existing text vector property.
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
int f_scansexa(const char *str0, double *dp)
convert sexagesimal string str AxBxC to double.
@ PRODUCT_FIRMWARE_VERSION
void NewRaDec(double ra, double dec)
The child class calls this function when it has updates.
bool isSimulation() const
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 defineProperty(INumberVectorProperty *property)
bool Handshake() override
perform handshake with device to check communication
int setStandardProcedureAndReturnResponse(int fd, const char *data, char *response, int max_response_length)
#define NEW_ALIGNMENT_POINTS
INumber AlignmentPointsN[1]
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.
const char * SATELLITE_TAB
SATELLITE_TAB.
#define MINIMAL_NEW_ALIGNMENT_POINT
@ TELESCOPE_HAS_TRACK_MODE
@ GSTAT_TRACKING_OUTSIDE_LIMITS
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
const char * getDeviceName() const
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
bool UnPark() override
Unpark the telescope if already parked.
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.
INumberVectorProperty NewAlignmentPointsNP
@ GSTAT_NOT_TRACKING_AND_NOT_MOVING
bool initProperties() override
Called to initialize basic properties required all the time.
int setStandardProcedureWithoutRead(int fd, const char *data)
int IUUpdateText(ITextVectorProperty *tvp, char *texts[], char *names[], int n)
Update all text members in a text vector property.
bool SyncConfigBehaviour(bool cmcfg)
virtual bool sendScopeLocation()
TelescopeStatus TrackState
INumber MiniNewAlpRON[MALPRO_COUNT]
virtual bool sendScopeTime()
bool isParked()
isParked is mount currently parked?
bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
INumber TLEfromDatabaseN[1]
IText SatPassWindowT[SAT_PASS_WINDOW_COUNT]
INumberVectorProperty ModelCountNP
#define MINIMAL_NEW_ALIGNMENT_POINT_RO
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
bool setUnattendedFlipSetting(bool setting)
virtual int SetRefractionModelPressure(double pressure)
INumberVectorProperty MiniNewAlpRONP
bool sendLocationOnStartup
bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
INumber RefractionModelTemperatureN[1]
#define NEW_ALIGNMENT_POINT
ITextVectorProperty TLEtoTrackTP
Text Vector property defining the orbital elements of an artificial satellite (TLE)....
ISwitch AlignmentStateS[ALIGN_COUNT]
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 SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount=0)
SetTelescopeCapability sets the Telescope capabilities. All capabilities must be initialized.
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.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
int setStandardProcedureAndExpect(int fd, const char *data, const char *expect)
@ LX200_HAS_TRACKING_FREQ
int setStandardProcedure(int fd, const char *writeData)
int extractISOTime(const char *timestr, struct ln_date *iso_date)
Extract ISO 8601 time and store it in a tm struct.
@ LX200_HAS_PULSE_GUIDING
@ TELESCOPE_HAS_PIER_SIDE
bool SetTLEtoFollow(const char *tle)
@ TELESCOPE_CAN_CONTROL_TRACK
bool getUnattendedFlipSetting()
@ SAT_HALT
Halt signal (abort)
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
bool updateProperties() override
Called when connected state changes, to add/remove properties.
int getTrackFreq(int fd, double *value)
int getCommandInt(int fd, int *value, const char *cmd)
bool setLocalDate(uint8_t days, uint8_t months, uint16_t years) override
void getBasicData() override
#define REFRACTION_MODEL_PRESSURE
#define LOGF_INFO(fmt,...)
#define REFRACTION_MODEL_TEMPERATURE
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
bool Park() override
Park the telescope to its home position.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
void setLX200Capability(uint32_t cap)
INumberVectorProperty NewAlpNP
int setCommandInt(int fd, int data, const char *cmd)
INumberVectorProperty RefractionModelPressureNP
virtual void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
INumberVectorProperty MiniNewAlpNP
#define DEBUGFDEVICE(device, priority, msg,...)
ISwitchVectorProperty UnattendedFlipSP
INumber MiniNewAlpN[MALP_COUNT]
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
int AddSyncPointHere(double PRa, double PDec)
int fs_sexa(char *out, double a, int w, int fracbase)
Converts a sexagesimal number to a string.
INumber NewAlignmentPointsN[1]
ITextVectorProperty NewModelNameTP
INumberVectorProperty TrackFreqNP
int getCommandString(int fd, char *data, const char *cmd)
int checkLX200EquatorialFormat(int fd)
INumber RefractionModelPressureN[1]
int IUFindOnSwitchIndex(const ISwitchVectorProperty *sp)
Returns the index of first ON switch it finds in the vector switch property.
int AddSyncPoint(double MRa, double MDec, double MSide, double PRa, double PDec, double SidTime)
@ SAT_PASS_WINDOW_END
Index for end of the window.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
void IUSaveConfigSwitch(FILE *fp, const ISwitchVectorProperty *svp)
Add a switch vector property value to the configuration file.
ISwitchVectorProperty TrackSatSP
Switch Vector property defining the state of the satellite tracking of the mount. Example implementat...
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
INumberVectorProperty TLEfromDatabaseNP
ISwitch UnattendedFlipS[UNATTENDED_FLIP_COUNT]
virtual int SetRefractionModelTemperature(double temperature)
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
void void void IDSetNumber(const INumberVectorProperty *n, const char *msg,...) ATTRIBUTE_FORMAT_PRINTF(2
Tell client to update an existing number vector property.
void void void void void IDSetSwitch(const ISwitchVectorProperty *s, const char *msg,...) ATTRIBUTE_FORMAT_PRINTF(2
Tell client to update an existing switch vector property.
const char * getDefaultName() override
@ GSTAT_SLEWING_OR_STOPPING
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.
bool SetTLEfromDatabase(int tleN)
@ TELESCOPE_CAN_TRACK_SATELLITE
bool ReadScopeStatus() override
Read telescope status.
ITextVectorProperty SatPassWindowTP
Text Vector property defining the start and end of a satellite pass (window contains pass)....
@ UNATTENDED_FLIP_DISABLED