def action_change_default_motor(self, motorPath):
     """
     Signal handler:
     set default motor model
     @type motorPath: String
     """
     try:
         self.defaultMotorDevice = devices.Motor(motorPath)
     except:
         pass
Beispiel #2
0
    def __init__(self, parent=None, devicePath=None, device=None):
        super(MotorWidget, self).__init__()
        default_gui.DefaultControls.__init__(self,
                                             parent=parent,
                                             devicePath=devicePath)

        if device is not None:
            self.defaultMotorDevice = device
        else:
            if devicePath is not None and (isinstance(devicePath, str)
                                           or isinstance(devicePath, unicode)):
                self.defaultMotorDevice = devices.Motor(devicePath)
            else:
                # default existing motor
                self.defaultMotorDevice = devices.Motor(config.DEVICE_MOTOR)

        self.action_change_motor()
        self.__init_variables()
        self.__init_signals()
        self.__init_ui()
        self.__main()
Beispiel #3
0
    # test if we have polling period - insert one in case of absence
    bfound = False
    for (i, el) in enumerate(sys.argv):
        if "--polling-period" in el:
            bfound = True

    if not bfound:
        sys.argv.append("--taurus-polling-period=250")

    app = TaurusApplication(sys.argv)

    # init widget
    # left = devices.Motor(config.DEVICE_SERVER + "p02/motor/exp.04")
    #right = devices.Motor(config.DEVICE_SERVER + "p02/motor/exp.05")
    #virtualMotor1 = devices.VirtualMotorDistance2D([left, right], "Dx")

    widget = MotorWidget(
        device=devices.Motor("haspp02oh1:10000/p02/motor/eh2b.42"))

    # connect signal from window "x" button to close the application correctly
    app.connect(app, signals.SIG_ABOUT_QUIT, widget.close_widget)

    # connect signal from keyboard interruption (if widget is closed with ctrl+c from console)
    signal.signal(signal.SIGINT, lambda *args, **kwargs: widget.close())

    # show widget
    widget.show()

    # execute application
    app.exec_()
        except:
            self.emit(signals.SIG_SHOW_ERROR, "Controller error",
                      "Controller does not exists")


# MAIN PROGRAM #################################################################################

if __name__ == '__main__':

    # create main window
    app = QtGui.QApplication(sys.argv)

    DEVICE_SERVER = "haspp02oh1.desy.de:10000/"

    # init widget
    left = devices.Motor(DEVICE_SERVER + "p02/motor/eh2b.42")
    right = devices.Motor(DEVICE_SERVER + "p02/motor/eh2b.43")

    widget = StackedMotorControls(motors=[left, right])

    widget3 = gui_default_widget.DefaultWidget()
    widget3.setLayout(QtGui.QGridLayout())
    widget3.layout().addWidget(widget)

    win = gui_default_widget.DefaultMainWindow()
    win.setCentralWidget(widget3)

    # connect signal from window "x" button to close the application correctly
    app.connect(app, signals.SIG_ABOUT_QUIT, widget.close_widget)

    # connect signal from keyboard interruption (if widget is closed with ctrl+c from console)
    def change_device(self, device):
        """
        Change default device for this widget. 
        Set current name to device_name lable.
        """
        self.device = device
        self.device_name.setText(self.device.name)
    
# MAIN PROGRAM #################################################################################

if __name__ == '__main__':
    
    # create main window
    app = QtGui.QApplication(sys.argv)
    
    # init widget
    motor = devices.Motor(config.DEVICE_MOTOR)
    widget = DeviceLedStatusWidget(device=motor)
    
    # connect signal from window "x" button to close the application correctly
    app.connect(app, signals.SIG_ABOUT_QUIT, widget.close_widget)

    # connect signal from keyboard interruption (if widget is closed with ctrl+c from console)
    signal.signal(signal.SIGINT, lambda *args, **kwargs: widget.close())
    
    # show widget
    widget.show()
    
    # execute application
    app.exec_()