Commit 5d3ff42f authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Add model

parent f700c159
......@@ -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
......
......@@ -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.
......
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