Commit 46c42632 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Fix Python3, fix bug with waitUntilThere, rename some members

parent bccf2a5e
......@@ -82,7 +82,7 @@ class telescope():
[self._j2000socket], [], [])
if len(exceptional)>0:
raise Exception("Error with j2000 read socket")
msg = readable[0].recv(4096)
msg = readable[0].recv(4096).decode("UTF-8")
vals = msg.strip().split()
(ra, dec) = (vals[2], vals[3])
self.radec = SkyCoord(ra, dec, frame='icrs')
......@@ -105,7 +105,7 @@ class telescope():
[self._tracesocket], [], [])
if len(exceptional)>0:
raise Exception("Error with trace read socket")
msg = readable[0].recv(4096)
msg = readable[0].recv(4096).decode("UTF-8")
vals = msg.strip().split()
self.az = (float(vals[0])*u.rad).to(u.deg)
self.el = (float(vals[1])*u.rad).to(u.deg)
......@@ -211,6 +211,17 @@ class telescope():
self._event_traces.wait()
return self.radec
def getSetpoint_RaDec(self, waitForUpdate=False):
'''
Get current Ra/Dec setpoint. If waitForUpdate=True, it waits for the
next signal from the socket.
Returns an astropy SkyCoord
'''
if waitForUpdate or self.radec is None:
self._event_traces.clear()
self._event_traces.wait()
return self.setpoint_radec
def waitUntilThere(self):
'''
Wait until distance to the setpoint gets within tolerance
......@@ -220,7 +231,7 @@ class telescope():
distIsSmall = False
while not distIsSmall:
diff = self.getDistance(waitForUpdate=True)
distIsSmall = abs(self.dist_el)<0.01*u.deg and abs(self.dist_az)>0.01*u.deg
distIsSmall = abs(self.dist_el)<0.01*u.deg and abs(self.dist_az)<0.01*u.deg
def waitUntilMoving(self):
'''
......@@ -234,16 +245,16 @@ class telescope():
def getJ2000(self):
'''
Generates a list of dicts with 'current_position_j2000' and
'setpoint_j2000', containing radec and setpoint_radec, at whichever
Generates dicts with 'radec' and 'setpoint_radec',
containing radec and setpoint_radec, at whichever
speed the console is outputting them (probably once a second).
'''
self._event_traces.clear()
while True:
self._event_j2000.wait()
self._event_j2000.clear()
yield({'position_j2000': self.radec,
'setpoint_j2000': self.setpoint_radec})
yield({'radec': self.radec,
'setpoint_radec': self.setpoint_radec})
def getTraces(self):
'''
......
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