def expose(self, exptime=1.0, exptype=1, expmeter=None): # imager = self.si_imager # """ host = self.ip port = self.camera_port client = SIClient (host, port) self.logger.info("Connected to SI client") imager = Imager(client) self.logger.info("Connected to SI imager") # """ self.si_imager = imager self.si_imager.nexp = 1 # number of exposures self.si_imager.texp = exptime # exposure time, float number self.si_imager.nome = "image" # file name to be saved if exptype == 0: self.si_imager.dark = True else: self.si_imager.dark = False self.si_imager.frametransfer = False # frame transfer? self.si_imager.getpars = False # Get camera parameters and print on the screen # expose until exptime or expmeter >= flux t0 = datetime.datetime.utcnow() elapsedtime = 0.0 flux = 0.0 if expmeter <> None: #S reset the exposure meter self.reset_expmeter_total() #S begin the imaging thread thread = threading.Thread(target=self.si_imager.do) thread.start() while elapsedtime < exptime: #S we are going to query the expmeter total every second #S probably could be finer resolution time.sleep(1.0) elapsedtime = (datetime.datetime.utcnow()-t0).total_seconds() flux = self.get_expmeter_total() self.logger.info("flux = " + str(flux)) if expmeter < flux: self.logger.info('got to flux of '+str(flux)+', greater than expmeter: '+str(expmeter)) self.si_imager.interrupt() #imager.retrieve_image() break #S this is on a level outside of the while for the elapsed time as the imager.do thread is #S is still running. e.g., we still want to wait whether the elapsed time has gone through or #S the expmeter has triggered the interrupt. thread.join(60) # time.sleep(25) #S I don't know if this is true.. i think if we terminate it still might leave the imager.do thread alive.. #TODO, or did you test this? if thread.isAlive(): self.logger.error("SI imaging thread timed out") return False else: self.si_imager.do() #client.disconnect() return self.save_image(self.file_name)
def connect_si_imager(self): client = SIClient(self.ip, self.camera_port) self.logger.info("Connected to SI client") imager = Imager(client) self.logger.info("Connected to SI imager") self.si_imager = imager
def si_imager_connect(self): host = self.ip port = self.camera_port client = SIClient(host, port) self.logger.info("Connected to SI client") imager = Imager(client) self.logger.info("Connected to SI imager") return imager
def initialize(self): client = SIClient(options.host, options.port) self.imager = Imager(client)
def initialize(self): host = 'localhost' port = 2055 client = SIClient(host, port) self.imager = Imager(client)
if __name__ == "__main__": import sys import time import os import socket from si.client import SIClient from si.imager import Imager host = "localhost" port = 2055 client = SIClient (host, port) imager = Imager (client) imager.nexp = 1 # number of exposures imager.texp = 1.0 # exposure time, float number imager.nome = "image" # file name to be saved imager.dark = False # dark frame? imager.frametransfer = False # frame transfer? imager.getpars = False # Get camera parameters and print on the screen #t0 = time.time () try: ret = "" shutter = "" if imager.dark: