add EQUINOX, pier side and JD to stellarium daemon

This commit is contained in:
eddyem 2020-02-23 12:34:42 +03:00
parent 9225e28d2e
commit f6fdff12a5
16 changed files with 133 additions and 21 deletions

View File

@ -39,6 +39,8 @@ glob_pars G;
//#define ACCEPT_IP "192.168.3.225"
// default PID filename:
#define DEFAULT_PIDFILE "/tmp/stellariumdaemon.pid"
// default file with headers
#define DEFAULT_FITSHDR "/tmp/10micron.fitsheader"
// DEFAULTS
// default global parameters
@ -46,7 +48,7 @@ glob_pars const Gdefault = {
.device = DEFAULT_COMDEV,
.port = DEFAULT_PORT,
.pidfile = DEFAULT_PIDFILE,
.crdsfile = "/tmp/10micron.fitsheader",
.crdsfile = DEFAULT_FITSHDR,
.emulation = 0,
.logfile = NULL // don't save logs
};

View File

@ -23,6 +23,9 @@
#include <sofam.h>
#include <sys/time.h>
// JD2451544.5 == 2000.0
#define MJD2000 (51544)
typedef struct{
double utc1; double utc2; // UTC JD, commonly used MJD = utc1+utc2-2400000.5
double MJD;

View File

@ -53,12 +53,14 @@ static volatile int global_quit = 0;
// quit by signal
void signals(int sig){
signal(sig, SIG_IGN);
unlink(GP->crdsfile); // remove header file
unlink(GP->pidfile); // and remove pidfile
restore_console();
restore_tty();
DBG("Get signal %d, quit.\n", sig);
global_quit = 1;
sleep(1);
putlog("PID %d exit with status %d", getpid(), sig);
WARNX(_("PID %d exit with status %d"), getpid(), sig);
exit(sig);
}
@ -179,7 +181,7 @@ char *radec2str(double ra, double dec){
int setCoords(double ra, double dec){
char *radec = radec2str(ra, dec);
DBG("Set RA/Decl to %s", radec);
putlog("try to set RA/Decl to %s", radec);
putlog("Try to set RA/Decl to %s", radec);
int (*pointfunction)(double, double) = point_telescope;
if(GP->emulation) pointfunction = point_emulation;
return pointfunction(ra, dec);
@ -427,10 +429,10 @@ int main(int argc, char **argv){
ERR("ERROR on fork");
}
if(childpid){
putlog("Created child with PID %d\n", childpid);
WARNX(_("Created child with PID %d\n"), childpid);
DBG("Created child with PID %d\n", childpid);
wait(NULL);
putlog("Child %d died\n", childpid);
WARNX(_("Child %d died\n"), childpid);
DBG("Child %d died\n", childpid);
}else{
prctl(PR_SET_PDEATHSIG, SIGTERM); // send SIGTERM to child when parent dies

View File

@ -22,6 +22,7 @@
*/
#include <pthread.h>
#include "libsofa.h"
#include "telescope.h"
#include "usefull_macros.h"
@ -38,6 +39,8 @@
#define BUFLEN 80
static char *hdname = NULL;
static double ptRAdeg, ptDECdeg; // target RA/DEC J2000
static int Target = 0; // target coordinates entered
/**
* read strings from terminal (ending with '\n') with timeout
@ -115,7 +118,6 @@ int connect_telescope(char *dev, char *hdrname){
if(!dev) return 0;
tcflag_t spds[] = {B9600, B115200, B57600, B38400, B19200, B4800, B2400, B1200, 0}, *speeds = spds;
DBG("Connection to device %s...", dev);
putlog("Try to connect to device %s...", dev);
while(*speeds){
DBG("Try %d", *speeds);
tty_init(dev, *speeds);
@ -130,9 +132,10 @@ int connect_telescope(char *dev, char *hdrname){
}
write_cmd(":U2#");
write_cmd(":U2#");
putlog("connected to %s@115200, will write FITS-header into %s", dev, hdrname);
putlog("Connected to %s@115200, will write FITS-header into %s", dev, hdrname);
hdname = strdup(hdrname);
DBG("connected");
Target = 0;
return 1;
}
@ -141,7 +144,6 @@ int connect_telescope(char *dev, char *hdrname){
:SrHH:MM:SS.SS# - set target RA (return 1 if all OK)
:SdsDD*MM:SS.S# - set target DECL (return 1 if all OK)
*/
/**
* send coordinates to telescope
* @param ra - right ascention (hours)
@ -150,6 +152,9 @@ int connect_telescope(char *dev, char *hdrname){
*/
int point_telescope(double ra, double dec){
DBG("try to send ra=%g, decl=%g", ra, dec);
ptRAdeg = ra * 15.;
ptDECdeg = dec;
Target = 0;
int err = 0;
static char buf[80];
char sign = '+';
@ -190,7 +195,8 @@ int point_telescope(double ra, double dec){
putlog("error sending coordinates (err = %d: RA/DEC/MOVE)!", err);
return 0;
}else{
putlog("Send ra=%g, dec=%g", ra, dec);
Target = 1;
putlog("Send ra=%g degr, dec=%g degr", ptRAdeg, ptDECdeg);
}
return 1;
}
@ -267,7 +273,10 @@ int get_telescope_coords(double *ra, double *decl){
void stop_telescope(){
for(int i = 0; i < 3; ++i){
if(write_cmd(":STOP#")) return;
if(write_cmd(":STOP#")){
Target = 0;
return;
}
}
putlog("Can't send command STOP");
}
@ -321,12 +330,13 @@ static void getplace(){
*/
void wrhdr(){
static int failcounter = 0;
char *ans = NULL, *jd = NULL, *lst = NULL, *date = NULL;
char *ans = NULL, *jd = NULL, *lst = NULL, *date = NULL, *pS = NULL;
// get coordinates for writing to file & sending to stellarium client
ans = write_cmd(":GR#");
if(!str2coord(ans, &r)){
if(++failcounter == 10){
DBG("Can't ger RA 10 times!");
putlog("Lost connection with mount");
DBG("Can't get RA!");
signals(9);
}
return;
@ -334,7 +344,8 @@ void wrhdr(){
ans = write_cmd(":GD#");
if(!str2coord(ans, &d)){
if(++failcounter == 10){
DBG("Can't ger DEC 10 times!");
putlog("Lost connection with mount");
DBG("Can't get DEC!");
signals(9);
}
return;
@ -353,36 +364,47 @@ void wrhdr(){
date = dups(ans, 1);
}
}
ans = write_cmd(":pS#"); pS = dups(ans, 1);
#define WRHDR(k, v, c) do{if(printhdr(hdrfd, k, v, c)){close(hdrfd); return;}}while(0)
char val[22];
if(unlink(hdname)){
WARN("unlink(%s)", hdname);
FREE(jd); FREE(lst); FREE(date); FREE(pS);
return;
}
int hdrfd = open(hdname, O_WRONLY | O_TRUNC | O_CREAT, 0644);
if(hdrfd < 0){
WARN("Can't open %s", hdname);
FREE(jd); FREE(lst); FREE(date); FREE(pS);
return;
}
WRHDR("TIMESYS", "'UTC'", "Time system");
WRHDR("ORIGIN", "'SAO RAS'", "Organization responsible for the data");
WRHDR("TELESCOP", "'Astrosib-500'", "Telescope name");
if(Target){ // target coordinates entered - store them @header
snprintf(val, 22, "%.10f", ptRAdeg);
WRHDR("TAGRA", val, "Target RA (J2000), degrees");
snprintf(val, 22, "%.10f", ptDECdeg);
WRHDR("TAGDEC", val, "Target DEC (J2000), degrees");
}
snprintf(val, 22, "%.10f", r*15.); // convert RA to degrees
WRHDR("RA", val, "Right ascension, current epoch");
WRHDR("RA", val, "Telescope right ascension, current epoch");
snprintf(val, 22, "%.10f", d);
WRHDR("DEC", val, "Declination, current epoch");
WRHDR("DEC", val, "Telescope declination, current epoch");
sMJD mjd;
if(!get_MJDt(NULL, &mjd)){
snprintf(val, 22, "%.10f", 2000.+(mjd.MJD-MJD2000)/365.25); // calculate EPOCH/EQUINOX
WRHDR("EQUINOX", val, "Equinox of celestial coordinate system");
}
if(pS) WRHDR("PIERSIDE", pS, "Pier side of telescope mount");
if(elevation) WRHDR("ELEVAT", elevation, "Elevation of site over the sea level");
if(longitude) WRHDR("LONGITUD", longitude, "Geo longitude of site (east negative)");
if(latitude) WRHDR("LATITUDE", latitude, "Geo latitude of site (south negative)");
if(jd) WRHDR("MJD-END", jd, "Julian date of observations end");
if(jd) WRHDR("JD-END", jd, "Julian date of observations end");
if(lst) WRHDR("LSTEND", lst, "Local sidereal time of observations end");
if(date) WRHDR("DATE-END", date, "Date (UTC) of observations end");
FREE(jd);
FREE(lst);
FREE(date);
FREE(jd); FREE(lst); FREE(date); FREE(pS);
// WRHDR("", , "");
//ans = write_cmd(":GC#");
//char *ans1 = write_cmd(":GC#");
#undef WRHDR
close(hdrfd);
}

9
Daemons/astrosib/HWoff Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
# start observation: open everything, turn on power etc
export http_proxy=""
echo "Turn OFF mount"
ssh obs@192.168.70.34 ~/bin/MOUNTpoweronoff
sleep 30
echo "Turn OFF hardware power"
ssh obs@192.168.70.34 ~/bin/HWpoweroff

9
Daemons/astrosib/HWon Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
# start observation: open everything, turn on power etc
export http_proxy=""
echo "Turn ON hardware power"
ssh obs@192.168.70.34 ~/bin/HWpoweron
sleep 5
echo "Turn ON mount"
ssh obs@192.168.70.34 ~/bin/MOUNTpoweronoff

7
Daemons/astrosib/Readme Normal file
View File

@ -0,0 +1,7 @@
Scripts from main telescope computer
HWoff - turn hardware off
HWon - turn hardware on
STARTobs - start observations: turn hardware on and open dome/telescope
STOPobs - end observations: turn all off and close everything

26
Daemons/astrosib/STARTobs Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
# start observation: open everything, turn on power etc
export http_proxy=""
echo "Turn ON hardware power"
ssh obs@192.168.70.34 ~/bin/HWpoweron
echo "Open dome"
curl localhost:55555/open
while true; do
ANS=$(curl localhost:55555/status 2>/dev/null)
echo "Status: $ANS"
[ $ANS = "opened" ] && break
sleep 1
done
echo "Turn ON mount"
ssh obs@192.168.70.34 ~/bin/MOUNTpoweronoff
echo "set camera temperature to -25degrC"
fli_control -t-25
echo "Open telescope doors"
curl localhost:4444/open
while true; do
ANS=$(curl localhost:4444/status 2>/dev/null)
echo "Status: $ANS"
[ $ANS = "opened" ] && break
sleep 1
done

27
Daemons/astrosib/STOPobs Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# stop observation: close everything, turn of power etc
export http_proxy=""
echo "Turn OFF mount"
ssh obs@192.168.70.34 ~/bin/MOUNTpoweronoff
echo "Turn off camera TEC"
fli_control -t25
echo "Close telescope doors"
curl localhost:4444/close
echo "Close dome"
curl localhost:55555/close
while true; do
ANS=$(curl localhost:55555/status 2>/dev/null)
echo "Status: $ANS"
[ $ANS = "closed" ] && break
sleep 1
done
echo "Dome closed!"
while true; do
ANS=$(curl localhost:4444/status 2>/dev/null)
echo "Status: $ANS"
[ $ANS = "closed" ] && break
sleep 1
done
sleep 10
echo "Turn OFF hardware power"
ssh obs@192.168.70.34 ~/bin/HWpoweroff

0
Daemons/netsocket/HWpoweroff Executable file → Normal file
View File

0
Daemons/netsocket/HWpoweron Executable file → Normal file
View File

0
Daemons/netsocket/MOUNTpoweronoff Executable file → Normal file
View File

5
Daemons/netsocket/Readme Normal file
View File

@ -0,0 +1,5 @@
Scripts from network socket
HWpoweroff - turn off hardware power
HWpoweron - turn on hardware power
MOUNTpoweronoff - switch mount on/off

0
Daemons/teldaemon/teldaemon Executable file → Normal file
View File

0
Docs/Alignment/makelist Executable file → Normal file
View File

0
Docs/focus Executable file → Normal file
View File