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

Initial commit of Harm's work

parents
import socket
def create_socket(host, port):
s = None
for res in socket.getaddrinfo(host, port,\
socket.AF_UNSPEC,\
socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
try:
s = socket.socket(af, socktype, proto)
except socket.error, msg:
s = None
continue
try:
s.connect(sa)
except socket.error, msg:
s.close()
s = None
continue
break
return s
class telescope():
def __init__(self, lat, long, alt,\
listenOnly = True, connect = False,\
RDPORT = 11030, STPORT = 11031, HOST = 'console'):
self._lat = lat
self._long = long
self._alt = alt
self._connect = connect
if connect:
self._readsocket = create_socket(HOST, RDPORT)
if self._readsocket == None:
print "Failed to create read connection"
elif not(listenOnly):
self._setsocket = create_socket(HOST, STPORT)
if self._setsocket == None:
print "Failed to create set socket"
else:
self._setsocket = None
else:
self._readsocket = None
self._setsocket = None
def lat(self):
return self._lat
def long(self):
return self._long
def alt(self):
return self._alt
def readPos(self):
if self._readsocket != None:
return self._readsocket.recv(1024)
else:
return None
def setPosRADec(self, RA, Dec):
if self._setsocket:
self._setsocket.send(str(RA)+" "+str(Dec)+"\n")
# The remote host
# Port for receiving setpoint position,
# current position in Ra, Dec, and UT Unix time in format
# "xxhxxmxx.x xxxdxxmxx.xs xxhxxmxx.x xxxdxxmxx.xs xxxxxxxxx"
# Port for setting setpoint position,
# new position in Ra, Dec
# "xxhxxmxx.x xxxdxxmxx.xs
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