# -*- coding: utf-8 -*- """ Created on Tue Jul 17 09:44:14 2018 @author: Daniele Antonio Santeramo """ import PyIndi import IndiClient import time from datetime import datetime from datetime import timedelta TIMEOUT = timedelta(seconds=30.0) # indiclient=IndiClient.IndiClient("192.168.0.196",7624) # indiclient.Indiconnect() indiclient=IndiClient.IndiClient("localhost",7624) indiclient.Indiconnect() telescope="Pulsar2" #telescope="Telescope Simulator" device_telescope = indiclient.getDevice(telescope) while not(device_telescope): device_telescope = indiclient.getDevice(telescope) time.sleep(0.2) telescope_connect = device_telescope.getSwitch("CONNECTION") while not(telescope_connect): telescope_connect = device_telescope.getSwitch("CONNECTION") time.sleep(0.2) if not(device_telescope.isConnected()): telescope_connect[0].s = PyIndi.ISS_ON telescope_connect[1].s = PyIndi.ISS_OFF indiclient.sendNewSwitch(telescope_connect) print("TELESCOPE_PARK") unpark_property = device_telescope.getSwitch("TELESCOPE_PARK") init = timedelta(seconds=0.0) while not(unpark_property): if TIMEOUT > init: unpark_property = device_telescope.getSwitch("TELESCOPE_PARK") time.sleep(0.2) init += timedelta(seconds=0.2) else: print('Timeout reachs') sys.exit(1) print(unpark_property[0].name, unpark_property[0].s) print(unpark_property[1].name ,unpark_property[1].s) unpark_property[0].s = PyIndi.ISS_OFF unpark_property[1].s = PyIndi.ISS_ON indiclient.sendNewSwitch(unpark_property) while unpark_property.s == PyIndi.IPS_BUSY: time.sleep(0.2) init = timedelta(seconds=0.0) while unpark_property.s == PyIndi.IPS_BUSY: if TIMEOUT > init: time.sleep(0.2) init += timedelta(seconds=0.2) else: print('Timeout reachs while unparking') sys.exit(1) print(unpark_property[0].name, unpark_property[0].s) print(unpark_property[1].name ,unpark_property[1].s)