Exemplo n.º 1
0
 def customInit(self):
     self.initButton.setEnabled(False)
     if not self.devpool.do(self.type, self.name, 'isOpen'):
         showQuickMessage(5000, 'NotOpen', 'device is not open! Please reconnect',
                          QtWidgets.QMessageBox.Warning, parent=self)
         self.initButton.setEnabled(True)
         return
     try:
         self.modeComboBox.setItems(validateRet(self.devpool.doSafely(self.type, self.name, 'getModeNameTable'),
                                                '无法获取光快门模式表', dict))
         self.modeComboBox.setCurrentIndex(self.modeComboBox.findText(
             self.devpool.doSafely(self.type, self.name, 'getModeName')))
         self.opentimeSpinbox.setValue(self.devpool.doSafely(
             self.type, self.name, 'getOpenDuration'))
         self.shuttimeSpinbox.setValue(self.devpool.doSafely(
             self.type, self.name, 'getShutDuration'))
         self.countSpinbox.setValue(self.devpool.doSafely(
             self.type, self.name, 'getRepeatCount'))
     except:
         self.initButton.setEnabled(True)
         return
     self.setButton.setEnabled(True)
     if not self._updateThread:
         self._updateThread = NonstopDo(self._updateFun, 200)
         self._updateThread.start(QtCore.QThread.LowPriority)
     else:
         pass
Exemplo n.º 2
0
 def _outRangeFun(self):
     self._info['range'] = self.devpool.do(self.type, self.name, 'getRange')
     self.rangeInfoLine.setText(str(self._info['range']))
     showQuickMessage(5000,
                      'OutofRange',
                      "{}超出范围,请输入正确值.".format(self.name),
                      QtWidgets.QMessageBox.Warning,
                      parent=self)
Exemplo n.º 3
0
 def _systemErrorFun(self):
     self.devpool.do(self.type, self.name, 'close')
     if self._updateThread.isRunning():
         self._updateThread.stopSafely()
     showQuickMessage(5000,
                      'SystemError',
                      "{}系统异常,请排除错误重新连接.".format(self.name),
                      QtWidgets.QMessageBox.Warning,
                      parent=self)
     self.initButton.setEnabled(True)
Exemplo n.º 4
0
 def _errorFun(self, info):
     self.devpool.do(self.type, self.name, 'close')
     if self._updateThread.isRunning():
         self._updateThread.stopSafely()
     showQuickMessage(5000,
                      'Error',
                      str(info),
                      QtWidgets.QMessageBox.Critical,
                      parent=self)
     self.initButton.setEnabled(True)
Exemplo n.º 5
0
 def customEnable(self, x):
     try:
         if x:
             self.devpool.doSafely(self.type, self.name, 'enable')
         else:
             self.devpool.doSafely(self.type, self.name, 'disable')
     except Exception as e:
         self.devpool.do(self.type, self.name, 'close')
         self.initButton.setEnabled(True)
         showQuickMessage(5000, 'Error', str(
             e), QtWidgets.QMessageBox.Critical, parent=self)
Exemplo n.º 6
0
 def customSave(self):
     if not isinstance(self._currImg, np.ndarray):
         showQuickMessage(5000,
                          'Error',
                          "camera not open",
                          QtWidgets.QMessageBox.Warning,
                          parent=self)
         return
     self.customStop()
     filename, ok = QtWidgets.QFileDialog.getSaveFileName(
         self, 'save points to file', os.getcwd(), '*.jpg,*.tiff')
     if ok:
         im = Image.fromarray(self._currImg)
         im.save(filename)
Exemplo n.º 7
0
 def customSet(self):
     try:
         mode = int(self.modeComboBox.value())
         self.devpool.doSafely(self.type, self.name, 'setMode', mode)
         opentime = float(self.opentimeSpinbox.value())
         self.devpool.doSafely(self.type, self.name,
                               'setOpenDuration', opentime)
         shuttime = float(self.shuttimeSpinbox.value())
         self.devpool.doSafely(self.type, self.name,
                               'setShutDuration', shuttime)
     except Exception as e:
         self._updateThread = None
         self.devpool.do(self.type, self.name, 'close')
         self.initButton.setEnabled(True)
         showQuickMessage(5000, 'Error', str(
             e), QtWidgets.QMessageBox.Critical, parent=self)
Exemplo n.º 8
0
 def customInit(self):
     self.initButton.setEnabled(False)
     if not self.devpool.do(self.type, self.name, 'isOpen'):
         showQuickMessage(5000,
                          'NotOpen',
                          'device is not open! Please reconnect',
                          QtWidgets.QMessageBox.Warning,
                          parent=self)
         self.initButton.setEnabled(True)
         return
     self.initInfo()
     for i in range(self._info['numaxes']):
         self.axesSpinBox[i].setValue(float(self._info['startPosition'][i]))
         self.axesSpinBox[i].setEnabled(True)
         self._lastMove[i] = float(self._info['startPosition'][i])
     self.rangeInfoLine.setText(str(self._info['range']))
     self.startPositionInfoLine.setText(str(self._info['startPosition']))
     self.setButtonEnabled(True)
     self._updateErrorSignalEmittedTimes = 0
     self._updateThread.restart(QtCore.QThread.LowPriority)
Exemplo n.º 9
0
    def sendEmail(self):
        successFlag = True

        subject = self.subject()
        report = self.report()
        toemail = self.toemail()
        server = self.server()
        port = self.port()
        fromemail = self.fromemail()
        password = self.password()
        self.progressBar.setValue(2)

        if successFlag:
            try:
                message = MIMEText(report, 'plain', 'utf-8')
                message['From'] = Header(formataddr(('Reporter', fromemail)), 'utf-8')   # 发送者
                message['To'] =  Header(formataddr(('Handler', toemail)), 'utf-8')    # 接收者
                message['Subject'] = Header(subject, 'utf-8')
                self.progressBar.setValue(4)
            except:
                showQuickMessage(title='error', text='请输入合法的邮箱', icon=QMessageBox.Critical, parent=self)
                successFlag = False

        if successFlag:
            try:
                with smtplib.SMTP() as smtpObj:
                    smtpObj.connect(server, port)
                    smtpObj.login(fromemail, password)
                    self.progressBar.setValue(6)
                    smtpObj.sendmail(fromemail, [toemail], message.as_string())
                    self.progressBar.setValue(10)
                showQuickMessage(title='info', text="邮件发送完成", icon=QMessageBox.Information, parent=self)
            except:
                showQuickMessage(title='error', 
                    text=textwrap.dedent("""
                            邮件发送失败,请检查
                            1)网络是否连接。
                            2)邮箱账号密码是否输入正确
                            3)邮箱是否与服务器对应"""),
                    icon=QMessageBox.Critical,
                    parent=self)
                successFlag = False

        if successFlag:
            self.emailSentSignal.emit()
        
        self.progressBar.reset()
Exemplo n.º 10
0
 def _readErrorFun(self, name):
     showQuickMessage(5000,
                      'Error',
                      "can't read image from camera {}!".format(name),
                      QtWidgets.QMessageBox.Warning,
                      parent=self)