-
Notifications
You must be signed in to change notification settings - Fork 0
/
simpleindiclient.py
53 lines (46 loc) · 1.33 KB
/
simpleindiclient.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import PyIndi
import time
import sys
import threading
class IndiClient(PyIndi.BaseClient):
def __init__(self, blobEvent):
super(IndiClient, self).__init__()
self._blobEvent = blobEvent
def newDevice(self, d):
pass
def newProperty(self, p):
pass
def removeProperty(self, p):
pass
def newBLOB(self, bp):
self._blobEvent.set()
pass
def newSwitch(self, svp):
pass
def newNumber(self, nvp):
pass
def newText(self, tvp):
pass
def newLight(self, lvp):
pass
def newMessage(self, d, m):
pass
def serverConnected(self):
pass
def serverDisconnected(self, code):
pass
def indi_connect(indiclient, server_host="localhost", server_port=7624):
assert isinstance(indiclient, IndiClient)
indiclient.setServer(server_host, server_port)
if not indiclient.connectServer():
raise RuntimeError('No indiserver running on {}:{}!'.format(indiclient.getHost(), indiclient.getPort()))
def indi_wait(func, timeout=15, poll_interval=0.5):
time_elapsed = 0.0
result = func()
while not result and time_elapsed < timeout:
time.sleep(poll_interval)
time_elapsed += poll_interval
result = func()
if not result:
raise TimeoutError('Timed out!')
return result