Commit 935b6f32 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Check that there is one instance

parent 77df4636
......@@ -16,12 +16,16 @@ config.readfp(open(os.path.join(os.path.dirname(__file__), 'telescope.ini')))
logging.basicConfig(level=logging.DEBUG)
_telescope__num_instances = 0
class telescope():
def __init__(self, setmode=None, consoleHost=None, trace2portHost=None):
'''
Initializes a telescope instance. The mode for writing can be
'J2000' or 'AZEL'.
'''
global __num_instances
if setmode not in ('J2000', 'AZEL', None):
raise ValueError("Mode must be None, 'J2000' or 'AZEL', not " + setmode)
self.setmode = setmode
......@@ -44,6 +48,11 @@ class telescope():
self.speed_az = None
self.speed_el = None
__num_instances += 1
if __num_instances != 1:
raise RuntimeError("Do not make more than one telescope instance.")
self._outsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if self.setmode == 'J2000':
try:
......
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