Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tammo Jan Dijkema
telescope
Commits
eab6dc01
Commit
eab6dc01
authored
May 31, 2022
by
Tammo Jan Dijkema
Browse files
Add moon tracker
parent
5d3ff42f
Changes
2
Hide whitespace changes
Inline
Side-by-side
telescope.ini
View file @
eab6dc01
...
...
@@ -2,6 +2,7 @@
HostName:
consoledemo.dmz.camras.nl
Port_Read_Status
:
11020
Port_Read_J2000
:
11030
Port_Read_Moon
:
11080
Port_Read_Model
:
11090
Port_Write_J2000
:
11031
Port_Write_AzEl
:
11041
...
...
telescope.py
View file @
eab6dc01
...
...
@@ -125,6 +125,12 @@ class Telescope:
thread_read_model
.
daemon
=
True
thread_read_model
.
start
()
self
.
_event_moon
=
threading
.
Event
()
thread_read_moon
=
threading
.
Thread
(
target
=
self
.
_readmoon
,
args
=
(
consoleHost
,
config
.
getint
(
'Console'
,
'Port_Read_Moon'
)))
thread_read_moon
.
daemon
=
True
thread_read_moon
.
start
()
def
_readj2000
(
self
,
consoleHost
,
j2000_read_port
):
"""
Poll the socket with the J2000 info, store its values in class members
...
...
@@ -223,6 +229,34 @@ class Telescope:
self
.
offset_el
=
(
float
(
vals
[
2
])
*
u
.
rad
).
to
(
u
.
deg
)
self
.
_event_status
.
set
()
def
_readmoon
(
self
,
host
,
port
):
"""
Poll the socket with the moon, store the values in class members
:param host: Hostname
:param port: Port at which the model is running
:return: None
"""
try
:
moonsocket
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
moonsocket
.
connect
((
host
,
port
))
except
socket
.
error
:
raise
IOError
(
"Cannot connect to moon server "
+
host
+
" at port "
+
str
(
port
))
while
True
:
readable
,
writable
,
exceptional
=
select
.
select
(
[
moonsocket
],
[],
[])
if
len
(
exceptional
)
>
0
:
raise
IOError
(
"Error with moon read socket"
)
msg
=
readable
[
0
].
recv
(
4096
).
decode
(
"UTF-8"
)
# Read the flags, they look like "enabled=0,refraction=1,dt_model=0"
switches
=
[
kv
.
split
(
"="
)
for
kv
in
msg
.
strip
().
split
(
","
)]
if
self
.
tracker
==
"console/moontracker"
:
self
.
tracking_enabled
=
bool
(
int
(
switches
[
0
][
1
]))
self
.
model_enabled
=
bool
(
int
(
switches
[
1
][
1
]))
self
.
_event_moon
.
set
()
def
_readmodel
(
self
,
host
,
port
):
"""
Poll the socket with the model, store the values in class members
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment