コード例 #1
0
    def initialized__(self):
        # Give notify library a reference to the statusbar
        NOTE.statusbar = self.w.statusbar
        if self.desktop_notify:
            NOTE.notify('Welcome', 'This is a test screen for Qtscreen', None,
                        4)
        self.w.button_frame.setEnabled(False)
        self.w.jog_slider.setValue(self.jog_velocity)
        self.w.feed_slider.setValue(100)
        self.w.rapid_slider.setValue(100)

        # add a backgrund image

        bgpath = self.IMAGE_PATH + '/bg_800x600.png'
        self.w.setStyleSheet(
            "#centralwidget { border-image: url(%s) 0 0 0 0 stretch stretch; }"
            % bgpath)
        bgpath = self.IMAGE_PATH + '/frame_bg_blue.png'
        self.w.frame.setStyleSheet(
            "#frame { border-image: url(%s) 0 0 0 0 stretch stretch; }" %
            bgpath)
        bgpath = self.IMAGE_PATH + '/frame_bg_grey.png'
        self.w.frame_2.setStyleSheet(
            "QFrame { border-image: url(%s) 0 0 0 0 stretch stretch; }" %
            bgpath)

        # add overlay to topWidget
        self.w.overlay = FocusOverlay(self.w)
        self.w.overlay.setGeometry(0, 0, 800, 600)
        self.w.overlay.hide()
コード例 #2
0
 def init_focus_overlay(self):
     from qtvcp.widgets.overlay_widget import FocusOverlay
     w = self.QTVCP_INSTANCE_
     w.focusOverlay_ = FocusOverlay(w)
     w.focusOverlay_.hal_init(self.HAL_GCOMP_, self.HAL_NAME_,
                              w.focusOverlay_, w, w.PATHS, self.PREFS_)
コード例 #3
0
 def init_focus_overlay(self):
     from qtvcp.widgets.overlay_widget import FocusOverlay
     w = self.QTVCP_INSTANCE_
     w.focusOverlay_ = FocusOverlay(w)
     w.focusOverlay_.setObjectName('focusOverlay_')
     w.focusOverlay_.hal_init(HAL_NAME='')
コード例 #4
0
    def init_gui(self):
        self.w.setWindowIcon(QIcon("BallScrewControlIcon.png"))
        # настройка цветов диодов (т.к. в дизайнере цвета выставляются с ошибками - одинаковый цвет для color и off_color)
        diodes_redgreen = (self.w.ledPos_Alarm31, )

        for led in diodes_redgreen:
            led.setColor(Qt.green)
            led.setOffColor(Qt.green)
        ini_control_match_dict = {
            'NOM_VEL': (self.w.sldVelocity31, self.w.spnVelocity31),
            'NOM_ACCEL': (self.w.sldAcceleration31, self.w.spnAcceleration31)
        }

        for key, controls in ini_control_match_dict.items():
            print '***controls[0] = ', controls[0]
            print '***controls[1] = ', controls[1]
            controls[0].setMinimum(
                int(
                    float(
                        INFO.INI.findall("BALLSCREWPARAMS", key + '_MIN')[0]) *
                    100))
            controls[0].setMaximum(
                int(
                    float(
                        INFO.INI.findall("BALLSCREWPARAMS", key + '_MAX')[0]) *
                    100))
            controls[0].setValue(
                int(float(INFO.INI.findall("BALLSCREWPARAMS", key)[0]) * 100))
            controls[1].setMinimum(
                float(INFO.INI.findall("BALLSCREWPARAMS", key + '_MIN')[0]))
            controls[1].setMaximum(
                float(INFO.INI.findall("BALLSCREWPARAMS", key + '_MAX')[0]))
            controls[1].setValue(
                float(INFO.INI.findall("BALLSCREWPARAMS", key)[0]))

        self.w.sldVelocity31.valueChanged.connect(
            lambda val: self.w.spnVelocity31.setValue(float(val) / 100.0))
        self.w.spnVelocity31.valueChanged.connect(
            lambda val: self.w.sldVelocity31.setValue(int(val * 100)))
        self.w.sldAcceleration31.valueChanged.connect(
            lambda val: self.w.spnAcceleration31.setValue(float(val) / 100.0))
        self.w.spnAcceleration31.valueChanged.connect(
            lambda val: self.w.sldAcceleration31.setValue(int(val * 100)))

        STATUS.connect('state-estop', lambda w:
                       (self.w.btnDevice_On31.setEnabled(False)))
        STATUS.connect(
            'state-estop-reset',
            lambda w: (
                self.w.btnDevice_On31.setEnabled(not STATUS.machine_is_on()),
                #tempVal=self.w.sldVelocity31.value(),
                self.w.sldVelocity31.setValue(self.w.sldVelocity31.value()),
                self.w.sldVelocity31.valueChanged.emit(self.w.sldVelocity31.
                                                       value()),
                self.w.sldVelocity31.sliderMoved.emit(self.w.sldVelocity31.
                                                      value()),
                self.w.sldVelocity31.sliderReleased.emit(),

                #tempVal=self.w.sldAcceleration31.value(),
                self.w.sldAcceleration31.setValue(self.w.sldAcceleration31.
                                                  value()),
                self.w.sldAcceleration31.valueChanged.emit(
                    self.w.sldAcceleration31.value())))

        STATUS.connect(
            'state-on', lambda s:
            (self.w.btnJog_Minus31.setEnabled(self.w.chkActivation31.isChecked(
            )),
             self.w.btnJog_Plus31.setEnabled(self.w.chkActivation31.isChecked(
             )), self.w.btnLog_Trigger31.setEnabled(True),
             self.w.btnDevice_On31.setEnabled(False),
             self.w.chkActivation31.setEnabled(True)))

        STATUS.connect(
            'state-off', lambda s:
            (self.w.btnJog_Minus31.setEnabled(False),
             self.w.btnJog_Plus31.setEnabled(False),
             self.w.btnLog_Trigger31.setEnabled(False),
             self.w.btnDevice_On31.setEnabled(STATUS.estop_is_clear()),
             self.w.chkActivation31.setEnabled(False)))

        self.w.chkActivation31.stateChanged.connect(
            lambda s: (self.w.btnJog_Minus31.setEnabled(STATUS.machine_is_on(
            ) and self.w.chkActivation31.isChecked()),
                       self.w.btnJog_Plus31.setEnabled(STATUS.machine_is_on(
                       ) and self.w.chkActivation31.isChecked())))

        self.w.sldAcceleration31.hal_pin_scale.set(0.01)
        self.w.sldAcceleration31.hal_pin_f.set(
            self.w.sldAcceleration31.value() * 0.01)

        self.w.sldVelocity31.hal_pin_scale.set(0.01)
        self.w.sldVelocity31.hal_pin_f.set(self.w.sldVelocity31.value() * 0.01)

        #self.hal["sldVelocity31-scale"]=0.01
        #self.hal["sldAcceleration31-scale"]=0.01

        #OLD если задавать пин scale в слайдерах - то они сами пересчитывают value во float
        # self.w.sldVelocity31.valueChanged.connect(
        #     lambda s: self.sldVelocity31float.set(float(self.w.sldVelocity31.value())/100.0))
        # self.w.sldAcceleration31.valueChanged.connect(
        #     lambda s: self.sldAcceleration31float.set(float(self.w.sldAcceleration31.value())/100.0))

        #OLD попытка заставить работать sldVelocity31-scale и sldAcceleration31-scale
        # т.к. если слайдер не двигать, то ldVelocity31-f и dAcceleration31-f не делится на масштаб
        #tempVal=self.w.sldVelocity31.value()
        #self.w.sldVelocity31.setValue(tempVal+10)
        #self.w.sldVelocity31.valueChanged.emit(tempVal+10)
        #self.w.sldVelocity31.sliderMoved.emit(tempVal+10)
        #self.w.sldVelocity31.sliderReleased.emit()
        #
        #tempVal=self.w.sldAcceleration31.value()
        #self.w.sldAcceleration31.setValue(tempVal+0.01)
        #self.w.sldAcceleration31.valueChanged.emit(tempVal)

        #self.w.wgtTestPanel.hide() # убрать панель с тестовым функционалом
        self.w.ledPos_Alarm31.setOffColor(Qt.yellow)

        # убрать панель с тестовым функционалом
        if INFO.INI.findall("BALLSCREWPARAMS", "TESTPANEL"):
            if INFO.INI.findall("BALLSCREWPARAMS",
                                "TESTPANEL")[0].lower() == "true":
                self.w.wgtTestPanel.show()
        else:
            self.w.wgtTestPanel.hide()  # убрать панель с тестовым функционалом

        # оверлей для затемнения окна
        self.w.overlay = FocusOverlay(self.w)
        self.w.overlay.setGeometry(0, 0, self.w.width(), self.w.height())
        self.w.overlay.hide()
        return
コード例 #5
0
 def createWidget(self, parent):
     return FocusOverlay(parent)
コード例 #6
0
    def init_gui(self):
        self.w.setWindowIcon(QIcon("BallScrewControlIcon.png"))
        self.DATETIME0 = QDateTime.currentDateTime()
        self.DATETIME_LAST = QDateTime.currentDateTime()
        self.PAUSE_TIME_MS = 0.0
        self.TRIAL_IS_ON = False
        self.load_ini()
        self.init_led_colors()

        # STATUS.connect('state-on', lambda w: self.w.btnDevice_On32.setEnabled(False))
        # STATUS.connect('state-on', lambda w: self.w.btnDevice_Off32.setEnabled(True))
        # STATUS.connect('state-off', lambda w: self.w.btnDevice_On32.setEnabled(True))
        # STATUS.connect('state-off', lambda w: self.w.btnDevice_Off32.setEnabled(False))
        # STATUS.connect('state-estop-reset', lambda w: self.w.btnDevice_Off32.setEnabled(False))

        #TODO связать с action-сигналом
        STATUS.connect('state-estop', lambda w:
                       (self.w.btnDevice_On32.setEnabled(False)))
        STATUS.connect(
            'state-estop-reset', lambda w:
            (self.w.btnDevice_On32.setEnabled(not STATUS.machine_is_on())))

        self.w.btnDevice_On32.clicked.connect(
            lambda x: ACTION.SET_MACHINE_STATE(True))

        STATUS.connect(
            'state-on', lambda _: (self.w.btnStart_Ccw32.setEnabled(True),
                                   self.w.btnStop32.setEnabled(True),
                                   self.w.btnStart_Cw32.setEnabled(True),
                                   self.w.btnDevice_On32.setEnabled(False)))

        STATUS.connect(
            'state-off', lambda _:
            (self.onbtnStop32_clicked(), self.w.btnStart_Ccw32.setEnabled(
                False), self.w.btnStop32.setEnabled(False),
             self.w.btnStart_Cw32.setEnabled(False),
             self.w.btnDevice_On32.setEnabled(STATUS.estop_is_clear())))

        self.w.btnStart_Ccw32.clicked.connect(self.onbtnStart_Ccw32_clicked)

        self.w.btnStart_Cw32.clicked.connect(self.onbtnStart_Cw32_clicked)

        self.w.btnStop32.clicked.connect(self.onbtnStop32_clicked)
        self.w.lblDuration32.setText(
            QTime(0, 0, 0).addSecs(self.DURATION).toString("mm:ss"))
        #STATUS.connect('state-estop-reset', lambda w: self._flip_state(False))
        #self.w.lblTest = QHalLabel()
        #self.w.lblTest.setText("!!!HAL Label!!!")
        # self.w.gridLayout_29.addWidget(self.w.lblTest, 3, 2)
        self.init_plot()

        # масштабирование с помощью пинов *-scale
        # (команды setp в hal-файле недостаточно - слайдер не масштабирует,
        # пока не сдвинуть вручную)

        sliders_to_scale = [self.w.sldVelocity32, self.w.sldTorque32]

        for slider_i in sliders_to_scale:
            slider_i.hal_pin_scale.set(0.01)
            slider_i.hal_pin_f.set(slider_i.value() * 0.01)

        # убрать панель с тестовым функционалом
        if INFO.INI.findall("BALLSCREWPARAMS", "TESTPANEL"):
            if INFO.INI.findall("BALLSCREWPARAMS",
                                "TESTPANEL")[0].lower() == "true":
                self.w.wgtTestPanel.show()
        else:
            self.w.wgtTestPanel.hide()  # убрать панель с тестовым функционалом

        # элементы, скрытые при изменении ТЗ
        items_to_hide = [
            self.w.ledGeartorque_Error32, self.w.label_115,
            self.w.lblGeartorque_Error_Value32,
            self.w.lblGeartorque_Error_Value_Max32, self.w.ledLoad_Alarm32,
            self.w.label_120, self.w.ledLoad_Error32, self.w.label_100,
            self.w.lblLoad_Error_Value32, self.w.lblLoad_Error_Value_Max32,
            self.w.ledLoad_Overheat32, self.w.label_118,
            self.w.lblLoad_Temperature32, self.w.lblLoad_Temperature_Max32,
            self.w.ledPos_Overheat32, self.w.label_119,
            self.w.lblPos_Temperature32, self.w.lblPos_Temperature_Max32
        ]
        for item in items_to_hide:
            item.hide()

        # создать оверлей для диалого завершения
        self.w.overlay = FocusOverlay(self.w)
        self.w.overlay.setGeometry(self.w.geometry())
        self.w.overlay.hide()
        return