class ContinuousShooterThread(QtCore.QThread): """classe para modo manual""" signalAfterShooting = QtCore.pyqtSignal(name="signalAfterShooting") signal_temp = QtCore.pyqtSignal(name="signalTemp") def __init__(self, timeSleep): super(ContinuousShooterThread, self).__init__() self.continuous = True self.s = timeSleep self.ss = SThread() self.ss.started.connect(self.thread_iniciada) self.console = ConsoleThreadOutput() self.count = 0 self.wait_temperature = False self.not_two_dark = True def set_sleep_time(self, t): self.s = t def run(self): self.count = 1 while self.continuous: try: self.signal_temp.emit() if self.wait_temperature: self.ss.start() while self.ss.isRunning(): time.sleep(1) except Exception as e: print(e) time.sleep(self.s) self.signalAfterShooting.emit() def start_continuous_shooter(self): self.continuous = True def stop_continuous_shooter(self): self.wait_temperature = False self.continuous = False self.not_two_dark = False self.console.raise_text("Taking dark photo", 1) self.ss.take_dark() time.sleep(1) self.count = 1 def thread_iniciada(self): if self.count == 1: self.console.raise_text("Taking dark photo", 1) self.ss.take_dark() self.count += 1 self.not_two_dark = False elif self.count != 1: self.console.raise_text("Taking photo N: {}".format(self.count), 1) self.count += 1
class ContinuousShooterThread(QtCore.QThread): signalAfterShooting = QtCore.pyqtSignal(name="signalAfterShooting") def __init__(self, timeSleep): super(ContinuousShooterThread, self).__init__() self.continuous = True self.s = timeSleep self.ss = SThread() self.ss.started.connect(self.thread_iniciada) self.console = ConsoleThreadOutput() self.count = 0 def set_sleep_time(self, t): self.s = t def run(self): self.count = 1 while self.continuous: try: self.ss.start() while self.ss.isRunning(): time.sleep(1) except Exception as e: print(e) time.sleep(self.s) self.signalAfterShooting.emit() def start_continuous_shooter(self): self.continuous = True def stop_continuous_shooter(self): self.count = 1 self.continuous = False def thread_iniciada(self): self.console.raise_text("Taking photo N: {}".format(self.count), 2) self.count += 1
class ContinuousShooterThread(QtCore.QThread): ''' classe para modo manual ''' signalAfterShooting = QtCore.pyqtSignal(name="signalAfterShooting") signal_temp = QtCore.pyqtSignal(name="signalTemp") def __init__(self, timeSleep): super(ContinuousShooterThread, self).__init__() self.continuous = True self.s = timeSleep self.ds = DarkShooterThread(self.s) ''' SThread manda para o Sbigdriver as informações para se tirar a foto em si. ''' self.ss = SThread() self.ss.started.connect(self.thread_iniciada) self.console = ConsoleThreadOutput() self.count = 0 self.wait_temperature = False self.not_two_dark = True self.one_photo = False def set_sleep_time(self, t): self.s = t def run(self): self.count = 1 while self.continuous: if not self.ss.check_connection(): self.console.raise_text("Connection Lost!", 3) time.sleep(1) self.console.raise_text("Attempting Reconnection...", 2) time.sleep(1) status = self.ss.reconnect() while (not status[0] and status[2]) and \ (datetime.now() < datetime.now() + timedelta(seconds=self.s)): continue if status[0] and status[2]: self.console.raise_text("Successfully Reconnected!", 1) time.sleep(1) else: self.console.raise_text("Reconnection Failed. Aborting...", 3) time.sleep(1) self.stop_continuous_shooter() try: self.signal_temp.emit() if self.wait_temperature: self.ss.start() self.ds.start() while self.ss.isRunning(): time.sleep(1) except Exception as e: print(e) # time.sleep(self.s) self.signalAfterShooting.emit() def start_continuous_shooter(self): """ if not self.one_photo: self.shutter_control(True) """ shutter_control(True) self.continuous = True self.ds.continuous = True def stop_continuous_shooter(self): if self.wait_temperature: self.ds.continuous = False self.wait_temperature = False self.continuous = False self.not_two_dark = False shutter_control(False) self.console.raise_text("Taking dark photo", 1) self.ss.take_dark() time.sleep(1) self.count = 1 else: self.ds.continuous = False self.wait_temperature = False self.continuous = False self.not_two_dark = False shutter_control(False) time.sleep(1) self.count = 1 def stop_one_photo(self): self.one_photo = False self.wait_temperature = False self.continuous = False self.count = 1 self.exit() def thread_iniciada(self): if self.one_photo: self.console.raise_text("Taking photo", 1) self.stop_one_photo() elif self.count == 1 and not self.one_photo: self.console.raise_text("Taking dark photo", 1) self.ss.take_dark() self.count += 1 self.not_two_dark = False elif self.count != 1 and not self.one_photo: self.console.raise_text("Taking photo N: {}".format(self.count), 1) self.count += 1 '''
class ContinuousShooterThread(QtCore.QThread): # classe para modo manual signalAfterShooting = QtCore.pyqtSignal(name="signalAfterShooting") signal_temp = QtCore.pyqtSignal(name="signalTemp") def __init__(self, time_sleep): super(ContinuousShooterThread, self).__init__() self.continuous = True # SThread manda para o Sbigdriver as informações para se tirar a foto em si. self.ss = SThread() self.photo_type = self.ss.recebe_argumento self.ss.started.connect(self.thread_iniciada) self.console = ConsoleThreadOutput() self.count = 0 self.wait_temperature = False self.not_two_dark = True self.one_photo = False self.one_photo_shutter_state = None self.select_filter_manual = None self.select_filter_shutter = None def recebe_args(self, select_filter_manual, select_filter_shutter): self.select_filter_manual = select_filter_manual self.select_filter_shutter = select_filter_shutter print("\n\nself.select_filter_shutter") print(self.select_filter_shutter) print("\nself.select_filter_manual") print(self.select_filter_manual) print("\n\n") def run(self): try: self.count = 1 while self.continuous: try: self.signal_temp.emit() if self.wait_temperature: if self.count <= 1 and not self.one_photo: self.console.raise_text("Taking dark photo", 1) self.start_dark_sthread() print("\n\nself.select_filter_shutter") print(self.select_filter_shutter) print("\n\n") if self.select_filter_shutter == "Closed" and self.one_photo: self.ss.recebe_argumento(1) else: self.ss.recebe_argumento(0) if self.one_photo: self.ss.args_one_photo(self.select_filter_manual, self.select_filter_shutter) self.ss.start() if self.one_photo: break while self.ss.isRunning(): time.sleep(1) self.signalAfterShooting.emit() except Exception as e: print(e) time.sleep(1) except Exception as e: print("Exception Run ContinuousShooterThread ->" + str(e)) finally: if not self.one_photo: self.console.raise_text("Taking dark photo", 1) self.start_dark_sthread() self.one_photo = False def start_continuous_shooter(self): self.continuous = True def stop_continuous_shooter(self): self.wait_temperature = False self.continuous = False self.not_two_dark = False # self.console.raise_text("Taking dark photo", 1) self.count = 1 def stop_one_photo(self): self.one_photo = False self.wait_temperature = False self.continuous = False self.count = 1 def thread_iniciada(self): if self.one_photo: self.console.raise_text("Taking photo", 1) self.stop_one_photo() else: self.console.raise_text("Taking photo N: {}".format(self.count), 1) self.count += 1 def start_dark_sthread(self): if not self.one_photo: try: self.ss.recebe_argumento(1) self.ss.start() while self.ss.isRunning(): time.sleep(1) except Exception as e: print("Error start_dark_sthread! {}".format(e)) self.console.raise_text("Error start_dark_sthread! {}".format(e), 3) finally: self.count = 1
class ContinuousShooterThread(QtCore.QThread): ''' classe para modo manual ''' signalAfterShooting = QtCore.pyqtSignal(name="signalAfterShooting") signal_temp = QtCore.pyqtSignal(name="signalTemp") def __init__(self, timeSleep): super(ContinuousShooterThread, self).__init__() self.continuous = True self.s = timeSleep ''' SThread manda para o Sbigdriver as informações para se tirar a foto em si. ''' self.ss = SThread() self.ss.started.connect(self.thread_iniciada) self.console = ConsoleThreadOutput() self.count = 0 self.wait_temperature = False self.not_two_dark = True self.one_photo = False def set_sleep_time(self, t): self.s = t def run(self): self.count = 1 while self.continuous: try: self.signal_temp.emit() if self.wait_temperature: self.ss.start() while self.ss.isRunning(): time.sleep(1) except Exception as e: print(e) time.sleep(self.s) self.signalAfterShooting.emit() def start_continuous_shooter(self): if not self.one_photo: self.shutter_control(True) self.continuous = True def stop_continuous_shooter(self): self.wait_temperature = False self.continuous = False self.not_two_dark = False self.console.raise_text("Taking dark photo", 1) self.shutter_control(False) self.ss.take_dark() time.sleep(1) self.count = 1 # Consertar Shutter Para o onePhoto def stop_one_photo(self): self.one_photo = False self.wait_temperature = False self.continuous = False self.count = 1 def thread_iniciada(self): if self.one_photo: self.console.raise_text("Taking photo", 1) self.stop_one_photo() elif self.count == 1 and not self.one_photo: self.console.raise_text("Taking dark photo", 1) self.ss.take_dark() self.count += 1 self.not_two_dark = False elif self.count != 1 and not self.one_photo: self.console.raise_text("Taking photo N: {}".format(self.count), 1) self.count += 1 def shutter_control(self, cont): try: ser = serial.Serial(serial_ports()[len(serial_ports()) - 1], 9600, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE) if cont is True: self.console.raise_text("Opening Shutter", 1) send = bytes([235, 144, 86, 1, 46]) ser.write(send) # time.sleep(15) else: self.console.raise_text("Closing Shutter", 1) send = bytes([235, 144, 214, 1, 174]) ser.write(send) # time.sleep(15) except Exception: self.console.raise_text("No Serial Equipment!", 3)