Commit eab6dc01 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Add moon tracker

parent 5d3ff42f
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
HostName: consoledemo.dmz.camras.nl HostName: consoledemo.dmz.camras.nl
Port_Read_Status : 11020 Port_Read_Status : 11020
Port_Read_J2000 : 11030 Port_Read_J2000 : 11030
Port_Read_Moon : 11080
Port_Read_Model : 11090 Port_Read_Model : 11090
Port_Write_J2000 : 11031 Port_Write_J2000 : 11031
Port_Write_AzEl : 11041 Port_Write_AzEl : 11041
......
...@@ -125,6 +125,12 @@ class Telescope: ...@@ -125,6 +125,12 @@ class Telescope:
thread_read_model.daemon = True thread_read_model.daemon = True
thread_read_model.start() 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): def _readj2000(self, consoleHost, j2000_read_port):
""" """
Poll the socket with the J2000 info, store its values in class members Poll the socket with the J2000 info, store its values in class members
...@@ -223,6 +229,34 @@ class Telescope: ...@@ -223,6 +229,34 @@ class Telescope:
self.offset_el = (float(vals[2]) * u.rad).to(u.deg) self.offset_el = (float(vals[2]) * u.rad).to(u.deg)
self._event_status.set() 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): def _readmodel(self, host, port):
""" """
Poll the socket with the model, store the values in class members Poll the socket with the model, store the values in class members
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment