Bi-monthly release with minor bug fixes and improvements
import sys, time, logging
import PyIndi
import numpy as np
exp_time=sys.argv[1]
name=sys.argv[2]
class IndiClient(PyIndi.BaseClient):
device = None
def __init__(self):
super(IndiClient, self).__init__()
self.logger = logging.getLogger('PyQtIndi.IndiClient')
self.logger.info('creating an instance of PyQtIndi.IndiClient')
def newDevice(self, d):
self.logger.info("new device " + d.getDeviceName())
if d.getDeviceName() == "Atik 383L+ CCD":
print ("found Atik 383L+ CCD")
self.logger.info("Atik 383L+ CCD")
# save reference to the device in member variable
self.device = d
'''
if d.getDeviceName() == "ZWO CCD ASI120MC":
print ("found ZWO CCD ASI120MC")
self.logger.info("ZWO CCD ASI120MC")
# save reference to the device in member variable
self.device = d
'''
def newProperty(self, p):
self.logger.info("new property "+ p.getName() + " for device "+ p.getDeviceName())
if self.device is not None and p.getName() == "CONNECTION" and p.getDeviceName() == self.device.getDeviceName():
self.logger.info("Got property CONNECTION for CCD Simulator!")
# connect to device
self.connectDevice(self.device.getDeviceName())
# set BLOB mode to BLOB_ALSO
self.setBLOBMode(1, self.device.getDeviceName(), None)
if p.getName() == "CCD_EXPOSURE":
# take first exposure
self.takeExposure()
def removeProperty(self, p):
self.logger.info("remove property "+ p.getName() + " for device "+ p.getDeviceName())
def newBLOB(self, bp):
#self.logger.info("new BLOB "+ bp.name)
# get image data
img = bp.getblobdata()
import io
# write image data to StringIO buffer
blobfile = io.BytesIO(img)
# open a file and save buffer to disk
with open("/home/user/Desktop/"+name+".fit", "wb") as f:
f.write(blobfile.getvalue())
# start new exposure for timelapse images!
# self.takeExposure()
# disconnect from server
self.disconnectServer()
def newSwitch(self, svp):
self.logger.info ("new Switch "+ svp.name + " for device "+ svp.device)
def newNumber(self, nvp):
self.logger.info("new Number "+ nvp.name + " for device "+ nvp.device)
def newText(self, tvp):
self.logger.info("new Text "+ tvp.name + " for device "+ tvp.device)
def newLight(self, lvp):
self.logger.info("new Light "+ lvp.name + " for device "+ lvp.device)
def newMessage(self, d, m):
#self.logger.info("new Message "+ d.messageQueue(m))
pass
def serverConnected(self):
print("Server connected ("+self.getHost()+":"+str(self.getPort())+")")
def serverDisconnected(self, code):
self.logger.info("Server disconnected (exit code = "+str(code)+","+str(self.getHost())+":"+str(self.getPort())+")")
def takeExposure(self):
self.logger.info(">>>>>>>>")
#get current exposure time
exp = self.device.getNumber("CCD_EXPOSURE")
exp[0].value = np.float(exp_time)
# send new exposure time to server/device
self.sendNewNumber(exp)
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
# instantiate the client
indiclient=IndiClient()
# set indi server localhost and port 7624
indiclient.setServer("localhost",7624)
# connect to indi server
print("Connecting to indiserver")
if (not(indiclient.connectServer())):
print("No indiserver running on "+indiclient.getHost()+":"+str(indiclient.getPort())+" - Try to run")
print(" indiserver indi_simulator_telescope indi_simulator_ccd")
sys.exit(1)
# start endless loop, client works asynchron in background
while True:
time.sleep(1)
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
def newProperty(self, p):
self.logger.info("new property "+ p.getName() + " for device "+ p.getDeviceName())
if self.device is not None and p.getName() == "CONNECTION" and p.getDeviceName() == self.device.getDeviceName():
self.logger.info("Got property CONNECTION for CCD Simulator!")
# connect to device
self.connectDevice(self.device.getDeviceName())
# set BLOB mode to BLOB_ALSO
self.setBLOBMode(1, self.device.getDeviceName(), None)
if p.getName() == "CCD_TEMPERATURE":
temp = self.device.getNumber("CCD_TEMPERATURE")
print(temp[0].value)
self.disconnectServer()
def newProperty(self, p):
self.logger.info("new property "+ p.getName() + " for device "+ p.getDeviceName())
if self.device is not None and p.getName() == "CONNECTION" and p.getDeviceName() == self.device.getDeviceName():
self.logger.info("Got property CONNECTION for CCD Simulator!")
# connect to device
self.connectDevice(self.device.getDeviceName())
# set BLOB mode to BLOB_ALSO
self.setBLOBMode(1, self.device.getDeviceName(), None)
if p.getName() == "CCD_TEMPERATURE":
temp = self.device.getNumber("CCD_TEMPERATURE")
temp[0].value=np.float(1) ### new temperature to reach
self.sendNewNumber(temp)
self.disconnectServer()
Please Log in or Create an account to join the conversation.