Unverified Commit 14966b1a authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Add offset, tracker

parent 3d283bf4
[Console]
HostName: consoledemo.dmz.camras.nl
Port_Read_Status : 11020
Port_Read_J2000 : 11030
Port_Write_J2000 : 11031
Port_Write_AzEl : 11041
......
......@@ -15,7 +15,7 @@ config.read_file(open(os.path.join(os.path.dirname(__file__), 'telescope.ini')))
_telescope__num_instances = 0
__version__ = "1.1.1"
__version__ = "1.2.0"
class Telescope:
......@@ -51,6 +51,9 @@ class Telescope:
self.tracking_enabled = None
self.refraction_enabled = None
self.model_enabled = None
self.tracker = None
self.offset_az = None
self.offset_el = None
_telescope__num_instances += 1
......@@ -95,6 +98,11 @@ class Telescope:
thread_read_traces.daemon = True
thread_read_traces.start()
self._event_status = threading.Event()
thread_read_status = threading.Thread(target=self._readstatus, args=(
consoleHost, config.getint('Console', 'Port_Read_Status')))
thread_read_status.start()
def _readj2000(self, consoleHost, j2000_read_port):
"""
Poll the socket with the J2000 info, store its values in class members
......@@ -103,14 +111,14 @@ class Telescope:
:return: None
"""
try:
self._j2000socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._j2000socket.connect((consoleHost, j2000_read_port))
j2000socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
j2000socket.connect((consoleHost, j2000_read_port))
except socket.error:
raise IOError("Cannot connect to j2000 status server")
while True:
readable, writable, exceptional = select.select(
[self._j2000socket], [], [])
[j2000socket], [], [])
if len(exceptional) > 0:
raise IOError("Error with j2000 read socket")
msg = readable[0].recv(4096).decode("UTF-8")
......@@ -146,14 +154,14 @@ class Telescope:
Poll the socket with the traces, store their values in class members
'''
try:
self._tracesocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._tracesocket.connect((tracehost, traceport))
tracesocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tracesocket.connect((tracehost, traceport))
except socket.error:
raise IOError("Cannot connect to trace2port server")
while True:
readable, writable, exceptional = select.select(
[self._tracesocket], [], [])
[tracesocket], [], [])
if len(exceptional) > 0:
raise IOError("Error with trace read socket")
msg = readable[0].recv(4096).decode("UTF-8")
......@@ -167,6 +175,31 @@ class Telescope:
self.focusbox_pos = float(vals[6])
self._event_traces.set()
def _readstatus(self, host, port):
"""
Poll the socket with the status, store the values in class members
:param host: Hostname
:param port: Port at which the status is running
:return: None
"""
try:
statussocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
statussocket.connect((host, port))
except socket.error:
raise IOError("Cannot connect to status server")
while True:
readable, writable, exceptional = select.select(
[statussocket], [], [])
if len(exceptional) > 0:
raise IOError("Error with trace read socket")
msg = readable[0].recv(4096).decode("UTF-8")
vals = msg.strip().split()
self.tracker = vals[0]
self.offset_az = (float(vals[1]) * u.rad).to(u.deg)
self.offset_el = (float(vals[2]) * u.rad).to(u.deg)
self._event_status.set()
def setRaDec(self, setpoint):
"""
Set the J2000 setpoint of the telescope.
......@@ -293,7 +326,7 @@ class Telescope:
self._event_traces.wait()
return self.setpoint_radec
def waitUntilThere(self, tolerance=0.01 * u.deg):
def waitUntilThere(self, waitForUpdate=True, tolerance=0.01 * u.deg):
"""
Wait until distance to the setpoint gets within tolerance
"""
......@@ -301,7 +334,7 @@ class Telescope:
self.logger.info("Waiting to reach setpoint")
distIsSmall = False
while not distIsSmall:
diff = self.getDistance(waitForUpdate=True)
diff = self.getDistance(waitForUpdate=waitForUpdate)
distIsSmall = abs(self.dist_el) < tolerance and abs(self.dist_az) < tolerance
def waitUntilMoving(self, tolerance=0.01 * u.deg):
......
Markdown is supported
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