mirror of
https://github.com/eddyem/small_tel.git
synced 2026-11-22 13:40:17 +03:00
some more fixes; added atmdens, added corrections
This commit is contained in:
@@ -47,3 +47,11 @@
|
|||||||
#define CMD_SETPRESSURE ":SRPRS%.1f#"
|
#define CMD_SETPRESSURE ":SRPRS%.1f#"
|
||||||
#define CMD_SETTEMPER ":SRTMP%.1f#"
|
#define CMD_SETTEMPER ":SRTMP%.1f#"
|
||||||
#define CMD_SETZD ":Sz%s#"
|
#define CMD_SETZD ":Sz%s#"
|
||||||
|
|
||||||
|
// corrections
|
||||||
|
#define CMD_GETGUIDERATE ":Ggui#"
|
||||||
|
#define CMD_CORRECT ":%s%d#"
|
||||||
|
#define CORR_EAST "Me"
|
||||||
|
#define CORR_WEST "Mw"
|
||||||
|
#define CORR_SOUTH "Ms"
|
||||||
|
#define CORR_NORTH "Mn"
|
||||||
|
|||||||
1157
Daemons/10micron_stellarium/airmass.inc
Normal file
1157
Daemons/10micron_stellarium/airmass.inc
Normal file
File diff suppressed because it is too large
Load Diff
77
Daemons/10micron_stellarium/am.c
Normal file
77
Daemons/10micron_stellarium/am.c
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#include <weather_data.h>
|
||||||
|
#include "angles.h"
|
||||||
|
#undef DEG2RAD
|
||||||
|
static int main(int argc, char *argv[]) __attribute((unused));
|
||||||
|
static void usage(void) __attribute((unused));
|
||||||
|
#define inline
|
||||||
|
#include "airmass.inc"
|
||||||
|
#undef inline
|
||||||
|
|
||||||
|
void calc_airmass(
|
||||||
|
// in
|
||||||
|
double daynum, // Day number from beginning of year, 0 = midnight Jan 1
|
||||||
|
weather_data_t *weather,// weather data
|
||||||
|
placeData_t *place, // for altitude and latitude
|
||||||
|
double z, // zenith distance in radians
|
||||||
|
// out
|
||||||
|
double *am, // AIRMASS
|
||||||
|
double *acd, // column density
|
||||||
|
double *wcd, // water vapor column density
|
||||||
|
double *wam // water vapor airmass
|
||||||
|
){
|
||||||
|
int i;
|
||||||
|
double colz, col0,
|
||||||
|
lambda = 5500.,
|
||||||
|
betapoly[5]={-0.0065107, -4.5403e-06,
|
||||||
|
3.6599e-07, -2.2174e-09, 7.9392e-12}, r1poly[11]={17.204, 8.9155e-03,
|
||||||
|
-3.6420e-03, 2.5617e-05, 2.4796e-07, -1.2774e-08, 1.3017e-10,
|
||||||
|
2.0151e-12, -2.6985e-14, -1.0397e-16, 1.4849e-18}, hvec[(NTLEVELS+1)]=
|
||||||
|
{0., 11000., 20000., 32000., 47000., 52000., 61000., 79000., 88743.};
|
||||||
|
double p0 = weather->pressure * 101325. / 760.;
|
||||||
|
double t0 = weather->exttemp + 273.15;
|
||||||
|
relhumid = weather->humidity / 100.;
|
||||||
|
double sinz = sin(z);
|
||||||
|
cee = CONSTC*(2.87566E-4+134.12/(lambda*lambda)+3.777E8*pow(lambda, -4.));
|
||||||
|
double cosyearfrac = cos((daynum-202.)*(360.*DEG2RAD/365.));
|
||||||
|
double coslatsq = cos(place->slat);
|
||||||
|
double lat = RAD2DEG(place->slat);
|
||||||
|
coslatsq *= coslatsq;
|
||||||
|
double rmsl = sqrt(((POLAR*POLAR*POLAR*POLAR)+(EQUATOR*EQUATOR*EQUATOR*EQUATOR-
|
||||||
|
POLAR*POLAR*POLAR*POLAR)*coslatsq)/((POLAR*POLAR)+(EQUATOR*EQUATOR-
|
||||||
|
POLAR*POLAR)*coslatsq));
|
||||||
|
double bigrmsl = (-STANDARDR02)/rmsl;
|
||||||
|
/* Calculate bigrvec, the bigr at the bottom of each temperature layer */
|
||||||
|
*bigrvec=(-STANDARDR02)/(rmsl+place->salt);
|
||||||
|
double rjunk = r1poly[10];
|
||||||
|
for (i=9;i>=0;i--) rjunk=rjunk*lat+((i%2) ? r1poly[i]*cosyearfrac :
|
||||||
|
r1poly[i]);
|
||||||
|
bigrvec[1]=(-STANDARDR02)/(rmsl+rjunk*1000.);
|
||||||
|
for (i=2;i<(NTLEVELS+1);i++) bigrvec[i]=hvec[i]+bigrmsl;
|
||||||
|
|
||||||
|
/* Set up our temperature profile for the troposphere/lower stratosphere */
|
||||||
|
*betavec=betapoly[4];
|
||||||
|
for (i=3;i>=0;i--) *betavec=*betavec*lat+((i%2) ? betapoly[i]*cosyearfrac :
|
||||||
|
betapoly[i]);
|
||||||
|
*betavec*=(-rmsl/bigrvec[1]);
|
||||||
|
*tvec=t0;
|
||||||
|
tvec[1]=t0+*betavec*(bigrvec[1]-*bigrvec);
|
||||||
|
betavec[1]=(tvec[2]-tvec[1])/(bigrvec[2]-bigrvec[1]);
|
||||||
|
|
||||||
|
/* Compute the density at the bottom of each temperature layer */
|
||||||
|
*rhovec=p0/(AIRCONSTANT*t0);
|
||||||
|
for (i=0;i<(NTLEVELS-1);i++) rhovec[i+1]=frho(bigrvec[i+1]-bigrvec[i],
|
||||||
|
rhovec[i], tvec[i], betavec[i]);
|
||||||
|
|
||||||
|
const6=musquare(*rhovec)*sinz*sinz/(*bigrvec*(*bigrvec)); /* for z */
|
||||||
|
colz=qromb(columndensityint, *bigrvec, bigrvec[NTLEVELS], 1.E-8);
|
||||||
|
const6=0.; /* equivalent to setting z = 0. */
|
||||||
|
col0=qromb(columndensityint, *bigrvec, bigrvec[NTLEVELS], 1.E-8);
|
||||||
|
*am = colz/col0; *acd = 0.1*colz;
|
||||||
|
if(weather->humidity < 0.1){ *wcd = 0.; *wam = 0.; return;}
|
||||||
|
const7=relhumid/(bigrvec[2]-bigrvec[1]);
|
||||||
|
const6=musquare(*rhovec)*sinz*sinz/(*bigrvec*(*bigrvec)); /* for z */
|
||||||
|
colz=qromb(vaporcolumndensityint, *bigrvec, bigrvec[2], 1.E-8);
|
||||||
|
const6=0.; /* equivalent to setting z = 0. */
|
||||||
|
col0=qromb(vaporcolumndensityint, *bigrvec, bigrvec[2], 1.E-8);
|
||||||
|
*wcd = 0.1*colz; *wam = colz/col0;
|
||||||
|
}
|
||||||
@@ -211,12 +211,11 @@ void hor2eq(horizCrds_t *h, polarCrds_t *pc, double sidTime){
|
|||||||
pc->ha = eraAnp(pc->ha); // normalize to [0,2pi)
|
pc->ha = eraAnp(pc->ha); // normalize to [0,2pi)
|
||||||
pc->ra = eraAnp(sidTime - pc->ha);
|
pc->ra = eraAnp(sidTime - pc->ha);
|
||||||
DBG("dec=%gdeg, ha=%gh, ra=%gh", RAD2DEG(pc->dec), RAD2HRS(pc->ha), RAD2HRS(pc->ra));
|
DBG("dec=%gdeg, ha=%gh, ra=%gh", RAD2DEG(pc->dec), RAD2HRS(pc->ha), RAD2HRS(pc->ra));
|
||||||
pc->eo = 0.;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief eq2horH - convert polar coordinates to horizontal
|
* @brief eq2horH - convert polar coordinates to horizontal (using hour angle)
|
||||||
* @param pc (i) - polar coordinates (only HA used)
|
* @param pc (i) - polar coordinates (HA, DEC used)
|
||||||
* @param h (o) - horizontal coordinates
|
* @param h (o) - horizontal coordinates
|
||||||
* @param sidTime - sidereal time
|
* @param sidTime - sidereal time
|
||||||
*/
|
*/
|
||||||
@@ -228,14 +227,14 @@ void eq2horH(polarCrds_t *pc, horizCrds_t *h){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief eq2hor - convert polar coordinates to horizontal
|
* @brief eq2hor - convert polar coordinates to horizontal (using RA)
|
||||||
* @param pc (i) - polar coordinates (RA, EO, DEC used) (radians)
|
* @param pc (i) - polar coordinates (RA, DEC used) (radians)
|
||||||
* @param h (o) - horizontal coordinates (radians)
|
* @param h (o) - horizontal coordinates (radians)
|
||||||
* @param sidTime - sidereal time (radians)
|
* @param sidTime - sidereal time (radians)
|
||||||
*/
|
*/
|
||||||
void eq2hor(polarCrds_t *pc, horizCrds_t *h, double sidTime){
|
void eq2hor(polarCrds_t *pc, horizCrds_t *h, double sidTime){
|
||||||
if(!h || !pc) return;
|
if(!h || !pc) return;
|
||||||
double ha = sidTime - pc->ra + pc->eo;
|
double ha = sidTime - pc->ra;
|
||||||
double alt;
|
double alt;
|
||||||
eraHd2ae(ha, pc->dec, place.slat, &h->az, &alt);
|
eraHd2ae(ha, pc->dec, place.slat, &h->az, &alt);
|
||||||
h->zd = ERFA_DPI/2. - alt;
|
h->zd = ERFA_DPI/2. - alt;
|
||||||
@@ -250,7 +249,9 @@ void r2sHMS(double radians, char buf[RADEC_STR_MAXLEN]){
|
|||||||
char pm;
|
char pm;
|
||||||
int i[4];
|
int i[4];
|
||||||
eraA2tf(2, radians, &pm, i);
|
eraA2tf(2, radians, &pm, i);
|
||||||
size_t l = snprintf(buf, RADEC_STR_MAXLEN, "%c%02d:%02d:%02d.%02d", pm, i[0],i[1],i[2],i[3]);
|
size_t l;
|
||||||
|
if(radians < 0.) l = snprintf(buf, RADEC_STR_MAXLEN, "-%02d:%02d:%02d.%02d", i[0],i[1],i[2],i[3]);
|
||||||
|
else l = snprintf(buf, RADEC_STR_MAXLEN, "%02d:%02d:%02d.%02d", i[0],i[1],i[2],i[3]);
|
||||||
if(l >= RADEC_STR_MAXLEN) buf[RADEC_STR_MAXLEN-1] = 0;
|
if(l >= RADEC_STR_MAXLEN) buf[RADEC_STR_MAXLEN-1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,7 +264,9 @@ void r2sDMS(double radians, char buf[RADEC_STR_MAXLEN]){
|
|||||||
char pm;
|
char pm;
|
||||||
int i[4];
|
int i[4];
|
||||||
eraA2af(1, radians, &pm, i);
|
eraA2af(1, radians, &pm, i);
|
||||||
size_t l = snprintf(buf, RADEC_STR_MAXLEN, "%c%02d:%02d:%02d.%d", pm, i[0],i[1],i[2],i[3]);
|
size_t l;
|
||||||
|
if(radians < 0.) l = snprintf(buf, RADEC_STR_MAXLEN, "-%02d:%02d:%02d.%d", i[0],i[1],i[2],i[3]);
|
||||||
|
else l = snprintf(buf, RADEC_STR_MAXLEN, "%02d:%02d:%02d.%d", i[0],i[1],i[2],i[3]);
|
||||||
if(l >= RADEC_STR_MAXLEN) buf[RADEC_STR_MAXLEN-1] = 0;
|
if(l >= RADEC_STR_MAXLEN) buf[RADEC_STR_MAXLEN-1] = 0;
|
||||||
}
|
}
|
||||||
// the same, but argument in degrees
|
// the same, but argument in degrees
|
||||||
@@ -306,7 +309,6 @@ bool str2coord(const char *str, double *val){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get_MJDt - calculate MJD of date from argument
|
* @brief get_MJDt - calculate MJD of date from argument
|
||||||
* @param tval (i) - given date (or NULL for current)
|
* @param tval (i) - given date (or NULL for current)
|
||||||
@@ -381,13 +383,25 @@ bool get_LST(sMJD_t *mjd, double *LST){
|
|||||||
double ST = eraGst06a(ut11, ut12, Mjd.tt1, Mjd.tt2);
|
double ST = eraGst06a(ut11, ut12, Mjd.tt1, Mjd.tt2);
|
||||||
//DBG("ST0=%gh; longitude=%gh (%gdeg) STl=%gh", RAD2HRS(ST),
|
//DBG("ST0=%gh; longitude=%gh (%gdeg) STl=%gh", RAD2HRS(ST),
|
||||||
// RAD2HRS(place.slong), RAD2DEG(place.slong), RAD2HRS(ST+place.slong));
|
// RAD2HRS(place.slong), RAD2DEG(place.slong), RAD2HRS(ST+place.slong));
|
||||||
ST += place.slong;
|
/*ST += place.slong;
|
||||||
if(ST > ERFA_D2PI) ST -= ERFA_D2PI;
|
if(ST > ERFA_D2PI) ST -= ERFA_D2PI;
|
||||||
else if(ST < 0.) ST += ERFA_D2PI;
|
else if(ST < 0.) ST += ERFA_D2PI;*/
|
||||||
|
ST = eraAnp(ST + place.slong);
|
||||||
*LST = ST;
|
*LST = ST;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief raha - convert HA to RA and vice versa
|
||||||
|
* @param hara - HA or RA
|
||||||
|
* @return RA or HA
|
||||||
|
*/
|
||||||
|
double raha(double hara){
|
||||||
|
double LST;
|
||||||
|
if(get_LST(NULL, &LST)) return eraAnp(LST - hara);
|
||||||
|
return 0.;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/**
|
/**
|
||||||
* @brief get_ObsPlace - calculate observed place (without PM etc) for given date @550nm
|
* @brief get_ObsPlace - calculate observed place (without PM etc) for given date @550nm
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ typedef struct{
|
|||||||
double ha; // hour angle
|
double ha; // hour angle
|
||||||
double dec; // declination
|
double dec; // declination
|
||||||
double ra; // right ascension
|
double ra; // right ascension
|
||||||
double eo; // equation of origins
|
|
||||||
} polarCrds_t;
|
} polarCrds_t;
|
||||||
|
|
||||||
// horizontal coordinates (all in radians)
|
// horizontal coordinates (all in radians)
|
||||||
@@ -75,6 +74,8 @@ void norm_RADEC(double *ra, double *dec);
|
|||||||
void norm_RADECr(double *ra, double *dec);
|
void norm_RADECr(double *ra, double *dec);
|
||||||
void norm_angle180(double *a);
|
void norm_angle180(double *a);
|
||||||
|
|
||||||
|
double raha(double hara);
|
||||||
|
|
||||||
void hor2eq(horizCrds_t *h, polarCrds_t *pc, double sidTime);
|
void hor2eq(horizCrds_t *h, polarCrds_t *pc, double sidTime);
|
||||||
void eq2horH(polarCrds_t *pc, horizCrds_t *h);
|
void eq2horH(polarCrds_t *pc, horizCrds_t *h);
|
||||||
void eq2hor(polarCrds_t *pc, horizCrds_t *h, double sidTime);
|
void eq2hor(polarCrds_t *pc, horizCrds_t *h, double sidTime);
|
||||||
|
|||||||
@@ -27,6 +27,9 @@
|
|||||||
|
|
||||||
static char *hdname = NULL;
|
static char *hdname = NULL;
|
||||||
|
|
||||||
|
// from am.c
|
||||||
|
extern void calc_airmass(double, weather_data_t*, placeData_t*, double, double *, double *, double *, double *);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief set_header_name - check ability of witing into file and set given name
|
* @brief set_header_name - check ability of witing into file and set given name
|
||||||
* @param name - header filename
|
* @param name - header filename
|
||||||
@@ -114,8 +117,8 @@ void wrhdr(fitsheader_t *HDR){
|
|||||||
char ang[RADEC_STR_MAXLEN], cmnt[CMNTLEN+1];
|
char ang[RADEC_STR_MAXLEN], cmnt[CMNTLEN+1];
|
||||||
val[VALLEN] = 0, cmnt[CMNTLEN] = 0;
|
val[VALLEN] = 0, cmnt[CMNTLEN] = 0;
|
||||||
#define WRHDR(k, v, c) do{if(printhdr(fd, k, v, c)){goto returning;}}while(0)
|
#define WRHDR(k, v, c) do{if(printhdr(fd, k, v, c)){goto returning;}}while(0)
|
||||||
WRHDR("TIMESYS", "'UTC'", "Time system");
|
//WRHDR("TIMESYS", "'UTC'", "Time system");
|
||||||
WRHDR("ORIGIN", "'SAO RAS'", "Organization responsible for the data");
|
WRHDR("ORIGIN", "'SAO RAS, Russia'", "Organization responsible for the data");
|
||||||
WRHDR("MOUNTNAM", HDR->mountname, "Mount name");
|
WRHDR("MOUNTNAM", HDR->mountname, "Mount name");
|
||||||
if(fabs(HDR->dut.px) > FLT_EPSILON){
|
if(fabs(HDR->dut.px) > FLT_EPSILON){
|
||||||
snprintf(val, VALLEN, "%.10f", HDR->dut.px);
|
snprintf(val, VALLEN, "%.10f", HDR->dut.px);
|
||||||
@@ -168,12 +171,11 @@ void wrhdr(fitsheader_t *HDR){
|
|||||||
if(poweredON){
|
if(poweredON){
|
||||||
snprintf(val, VALLEN, "%.10f", RAD2HRS(HDR->polar.ra)); // convert RA to degrees
|
snprintf(val, VALLEN, "%.10f", RAD2HRS(HDR->polar.ra)); // convert RA to degrees
|
||||||
r2sHMS(HDR->polar.ra, ang);
|
r2sHMS(HDR->polar.ra, ang);
|
||||||
snprintf(cmnt, CMNTLEN, "Telescope Right Ascension, deg. (%s)", ang);
|
snprintf(cmnt, CMNTLEN, "Telescope Right Ascension, hrs. (%s)", ang);
|
||||||
WRHDR("RA", val, cmnt);
|
WRHDR("RA", val, cmnt);
|
||||||
double ha = eraAnp(HDR->sidtime - HDR->polar.ra);
|
snprintf(val, VALLEN, "%.10f", RAD2HRS(HDR->polar.ha)); // hour angle
|
||||||
snprintf(val, VALLEN, "%.10f", RAD2HRS(ha)); // hour angle
|
r2sHMS(HDR->polar.ha, ang);
|
||||||
r2sHMS(ha, ang);
|
snprintf(cmnt, CMNTLEN, "Telescope Hour Angle, hrs. (%s)", ang);
|
||||||
snprintf(cmnt, CMNTLEN, "Telescope Hour Angle, deg. (%s)", ang);
|
|
||||||
WRHDR("HA", val, cmnt);
|
WRHDR("HA", val, cmnt);
|
||||||
snprintf(val, VALLEN, "%.10f", RAD2DEG(HDR->polar.dec));
|
snprintf(val, VALLEN, "%.10f", RAD2DEG(HDR->polar.dec));
|
||||||
r2sDMS(HDR->polar.dec, ang);
|
r2sDMS(HDR->polar.dec, ang);
|
||||||
@@ -187,6 +189,31 @@ void wrhdr(fitsheader_t *HDR){
|
|||||||
r2sDMS(HDR->altaz.zd, ang);
|
r2sDMS(HDR->altaz.zd, ang);
|
||||||
snprintf(cmnt, CMNTLEN, "Telescope Zenith Distance, deg. (%s)", ang);
|
snprintf(cmnt, CMNTLEN, "Telescope Zenith Distance, deg. (%s)", ang);
|
||||||
WRHDR("ZD", val, cmnt);
|
WRHDR("ZD", val, cmnt);
|
||||||
|
// A/Z calculated by ha/dec
|
||||||
|
horizCrds_t hor;
|
||||||
|
eq2horH(&HDR->polar, &hor);
|
||||||
|
snprintf(val, VALLEN, "%.10f", RAD2DEG(hor.az));
|
||||||
|
r2sDMS(hor.az, ang);
|
||||||
|
snprintf(cmnt, CMNTLEN, "Calculated A, deg. (%s)", ang);
|
||||||
|
WRHDR("AZCALC", val, cmnt);
|
||||||
|
snprintf(val, VALLEN, "%.10f", RAD2DEG(hor.zd));
|
||||||
|
r2sDMS(hor.zd, ang);
|
||||||
|
snprintf(cmnt, CMNTLEN, "Calculated ZD, deg. (%s)", ang);
|
||||||
|
WRHDR("ZDCALC", val, cmnt);
|
||||||
|
// calculate airmass
|
||||||
|
time_t t_now = time(NULL);
|
||||||
|
struct tm *tm_loc;
|
||||||
|
tm_loc = localtime(&t_now);
|
||||||
|
double am, acd, wcd, wam;
|
||||||
|
calc_airmass(tm_loc->tm_yday, &HDR->weather, &HDR->place, hor.zd, &am, &acd, &wcd, &wam);
|
||||||
|
snprintf(val, VALLEN, "%.2f", am);
|
||||||
|
WRHDR("AIRMASS", val, "Air mass by Reed D. Meyer");
|
||||||
|
snprintf(val, VALLEN, "%.2f", acd);
|
||||||
|
WRHDR("ATMDENS", val, "Atm. column density by Reed D. Meyer (g/cm^2)");
|
||||||
|
snprintf(val, VALLEN, "%.2f", wcd);
|
||||||
|
WRHDR("WVDENS", val, "WV column density by Reed D. Meyer (g/cm^2)");
|
||||||
|
snprintf(val, VALLEN, "%.2f", wam);
|
||||||
|
WRHDR("WVAM", val, "Water vapour air mass by Reed D. Meyer");
|
||||||
}
|
}
|
||||||
WRHDR("TELSTAT", mount_status_str(HDR->status), "Telescope mount status");
|
WRHDR("TELSTAT", mount_status_str(HDR->status), "Telescope mount status");
|
||||||
double epoch;
|
double epoch;
|
||||||
@@ -199,7 +226,10 @@ void wrhdr(fitsheader_t *HDR){
|
|||||||
WRHDR("EQUINOX", val, "Equinox of telescope celestial coordinate sys.");
|
WRHDR("EQUINOX", val, "Equinox of telescope celestial coordinate sys.");
|
||||||
snprintf(val, VALLEN, "%.10f", HDR->MJD.MJD);
|
snprintf(val, VALLEN, "%.10f", HDR->MJD.MJD);
|
||||||
WRHDR("MJD", val, "Modified Julian date of file creation");
|
WRHDR("MJD", val, "Modified Julian date of file creation");
|
||||||
if(*HDR->pierside) WRHDR("PIERSIDE", HDR->pierside, "Pier side of telescope mount");
|
if(*HDR->pierside){
|
||||||
|
snprintf(val, VALLEN, "'%s'", HDR->pierside);
|
||||||
|
WRHDR("PIERSIDE", val, "Pier side of telescope mount");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
snprintf(val, VALLEN, "%.1f", HDR->place.salt);
|
snprintf(val, VALLEN, "%.1f", HDR->place.salt);
|
||||||
WRHDR("ELEVAT", val, "Elevation of site over the sea level");
|
WRHDR("ELEVAT", val, "Elevation of site over the sea level");
|
||||||
@@ -208,26 +238,9 @@ void wrhdr(fitsheader_t *HDR){
|
|||||||
snprintf(val, VALLEN, "%.10f", RAD2DEG(HDR->place.slat));
|
snprintf(val, VALLEN, "%.10f", RAD2DEG(HDR->place.slat));
|
||||||
WRHDR("LATITUDE", val, "Geo latitude of site (south negative)");
|
WRHDR("LATITUDE", val, "Geo latitude of site (south negative)");
|
||||||
snprintf(val, VALLEN, "%.6f", RAD2HRS(HDR->sidtime));
|
snprintf(val, VALLEN, "%.6f", RAD2HRS(HDR->sidtime));
|
||||||
WRHDR("LSTEND", val, "Local sidereal time of file creation");
|
r2sHMS(HDR->sidtime, ang);
|
||||||
/* Weather data is written into separate header-file by weather daemon
|
snprintf(cmnt, CMNTLEN, "File creation LST, hrs. (%s)", ang);
|
||||||
if(haveweather){
|
WRHDR("LSTEND", val, cmnt);
|
||||||
snprintf(val, VALLEN, "%.1f", HDR->weather.humidity);
|
|
||||||
WRHDR("HUMIDITY", val, "Relative humidity, %%");
|
|
||||||
snprintf(val, VALLEN, "%.1f", HDR->weather.pressure);
|
|
||||||
WRHDR("PRESSURE", val, "Atmospheric pressure, mmHg");
|
|
||||||
snprintf(val, VALLEN, "%.1f", HDR->weather.exttemp);
|
|
||||||
WRHDR("EXTTEMP", val, "External temperature, degrC");
|
|
||||||
snprintf(val, VALLEN, "%d", HDR->weather.rain);
|
|
||||||
WRHDR("RAIN", val, "Rain conditions");
|
|
||||||
snprintf(val, VALLEN, "%.1f", HDR->weather.clouds);
|
|
||||||
WRHDR("SKYQUAL", val, "Sky quality (0 - wery bad, >2500 - good)");
|
|
||||||
snprintf(val, VALLEN, "%.1f", HDR->weather.wind);
|
|
||||||
WRHDR("WINDSPD", val, "Wind speed (m/s)");
|
|
||||||
snprintf(val, VALLEN, "%.1f", HDR->weather.windmax);
|
|
||||||
WRHDR("WINDMAX", val, "Last hour maximal wind speed (m/s)");
|
|
||||||
snprintf(val, VALLEN, "%lld", (long long)HDR->weather.last_update);
|
|
||||||
WRHDR("WEATTIME", val, "Unix time of weather measurements");
|
|
||||||
}*/
|
|
||||||
// WRHDR("", , "");
|
// WRHDR("", , "");
|
||||||
#undef WRHDR
|
#undef WRHDR
|
||||||
returning:
|
returning:
|
||||||
|
|||||||
@@ -19,6 +19,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <weather_data.h>
|
#include <weather_data.h>
|
||||||
|
/* for:
|
||||||
|
typedef struct {
|
||||||
|
weather_condition_t weather; // conditions: field "WEATHER"
|
||||||
|
float windmax; // maximal wind for last hour, m/s: "WINDMAX1"
|
||||||
|
float wind; // current wind speed, m/s: "WIND"
|
||||||
|
float clouds; // sky "quality" (>2500 - OK): "CLOUDS"
|
||||||
|
float exttemp; // external temperature, degC: "EXTTEMP"
|
||||||
|
float pressure; // atm. pressure, mmHg: "PRESSURE"
|
||||||
|
float humidity; // humidity, percents: "HUMIDITY"
|
||||||
|
int rain; // ==1 when rainy: "PRECIP"
|
||||||
|
int forceoff; // force power off (AC power lost or lightning)
|
||||||
|
time_t last_update; // value of "TMEAS"
|
||||||
|
} weather_data_t;
|
||||||
|
*/
|
||||||
|
|
||||||
#include "angles.h"
|
#include "angles.h"
|
||||||
#include "mount.h"
|
#include "mount.h"
|
||||||
@@ -33,6 +47,7 @@
|
|||||||
#define FLT_EPSILON 1e-6
|
#define FLT_EPSILON 1e-6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
weather_data_t weather;
|
weather_data_t weather;
|
||||||
mount_status_t status;
|
mount_status_t status;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ int main(int argc, char **argv){
|
|||||||
if(G->altitude && sl_str2d(&val, G->altitude)) place.salt = val;
|
if(G->altitude && sl_str2d(&val, G->altitude)) place.salt = val;
|
||||||
if(G->longitude && str2coord(G->longitude, &val)) place.slong = DEG2RAD(val);
|
if(G->longitude && str2coord(G->longitude, &val)) place.slong = DEG2RAD(val);
|
||||||
if(G->latitude && str2coord(G->latitude, &val)) place.slat = DEG2RAD(val);
|
if(G->latitude && str2coord(G->latitude, &val)) place.slat = DEG2RAD(val);
|
||||||
setPlaceData(&place);
|
if(!setPlaceData(&place)) WARNX("Can't change default place data");
|
||||||
}
|
}
|
||||||
signal(SIGTERM, signals);
|
signal(SIGTERM, signals);
|
||||||
signal(SIGINT, signals);
|
signal(SIGINT, signals);
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ bool mount_setInpHA(double ha){
|
|||||||
if(ha < 0) ha += 24.;
|
if(ha < 0) ha += 24.;
|
||||||
if(ha < 0. || ha >= 24.) return false;
|
if(ha < 0. || ha >= 24.) return false;
|
||||||
InpCoords.ha = HRS2RAD(ha);
|
InpCoords.ha = HRS2RAD(ha);
|
||||||
|
InpCoords.ra = raha(InpCoords.ha);
|
||||||
InpCTime = sl_dtime();
|
InpCTime = sl_dtime();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -102,6 +103,7 @@ bool mount_setInpHA(double ha){
|
|||||||
bool mount_setInpRA(double ra){
|
bool mount_setInpRA(double ra){
|
||||||
if(ra < 0. || ra >= 24.) return false;
|
if(ra < 0. || ra >= 24.) return false;
|
||||||
InpCoords.ra = HRS2RAD(ra);
|
InpCoords.ra = HRS2RAD(ra);
|
||||||
|
InpCoords.ha = raha(InpCoords.ra);
|
||||||
InpCTime = sl_dtime();
|
InpCTime = sl_dtime();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -286,7 +288,7 @@ static bool write_cmd(const char *cmd, bool haveanswer){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
while(sl_tty_read(mount_dev) > 0);
|
while(sl_tty_read(mount_dev) > 0);
|
||||||
}else if(!send_cmd_resp(cmd, buf, 128)){
|
}else if(!send_cmd_resp(cmd, buf, sizeof(buf))){
|
||||||
WARNX("Error writing command '%s'", cmd);
|
WARNX("Error writing command '%s'", cmd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -306,7 +308,7 @@ mount_status_t mount_status(){
|
|||||||
pthread_mutex_lock(&mntdev_mutex);
|
pthread_mutex_lock(&mntdev_mutex);
|
||||||
int ntry = 0;
|
int ntry = 0;
|
||||||
for(; ntry < 3; ++ntry)
|
for(; ntry < 3; ++ntry)
|
||||||
if(send_cmd_resp(CMD_GETSTAT, resp, 64)) break;
|
if(send_cmd_resp(CMD_GETSTAT, resp, sizeof(resp))) break;
|
||||||
if(ntry == 3){ // mount not responded -> set status OFF
|
if(ntry == 3){ // mount not responded -> set status OFF
|
||||||
curst = MNT_S_OFF;
|
curst = MNT_S_OFF;
|
||||||
}else{ // parsing of status
|
}else{ // parsing of status
|
||||||
@@ -438,7 +440,7 @@ bool mount_point(double ra, double dec){
|
|||||||
if(!write_cmd(cmd, true)) goto retn;
|
if(!write_cmd(cmd, true)) goto retn;
|
||||||
snprintf(cmd, 127, CMD_SETDEC, decstr); // send Dec
|
snprintf(cmd, 127, CMD_SETDEC, decstr); // send Dec
|
||||||
if(!write_cmd(cmd, true)) goto retn;
|
if(!write_cmd(cmd, true)) goto retn;
|
||||||
if(send_cmd_resp(CMD_SLEWRADEC, cmd, 127)){ // check error
|
if(send_cmd_resp(CMD_SLEWRADEC, cmd, sizeof(cmd))){ // check error
|
||||||
if(*cmd != '0'){
|
if(*cmd != '0'){
|
||||||
WARNX("Slew error, answer: %s", cmd);
|
WARNX("Slew error, answer: %s", cmd);
|
||||||
LOGWARN("Slew error, answer: %s", cmd);
|
LOGWARN("Slew error, answer: %s", cmd);
|
||||||
@@ -447,6 +449,7 @@ bool mount_point(double ra, double dec){
|
|||||||
}
|
}
|
||||||
ret = true;
|
ret = true;
|
||||||
TagCoords.ra = HRS2RAD(ra);
|
TagCoords.ra = HRS2RAD(ra);
|
||||||
|
TagCoords.ha = raha(TagCoords.ra);
|
||||||
TagCoords.dec = DEG2RAD(dec);
|
TagCoords.dec = DEG2RAD(dec);
|
||||||
TagTime = sl_dtime();
|
TagTime = sl_dtime();
|
||||||
LOGMSG("Go to RA/Decl: %s/%s", rastr, decstr);
|
LOGMSG("Go to RA/Decl: %s/%s", rastr, decstr);
|
||||||
@@ -481,7 +484,7 @@ bool mount_pointAZ(double A, double Z){
|
|||||||
if(!write_cmd(cmd, true)) goto retn;
|
if(!write_cmd(cmd, true)) goto retn;
|
||||||
snprintf(cmd, 127, CMD_SETZD, azstr);
|
snprintf(cmd, 127, CMD_SETZD, azstr);
|
||||||
if(!write_cmd(cmd, true)) goto retn;
|
if(!write_cmd(cmd, true)) goto retn;
|
||||||
if(send_cmd_resp(CMD_GOTOAZ, cmd, 128)){ // returned not '0'
|
if(send_cmd_resp(CMD_GOTOAZ, cmd, sizeof(cmd))){ // returned not '0'
|
||||||
if(*cmd != '0'){
|
if(*cmd != '0'){
|
||||||
WARNX("Goto error, answer: %s", cmd);
|
WARNX("Goto error, answer: %s", cmd);
|
||||||
LOGWARN("Goto error, answer: %s", cmd);
|
LOGWARN("Goto error, answer: %s", cmd);
|
||||||
@@ -498,6 +501,12 @@ void set_emulation_mode(){
|
|||||||
isemulated = true;
|
isemulated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool get_declination(double *dec){
|
||||||
|
char resp[64];
|
||||||
|
if(!send_cmd_resp(CMD_GETDEC, resp, sizeof(resp))) return false;
|
||||||
|
return str2coord(resp, dec);
|
||||||
|
}
|
||||||
|
|
||||||
bool mount_getcoords(double *ra, double *dec){
|
bool mount_getcoords(double *ra, double *dec){
|
||||||
if(!ra || !dec) return false;
|
if(!ra || !dec) return false;
|
||||||
if(isemulated){
|
if(isemulated){
|
||||||
@@ -511,10 +520,9 @@ bool mount_getcoords(double *ra, double *dec){
|
|||||||
char resp[64];
|
char resp[64];
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
pthread_mutex_lock(&mntdev_mutex);
|
pthread_mutex_lock(&mntdev_mutex);
|
||||||
if(!send_cmd_resp(CMD_GETRA, resp, 64)) goto retn;
|
if(!get_declination(dec)) goto retn;
|
||||||
|
if(!send_cmd_resp(CMD_GETRA, resp, sizeof(resp))) goto retn;
|
||||||
if(!str2coord(resp, ra)) goto retn;
|
if(!str2coord(resp, ra)) goto retn;
|
||||||
if(!send_cmd_resp(CMD_GETDEC, resp, 64)) goto retn;
|
|
||||||
if(!str2coord(resp, dec)) goto retn;
|
|
||||||
ret = true;
|
ret = true;
|
||||||
retn:
|
retn:
|
||||||
pthread_mutex_unlock(&mntdev_mutex);
|
pthread_mutex_unlock(&mntdev_mutex);
|
||||||
@@ -538,9 +546,9 @@ bool mount_getaz(double *a, double *z){
|
|||||||
char resp[64];
|
char resp[64];
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
pthread_mutex_lock(&mntdev_mutex);
|
pthread_mutex_lock(&mntdev_mutex);
|
||||||
if(!send_cmd_resp(CMD_GETAZIM, resp, 64)) goto retn;
|
if(!send_cmd_resp(CMD_GETAZIM, resp, sizeof(resp))) goto retn;
|
||||||
if(!str2coord(resp, a)) goto retn;
|
if(!str2coord(resp, a)) goto retn;
|
||||||
if(!send_cmd_resp(CMD_GETALT, resp, 64)) goto retn;
|
if(!send_cmd_resp(CMD_GETALT, resp, sizeof(resp))) goto retn;
|
||||||
double alt;
|
double alt;
|
||||||
if(!str2coord(resp, &alt)) goto retn;
|
if(!str2coord(resp, &alt)) goto retn;
|
||||||
*z = 90. - alt;
|
*z = 90. - alt;
|
||||||
@@ -585,6 +593,13 @@ bool mount_tracking_stop(){
|
|||||||
* @return false if failed
|
* @return false if failed
|
||||||
*/
|
*/
|
||||||
bool mount_tracking_start(){
|
bool mount_tracking_start(){
|
||||||
|
double ra, dec;
|
||||||
|
if(!mount_getcoords(&ra, &dec)) return false;
|
||||||
|
TagCoords.ra = HRS2RAD(ra);
|
||||||
|
TagCoords.dec = DEG2RAD(dec);
|
||||||
|
TagCoords.ha = raha(TagCoords.ra);
|
||||||
|
TagTime = sl_dtime();
|
||||||
|
mount_setInpEpoch(-1.); // Jnow
|
||||||
if(isemulated){
|
if(isemulated){
|
||||||
emul_start_tracking();
|
emul_start_tracking();
|
||||||
return true;
|
return true;
|
||||||
@@ -606,7 +621,10 @@ bool mount_park(){
|
|||||||
if(isemulated) return pointAZ_emulation(RAD2DEG(ParkCoords.az), RAD2DEG(ParkCoords.zd));
|
if(isemulated) return pointAZ_emulation(RAD2DEG(ParkCoords.az), RAD2DEG(ParkCoords.zd));
|
||||||
char buf[64];
|
char buf[64];
|
||||||
snprintf(buf, 63, CMD_SETMINALT, 0);
|
snprintf(buf, 63, CMD_SETMINALT, 0);
|
||||||
if(!write_cmd(buf, true)) return false;
|
pthread_mutex_lock(&mntdev_mutex);
|
||||||
|
bool ret = write_cmd(buf, true);
|
||||||
|
pthread_mutex_unlock(&mntdev_mutex);
|
||||||
|
if(!ret) return false;
|
||||||
return mount_pointAZ(RAD2DEG(ParkCoords.az), RAD2DEG(ParkCoords.zd));
|
return mount_pointAZ(RAD2DEG(ParkCoords.az), RAD2DEG(ParkCoords.zd));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -708,7 +726,10 @@ bool mount_corrdata(weather_data_t *w){
|
|||||||
*/
|
*/
|
||||||
bool mount_shutdown(){
|
bool mount_shutdown(){
|
||||||
if(isemulated) return false;
|
if(isemulated) return false;
|
||||||
return write_cmd(CMD_SHUTDOWN, true);
|
pthread_mutex_lock(&mntdev_mutex);
|
||||||
|
bool ret = write_cmd(CMD_SHUTDOWN, true);
|
||||||
|
pthread_mutex_unlock(&mntdev_mutex);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -720,5 +741,94 @@ bool mount_shutdown(){
|
|||||||
*/
|
*/
|
||||||
bool mount_rawcmd(const char *cmd, char *ans, size_t anslen){
|
bool mount_rawcmd(const char *cmd, char *ans, size_t anslen){
|
||||||
if(isemulated) return false;
|
if(isemulated) return false;
|
||||||
return send_cmd_resp(cmd, ans, anslen);
|
pthread_mutex_lock(&mntdev_mutex);
|
||||||
|
LOGDBG("Send %s", cmd);
|
||||||
|
bool ret = send_cmd_resp(cmd, ans, anslen);
|
||||||
|
LOGDBG("Ans: %s", ret ? "true" : "false");
|
||||||
|
pthread_mutex_unlock(&mntdev_mutex);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**** Coordinate correction (useful for guiding etc) ****/
|
||||||
|
/**
|
||||||
|
* @brief get_guide_rate - get current guiding rate
|
||||||
|
* @return fraction of sidereal rate
|
||||||
|
*/
|
||||||
|
static double get_guide_rate(){
|
||||||
|
char resp[32];
|
||||||
|
if(send_cmd_resp(CMD_GETGUIDERATE, resp, sizeof(resp))){
|
||||||
|
double rate = atof(resp);
|
||||||
|
LOGDBG("get guide rate: %g", rate);
|
||||||
|
if(rate > 0.0 && rate <= SIDEREAL_RATE){
|
||||||
|
return rate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DEFAULT_GUIDE_RATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief send_pulse - common funtion to send correction pulse
|
||||||
|
* @param dir_cmd - direction like "Me" etc.
|
||||||
|
* @param total_ms - pulse length
|
||||||
|
* @return false if failed
|
||||||
|
*/
|
||||||
|
static bool send_pulse(const char *dir_cmd, int total_ms){
|
||||||
|
char cmd[16];
|
||||||
|
snprintf(cmd, sizeof(cmd), CMD_CORRECT, dir_cmd, total_ms);
|
||||||
|
LOGDBG("Correct by command %s", cmd);
|
||||||
|
return write_cmd(cmd, false); // these commands have no answer
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief correct_ra - correct RA by `arcsec` arcseconds
|
||||||
|
* @param arcsec - angle to correct
|
||||||
|
* @return false if failed
|
||||||
|
*/
|
||||||
|
bool correct_ra(double arcsec){
|
||||||
|
if(fabs(arcsec) < 1e-6) return false; // near pole there's may be...
|
||||||
|
bool ret = false;
|
||||||
|
pthread_mutex_lock(&mntdev_mutex);
|
||||||
|
double guide_rate = get_guide_rate();
|
||||||
|
// recalculate by plate coordinates
|
||||||
|
double dec_deg;
|
||||||
|
if(!get_declination(&dec_deg)){
|
||||||
|
LOGDBG("Can't get dec");
|
||||||
|
goto rtn;
|
||||||
|
}
|
||||||
|
double cos_dec = cos(DEG2RAD(dec_deg));
|
||||||
|
if(fabs(cos_dec) < 1e-6) cos_dec = 1e-6; // avoid dividing by zero
|
||||||
|
// calculate guiding duration
|
||||||
|
double duration_ms = (fabs(arcsec) / cos_dec) / (guide_rate) * 1000.0;
|
||||||
|
//LOGDBG("arcsec=%g, cosdec=%g, gr=%g, dms=%g", arcsec, cos_dec, guide_rate, duration_ms);
|
||||||
|
int total_ms = (int)round(duration_ms);
|
||||||
|
if(total_ms > MAX_PULSE_MS){
|
||||||
|
LOGDBG("duration %d too high", total_ms);
|
||||||
|
goto rtn;
|
||||||
|
}
|
||||||
|
const char *dir = (arcsec > 0) ? CORR_EAST : CORR_WEST;
|
||||||
|
ret = send_pulse(dir, total_ms);
|
||||||
|
rtn:
|
||||||
|
pthread_mutex_unlock(&mntdev_mutex);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief correct_dec - make correction for declination
|
||||||
|
* @param arcsec - angle to correct
|
||||||
|
* @return false if failed
|
||||||
|
*/
|
||||||
|
bool correct_dec(double arcsec){
|
||||||
|
if(fabs(arcsec) < MIN_CORR_ANGLE) return false;
|
||||||
|
bool ret = false;
|
||||||
|
pthread_mutex_lock(&mntdev_mutex);
|
||||||
|
double guide_rate = get_guide_rate();
|
||||||
|
double duration_ms = fabs(arcsec) / (guide_rate) * 1000.0;
|
||||||
|
int total_ms = (int)round(duration_ms);
|
||||||
|
if(total_ms > MAX_PULSE_MS) goto rtn;
|
||||||
|
const char *dir = (arcsec > 0) ? CORR_NORTH : CORR_SOUTH;
|
||||||
|
ret = send_pulse(dir, total_ms);
|
||||||
|
rtn:
|
||||||
|
pthread_mutex_unlock(&mntdev_mutex);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,15 @@
|
|||||||
// make datetime/pressure/temperature corrections each CORRECTIONS_TIMEDIFF seconds
|
// make datetime/pressure/temperature corrections each CORRECTIONS_TIMEDIFF seconds
|
||||||
#define CORRECTIONS_TIMEDIFF (3600)
|
#define CORRECTIONS_TIMEDIFF (3600)
|
||||||
|
|
||||||
|
// sidereal tracking rate
|
||||||
|
#define SIDEREAL_RATE 15.041
|
||||||
|
// max correction pulse (ms)
|
||||||
|
#define MAX_PULSE_MS 9999
|
||||||
|
// default guiding rate
|
||||||
|
#define DEFAULT_GUIDE_RATE 7.5
|
||||||
|
// minimal angle (arcsec) for correction
|
||||||
|
#define MIN_CORR_ANGLE 1.
|
||||||
|
|
||||||
// mount statuses
|
// mount statuses
|
||||||
typedef enum{
|
typedef enum{
|
||||||
MNT_S_TRACKING = 0,
|
MNT_S_TRACKING = 0,
|
||||||
@@ -92,3 +101,6 @@ void mount_getPark(horizCrds_t *c);
|
|||||||
bool mount_shutdown();
|
bool mount_shutdown();
|
||||||
|
|
||||||
bool mount_rawcmd(const char *cmd, char *ans, size_t anslen);
|
bool mount_rawcmd(const char *cmd, char *ans, size_t anslen);
|
||||||
|
|
||||||
|
bool correct_ra(double arcsec);
|
||||||
|
bool correct_dec(double arcsec);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 20.0.1, 2026-10-15T00:52:00. -->
|
<!-- Written by QtCreator 20.0.1, 2026-10-16T02:19:07. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
10micron_commands.h
|
10micron_commands.h
|
||||||
Readme.md
|
Readme.md
|
||||||
|
airmass.inc
|
||||||
|
am.c
|
||||||
angles.c
|
angles.c
|
||||||
angles.h
|
angles.h
|
||||||
args.c
|
args.c
|
||||||
|
|||||||
@@ -35,6 +35,8 @@
|
|||||||
#define STATUS_MAX_AGE (30.)
|
#define STATUS_MAX_AGE (30.)
|
||||||
|
|
||||||
// commands
|
// commands
|
||||||
|
#define CMD_CORDEC "cordec"
|
||||||
|
#define CMD_CORRA "corra"
|
||||||
#define CMD_DUT1 "dut1"
|
#define CMD_DUT1 "dut1"
|
||||||
#define CMD_GOTOAZ "gotoaz"
|
#define CMD_GOTOAZ "gotoaz"
|
||||||
#define CMD_GOTORD "gotord"
|
#define CMD_GOTORD "gotord"
|
||||||
@@ -116,7 +118,7 @@ static int parse_key_value(const char *req, double *val){
|
|||||||
return 1; // is setter
|
return 1; // is setter
|
||||||
}
|
}
|
||||||
|
|
||||||
// setters of RA/DEC/HA/Az/ZD (TODO: fix `parse_key_value` for HH:MM:SS/DD:MM:SS/DDD.DD/HHH.HH formats!)
|
// setters of RA/DEC/HA/Az/ZD
|
||||||
static sl_sock_hresult_e cmd_tagra(sl_sock_t *c, sl_sock_hitem_t *item, const char *req){
|
static sl_sock_hresult_e cmd_tagra(sl_sock_t *c, sl_sock_hitem_t *item, const char *req){
|
||||||
double val;
|
double val;
|
||||||
int res = parse_key_value(req, &val);
|
int res = parse_key_value(req, &val);
|
||||||
@@ -230,8 +232,7 @@ static sl_sock_hresult_e cmd_telra(sl_sock_t *c, sl_sock_hitem_t *item, _U_ cons
|
|||||||
static sl_sock_hresult_e cmd_telha(sl_sock_t *c, sl_sock_hitem_t *item, _U_ const char *req){
|
static sl_sock_hresult_e cmd_telha(sl_sock_t *c, sl_sock_hitem_t *item, _U_ const char *req){
|
||||||
if(weatherlost || HDR.status == MNT_S_ERROR) return RESULT_FAIL;
|
if(weatherlost || HDR.status == MNT_S_ERROR) return RESULT_FAIL;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
double ha = eraAnp(HDR.sidtime - HDR.polar.ra);
|
snprintf(buf, 63, "%s=%.6f\n", item->key, RAD2HRS(HDR.polar.ha));
|
||||||
snprintf(buf, 63, "%s=%.6f\n", item->key, RAD2HRS(ha));
|
|
||||||
sl_sock_sendstrmessage(c, buf);
|
sl_sock_sendstrmessage(c, buf);
|
||||||
return RESULT_SILENCE;
|
return RESULT_SILENCE;
|
||||||
}
|
}
|
||||||
@@ -281,11 +282,7 @@ static sl_sock_hresult_e cmd_gotorh(_U_ sl_sock_t *c, _U_ sl_sock_hitem_t *item,
|
|||||||
if(weatherlost || HDR.status == MNT_S_ERROR) return RESULT_FAIL;
|
if(weatherlost || HDR.status == MNT_S_ERROR) return RESULT_FAIL;
|
||||||
polarCrds_t p;
|
polarCrds_t p;
|
||||||
mount_getInpCoords(&p);
|
mount_getInpCoords(&p);
|
||||||
sMJD_t mjd;
|
double RA_rad = raha(p.ha); // re-convert (as time could have passed)
|
||||||
if(!get_MJDt(NULL, &mjd)) return RESULT_FAIL;
|
|
||||||
double LST;
|
|
||||||
if(!get_LST(&mjd, &LST)) return RESULT_FAIL;
|
|
||||||
double RA_rad = eraAnp(LST - p.ha);
|
|
||||||
double ra_h = RAD2HRS(RA_rad);
|
double ra_h = RAD2HRS(RA_rad);
|
||||||
double dec_d = RAD2DEG(p.dec);
|
double dec_d = RAD2DEG(p.dec);
|
||||||
LOGDBG("Client %d asks to point to HA/Dec", c->fd);
|
LOGDBG("Client %d asks to point to HA/Dec", c->fd);
|
||||||
@@ -451,6 +448,7 @@ static sl_sock_hresult_e cmd_raw(sl_sock_t *c, sl_sock_hitem_t _U_ *item, const
|
|||||||
size_t L = strlen(buf);
|
size_t L = strlen(buf);
|
||||||
buf[L] = '\n';
|
buf[L] = '\n';
|
||||||
buf[L + 1] = 0;
|
buf[L + 1] = 0;
|
||||||
|
LOGMSG("Client %d asks for raw command '%s'; answer: '%s'", req, buf);
|
||||||
sl_sock_sendstrmessage(c, buf);
|
sl_sock_sendstrmessage(c, buf);
|
||||||
return RESULT_SILENCE;
|
return RESULT_SILENCE;
|
||||||
}
|
}
|
||||||
@@ -484,6 +482,25 @@ static sl_sock_hresult_e cmd_shutdown(sl_sock_t *c, sl_sock_hitem_t *item, const
|
|||||||
return RESULT_OK;
|
return RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static sl_sock_hresult_e cmd_cordec(sl_sock_t *c, sl_sock_hitem_t _U_ *item, const char *req){
|
||||||
|
double val;
|
||||||
|
int res = parse_key_value(req, &val);
|
||||||
|
if(res <= 0) return RESULT_BADVAL;
|
||||||
|
LOGDBG("Client %d ask to correct Dec by %g''", c->fd, val);
|
||||||
|
if(correct_dec(val)) return RESULT_OK;
|
||||||
|
return RESULT_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static sl_sock_hresult_e cmd_corra(sl_sock_t *c, sl_sock_hitem_t _U_ *item, const char *req){
|
||||||
|
double val;
|
||||||
|
int res = parse_key_value(req, &val);
|
||||||
|
if(res <= 0) return RESULT_BADVAL;
|
||||||
|
LOGDBG("Client %d ask to correct RA by %g''", c->fd, val);
|
||||||
|
if(correct_ra(val)) return RESULT_OK;
|
||||||
|
return RESULT_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// and all handlers collection
|
// and all handlers collection
|
||||||
static sl_sock_hitem_t handlers[] = {
|
static sl_sock_hitem_t handlers[] = {
|
||||||
@@ -516,6 +533,8 @@ static sl_sock_hitem_t handlers[] = {
|
|||||||
{cmd_telzd, CMD_TELZD, "get current telescope zenith distance (Deg)", NULL},
|
{cmd_telzd, CMD_TELZD, "get current telescope zenith distance (Deg)", NULL},
|
||||||
{cmd_track, CMD_TRACK, "start tracking from current position", NULL},
|
{cmd_track, CMD_TRACK, "start tracking from current position", NULL},
|
||||||
{dtimeh, CMD_UNIXT, "get server's UNIX time", NULL},
|
{dtimeh, CMD_UNIXT, "get server's UNIX time", NULL},
|
||||||
|
{cmd_corra, CMD_CORRA, "correct RA by x arcseconds", NULL},
|
||||||
|
{cmd_cordec, CMD_CORDEC, "correct Dec by x arcseconds", NULL},
|
||||||
{NULL, NULL, NULL, NULL}
|
{NULL, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -631,6 +650,7 @@ void server_run(){
|
|||||||
get_LST(&HDR.MJD, &HDR.sidtime);
|
get_LST(&HDR.MJD, &HDR.sidtime);
|
||||||
HDR.polar.ra = HRS2RAD(deg1);
|
HDR.polar.ra = HRS2RAD(deg1);
|
||||||
HDR.polar.dec = DEG2RAD(deg2);
|
HDR.polar.dec = DEG2RAD(deg2);
|
||||||
|
HDR.polar.ha = eraAnp(HDR.sidtime - HDR.polar.ra);
|
||||||
}
|
}
|
||||||
if(mount_getaz(°1, °2)){
|
if(mount_getaz(°1, °2)){
|
||||||
HDR.altaz.az = DEG2RAD(deg1);
|
HDR.altaz.az = DEG2RAD(deg1);
|
||||||
|
|||||||
Reference in New Issue
Block a user