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
5d3ff42f
Commit
5d3ff42f
authored
May 31, 2022
by
Tammo Jan Dijkema
Browse files
Add model
parent
f700c159
Changes
2
Hide whitespace changes
Inline
Side-by-side
telescope.ini
View file @
5d3ff42f
...
...
@@ -2,6 +2,7 @@
HostName:
consoledemo.dmz.camras.nl
Port_Read_Status
:
11020
Port_Read_J2000
:
11030
Port_Read_Model
:
11090
Port_Write_J2000
:
11031
Port_Write_AzEl
:
11041
Port_Write_Offset:
11011
...
...
telescope.py
View file @
5d3ff42f
...
...
@@ -119,6 +119,12 @@ class Telescope:
thread_read_status
.
daemon
=
True
thread_read_status
.
start
()
self
.
_event_model
=
threading
.
Event
()
thread_read_model
=
threading
.
Thread
(
target
=
self
.
_readmodel
,
args
=
(
consoleHost
,
config
.
getint
(
'Console'
,
'Port_Read_Model'
)))
thread_read_model
.
daemon
=
True
thread_read_model
.
start
()
def
_readj2000
(
self
,
consoleHost
,
j2000_read_port
):
"""
Poll the socket with the J2000 info, store its values in class members
...
...
@@ -152,9 +158,10 @@ class Telescope:
# Read the flags, they look like "enabled=0,refraction=1,dt_model=0"
switches
=
[
kv
.
split
(
"="
)
for
kv
in
vals
[
5
].
split
(
","
)]
self
.
tracking_enabled
=
bool
(
int
(
switches
[
0
][
1
]))
self
.
refraction_enabled
=
bool
(
int
(
switches
[
1
][
1
]))
self
.
model_enabled
=
bool
(
int
(
switches
[
2
][
1
]))
if
self
.
tracker
==
"console/j2000tracker"
:
self
.
tracking_enabled
=
bool
(
int
(
switches
[
0
][
1
]))
self
.
refraction_enabled
=
bool
(
int
(
switches
[
1
][
1
]))
self
.
model_enabled
=
bool
(
int
(
switches
[
2
][
1
]))
self
.
_event_j2000
.
set
()
...
...
@@ -208,7 +215,7 @@ class Telescope:
readable
,
writable
,
exceptional
=
select
.
select
(
[
statussocket
],
[],
[])
if
len
(
exceptional
)
>
0
:
raise
IOError
(
"Error with
trace
read socket"
)
raise
IOError
(
"Error with
status
read socket"
)
msg
=
readable
[
0
].
recv
(
4096
).
decode
(
"UTF-8"
)
vals
=
msg
.
strip
().
split
()
self
.
tracker
=
vals
[
0
]
...
...
@@ -216,6 +223,29 @@ class Telescope:
self
.
offset_el
=
(
float
(
vals
[
2
])
*
u
.
rad
).
to
(
u
.
deg
)
self
.
_event_status
.
set
()
def
_readmodel
(
self
,
host
,
port
):
"""
Poll the socket with the model, store the values in class members
:param host: Hostname
:param port: Port at which the model is running
:return: None
"""
try
:
modelsocket
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
modelsocket
.
connect
((
host
,
port
))
except
socket
.
error
:
raise
IOError
(
"Cannot connect to model server "
+
host
+
" at port "
+
str
(
port
))
while
True
:
readable
,
writable
,
exceptional
=
select
.
select
(
[
modelsocket
],
[],
[])
if
len
(
exceptional
)
>
0
:
raise
IOError
(
"Error with model read socket"
)
msg
=
readable
[
0
].
recv
(
4096
).
decode
(
"UTF-8"
)
vals
=
msg
.
strip
().
split
(
','
)
self
.
model
=
vals
[
0
].
split
(
'='
)[
1
]
self
.
_event_model
.
set
()
def
setRaDec
(
self
,
setpoint
):
"""
Set the J2000 setpoint of the telescope.
...
...
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