def test_write_and_check_exception():
     cmd = AsciiCommand("1 1 move abs 200")
     device = AsciiDevice(asciiserial, 1)
     rep = None
     try:
         device.send(cmd)
     except UnexpectedReplyError as ure:
         rep = ure.reply
     assert (rep != None)
 def test_write_and_check_exception():
     cmd = AsciiCommand("1 1 move abs 200")
     device = AsciiDevice(asciiserial, 1)
     rep = None
     try:
         device.send(cmd)
     except UnexpectedReplyError as ure:
         rep = ure.reply
     assert(rep != None)
Beispiel #3
0
    def __init__(self, name, device_number=1):
        '''
           None
        '''
        logging.info(__name__ +
                     ' : Initializing instrument Zaber Linear Stage')
        Instrument.__init__(self, name, tags=['physical'])

        self.add_parameter('position',
                           units='',
                           type=types.IntType,
                           flags=Instrument.FLAG_GETSET +
                           Instrument.FLAG_GET_AFTER_SET)

        self.add_parameter('device_number',
                           flags=Instrument.FLAG_GET,
                           type=types.StringType)

        self._device_number = device_number
        self.step_to_mm = 0.047625e-3

        self.client = AsciiDevice(AsciiSerial("COM4"), device_number)
    def __init__(self, serial_port_string):
        try:
            # Connect to serial
            self.mAsciiSerial = AsciiSerial(serial_port_string)

            # Connect to device
            self.mAsciiDevice = AsciiDevice(self.mAsciiSerial, 1)

            # Establish axes
            self.x_axis = AsciiAxis(self.mAsciiDevice, 1)
            self.y_axis = AsciiAxis(self.mAsciiDevice, 2)

            mLastRet = 0

        except Exception as e:
            print "Error! ", e
            mLastRet = 1

            return
Beispiel #5
0
def main():
    mmx = clargs.step_size_x
    mmy = clargs.step_size_y
    if mmx is None or mmy is None:
        print("You must specify step sizes! \n")
        print("Example:     move_led_abs.py -mmx 100 -mmy 80")
        #print "Example:     move_led_abs.py command -mmx 100 -mmy 80"
        return -1
    #if scx is None or scy is None:
    #print "You must specify step counts! \n"
    #print "Example:     move_led_abs.py command -mmx 100 -mmy 80 -scx 2.88 -scy 2.88"
    #return -1

    mmx = float(mmx)
    mmy = float(mmy)

    # Uncomment the lines below to to have a continuous acquisition
    #ssx = int(ssx)
    #ssy = int(ssy)
    #scx=int(scx)
    #scy=int(scy)

    # Setup the engines
    port = AsciiSerial("/dev/ttyUSB0")
    device = AsciiDevice(port, 1)
    device2 = AsciiDevice(port, 2)
    axis1 = device.axis(1)
    axis2 = device2.axis(1)

    mmx_declared = mmx * no_of_steps_for_mm
    mmy_declared = mmy * no_of_steps_for_mm
    #x_step_declared = scx*no_of_steps_for_mm
    #y_step_declared = scy*no_of_steps_for_mm

    movex = int(round(mmx_declared))
    movey = int(round(mmy_declared))
    #x_step = int(round(x_step_declared))
    #y_step = int(round(y_step_declared))

    if movex > step_max or movey > step_max:
        print("You are trying to exceed the maximum lenght of 200 mm!")
        return -1

    #print movex
    #print movey
    #print mmx_declared
    #print mmy_declared

    axis1.move_rel(movex)
    axis2.move_rel(movey)
Beispiel #6
0
    def __init__(self):
        self.micronsPerStep = 0.124023437

        self.xAddress = 2
        self.yAddress = 1
        self.zAddress = 3

        self.portName = "COM3"

        self.serialPort = AsciiSerial(self.portName)

        self.xDevice = AsciiDevice(self.serialPort, self.xAddress)
        self.yDevice = AsciiDevice(self.serialPort, self.yAddress)
        self.zDevice = AsciiDevice(self.serialPort, self.zAddress)

        self.moveSpeed = 20000
Beispiel #7
0
 def __init__(self):
     super(Window, self).__init__()
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)
     #PMA Setup, mostly copied from the file-based motion control
     try:
         USB_DEVICE = 'COM6'
         ZABER_ASCII_PORT = AsciiSerial(USB_DEVICE)
         print("NUTS!")
         self.torch_output = 1
         self.wire_output = 2
         self.iodev = AsciiDevice(
             ZABER_ASCII_PORT, 1)  #additional xy dev created to deal w/ io
         self.xdev = AsciiDevice(ZABER_ASCII_PORT, 1).axis(1)
         self.ydev = AsciiDevice(ZABER_ASCII_PORT, 1).axis(2)
         self.zdev = AsciiDevice(ZABER_ASCII_PORT, 2)
         self.number_devices = 2
         self.xdev.home()
         self.ydev.home()
         self.zdev.home()
         self.cm = 2016
     except:
         print("No Connection!!")
Beispiel #8
0
    def __init__(self):
        super(Window, self).__init__()
        #self.setMinimumSize(1000, 1000) #How I tested which window accepted qt methods
        #PMA Setup, mostly copied from the file-based motion control
        try:
            USB_DEVICE = 'COM6'
            ZABER_ASCII_PORT = AsciiSerial(USB_DEVICE)
            print("NUTS!")
            self.torch_output = 1
            self.wire_output = 2
            self.iodev = AsciiDevice(
                ZABER_ASCII_PORT, 1)  #additional xy dev created to deal w/ io
            self.xdev = AsciiDevice(ZABER_ASCII_PORT, 1).axis(1)
            self.ydev = AsciiDevice(ZABER_ASCII_PORT, 1).axis(2)
            self.zdev = AsciiDevice(ZABER_ASCII_PORT, 2)
            self.number_devices = 2
            self.xdev.home()
            self.ydev.home()
            self.zdev.home()
            self.cm = 2016
        except:
            print("No Connection!!")
        #UI Setup
        self.setObjectName("MainWindow")
        self.resize(691, 876)
        self.centralwidget = QtWidgets.QWidget(self)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout_6 = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout_6.setObjectName("gridLayout_6")
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setSizeConstraint(QtWidgets.QLayout.SetNoConstraint)
        self.gridLayout.setObjectName("gridLayout")
        self.gridLayout_5 = QtWidgets.QGridLayout()
        self.gridLayout_5.setObjectName("gridLayout_5")
        self.verticalSlider = QtWidgets.QSlider(self.centralwidget)
        self.verticalSlider.setOrientation(QtCore.Qt.Vertical)
        self.verticalSlider.setObjectName("verticalSlider")
        self.verticalSlider.setMaximum(143)
        self.verticalSlider.valueChanged.connect(self.updateLCD)
        self.gridLayout_5.addWidget(self.verticalSlider, 0, 0, 1, 1)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.label_8 = QtWidgets.QLabel(self.centralwidget)
        self.label_8.setObjectName("label_8")
        self.verticalLayout.addWidget(self.label_8)
        self.lcdNumber = QtWidgets.QLCDNumber(self.centralwidget)
        palette = QtGui.QPalette()
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText,
                         QtGui.QBrush(QtGui.QColor('red')))
        self.lcdNumber.setPalette(palette)
        self.verticalLayout.addWidget(self.lcdNumber)
        self.gridLayout_5.addLayout(self.verticalLayout, 0, 1, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_5, 3, 1, 1, 1)
        self.gridLayout_3 = QtWidgets.QGridLayout()
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setObjectName("label_4")
        self.gridLayout_3.addWidget(self.label_4, 0, 0, 1, 1)
        self.plainTextEdit = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.plainTextEdit.setReadOnly(True)
        self.plainTextEdit.setObjectName("plainTextEdit")
        self.gridLayout_3.addWidget(self.plainTextEdit, 1, 0, 1, 1)
        self.label_5 = QtWidgets.QLabel(self.centralwidget)
        self.label_5.setObjectName("label_5")
        self.gridLayout_3.addWidget(self.label_5, 1, 1, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_3, 5, 1, 1, 1)
        self.gridLayout_4 = QtWidgets.QGridLayout()
        self.gridLayout_4.setObjectName("gridLayout_4")
        self.lcdNumber_2 = QtWidgets.QLCDNumber(self.centralwidget)
        self.lcdNumber_2.setObjectName("lcdNumber_2")
        self.lcdNumber_2.setMinimumHeight(75)
        self.lcdNumber_2.setPalette(palette)
        self.gridLayout_4.addWidget(self.lcdNumber_2, 1, 1, 1, 1)
        self.lcdNumber_3 = QtWidgets.QLCDNumber(self.centralwidget)
        self.lcdNumber_3.setObjectName("lcdNumber_3")
        self.lcdNumber_3.setPalette(palette)
        self.gridLayout_4.addWidget(self.lcdNumber_3, 1, 0, 1, 1)
        self.label_6 = QtWidgets.QLabel(self.centralwidget)
        self.label_6.setObjectName("label_6")
        self.gridLayout_4.addWidget(self.label_6, 0, 1, 1, 1)
        self.label_7 = QtWidgets.QLabel(self.centralwidget)
        self.label_7.setObjectName("label_7")
        self.gridLayout_4.addWidget(self.label_7, 0, 0, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_4, 4, 0, 1, 1)
        self.gridLayout_2 = QtWidgets.QGridLayout()
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_3.clicked.connect(self.ButtAdjYUp)
        self.gridLayout_2.addWidget(self.pushButton_3, 0, 0, 1, 1)
        self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_4.setObjectName("pushButton_4")
        self.pushButton_4.clicked.connect(self.ButtAdjYDn)
        self.gridLayout_2.addWidget(self.pushButton_4, 2, 0, 1, 1)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_6.setObjectName("pushButton_6")
        self.pushButton_6.clicked.connect(self.ButtAdjXUp)
        self.horizontalLayout.addWidget(self.pushButton_6)
        self.frame = QtWidgets.QFrame(self.centralwidget)
        self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame.setMinimumSize(200, 200)
        self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.horizontalLayout.addWidget(self.frame)
        self.joystick = Joystick(self.frame)
        #need to find a way to connect joystick to handler to use successfully
        #print(self.joystick.property("clicked"))
        #self.joystick.clicked.connect(self.JoyWrangler)
        self.horizontalLayout.addWidget(self.joystick)
        self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_5.setObjectName("pushButton_5")
        self.pushButton_5.clicked.connect(self.ButtAdjXDn)
        self.horizontalLayout.addWidget(self.pushButton_5)
        self.gridLayout_2.addLayout(self.horizontalLayout, 1, 0, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_2, 3, 0, 1, 1)
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
        self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_2.setObjectName("pushButton_2")
        self.pushButton_2.clicked.connect(self.ButtAdjZDn)
        self.gridLayout.addWidget(self.pushButton_2, 4, 1, 1, 1)
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 1, 1, 1, 1)
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setObjectName("label_3")
        self.gridLayout.addWidget(self.label_3, 0, 0, 1, 1)
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setObjectName("pushButton")
        self.pushButton.clicked.connect(self.ButtAdjZUp)
        self.gridLayout.addWidget(self.pushButton, 2, 1, 1, 1)
        self.label_9 = QtWidgets.QLabel(self.centralwidget)
        self.label_9.setObjectName("label_9")
        self.gridLayout.addWidget(self.label_9, 6, 0, 1, 1)
        self.label_10 = QtWidgets.QLabel(self.centralwidget)
        self.label_10.setObjectName("label_10")
        self.gridLayout.addWidget(self.label_10, 7, 0, 1, 1)
        self.pushButton_8 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_8.setObjectName("pushButton_8")
        self.pushButton_8.setCheckable(True)
        self.pushButton_8.clicked[bool].connect(self.FIRE)
        self.gridLayout.addWidget(self.pushButton_8, 5, 0, 1, 1)
        self.label_11 = QtWidgets.QLabel(self.centralwidget)
        self.label_11.setObjectName("label_11")
        self.gridLayout.addWidget(self.label_11, 8, 0, 1, 1)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.plainTextEdit_2 = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit_2.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.plainTextEdit_2.setObjectName("plainTextEdit_2")
        self.plainTextEdit_2.setReadOnly(True)
        self.horizontalLayout_2.addWidget(self.plainTextEdit_2)
        self.label_12 = QtWidgets.QLabel(self.centralwidget)
        self.label_12.setObjectName("label_12")
        self.horizontalLayout_2.addWidget(self.label_12)
        self.gridLayout.addLayout(self.horizontalLayout_2, 6, 1, 1, 1)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.plainTextEdit_3 = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit_3.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.plainTextEdit_3.setObjectName("plainTextEdit_3")
        self.plainTextEdit_3.setReadOnly(True)
        self.horizontalLayout_3.addWidget(self.plainTextEdit_3)
        self.label_13 = QtWidgets.QLabel(self.centralwidget)
        self.label_13.setObjectName("label_13")
        self.horizontalLayout_3.addWidget(self.label_13)
        self.gridLayout.addLayout(self.horizontalLayout_3, 7, 1, 1, 1)
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.plainTextEdit_4 = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit_4.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.plainTextEdit_4.setObjectName("plainTextEdit_4")
        self.plainTextEdit_4.setReadOnly(True)
        self.horizontalLayout_4.addWidget(self.plainTextEdit_4)
        self.label_14 = QtWidgets.QLabel(self.centralwidget)
        self.label_14.setObjectName("label_14")
        self.horizontalLayout_4.addWidget(self.label_14)
        self.gridLayout.addLayout(self.horizontalLayout_4, 8, 1, 1, 1)
        self.gridLayout_6.addLayout(self.gridLayout, 0, 0, 1, 1)
        self.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(self)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 691, 21))
        self.menubar.setObjectName("menubar")
        self.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(self)
        self.statusbar.setObjectName("statusbar")
        self.setStatusBar(self.statusbar)

        self.retranslateUi(self)
        QtCore.QMetaObject.connectSlotsByName(self)
Beispiel #9
0
class Window(QtWidgets.QMainWindow):
    #only way I found to get keypressed working
    def __init__(self):
        super(Window, self).__init__()
        #self.setMinimumSize(1000, 1000) #How I tested which window accepted qt methods
        #PMA Setup, mostly copied from the file-based motion control
        try:
            USB_DEVICE = 'COM6'
            ZABER_ASCII_PORT = AsciiSerial(USB_DEVICE)
            print("NUTS!")
            self.torch_output = 1
            self.wire_output = 2
            self.iodev = AsciiDevice(
                ZABER_ASCII_PORT, 1)  #additional xy dev created to deal w/ io
            self.xdev = AsciiDevice(ZABER_ASCII_PORT, 1).axis(1)
            self.ydev = AsciiDevice(ZABER_ASCII_PORT, 1).axis(2)
            self.zdev = AsciiDevice(ZABER_ASCII_PORT, 2)
            self.number_devices = 2
            self.xdev.home()
            self.ydev.home()
            self.zdev.home()
            self.cm = 2016
        except:
            print("No Connection!!")
        #UI Setup
        self.setObjectName("MainWindow")
        self.resize(691, 876)
        self.centralwidget = QtWidgets.QWidget(self)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout_6 = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout_6.setObjectName("gridLayout_6")
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setSizeConstraint(QtWidgets.QLayout.SetNoConstraint)
        self.gridLayout.setObjectName("gridLayout")
        self.gridLayout_5 = QtWidgets.QGridLayout()
        self.gridLayout_5.setObjectName("gridLayout_5")
        self.verticalSlider = QtWidgets.QSlider(self.centralwidget)
        self.verticalSlider.setOrientation(QtCore.Qt.Vertical)
        self.verticalSlider.setObjectName("verticalSlider")
        self.verticalSlider.setMaximum(143)
        self.verticalSlider.valueChanged.connect(self.updateLCD)
        self.gridLayout_5.addWidget(self.verticalSlider, 0, 0, 1, 1)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.label_8 = QtWidgets.QLabel(self.centralwidget)
        self.label_8.setObjectName("label_8")
        self.verticalLayout.addWidget(self.label_8)
        self.lcdNumber = QtWidgets.QLCDNumber(self.centralwidget)
        palette = QtGui.QPalette()
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText,
                         QtGui.QBrush(QtGui.QColor('red')))
        self.lcdNumber.setPalette(palette)
        self.verticalLayout.addWidget(self.lcdNumber)
        self.gridLayout_5.addLayout(self.verticalLayout, 0, 1, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_5, 3, 1, 1, 1)
        self.gridLayout_3 = QtWidgets.QGridLayout()
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setObjectName("label_4")
        self.gridLayout_3.addWidget(self.label_4, 0, 0, 1, 1)
        self.plainTextEdit = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.plainTextEdit.setReadOnly(True)
        self.plainTextEdit.setObjectName("plainTextEdit")
        self.gridLayout_3.addWidget(self.plainTextEdit, 1, 0, 1, 1)
        self.label_5 = QtWidgets.QLabel(self.centralwidget)
        self.label_5.setObjectName("label_5")
        self.gridLayout_3.addWidget(self.label_5, 1, 1, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_3, 5, 1, 1, 1)
        self.gridLayout_4 = QtWidgets.QGridLayout()
        self.gridLayout_4.setObjectName("gridLayout_4")
        self.lcdNumber_2 = QtWidgets.QLCDNumber(self.centralwidget)
        self.lcdNumber_2.setObjectName("lcdNumber_2")
        self.lcdNumber_2.setMinimumHeight(75)
        self.lcdNumber_2.setPalette(palette)
        self.gridLayout_4.addWidget(self.lcdNumber_2, 1, 1, 1, 1)
        self.lcdNumber_3 = QtWidgets.QLCDNumber(self.centralwidget)
        self.lcdNumber_3.setObjectName("lcdNumber_3")
        self.lcdNumber_3.setPalette(palette)
        self.gridLayout_4.addWidget(self.lcdNumber_3, 1, 0, 1, 1)
        self.label_6 = QtWidgets.QLabel(self.centralwidget)
        self.label_6.setObjectName("label_6")
        self.gridLayout_4.addWidget(self.label_6, 0, 1, 1, 1)
        self.label_7 = QtWidgets.QLabel(self.centralwidget)
        self.label_7.setObjectName("label_7")
        self.gridLayout_4.addWidget(self.label_7, 0, 0, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_4, 4, 0, 1, 1)
        self.gridLayout_2 = QtWidgets.QGridLayout()
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_3.clicked.connect(self.ButtAdjYUp)
        self.gridLayout_2.addWidget(self.pushButton_3, 0, 0, 1, 1)
        self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_4.setObjectName("pushButton_4")
        self.pushButton_4.clicked.connect(self.ButtAdjYDn)
        self.gridLayout_2.addWidget(self.pushButton_4, 2, 0, 1, 1)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_6.setObjectName("pushButton_6")
        self.pushButton_6.clicked.connect(self.ButtAdjXUp)
        self.horizontalLayout.addWidget(self.pushButton_6)
        self.frame = QtWidgets.QFrame(self.centralwidget)
        self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame.setMinimumSize(200, 200)
        self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.horizontalLayout.addWidget(self.frame)
        self.joystick = Joystick(self.frame)
        #need to find a way to connect joystick to handler to use successfully
        #print(self.joystick.property("clicked"))
        #self.joystick.clicked.connect(self.JoyWrangler)
        self.horizontalLayout.addWidget(self.joystick)
        self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_5.setObjectName("pushButton_5")
        self.pushButton_5.clicked.connect(self.ButtAdjXDn)
        self.horizontalLayout.addWidget(self.pushButton_5)
        self.gridLayout_2.addLayout(self.horizontalLayout, 1, 0, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_2, 3, 0, 1, 1)
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
        self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_2.setObjectName("pushButton_2")
        self.pushButton_2.clicked.connect(self.ButtAdjZDn)
        self.gridLayout.addWidget(self.pushButton_2, 4, 1, 1, 1)
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 1, 1, 1, 1)
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setObjectName("label_3")
        self.gridLayout.addWidget(self.label_3, 0, 0, 1, 1)
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setObjectName("pushButton")
        self.pushButton.clicked.connect(self.ButtAdjZUp)
        self.gridLayout.addWidget(self.pushButton, 2, 1, 1, 1)
        self.label_9 = QtWidgets.QLabel(self.centralwidget)
        self.label_9.setObjectName("label_9")
        self.gridLayout.addWidget(self.label_9, 6, 0, 1, 1)
        self.label_10 = QtWidgets.QLabel(self.centralwidget)
        self.label_10.setObjectName("label_10")
        self.gridLayout.addWidget(self.label_10, 7, 0, 1, 1)
        self.pushButton_8 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_8.setObjectName("pushButton_8")
        self.pushButton_8.setCheckable(True)
        self.pushButton_8.clicked[bool].connect(self.FIRE)
        self.gridLayout.addWidget(self.pushButton_8, 5, 0, 1, 1)
        self.label_11 = QtWidgets.QLabel(self.centralwidget)
        self.label_11.setObjectName("label_11")
        self.gridLayout.addWidget(self.label_11, 8, 0, 1, 1)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.plainTextEdit_2 = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit_2.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.plainTextEdit_2.setObjectName("plainTextEdit_2")
        self.plainTextEdit_2.setReadOnly(True)
        self.horizontalLayout_2.addWidget(self.plainTextEdit_2)
        self.label_12 = QtWidgets.QLabel(self.centralwidget)
        self.label_12.setObjectName("label_12")
        self.horizontalLayout_2.addWidget(self.label_12)
        self.gridLayout.addLayout(self.horizontalLayout_2, 6, 1, 1, 1)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.plainTextEdit_3 = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit_3.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.plainTextEdit_3.setObjectName("plainTextEdit_3")
        self.plainTextEdit_3.setReadOnly(True)
        self.horizontalLayout_3.addWidget(self.plainTextEdit_3)
        self.label_13 = QtWidgets.QLabel(self.centralwidget)
        self.label_13.setObjectName("label_13")
        self.horizontalLayout_3.addWidget(self.label_13)
        self.gridLayout.addLayout(self.horizontalLayout_3, 7, 1, 1, 1)
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.plainTextEdit_4 = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit_4.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.plainTextEdit_4.setObjectName("plainTextEdit_4")
        self.plainTextEdit_4.setReadOnly(True)
        self.horizontalLayout_4.addWidget(self.plainTextEdit_4)
        self.label_14 = QtWidgets.QLabel(self.centralwidget)
        self.label_14.setObjectName("label_14")
        self.horizontalLayout_4.addWidget(self.label_14)
        self.gridLayout.addLayout(self.horizontalLayout_4, 8, 1, 1, 1)
        self.gridLayout_6.addLayout(self.gridLayout, 0, 0, 1, 1)
        self.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(self)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 691, 21))
        self.menubar.setObjectName("menubar")
        self.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(self)
        self.statusbar.setObjectName("statusbar")
        self.setStatusBar(self.statusbar)

        self.retranslateUi(self)
        QtCore.QMetaObject.connectSlotsByName(self)

    def ButtAdjZUp(self):
        self.verticalSlider.setValue(self.verticalSlider.value() + 1)
        print("+1cm Z")

    #individual handlers for each button is inefficient, fix later
    def ButtAdjZDn(self):
        self.verticalSlider.setValue(self.verticalSlider.value() - 1)
        print("-1cm Z")

    def ButtAdjXUp(self):
        try:
            self.x = self.x + 1
        except:
            self.x = 1
        self.lcdNumber_3.display(self.x)
        print("+1cm X")
        self.updateLCD3()

    def ButtAdjXDn(self):
        try:
            if self.x > 0:
                self.x = self.x - 1
                print("-1cm X")
        except:
            self.x = 0
        self.lcdNumber_3.display(self.x)
        self.updateLCD3()

    def ButtAdjYUp(self):
        try:
            self.y = self.y + 1
        except:
            self.y = 1
        self.lcdNumber_2.display(self.y)
        print("+1cm Y")
        self.updateLCD2()

    def ButtAdjYDn(self):
        try:
            if self.y > 0:
                self.y = self.y - 1
                print("-1cm Y")
        except:
            self.y = 0
        self.lcdNumber_2.display(self.y)
        self.updateLCD2()

    def JoyWrangler(self):
        #dysfunctional joystick handler
        print("I'm in")

    def FIRE(self, pressed):
        if pressed:
            print("ZAP!")
            switch1 = self.iodev.send("io set do 1 1")
            switch2 = self.iodev.send("io set do 2 1")
            state = self.iodev.send("io get do")
        else:
            print("no zap")
            switch1 = self.iodev.send("io set do 1 0")
            switch2 = self.iodev.send("io set do 2 0")
            state = self.iodev.send("io get do")

    def updateLCD(self, event):
        print(event)
        self.lcdNumber.display(event)
        #sleep(1) #delaying didn't seem to help the refresh lag
        reply = self.zdev.move_abs(self.cm * self.lcdNumber.intValue())

    def updateLCD3(self):
        print('x beep beep')
        reply = self.xdev.move_abs(self.cm * self.x)

    def updateLCD2(self):
        print('y beep beep')
        reply = self.ydev.move_abs(self.cm * self.y)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.label_8.setText(_translate("MainWindow", "Z pos (cm)"))
        self.label_4.setText(_translate("MainWindow", "Wire Length"))
        self.label_5.setText(_translate("MainWindow", "cm"))
        self.label_6.setText(_translate("MainWindow", "Y pos (cm)"))
        self.label_7.setText(_translate("MainWindow", "X pos (cm)"))
        self.pushButton_3.setText(_translate("MainWindow", "+y (1cm)"))
        self.pushButton_4.setText(_translate("MainWindow", "-y (1cm)"))
        self.pushButton_6.setText(_translate("MainWindow", "+x (1cm)"))
        self.pushButton_5.setText(_translate("MainWindow", "-x (1cm)"))
        self.label_2.setText(_translate("MainWindow", "XY Control"))
        self.pushButton_2.setText(_translate("MainWindow", "-z (1cm)"))
        self.label.setText(_translate("MainWindow", "Z Control"))
        self.label_3.setText(
            _translate("MainWindow", "Welcome to the PMA GUI!1!"))
        self.pushButton.setText(_translate("MainWindow", "+z (1cm)"))
        self.label_9.setText(_translate("MainWindow", "Wire Feed Delay"))
        self.label_10.setText(_translate("MainWindow", "Arc Delay"))
        self.pushButton_8.setText(_translate("MainWindow", "TEST FIRE"))
        self.label_11.setText(_translate("MainWindow", "Velocity"))
        self.label_12.setText(_translate("MainWindow", "Sec"))
        self.label_13.setText(_translate("MainWindow", "Sec"))
        self.label_14.setText(_translate("MainWindow", "fast"))
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

    #wasd control not working currently, leaving it here
    def keyPressEvent(self, e):
        if e.key() == QtCore.Qt.Key_W:
            print("+0.388455cm Y")
            try:
                self.y = self.y + 0.388455
            except:
                self.y = 0.388455
            self.lcdNumber_2.display(self.y)
            reply = self.ydev.move_vel(20 * self.cm)
        elif e.key() == QtCore.Qt.Key_S:
            try:
                if self.y > 0:
                    self.y = self.y - 0.388455
                    print("-0.388455cm Y")
            except:
                self.y = 0
            self.lcdNumber_2.display(self.y)
            reply = self.ydev.move_vel(-(20 * self.cm))
        elif e.key() == QtCore.Qt.Key_A:
            print("+0.377799cm X")
            try:
                self.x = self.x + 0.377799
            except:
                self.x = 0.377799
            self.lcdNumber_3.display(self.x)
            reply = self.xdev.move_vel(20 * self.cm)
        elif e.key() == QtCore.Qt.Key_D:
            try:
                if self.x > 0:
                    self.x = self.x - 0.377799
                    print("-0.377799cm X")
            except:
                self.x = 0
            self.lcdNumber_3.display(self.x)
            reply = self.xdev.move_vel(-(20 * self.cm))
        elif e.key() == QtCore.Qt.Key_Up:
            #Z keyboard control isn't very useful compared to GUI so might remove
            self.verticalSlider.setValue(self.verticalSlider.value() + 1)
            print("+1cm Z")
        elif e.key() == QtCore.Qt.Key_Down:
            self.verticalSlider.setValue(self.verticalSlider.value() - 1)
            print("-1cm Z")

    def keyReleaseEvent(self, e):
        if e.key() == QtCore.Qt.Key_W:
            print('0y')
            reply = self.ydev.move_vel(0)
        elif e.key() == QtCore.Qt.Key_S:
            print('0y')
            reply = self.ydev.move_vel(0)
        elif e.key() == QtCore.Qt.Key_A:
            print('0x')
            reply = self.xdev.move_vel(0)
        elif e.key() == QtCore.Qt.Key_D:
            print('0x')
            reply = self.xdev.move_vel(0)
        elif e.key() == QtCore.Qt.Key_Up:
            print('0z')
        elif e.key() == QtCore.Qt.Key_Down:
            print('0z')
Beispiel #10
0
class Printer:
    def __init__(self):
        self.micronsPerStep = 0.124023437

        self.xAddress = 2
        self.yAddress = 1
        self.zAddress = 3

        self.portName = "COM3"

        self.serialPort = AsciiSerial(self.portName)

        self.xDevice = AsciiDevice(self.serialPort, self.xAddress)
        self.yDevice = AsciiDevice(self.serialPort, self.yAddress)
        self.zDevice = AsciiDevice(self.serialPort, self.zAddress)

        self.moveSpeed = 20000

    def IsBusy(self):
        return self.xDevice.get_status() == "BUSY" or self.yDevice.get_status(
        ) == "BUSY" or self.zDevice.get_status() == "BUSY"

    def Home(self):
        print("Homing...\n")

        self.serialPort.write(AsciiCommand("home"))
        self.serialPort.read()
        self.serialPort.read()
        self.serialPort.read()
        while self.IsBusy():
            pass

        print("Done.\n")

    def PromptBounds(self):
        printer.zDevice.send("move max")

        print("Move the print head to the top-left corner of the print area\n")
        self.GiveKeyControl()
        self.left = self.xDevice.get_position()
        self.top = self.yDevice.get_position()

        print(
            "Move the print head to the bottom-right corner of the print area\n"
        )
        self.GiveKeyControl()
        self.right = self.xDevice.get_position()
        self.bottom = self.yDevice.get_position()

        printer.zDevice.send("move max")
        self.MoveToCenter()

        print("Move the print head to the working height.")
        self.GiveKeyControl(x=False, y=False)
        self.printPoint = self.zDevice.get_position()

    def MoveToCenter(self):
        print("Centering...")

        center = ((self.left + self.right) / 2, (self.top + self.bottom) / 2)

        self.xDevice.move_abs(int(center[0]), blocking=False)
        self.yDevice.move_abs(int(center[1]), blocking=False)

        while (self.IsBusy()):
            pass

        print("Done.")

    def SafeMove(self, device, speed):
        if self.movingList[device] == True or self.enableList[device] == False:
            return
        else:
            device.move_vel(speed)
            self.movingList[device] = True

    def SafeStop(self, device):
        self.movingList[device] = False
        device.stop()

    def on_press(self, key):
        if key == Key.up:
            self.SafeMove(self.zDevice, -self.moveSpeed)
        if key == Key.down:
            self.SafeMove(self.zDevice, self.moveSpeed)
        if key == KeyCode(char='w'):
            self.SafeMove(self.yDevice, self.moveSpeed)
        if key == KeyCode(char='s'):
            self.SafeMove(self.yDevice, -self.moveSpeed)
        if key == KeyCode(char='a'):
            self.SafeMove(self.xDevice, self.moveSpeed)
        if key == KeyCode(char='d'):
            self.SafeMove(self.xDevice, -self.moveSpeed)

    def on_release(self, key):
        if key == Key.enter:
            # Stop listener
            return False

        if key == Key.up or key == Key.down:
            self.SafeStop(self.zDevice)
        if key == KeyCode(char='w') or key == KeyCode(char='s'):
            self.SafeStop(self.yDevice)
        if key == KeyCode(char='a') or key == KeyCode(char='d'):
            self.SafeStop(self.xDevice)

        change = False
        if key == KeyCode(char='+') or key == KeyCode(char='='):
            self.moveSpeed *= 2
            change = True
        if key == KeyCode(char='-') or key == KeyCode(char='_'):
            self.moveSpeed = math.ceil(self.moveSpeed / 2)
            change = True

        if change:
            print("New movement speed: " +
                  str(self.moveSpeed * self.micronsPerStep * 0.0001) +
                  " centimeters per second.")
            self.SafeStop(self.xDevice)
            self.SafeStop(self.yDevice)
            self.SafeStop(self.zDevice)

    def GiveKeyControl(self, x=True, y=True, z=True):
        self.movingList = {}
        self.SafeStop(self.xDevice)
        self.SafeStop(self.yDevice)
        self.SafeStop(self.zDevice)

        self.enableList = {self.xDevice: x, self.yDevice: y, self.zDevice: z}

        xString = "Move X with A-D. "
        yString = "Move Y with W-S. "
        zString = "Move Z with the up and down arrow keys. "

        string = "("

        if x:
            string += xString
        if y:
            string += yString
        if z:
            string += zString

        string += "Change speed with +/-. Press ENTER to finish.)\n"
        print(string)
        # Collect events until released
        with Listener(on_press=lambda key: self.on_press(key),
                      on_release=lambda key: self.on_release(key),
                      suppress=True) as listener:
            listener.join()
class MicroscopeBase:

    """ Encapsulated version of the zaber microscope class. Allows for two degrees of 
    freedom in movement as well as the ability to save/return to locations """

    # Defining self variables

    mAsciiSerial = None                  # The serial port
    mAsciiDevice = None                  # The reference to the microscope object

    x_axis = None                       # The reference to the x axis object
    y_axis = None                       # The reference to the y axis object

    mLastRet = 0                         # Will be 1 if there was an error in the last operation done



    ''' 
    Constructor that sets up connection to the microscope base. Instantiates all the 
    internal variables
    @ param serial_port : String describing the port that the base is connected to, eg "COM5"
    Returns None
    '''
    def __init__(self, serial_port_string):
        try:
            # Connect to serial
            self.mAsciiSerial = AsciiSerial(serial_port_string)

            # Connect to device
            self.mAsciiDevice = AsciiDevice(self.mAsciiSerial, 1)

            # Establish axes
            self.x_axis = AsciiAxis(self.mAsciiDevice, 1)
            self.y_axis = AsciiAxis(self.mAsciiDevice, 2)

            mLastRet = 0

        except Exception as e:
            print "Error! ", e
            mLastRet = 1

            return

    
    '''
    Returns a tuple representing the absolute location of the device right now
    Returns (int, int) representing (location_x, location_y)
    '''
    def get_absolute_position(self):
    
        reply = self.mAsciiDevice.send("get pos")
        position_array = reply.data.split()
        x_curr = int(position_array[0])
        y_curr = int(position_array[1])
        mLastRet = 0
    
        return (x_curr, y_curr)


    '''
    Internal helper function that returns true if command succeeded, print reason and return false if command
    rejected
    @param reply: AsciiReply
    Returns Boolean
    '''
    def check_command_succeeded(self, reply):
        if reply.reply_flag != "OK": # If command not accepted (received "RJ")
            print ("Danger! Command rejected because: {}".format(reply.data))
            return False
        else: # Command was accepted
            return True

    '''
    Moves the x axis of the microscope base num amount of microsteps
    @param num : number of microsteps to be moved
    Returns : None
    '''
    def x_move_rel(self, num):
        reply = self.x_axis.move_rel(num)
        if not self.check_command_succeeded(reply):
            self.mLastRet = 1
            print "Command failed in x_move_rel!"
            return
        self.mLastRet = 0    

    '''
    Moves the y axis of the microscope base num amount of microsteps
    @param num : number of microsteps to be moved
    Returns : None
    '''
    def y_move_rel(self, num):
        reply = self.y_axis.move_rel(num)
        if not self.check_command_succeeded(reply):
            self.mLastRet = 1
            print "Command failed in y_move_rel!"
            return
        self.mLastRet = 0


    ''' 
    Moves the x axis of the microscope base to the coordinate defined by x_coord
    @ param x_coord : int that describes the desired location of the x axis
    Returns None
    '''
    def x_move_abs(self, x_coord):
        reply = self.x_axis.move_abs(x_coord)
        if not self.check_command_succeeded(reply):
            self.mLastRet = 1
            print "Command failed in x_move_abs!"
            return
        self.mLastRet = 0


    ''' 
    Moves the y axis of the microscope base to the coordinate defined by y_coord
    @ param x_coord : int that describes the desired location of the y axis
    Returns None
    '''
    def y_move_abs(self,y_coord):
        reply = self.y_axis.move_abs(y_coord)
        if not self.check_command_succeeded(reply):
            self.mLastRet = 1
            print "Command failed in y_move_abs!"
            return
        self.mLastRet = 0
        

    ''' 
    Moves the x axis of the microscope according to the speed set by input_speed
    @ param input_speed : int that describes the desired speed that the x axis should move
    Returns None
    '''
    def x_move_vel(self,input_speed):
        reply = self.x_axis.move_vel(input_speed)
        if not self.check_command_succeeded(reply):
            self.mLastRet = 1
            print "Command failed in x_move_vel!"
            return
        self.mLastRet = 0        
        

    ''' 
    Moves the y axis of the microscope according to the speed set by input_speed
    @ param input_speed : int that describes the desired speed that the y axis should move
    Returns None
    '''
    def y_move_vel(self,input_speed):
        reply = self.y_axis.move_vel(input_speed)
        if not self.check_command_succeeded(reply):
            self.mLastRet = 1
            print "Command failed in y_move_vel!"
            return
        self.mLastRet = 0


    ''' 
    Homes the device. Ensures that the internal x and y coordinates are accurate
    '''
    def home_device(self):
        reply = self.mAsciiDevice.home()
        if not self.check_command_succeeded(reply):
            print "Device home failed!"
            self.mLastRet = 1
            return
        self.mLastRet = 0
Beispiel #12
0
if __name__ == '__main__':

    # Open a serial port. You may need to edit this section for your particular
    # hardware and OS setup.
    port = AsciiSerial("COM3")

    # Get a handle for device #1 on the serial chain. This assumes you have a
    # device already in ASCII 115,220 baud mode at address 1 on your port.
    # Finds how many devices there are and homes them all
    maxDevices = 10
    numDevices = maxDevices
    device = {}
    for i in range(0, maxDevices):
        try:
            device[i] = AsciiDevice(port, i)  # Device number i
            device[i].home()
        except:
            break

    numDevices = i
    print(numDevices)

    #Initializing the devices as axis uneccessary for devices with only one axis, for demonstration.]
    axis = {}
    for i in range(0, numDevices - 1):
        axis[i] = device[i].axis(1)

    reply = {}
    for i in range(0, numDevices - 1):
        reply[i] = axis[i].home()  # Home the fist axis and check the result.
Beispiel #13
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        #PMA Setup, mostly copied from G_Code
        try:
            #port = AsciiSerial('COM6')
            #port.close()
            USB_DEVICE = 'COM6'
            ZABER_ASCII_PORT = AsciiSerial(USB_DEVICE)
            print("NUTS!")
            self.torch_output = 1
            self.wire_output = 2
            self.iodev = AsciiDevice(
                ZABER_ASCII_PORT, 1)  #additional xy dev created to deal w/ io
            self.xdev = AsciiDevice(ZABER_ASCII_PORT, 1).axis(1)
            self.ydev = AsciiDevice(ZABER_ASCII_PORT, 1).axis(2)
            self.zdev = AsciiDevice(ZABER_ASCII_PORT, 2)
            self.number_devices = 2
            self.xdev.home()
            self.ydev.home()
            self.zdev.home()
            self.cm = 2016
        except:
            print("No Connection!!")
        #UI Setup
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(691, 876)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout_6 = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout_6.setObjectName("gridLayout_6")
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setSizeConstraint(QtWidgets.QLayout.SetNoConstraint)
        self.gridLayout.setObjectName("gridLayout")
        self.gridLayout_5 = QtWidgets.QGridLayout()
        self.gridLayout_5.setObjectName("gridLayout_5")
        self.verticalSlider = QtWidgets.QSlider(self.centralwidget)
        self.verticalSlider.setOrientation(QtCore.Qt.Vertical)
        self.verticalSlider.setObjectName("verticalSlider")
        self.verticalSlider.setMaximum(143)
        self.verticalSlider.valueChanged.connect(self.updateLCD)
        self.gridLayout_5.addWidget(self.verticalSlider, 0, 0, 1, 1)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.label_8 = QtWidgets.QLabel(self.centralwidget)
        self.label_8.setObjectName("label_8")
        self.verticalLayout.addWidget(self.label_8)
        self.lcdNumber = QtWidgets.QLCDNumber(self.centralwidget)
        palette = QtGui.QPalette()
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText,
                         QtGui.QBrush(QtGui.QColor('red')))
        self.lcdNumber.setPalette(palette)
        self.verticalLayout.addWidget(self.lcdNumber)
        self.gridLayout_5.addLayout(self.verticalLayout, 0, 1, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_5, 3, 1, 1, 1)
        self.gridLayout_3 = QtWidgets.QGridLayout()
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setObjectName("label_4")
        self.gridLayout_3.addWidget(self.label_4, 0, 0, 1, 1)
        self.plainTextEdit = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.plainTextEdit.setReadOnly(True)
        self.plainTextEdit.setObjectName("plainTextEdit")
        self.gridLayout_3.addWidget(self.plainTextEdit, 1, 0, 1, 1)
        self.label_5 = QtWidgets.QLabel(self.centralwidget)
        self.label_5.setObjectName("label_5")
        self.gridLayout_3.addWidget(self.label_5, 1, 1, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_3, 5, 1, 1, 1)
        self.gridLayout_4 = QtWidgets.QGridLayout()
        self.gridLayout_4.setObjectName("gridLayout_4")
        self.lcdNumber_2 = QtWidgets.QLCDNumber(self.centralwidget)
        self.lcdNumber_2.setObjectName("lcdNumber_2")
        self.lcdNumber_2.setMinimumHeight(75)
        self.lcdNumber_2.setPalette(palette)
        self.gridLayout_4.addWidget(self.lcdNumber_2, 1, 1, 1, 1)
        self.lcdNumber_3 = QtWidgets.QLCDNumber(self.centralwidget)
        self.lcdNumber_3.setObjectName("lcdNumber_3")
        self.lcdNumber_3.setPalette(palette)
        self.gridLayout_4.addWidget(self.lcdNumber_3, 1, 0, 1, 1)
        self.label_6 = QtWidgets.QLabel(self.centralwidget)
        self.label_6.setObjectName("label_6")
        self.gridLayout_4.addWidget(self.label_6, 0, 1, 1, 1)
        self.label_7 = QtWidgets.QLabel(self.centralwidget)
        self.label_7.setObjectName("label_7")
        self.gridLayout_4.addWidget(self.label_7, 0, 0, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_4, 4, 0, 1, 1)
        self.gridLayout_2 = QtWidgets.QGridLayout()
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_3.clicked.connect(self.ButtAdjYUp)
        self.gridLayout_2.addWidget(self.pushButton_3, 0, 0, 1, 1)
        self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_4.setObjectName("pushButton_4")
        self.pushButton_4.clicked.connect(self.ButtAdjYDn)
        self.gridLayout_2.addWidget(self.pushButton_4, 2, 0, 1, 1)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_6.setObjectName("pushButton_6")
        self.pushButton_6.clicked.connect(self.ButtAdjXUp)
        self.horizontalLayout.addWidget(self.pushButton_6)
        self.frame = QtWidgets.QFrame(self.centralwidget)
        self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame.setMinimumSize(200, 200)
        self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.horizontalLayout.addWidget(self.frame)
        self.joystick = Joystick(self.frame)
        #need to find a way to connect joystick to handler
        #print(self.joystick.property("clicked"))
        #self.joystick.clicked.connect(self.JoyWrangler)
        self.horizontalLayout.addWidget(self.joystick)
        self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_5.setObjectName("pushButton_5")
        self.pushButton_5.clicked.connect(self.ButtAdjXDn)
        self.horizontalLayout.addWidget(self.pushButton_5)
        self.gridLayout_2.addLayout(self.horizontalLayout, 1, 0, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_2, 3, 0, 1, 1)
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
        self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_2.setObjectName("pushButton_2")
        self.pushButton_2.clicked.connect(self.ButtAdjZDn)
        self.gridLayout.addWidget(self.pushButton_2, 4, 1, 1, 1)
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 1, 1, 1, 1)
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setObjectName("label_3")
        self.gridLayout.addWidget(self.label_3, 0, 0, 1, 1)
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setObjectName("pushButton")
        self.pushButton.clicked.connect(self.ButtAdjZUp)
        self.gridLayout.addWidget(self.pushButton, 2, 1, 1, 1)
        self.label_9 = QtWidgets.QLabel(self.centralwidget)
        self.label_9.setObjectName("label_9")
        self.gridLayout.addWidget(self.label_9, 6, 0, 1, 1)
        self.label_10 = QtWidgets.QLabel(self.centralwidget)
        self.label_10.setObjectName("label_10")
        self.gridLayout.addWidget(self.label_10, 7, 0, 1, 1)
        self.pushButton_8 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_8.setObjectName("pushButton_8")
        self.pushButton_8.setCheckable(True)
        self.pushButton_8.clicked[bool].connect(self.FIRE)
        self.gridLayout.addWidget(self.pushButton_8, 5, 0, 1, 1)
        self.label_11 = QtWidgets.QLabel(self.centralwidget)
        self.label_11.setObjectName("label_11")
        self.gridLayout.addWidget(self.label_11, 8, 0, 1, 1)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.plainTextEdit_2 = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit_2.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.plainTextEdit_2.setObjectName("plainTextEdit_2")
        self.plainTextEdit_2.setReadOnly(True)
        self.horizontalLayout_2.addWidget(self.plainTextEdit_2)
        self.label_12 = QtWidgets.QLabel(self.centralwidget)
        self.label_12.setObjectName("label_12")
        self.horizontalLayout_2.addWidget(self.label_12)
        self.gridLayout.addLayout(self.horizontalLayout_2, 6, 1, 1, 1)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.plainTextEdit_3 = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit_3.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.plainTextEdit_3.setObjectName("plainTextEdit_3")
        self.plainTextEdit_3.setReadOnly(True)
        self.horizontalLayout_3.addWidget(self.plainTextEdit_3)
        self.label_13 = QtWidgets.QLabel(self.centralwidget)
        self.label_13.setObjectName("label_13")
        self.horizontalLayout_3.addWidget(self.label_13)
        self.gridLayout.addLayout(self.horizontalLayout_3, 7, 1, 1, 1)
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.plainTextEdit_4 = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit_4.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.plainTextEdit_4.setObjectName("plainTextEdit_4")
        self.plainTextEdit_4.setReadOnly(True)
        self.horizontalLayout_4.addWidget(self.plainTextEdit_4)
        self.label_14 = QtWidgets.QLabel(self.centralwidget)
        self.label_14.setObjectName("label_14")
        self.horizontalLayout_4.addWidget(self.label_14)
        self.gridLayout.addLayout(self.horizontalLayout_4, 8, 1, 1, 1)
        self.gridLayout_6.addLayout(self.gridLayout, 0, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 691, 21))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def ButtAdjZUp(self):
        self.verticalSlider.setValue(self.verticalSlider.value() + 1)
        print("+1cm Z")

    #this system of individual handlers for each button is inefficient, couldn't get if to check them tho
    def ButtAdjZDn(self):
        self.verticalSlider.setValue(self.verticalSlider.value() - 1)
        print("-1cm Z")

    def ButtAdjXUp(self):
        try:
            self.x = self.x + 1
        except:
            self.x = 1
        self.lcdNumber_3.display(self.x)
        print("+1cm X")
        self.updateLCD3()

    def ButtAdjXDn(self):
        try:
            if self.x > 0:
                self.x = self.x - 1
                print("-1cm X")
        except:
            self.x = 0
        self.lcdNumber_3.display(self.x)
        self.updateLCD3()

    def ButtAdjYUp(self):
        try:
            self.y = self.y + 1
        except:
            self.y = 1
        self.lcdNumber_2.display(self.y)
        print("+1cm Y")
        self.updateLCD2()

    def ButtAdjYDn(self):
        try:
            if self.y > 0:
                self.y = self.y - 1
                print("-1cm Y")
        except:
            self.y = 0
        self.lcdNumber_2.display(self.y)
        self.updateLCD2()

    def JoyWrangler(self):
        print("I'm in")

        #original plan was using this handler for joystick, got it working other
        #way, left this here if I'm gonna change it later tho

    def FIRE(self, pressed):
        if pressed:
            print("ZAP!")
            switch1 = self.iodev.send("io set do 1 1")
            switch2 = self.iodev.send("io set do 2 1")
            state = self.iodev.send("io get do")
        else:
            print("no zap")
            switch1 = self.iodev.send("io set do 1 0")
            switch2 = self.iodev.send("io set do 2 0")
            state = self.iodev.send("io get do")

    def updateLCD(self, event):
        print(event)
        self.lcdNumber.display(event)
        #sleep(1) #delaying didn't seem to help the refresh lag
        reply = self.zdev.move_abs(self.cm * self.lcdNumber.intValue())

    def updateLCD3(self):
        print('x beep beep')
        reply = self.xdev.move_abs(self.cm * self.x)

    def updateLCD2(self):
        print('y beep beep')
        reply = self.ydev.move_abs(self.cm * self.y)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.label_8.setText(_translate("MainWindow", "Z pos (cm)"))
        self.label_4.setText(_translate("MainWindow", "Wire Length"))
        self.label_5.setText(_translate("MainWindow", "cm"))
        self.label_6.setText(_translate("MainWindow", "Y pos (cm)"))
        self.label_7.setText(_translate("MainWindow", "X pos (cm)"))
        self.pushButton_3.setText(_translate("MainWindow", "+y (1cm)"))
        self.pushButton_4.setText(_translate("MainWindow", "-y (1cm)"))
        self.pushButton_6.setText(_translate("MainWindow", "+x (1cm)"))
        self.pushButton_5.setText(_translate("MainWindow", "-x (1cm)"))
        self.label_2.setText(_translate("MainWindow", "XY Control"))
        self.pushButton_2.setText(_translate("MainWindow", "-z (1cm)"))
        self.label.setText(_translate("MainWindow", "Z Control"))
        self.label_3.setText(
            _translate("MainWindow", "Welcome to the PMA GUI!1!"))
        self.pushButton.setText(_translate("MainWindow", "+z (1cm)"))
        self.label_9.setText(_translate("MainWindow", "Wire Feed Delay"))
        self.label_10.setText(_translate("MainWindow", "Arc Delay"))
        self.pushButton_8.setText(_translate("MainWindow", "TEST FIRE"))
        self.label_11.setText(_translate("MainWindow", "Velocity"))
        self.label_12.setText(_translate("MainWindow", "Sec"))
        self.label_13.setText(_translate("MainWindow", "Sec"))
        self.label_14.setText(_translate("MainWindow", "fast"))
Beispiel #14
0
def device(asciiserial):
    return AsciiDevice(asciiserial, 1)
Beispiel #15
0
class Window(QtWidgets.QMainWindow):
    #only way I found to get keypressed working
    def __init__(self):
        super(Window, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        #PMA Setup, mostly copied from the file-based motion control
        try:
            USB_DEVICE = 'COM6'
            ZABER_ASCII_PORT = AsciiSerial(USB_DEVICE)
            print("NUTS!")
            self.torch_output = 1
            self.wire_output = 2
            self.iodev = AsciiDevice(
                ZABER_ASCII_PORT, 1)  #additional xy dev created to deal w/ io
            self.xdev = AsciiDevice(ZABER_ASCII_PORT, 1).axis(1)
            self.ydev = AsciiDevice(ZABER_ASCII_PORT, 1).axis(2)
            self.zdev = AsciiDevice(ZABER_ASCII_PORT, 2)
            self.number_devices = 2
            self.xdev.home()
            self.ydev.home()
            self.zdev.home()
            self.cm = 2016
        except:
            print("No Connection!!")

    #wasd control not working currently, leaving it here
    def keyPressEvent(self, e):
        print("key press")
        if e.key() == QtCore.Qt.Key_W:
            print('+y')
            reply = self.ydev.move_rel(self.cm)
        elif e.key() == QtCore.Qt.Key_S:
            print('-y')
            reply = self.ydev.move_rel(-self.cm)
        elif e.key() == QtCore.Qt.Key_A:
            print('+x')
            reply = self.xdev.move_rel(self.cm)
        elif e.key() == QtCore.Qt.Key_D:
            print('-x')
            reply = self.xdev.move_rel(-self.cm)
        elif e.key() == QtCore.Qt.Key_Up:
            print('+z')
            reply = self.zdev.move_rel(self.cm)
        elif e.key() == QtCore.Qt.Key_Down:
            print('-z')
            reply = self.zdev.move_rel(-self.cm)

    def keyReleaseEvent(self, e):
        print("key release")
        if e.key() == QtCore.Qt.Key_W:
            print('0y')
        elif e.key() == QtCore.Qt.Key_S:
            print('0y')
        elif e.key() == QtCore.Qt.Key_A:
            print('0x')
        elif e.key() == QtCore.Qt.Key_D:
            print('0x')
        elif e.key() == QtCore.Qt.Key_Up:
            print('0z')
        elif e.key() == QtCore.Qt.Key_Down:
            print('0z')
Beispiel #16
0
class Zaber_lin_stage(Instrument):
    '''
        None
    '''
    def __init__(self, name, device_number=1):
        '''
           None
        '''
        logging.info(__name__ +
                     ' : Initializing instrument Zaber Linear Stage')
        Instrument.__init__(self, name, tags=['physical'])

        self.add_parameter('position',
                           units='',
                           type=types.IntType,
                           flags=Instrument.FLAG_GETSET +
                           Instrument.FLAG_GET_AFTER_SET)

        self.add_parameter('device_number',
                           flags=Instrument.FLAG_GET,
                           type=types.StringType)

        self._device_number = device_number
        self.step_to_mm = 0.047625e-3

        self.client = AsciiDevice(AsciiSerial("COM4"), device_number)

    def poll_until_idle(self):
        reply = self.client.poll_until_idle()

    def home(self):
        reply = self.client.home()

    def move_rel(self, distance, blocking=True):
        reply = self.client.move_rel(distance, blocking)

    def move_rel_mm(self, distance, blocking=True):
        reply = self.client.move_rel(int(distance / self.step_to_mm), blocking)

    def move_abs(self, position, blocking=True):
        reply = self.client.move_abs(position, blocking)

    def move_abs_mm(self, position, blocking=True):
        reply = self.client.move_abs(int(position / self.step_to_mm), blocking)

    def move_vel(self, speed, blocking=False):
        reply = self.client.move_vel(speed, blocking)

    def move_vel_distance(self, vel, distance):
        x0 = self.client.get_position()
        speed = int(vel / self.step_to_mm)
        d = int(distance / self.step_to_mm)
        reply = self.client.move_vel(vel)
        while (1):
            x = self.client.get_position()
            if (abs(x - x0) > d):
                self.client.stop()
                breaktnm

    def stop(self):
        reply = self.client.stop()

    def current_status(self):
        reply = self.client.get_status()

    def current_position(self):
        reply = self.client.get_position()
        return reply