Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michel Roelofs
dt_ctrl
Commits
1cee7e77
Commit
1cee7e77
authored
Feb 15, 2013
by
Jeroen Vreeken
Browse files
20130214
parent
8913f709
Changes
128
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
1cee7e77
...
...
@@ -3,3 +3,8 @@
*.sw?
*~
*.a
*.tab.c
*.tab.h
*.yy.c
*.yy.h
*.log
Makefile
0 → 100644
View file @
1cee7e77
all
:
$(MAKE)
-C
common/utils
$(MAKE)
-C
common/trace
$(MAKE)
-C
controller
cd
libnova-0.13.0
;
./configure
;
make
$(MAKE)
-C
console
common/include/dt_port_numbers.h
View file @
1cee7e77
...
...
@@ -24,6 +24,10 @@
#define CONSOLE_MANUAL_CMD_PORT 11051
#define CONSOLE_SAT_STAT_PORT 11060
#define CONSOLE_SAT_CMD_PORT 11061
#define CONSOLE_SUN_STAT_PORT 11070
#define CONSOLE_SUN_CMD_PORT 11071
#define CONSOLE_MOON_STAT_PORT 11080
#define CONSOLE_MOON_CMD_PORT 11081
#define CONSOLE_LOG_PORT 11200
...
...
common/utils/Makefile
View file @
1cee7e77
...
...
@@ -2,7 +2,10 @@
CFLAGS
=
-Wall
-O3
LDFLAGS
=
-lpthread
UTILSRCS
=
tcp_connect.c tcp_listen.c config.c weather.c dt_model.c location.c
CFLAGS
+=
`
pkg-config
--cflags
glib-2.0
`
LDFLAGS
+=
`
pkg-config
--libs
glib-2.0
`
UTILSRCS
=
tcp_connect.c tcp_listen.c config.c weather.c dt_model.c location.c dt_host.c
UTILOBJS
=
$(UTILSRCS:.c=.o)
all
:
$(UTILOBJS) utils weather_test
...
...
co
nsole/htdocs/j2000/j2000_command.js
→
co
mmon/utils/dt_host.c
View file @
1cee7e77
/*
Javascript sending j2000 coordinates over XMLHttp
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008
Copyright Stichting C.A. Muller Radioastronomiestation, 2008
/*
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2013
Copyright Stichting C.A. Muller Radioastronomiestation, 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -19,45 +17,74 @@
*/
function
j2000_command_cb_default
(
line
)
{
/* default callback */
}
function
j2000_command
()
{
var
j2000_command_this
=
this
;
/* Callbacks */
this
.
callback
=
j2000_command_cb_default
;
#include
<glib.h>
#include
<stdbool.h>
#include
<string.h>
#include
"dt_host.h"
this
.
xrequest
=
0
;
this
.
xrequest_prev
=
0
;
static
char
*
controller_host
=
"localhost"
;
static
char
*
console_host
=
"localhost"
;
static
bool
init_done
=
false
;
this
.
handle_xml
=
function
(
event
)
{
j2000_command_this
.
callback
(
j2000_command_this
,
event
.
target
.
responseText
);
j2000_command_this
.
data_wd
=
1
;
}
static
int
load_config
(
void
)
{
GKeyFile
*
keyfile
;
gboolean
loaded
;
gchar
*
keyfilename
=
"dt_host.ini"
;
int
ret
=
0
;
this
.
url
;
keyfile
=
g_key_file_new
();
loaded
=
g_key_file_load_from_file
(
keyfile
,
keyfilename
,
G_KEY_FILE_NONE
,
NULL
);
this
.
open
=
function
(
url
,
ra
,
dec
)
{
if
(
j2000_command_this
.
xrequest_prev
)
{
j2000_command_this
.
xrequest
.
abort
();
delete
j2000_command_this
.
xrequest
;
if
(
loaded
)
{
gsize
groups_nr
;
gchar
**
groups
;
int
i
;
groups
=
g_key_file_get_groups
(
keyfile
,
&
groups_nr
);
for
(
i
=
0
;
i
<
groups_nr
;
i
++
)
{
if
(
!
strcmp
(
groups
[
i
],
"controller"
))
{
if
(
g_key_file_has_key
(
keyfile
,
groups
[
i
],
"host"
,
NULL
))
{
controller_host
=
g_key_file_get_string
(
keyfile
,
groups
[
i
],
"host"
,
NULL
);
}
}
if
(
!
strcmp
(
groups
[
i
],
"console"
))
{
if
(
g_key_file_has_key
(
keyfile
,
groups
[
i
],
"host"
,
NULL
))
{
console_host
=
g_key_file_get_string
(
keyfile
,
groups
[
i
],
"host"
,
NULL
);
}
}
}
j2000_command_this
.
url
=
url
;
j2000_command_this
.
xrequest
=
new
XMLHttpRequest
();
j2000_command_this
.
xrequest
.
multipart
=
true
;
j2000_command_this
.
xrequest
.
open
(
"
POST
"
,
url
,
true
);
j2000_command_this
.
xrequest
.
onload
=
this
.
handle_xml
;
j2000_command_this
.
xrequest
.
send
(
ra
+
"
"
+
dec
);
j2000_command_this
.
xrequest_prev
=
1
;
init_done
=
true
;
g_strfreev
(
groups
);
}
else
{
ret
=
-
1
;;
}
g_key_file_free
(
keyfile
);
return
ret
;
}
char
*
dt_host_console
(
void
)
{
if
(
!
init_done
)
load_config
();
return
console_host
;
}
char
*
dt_host_controller
(
void
)
{
if
(
!
init_done
)
load_config
();
return
controller_host
;
}
co
ntroller/dt_elevation/dt_el
.h
→
co
mmon/utils/dt_host
.h
View file @
1cee7e77
/*
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 20
07
Copyright Stichting C.A. Muller Radioastronomiestation, 20
07
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 20
13
Copyright Stichting C.A. Muller Radioastronomiestation, 20
13
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -17,9 +17,10 @@
*/
#ifndef _INCLUDE_DT_
EL
_H_
#define _INCLUDE_DT_
EL
_H_
#ifndef _INCLUDE_DT_
HOST
_H_
#define _INCLUDE_DT_
HOST
_H_
char
*
dt_host_console
(
void
);
char
*
dt_host_controller
(
void
);
#endif
/* _INCLUDE_DT_EL_H_ */
#endif
/* _INCLUDE_DT_HOST_H_ */
common/utils/tcp_connect.c
View file @
1cee7e77
...
...
@@ -88,7 +88,7 @@ int tcp_connect(char *host, int port)
}
freeaddrinfo
(
result
);
if
(
sock
<
0
)
printf
(
"Failed to connect
\n
"
);
//
if (sock < 0)
//
printf("Failed to connect\n");
return
sock
;
}
console/console/.gitignore
View file @
1cee7e77
...
...
@@ -18,9 +18,14 @@ console_zenith
log_proxy
predictlib/test-001
predictlib/test-002
predictlib/test-003
spg_auth
spg_list
spg_log_parser
trace_line
trace_log
trace_proxy
command.cgi
shell.cgi
status.cgi
trace.cgi
console/console/Makefile
View file @
1cee7e77
...
...
@@ -3,30 +3,28 @@ include ../build.mk
CFLAGS
=
-Wall
-g
-I
../../common/utils
-I
../controller
-Iaalib
-Ipredictlib
-I
../../common/trace
-I
../../common/include
-I
../../libnova-0.13.0/src
ARCHIVES
=
../../common/utils/utils.a aalib/aalib.a predictlib/predictlib.a ../../common/trace/trace.a
LIBNOVA
=
../../libnova-0.13.0/src/.libs/libnova.a
LDFLAGS
+=
`
pkg-config
--libs
glib-2.0
`
all
:
aalib predictlib
\
setpoint.o console_easycomm console_joystick command_shell
\
spg_list spg_log_parser
\
console_moontracker
\
console_httptrace
console_httpline console_httpline_install
\
trace_proxy trace
_line
_install trace_log
\
console_httptrace
\
trace_proxy trace
.cgi
_install trace_log
\
console_j2000tracker console_j2000tracer console_j2000_indi
\
log_proxy spg_auth console_idle console_zenith
\
console_suntracker console_azel console_manual
\
console_weather
\
await_controller
\
console_sattracker
console_sattracker
\
status.cgi_install command.cgi_install shell.cgi_install
await_controller
:
await_controller.o $(ARCHIVES)
console_easycomm
:
console_easycomm.o setpoint.o $(ARCHIVES)
console_httpline
:
console_httpline.o $(ARCHIVES)
console_httpline_install
:
console_httpline
@
echo
" CP console_httpline"
@
cp
console_httpline ../htdocs
console_httptrace
:
console_httptrace.o $(ARCHIVES)
console_joystick
:
console_joystick.o setpoint.o $(ARCHIVES)
...
...
@@ -59,11 +57,11 @@ console_zenith: console_zenith.o setpoint.o $(ARCHIVES)
trace_proxy
:
trace_proxy.o $(ARCHIVES)
trace
_line
:
trace
_line
.o $(ARCHIVES)
trace
.cgi
:
trace
.cgi
.o $(ARCHIVES)
trace
_line
_install
:
trace
_line
@
echo
" CP trace
_line
"
@
cp
trace
_line
../htdocs
trace
.cgi
_install
:
trace
.cgi
@
echo
" CP trace
.cgi
"
@
cp
trace
.cgi
../htdocs
trace_log
:
trace_log.o $(ARCHIVES)
...
...
@@ -74,6 +72,24 @@ spg_auth: spg_auth.o setpoint.o $(ARCHIVES)
console_sattracker
:
console_sattracker.o setpoint.o $(ARCHIVES) -lpthread $(LIBNOVA) -lm
command.cgi
:
command.cgi.o $(ARCHIVES)
command.cgi_install
:
command.cgi
@
echo
" CP command.cgi"
@
cp
command.cgi ../htdocs
shell.cgi
:
shell.cgi.o $(ARCHIVES)
shell.cgi_install
:
shell.cgi
@
echo
" CP shell.cgi"
@
cp
shell.cgi ../htdocs
status.cgi
:
status.cgi.o $(ARCHIVES)
status.cgi_install
:
status.cgi
@
echo
" CP status.cgi"
@
cp
status.cgi ../htdocs
aalib
:
@
$(MAKE)
-C
aalib
...
...
@@ -93,7 +109,6 @@ clean:
console_easycomm
\
spg_list
\
console_httptrace
\
console_httpline
\
trace_proxy
\
console_manual
\
console_moontracker
\
...
...
@@ -107,12 +122,14 @@ clean:
console_weather
\
console_zenith
\
trace_proxy
\
trace
_line
\
trace
.cgi
\
trace_log
\
log_proxy
\
spg_auth
\
spg_log_parser
\
await_controller
await_controller
\
command.cgi
\
status.cgi
$(MAKE)
-C
aalib clean
$(MAKE)
-C
doc clean
$(MAKE)
-C
predictlib clean
...
...
console/console/command.cgi.c
0 → 100644
View file @
1cee7e77
/*
HTTP frontend for commands
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2013
Copyright Stichting C.A. Muller Radioastronomiestation, 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
<string.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<unistd.h>
#include
<math.h>
#include
<fcntl.h>
#include
<sys/ioctl.h>
#include
"tcp_connect.h"
#include
"dt_port_numbers.h"
#include
"dt_host.h"
int
main
(
int
argc
,
char
**
argv
)
{
int
fd
;
char
buffer
[
1000
];
char
*
host
;
int
port
=
-
1
;
host
=
dt_host_console
();
fgets
(
buffer
,
sizeof
(
buffer
),
stdin
);
while
(
buffer
[
strlen
(
buffer
)
-
1
]
==
'\n'
)
buffer
[
strlen
(
buffer
)
-
1
]
=
0
;
if
(
!
strcmp
(
buffer
,
"sat"
))
port
=
CONSOLE_SAT_CMD_PORT
;
else
if
(
!
strcmp
(
buffer
,
"sun"
))
port
=
CONSOLE_SUN_CMD_PORT
;
else
if
(
!
strcmp
(
buffer
,
"moon"
))
port
=
CONSOLE_MOON_CMD_PORT
;
else
if
(
!
strcmp
(
buffer
,
"auth"
))
port
=
CONSOLE_ACTIVE_PORT
;
else
if
(
!
strcmp
(
buffer
,
"j2000"
))
port
=
CONSOLE_J2000_CMD_PORT
;
else
if
(
!
strcmp
(
buffer
,
"offset"
))
port
=
CONSOLE_OFFSET_PORT
;
else
if
(
!
strcmp
(
buffer
,
"azel"
))
port
=
CONSOLE_AZEL_PORT
;
else
if
(
!
strcmp
(
buffer
,
"manual"
))
port
=
CONSOLE_MANUAL_CMD_PORT
;
alarm
(
10
);
fd
=
tcp_connect
(
host
,
port
);
if
(
fd
>=
0
)
{
ioctl
(
fd
,
FIONBIO
,
&
(
int
){
0
});
while
(
fgets
(
buffer
,
sizeof
(
buffer
),
stdin
))
write
(
fd
,
buffer
,
strlen
(
buffer
));
write
(
fd
,
"
\n
"
,
1
);
fsync
(
fd
);
printf
(
"Content-type: text/plain
\n
"
);
printf
(
"Cache-Control: no-cache
\n
"
);
printf
(
"Pragma: no-cache
\n
"
);
printf
(
"
\n
"
);
printf
(
"done
\n
"
);
}
else
{
printf
(
"Content-type: text/plain
\n
"
);
printf
(
"Cache-Control: no-cache
\n
"
);
printf
(
"Pragma: no-cache
\n
"
);
printf
(
"
\n
"
);
sleep
(
1
);
printf
(
"failed
\n
"
);
printf
(
"No response from %s:%d
\n
"
,
host
,
port
);
}
return
0
;
}
console/console/console_azel.c
View file @
1cee7e77
...
...
@@ -183,14 +183,23 @@ int main(int argc, char **argv)
command_host
=
argv
[
argc
-
1
];
}
sp_command_az
=
setpoint_command_init
(
command_host
,
command_port
,
az_command_spg
,
"console/azel"
);
sp_command_el
=
setpoint_command_init
(
command_host
,
command_port
,
el_command_spg
,
"console/azel"
);
if
(
!
sp_command_az
||
!
sp_command_el
)
{
fprintf
(
stderr
,
"Setpoint generator(s) not found
\n
"
);
exit
(
-
1
);
}
do
{
sp_command_az
=
setpoint_command_init
(
command_host
,
command_port
,
az_command_spg
,
"console/azel"
);
if
(
!
sp_command_az
)
{
printf
(
"Could not open connection for az commands
\n
"
);
sleep
(
1
);
}
}
while
(
!
sp_command_az
);
do
{
sp_command_el
=
setpoint_command_init
(
command_host
,
command_port
,
el_command_spg
,
"console/azel"
);
if
(
!
sp_command_el
)
{
printf
(
"Could not open connection for el commands
\n
"
);
sleep
(
1
);
}
}
while
(
!
sp_command_el
);
fd_cmd
=
tcp_listen
(
cmd_port
,
0
,
100
);
if
(
fd_cmd
<
0
)
{
...
...
console/console/console_easycomm.c
View file @
1cee7e77
...
...
@@ -32,9 +32,9 @@
#include
<errno.h>
#include
<signal.h>
#include
"
tcp_connect.h
"
#include
"
tcp_listen.h
"
#include
"
config.h
"
#include
<
tcp_connect.h
>
#include
<
tcp_listen.h
>
#include
<
config.h
>
#include
"setpoint.h"
...
...
console/console/console_httptrace.c
View file @
1cee7e77
...
...
@@ -26,7 +26,7 @@
#include
<string.h>
#include
<math.h>
#include
<time.h>
#include
"
tcp_connect.h
"
#include
<
tcp_connect.h
>
typedef
union
{
float
f
;
...
...
console/console/console_idle.c
View file @
1cee7e77
...
...
@@ -48,14 +48,22 @@ int main(int argc, char **argv)
command_host
=
argv
[
1
];
}
sp_command_az
=
setpoint_command_init
(
command_host
,
command_port
,
az_command_spg
,
"console/idle"
);
sp_command_el
=
setpoint_command_init
(
command_host
,
command_port
,
el_command_spg
,
"console/idle"
);
if
(
!
sp_command_az
||
!
sp_command_el
)
{
fprintf
(
stderr
,
"Setpoint generator(s) not found
\n
"
);
exit
(
-
1
);
}
do
{
sp_command_az
=
setpoint_command_init
(
command_host
,
command_port
,
az_command_spg
,
"console/idle"
);
if
(
!
sp_command_az
)
{
printf
(
"Could not open connection for az commands
\n
"
);
sleep
(
1
);
}
}
while
(
!
sp_command_az
);
do
{
sp_command_el
=
setpoint_command_init
(
command_host
,
command_port
,
el_command_spg
,
"console/idle"
);
if
(
!
sp_command_el
)
{
printf
(
"Could not open connection for el commands
\n
"
);
sleep
(
1
);
}
}
while
(
!
sp_command_el
);
while
(
1
)
{
...
...
console/console/console_j2000tracer.c
View file @
1cee7e77
...
...
@@ -36,9 +36,9 @@
#include
<sys/ioctl.h>
#include
<errno.h>
#include
"
libnova/transform.h
"
#include
"
libnova/julian_day.h
"
#include
"
libnova/utility.h
"
#include
<
libnova/transform.h
>
#include
<
libnova/julian_day.h
>
#include
<
libnova/utility.h
>
#include
"setpoint.h"
#include
"tcp_connect.h"
...
...
console/console/console_j2000tracker.c
View file @
1cee7e77
/*
Command generator for J2000.0 positions
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008, 2011
Copyright Stichting C.A. Muller Radioastronomiestation, 2008, 2011
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008, 2011
, 2013
Copyright Stichting C.A. Muller Radioastronomiestation, 2008, 2011
, 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -37,12 +37,12 @@
#include
<errno.h>
#include
<stdbool.h>
#include
"
libnova/transform.h
"
#include
"
libnova/julian_day.h
"
#include
"
libnova/utility.h
"
#include
"
libnova/aberration.h
"
#include
"
libnova/precession.h
"
#include
"
libnova/refraction.h
"
#include
<
libnova/transform.h
>
#include
<
libnova/julian_day.h
>
#include
<
libnova/utility.h
>
#include
<
libnova/aberration.h
>
#include
<
libnova/precession.h
>
#include
<
libnova/refraction.h
>
#include
"setpoint.h"
#include
"tcp_connect.h"
...
...
@@ -66,6 +66,12 @@ char *el_command_spg = "Elevation_Setpoint";
char
*
az_trace_name
=
"Azimuth_Position"
;
char
*
el_trace_name
=
"Elevation_Position"
;
static
bool
tracking_command_send_p180
=
false
;
static
bool
tracking_command_last_az_valid
=
false
;
static
float
tracking_command_last_az
=
0
;
bool
tracking_enabled
=
false
;
bool
refraction_enable
=
false
;
bool
dt_model_enable
=
true
;
...
...
@@ -75,6 +81,7 @@ struct compensation_switch {
};
struct
compensation_switch
compensation_switches
[]
=
{
{
"enabled"
,
&
tracking_enabled
},
{
"refraction"
,
&
refraction_enable
},
{
"dt_model"
,
&
dt_model_enable
},
{
NULL
,
NULL
}
...
...
@@ -232,6 +239,7 @@ void fdset_cmd_clients(fd_set *fdset_rx, int *high)
void
handle_cmd
(
struct
cmd_client
*
cmd
)
{
char
*
ara
,
*
adec
,
*
switches
,
*
ptr
;
double
oldra
,
olddec
;
ara
=
strtok_r
(
cmd
->
buffer
,
"
\t
"
,
&
ptr
);
adec
=
strtok_r
(
NULL
,
"
\t
"
,
&
ptr
);
...
...
@@ -245,9 +253,14 @@ void handle_cmd(struct cmd_client *cmd)
adec
[
strlen
(
adec
)
-
1
]
=
0
;
a2coord
(
ara
,
adec
,
&
track_hms
,
&
track_dms
);
oldra
=
object
.
ra
;
olddec
=
object
.
dec
;
object
.
ra
=
ln_hms_to_deg
(
&
track_hms
);
object
.
dec
=
ln_dms_to_deg
(
&
track_dms
);
if
(
oldra
!=
object
.
ra
||
olddec
!=
object
.
dec
)
tracking_command_last_az_valid
=
false
;
if
(
switches
)
{
char
*
name
,
*
val
;
int
i
;
...
...
@@ -380,11 +393,14 @@ void output(void)
hrz
.
alt
-=
alt_adj
;
}
/* libnova can't handle anything above 90.0 */
if
(
hrz
.
alt
>
90
.
0
)
hrz
.
alt
=
90
.
0
;
ln_get_equ_from_hrz
(
&
hrz
,
&
dwingeloo_pos
,
JD
,
&
equ_pos_prec
);
/* Calculate inverse precession */
ln_get_equ_prec2
(
&
equ_pos_prec
,
JD
,
JD2000
,
&
equ_pos_aber
);
/* qqq MR: to be added again, for modified libnova */
/*ln_get_equ_mean_from_aber(&equ_pos_aber, JD, &equ_pos);*/
ln_get_equ_mean_from_aber
(
&
equ_pos_aber
,
JD
,
&
equ_pos
);
ln_deg_to_hms
(
equ_pos
.
ra
,
&
hms
);
ln_deg_to_dms
(
equ_pos
.
dec
,
&
dms
);
...
...
@@ -479,15 +495,23 @@ int main(int argc, char **argv)
ln_deg_to_hms
(
object
.
ra
,
&
track_hms
);
ln_deg_to_dms
(
object
.
dec
,
&
track_dms
);
sp_command_az
=
setpoint_command_init
(
command_host
,
command_port
,
az_command_spg
,
"console/j2000tracker"
);
sp_command_el
=
setpoint_command_init
(
command_host
,
command_port
,
el_command_spg
,
"console/j2000tracker"
);
if
(
!
sp_command_az
||
!
sp_command_el
)
{
fprintf
(
stderr
,
"Setpoint generator(s) not found
\n
"
);
exit
(
-
1
);
}
do
{
sp_command_az
=
setpoint_command_init
(
command_host
,
command_port
,
az_command_spg
,
"console/j2000tracker"
);
if
(
!
sp_command_az
)
{
printf
(
"Could not open connection for az commands
\n
"
);
sleep
(
1
);
}
}
while
(
!
sp_command_az
);
do
{