コード例 #1
0
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
コード例 #2
0
ファイル: DarkShooterThread.py プロジェクト: fpsf/ccd1.4.0
class DarkShooterThread(QtCore.QThread):
    def __init__(self, timeSleep):
        self.continuous = None
        super(DarkShooterThread, self).__init__()
        self.console = ConsoleThreadOutput()
        self.s = timeSleep
        self.ss = SThread()
        self.settings = SettingsCamera()

    def run(self):
        self.s = int(self.settings.get_camera_settings()[4])
        while self.continuous:
            time.sleep(self.s)
            if self.continuous:
                self.console.raise_text("Taking dark photo", 1)
                self.ss.take_dark()
コード例 #3
0
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

    '''
コード例 #4
0
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)