# debug v8 - local, simulated and real, switch tracking On/OFF view switch and radec. import PyIndi import time import sys def strISState(s): if (s == PyIndi.ISS_OFF): return "Off" else: return "On" def strIPState(s): if (s == PyIndi.IPS_IDLE): return "Idle" elif (s == PyIndi.IPS_OK): return "Ok" elif (s == PyIndi.IPS_BUSY): return "Busy" elif (s == PyIndi.IPS_ALERT): return "Alert" def print_radec(secs): # cycle / show radec for i in range(secs): time.sleep(1) print('radec{}, {}'.format(telescope_radec[0].value,telescope_radec[1].value)) class IndiClient(PyIndi.BaseClient): def __init__(self): super(IndiClient, self).__init__() def newDevice(self, d): device_telescope = d print("New device ", d.getDeviceName()) return def newProperty(self, p): #if (p.getDeviceName() == telescope and p.getName() == "CONNECTION"): print("New property {} {}, for {} ".format(p.getName(), p.getSwitch(), p.getDeviceName())) return def removeProperty(self, p): pass def newBLOB(self, bp): pass def newSwitch(self, svp): a=strISState(svp.s) print('new switch :{} is {} = {} {}'.format(svp.name,svp.label,svp.s,a)) return def newNumber(self, nvp): pass def newText(self, tvp): pass def newLight(self, lvp): pass def newMessage(self, d, m): pass #print("new Message {}".format(d.messageQueue(m))) def serverConnected(self): pass def serverDisconnected(self, code): pass telescope = "Telescope Simulator" #telescope = "SkySensor2000PC" device_telescope = None telescope_connect = None indiclient = IndiClient() #indiclient.setServer("192.168.1.139", 7624) indiclient.setServer("localhost", 7624) if (not (indiclient.connectServer())): print("No indiserver running on " + indiclient.getHost() + ":" + str(indiclient.getPort()) + " - Try to run") print(" indiserver ") sys.exit(1) indiclient.watchDevice(telescope) indiclient.connectServer() device_telescope = None while not (device_telescope): time.sleep(0.5) device_telescope = indiclient.getDevice(telescope) dp = None while not (dp): time.sleep(1) dp = device_telescope.getProperties() for p in dp: print(" > " + p.getName()) telescope_connect = device_telescope.getSwitch("CONNECTION") while not (telescope_connect): time.sleep(0.5) telescope_connect = device_telescope.getSwitch("CONNECTION") status = device_telescope.getSwitch("EQUATORIAL_EOD_COORD") if not (device_telescope.isConnected()): telescope_connect[0].s = PyIndi.ISS_ON # the "CONNECT" switch telescope_connect[1].s = PyIndi.ISS_OFF # the "DISCONNECT" switch indiclient.sendNewSwitch(telescope_connect) # send this new value to the device # switch cycle watch switch and radec while (device_telescope.isConnected()): telescope_radec = device_telescope.getNumber("EQUATORIAL_EOD_COORD") print_radec(2) ts = device_telescope.getSwitch("TELESCOPE_TRACK_STATE") telescope_on_coord_set = device_telescope.getSwitch("ON_COORD_SET") telescope_on_coord_set[0].s = PyIndi.ISS_OFF # TRACK indiclient.sendNewSwitch(telescope_on_coord_set) time.sleep(2) print_radec(5) print('---------------------- switched off') telescope_on_coord_set = device_telescope.getSwitch("ON_COORD_SET") print('tracking is now {}'.format(telescope_on_coord_set[0].s)) telescope_on_coord_set[0].s = PyIndi.ISS_ON # TRACK indiclient.sendNewSwitch(telescope_on_coord_set) time.sleep(2) print_radec(5) print('---------------------- switch on ') telescope_on_coord_set = device_telescope.getSwitch("ON_COORD_SET") print('tracking is {}'.format(telescope_on_coord_set[0].s)) #try TELESCOPE_ABORT_MOTION and TELESCOPE_TRACK_STATE