コード例 #1
0
    def __init__(self, sn_motor1=94832870, sn_motor2=94832869, **kwds):
        """
        Connect to the thorlabs stage at the specified port.
        """
        self.live = True
        self.unit_to_um = 1000.0  # units are mm
        self.um_to_unit = 1.0 / self.unit_to_um
        self.x = 0.0
        self.y = 0.0

        # sn_motor1 = 94832870
        # sn_motor2 = 94832869
        self.Motor1 = APTMotor(sn_motor1, HWTYPE=44)  # initialize motor 1 "x"
        self.Motor2 = APTMotor(sn_motor2, HWTYPE=44)  # initizalize motor 2 "y"
コード例 #2
0
class ControlStage(object):
    def __init__(self):
        self.M = APTMotor(83829712, HWTYPE=31, verbose=True)
        self.df = pd.read_csv('../../HPF_FRD/sequence.csv')
        self.x = df.x_out_fiber_dist.values

    def go_home(self):
        self.M.go_home()

    def go_to_32(self):
        # Move absolute
        self.M.mAbs(32.)

    def go_to(self, value):
        self.M.mAbs(value)

    def exit(self):
        self.M.cleanUpAPT()

    def run_sequence(self):
        print("Running sequence")
        for i, x in enumerate(self.x):
            self.go_to(x)
            print("##########################################")
            print(i, "Now at", x, "mm")
            input_val = raw_input("Press Enter to continue. Press q to stop")
            if input_val == "q":
                break
コード例 #3
0
 def connect_motor(serial_no):
     print("**** CONNECTING TO MOTOR", serial_no, "****")
     try:
         motor = APTMotor(SerialNum = serial_no, dllname=dll_location)
     except Exception as e:
         print("**** CONNECTION FAILED ****")
         raise
     try:
         pass
         #motor.go_home()
     except ValueError:
         pass  # always gives a ValueError for some reason
     motor.identify()  # blink to show connection clearly
     print(serial_no, "\n**** CONNECTED ****")
     return motor
コード例 #4
0
ファイル: MotorController.py プロジェクト: graysomb/Spec2
    def __init__(self):
        '''
        Constructor
        
        correct serial number:
        old 83863559
        83815746
        '''
        self.connectFailed = False
        try:
            self.Motor1 = APTMotor(83863559, HWTYPE=31)
            print self.Motor1.getHardwareInformation()
            print self.Motor1.getStageAxisInformation()
            print self.Motor1.getVelocityParameters()
#             self.degreeConv = 15.0156077
            self.degreeConv = 1
            self.Motor1.setVelocityParameters(0.0, 5.0, 5.99976)
            print self.Motor1.getVelocityParameters()
        except Exception as e:
            import ThreadedGUI
            self.connectFailed = True
            title = "Motor Connection Error"
            text = "Motor connection failed, make sure it is connected"
            p = mp.Process(target = ThreadedGUI.displayError, args =(title, text) )
            p.start()
            p.join()
コード例 #5
0
V1.2
20141125 V1.0    First working version
20141201 V1.0a   Updated to short notation
20150324 V1.1    Added more descriptions
20150417 V1.2    Implemented motor without serial

Michael Leung
[email protected]
"""

# Import APTMotor class from PyAPT
from PyAPT import APTMotor
import time

# Create object corresponding to the motor.
Motor1 = APTMotor(
    83828393, HWTYPE=31)  # The number should correspond to the serial number.
# Use help APTMotor to obtain full list of hardware (HW) supported.

# Note: You can control multiple motors by creating more APTMotor Objects

# Obtain current position of motor
print(Motor1.getPos())

# You can control multiple motors by creating more APTMotor Objects
# Serial numbers can be added later by using setSerialNumber and initializeHardwareDevice
# This functionality is particularly useful in the GUI setup.
Motor2 = APTMotor()
Motor2.setSerialNumber(83828393)
Motor2.initializeHardwareDevice()
print(Motor2.getPos())
コード例 #6
0
ファイル: myGUI.py プロジェクト: perezed00/InstrumentControl
    def __init__(self, parent=None, serial=00000000, verbose=False):
        super(widgetAPT, self).__init__(parent)
        self.resize(200, 100)
        #self.move(100, 100)
        #setGeometry sets both location and size
        #self.setGeometry(50, 50, 1180, 900)
        self.setWindowTitle('APT Motor')
        #self.m = APTMotor(0)

        # QT GridLayout
        # TODO: Implement GridLayout
        #grid = QGridLayout()

        # Layout objects
        sAuthor = QLabel("QT-APT", self)
        sAuthor.resize(100, 20)
        sAuthor.move(100, 0)
        sAuthor.setAlignment(Qt.AlignRight)
        sVersion = QLabel("v1.0.0", self)
        sVersion.resize(100, 20)
        sVersion.move(100, 15)
        sVersion.setAlignment(Qt.AlignRight)
        sEmail = QLabel("Michael Leung", self)
        sEmail.resize(100, 40)
        sEmail.move(100, 30)
        sEmail.setAlignment(Qt.AlignRight)

        # Motor Serial Number
        sSer = QLabel("Serial:", self)
        sSer.resize(60, 20)
        sSer.move(0, 0)
        self.txtSerial = QSpinBox(self)
        self.txtSerial.resize(70, 20)
        self.txtSerial.move(30, 0)
        self.txtSerial.setRange(0, 99999999)
        self.txtSerial.setSingleStep(1)
        self.txtSerial.setValue(83840946)
        # qle.textChanged[str].connect(self.onChanged) #do onChanged when changed
        self._Motor_ = APTMotor(verbose=verbose)

        # Motor Connect
        self.btnConnect = QPushButton("Connect", self)
        self.btnConnect.setStyleSheet("background-color: grey")
        self.btnConnect.setText("Connect")
        self.btnConnect.setCheckable(True)
        self.btnConnect.setToolTip("Connect to Motor")
        self.btnConnect.resize(50, 20)
        self.btnConnect.move(105, 0)
        self.btnConnect.clicked[bool].connect(self.connectAPT)

        sPos = QLabel("Pos:", self)
        sPos.resize(70, 20)
        sPos.move(0, 25)
        self.txtPos = QDoubleSpinBox(self)
        self.txtPos.resize(60, 20)
        self.txtPos.move(30, 25)
        #self.txtPos.setMaxLength(7)
        self.txtPos.setRange(0, 20)
        self.txtPos.setSingleStep(.1)
        self.txtPos.setDecimals(5)
        self.txtPos.setValue(0.0000000)
        self.txtPos.setToolTip("Current Motor Position")
        #self.txtPos.setValidator( QDoubleValidator(0, 100, 2) )
        self.txtPos.setEnabled(False)

        # Go to position
        btnGOp = QPushButton("Go", self)
        btnGOp.resize(25, 20)
        btnGOp.move(100, 25)
        btnGOp.clicked.connect(lambda: self.motAbs(float(self.txtPos.text())))

        # Movement buttons
        btnN3 = QPushButton("-100", self)
        btnN3.resize(32, 20)
        btnN3.move(0, 50)
        btnN3.clicked.connect(lambda: self.motRel(-.1))

        btnN2 = QPushButton("-10", self)
        btnN2.resize(32, 20)
        btnN2.move(33, 50)
        btnN2.clicked.connect(lambda: self.motRel(-.01))

        btnN1 = QPushButton("-1", self)
        btnN1.resize(32, 20)
        btnN1.move(66, 50)
        btnN1.clicked.connect(lambda: self.motRel(-.001))

        btnP1 = QPushButton("+1", self)
        btnP1.resize(32, 20)
        btnP1.move(100, 50)
        btnP1.clicked.connect(lambda: self.motRel(.001))

        btnP2 = QPushButton("+10", self)
        btnP2.resize(32, 20)
        btnP2.move(133, 50)
        btnP2.clicked.connect(lambda: self.motRel(.01))

        btnP3 = QPushButton("+100", self)
        btnP3.resize(32, 20)
        btnP3.move(166, 50)
        btnP3.clicked.connect(lambda: self.motRel(.1))

        sVel = QLabel("Vel:", self)
        sVel.resize(60, 20)
        sVel.move(0, 75)
        self.txtVel = QDoubleSpinBox(self)
        self.txtVel.resize(60, 20)
        self.txtVel.move(30, 75)
        #self.txtVel.setMaxLength(7)
        self.txtVel.setRange(0, 2.2)
        self.txtVel.setSingleStep(.1)
        self.txtVel.setValue(0.000)
        self.txtVel.setToolTip("Current Motor Position")
        self.txtVel.setEnabled(False)
        # Go to velocity
        btnGOv = QPushButton("Go", self)
        btnGOv.resize(25, 20)
        btnGOv.move(100, 75)
        btnGOv.clicked.connect(
            lambda: self._Motor_.setVel(float(self.txtVel.text())))

        sBack = QLabel("Backlash:", self)
        sBack.resize(60, 20)
        sBack.move(130, 75)
        self.cbBacklash = QCheckBox(self)
        self.cbBacklash.resize(60, 20)
        self.cbBacklash.move(180, 75)

        self.show()
コード例 #7
0
 def __init__(self):
     self.M = APTMotor(83829712, HWTYPE=31, verbose=True)
     self.df = pd.read_csv('../../HPF_FRD/sequence.csv')
     self.x = df.x_out_fiber_dist.values
コード例 #8
0
ファイル: myGUI.py プロジェクト: edbarnard/PyAPT
    def __init__(self, parent = None, serial=00000000, verbose=False):
        super(widgetAPT, self).__init__(parent)
        self.resize(200, 100)
        #self.move(100, 100)
        #setGeometry sets both location and size
        #self.setGeometry(50, 50, 1180, 900)
        self.setWindowTitle('APT Motor')
        #self.m = APTMotor(0)

        # QT GridLayout
        # TODO: Implement GridLayout
        #grid = QGridLayout()

        # Layout objects
        sAuthor = QLabel("QT-APT", self)
        sAuthor.resize(100, 20)
        sAuthor.move(100, 0)
        sAuthor.setAlignment(Qt.AlignRight)
        sVersion = QLabel("v1.0.0", self)
        sVersion.resize(100, 20)
        sVersion.move(100, 15)
        sVersion.setAlignment(Qt.AlignRight)
        sEmail = QLabel("Michael Leung", self)
        sEmail.resize(100, 40)
        sEmail.move(100, 30)
        sEmail.setAlignment(Qt.AlignRight)


        # Motor Serial Number
        sSer = QLabel("Serial:", self)
        sSer.resize(60, 20)
        sSer.move(0, 0)
        self.txtSerial = QSpinBox(self)
        self.txtSerial.resize(70,20)
        self.txtSerial.move(30,0)
        self.txtSerial.setRange(0, 99999999)
        self.txtSerial.setSingleStep(1)
        self.txtSerial.setValue(83840946)
        # qle.textChanged[str].connect(self.onChanged) #do onChanged when changed
        self._Motor_ = APTMotor(verbose=verbose)

        # Motor Connect
        self.btnConnect = QPushButton("Connect", self)
        self.btnConnect.setStyleSheet("background-color: grey")
        self.btnConnect.setText("Connect")
        self.btnConnect.setCheckable(True)
        self.btnConnect.setToolTip("Connect to Motor")
        self.btnConnect.resize(50, 20)
        self.btnConnect.move(105, 0)
        self.btnConnect.clicked[bool].connect(self.connectAPT)

        sPos = QLabel("Pos:", self)
        sPos.resize(70, 20)
        sPos.move(0, 25)
        self.txtPos = QDoubleSpinBox(self)
        self.txtPos.resize(60, 20)
        self.txtPos.move(30, 25)
        #self.txtPos.setMaxLength(7)
        self.txtPos.setRange(0, 20)
        self.txtPos.setSingleStep(.1)
        self.txtPos.setDecimals(5)
        self.txtPos.setValue(0.0000000)
        self.txtPos.setToolTip("Current Motor Position")
        #self.txtPos.setValidator( QDoubleValidator(0, 100, 2) )
        self.txtPos.setEnabled(False)

        # Go to position
        btnGOp = QPushButton("Go", self)
        btnGOp.resize(25, 20)
        btnGOp.move(100, 25)
        btnGOp.clicked.connect(lambda: self.motAbs(float(self.txtPos.text())))

        # Movement buttons
        btnN3 = QPushButton("-100", self)
        btnN3.resize(32, 20)
        btnN3.move(0, 50)
        btnN3.clicked.connect(lambda: self.motRel(-.1))

        btnN2 = QPushButton("-10", self)
        btnN2.resize(32, 20)
        btnN2.move(33, 50)
        btnN2.clicked.connect(lambda: self.motRel(-.01))

        btnN1 = QPushButton("-1", self)
        btnN1.resize(32, 20)
        btnN1.move(66, 50)
        btnN1.clicked.connect(lambda: self.motRel(-.001))

        btnP1 = QPushButton("+1", self)
        btnP1.resize(32, 20)
        btnP1.move(100, 50)
        btnP1.clicked.connect(lambda: self.motRel(.001))

        btnP2 = QPushButton("+10", self)
        btnP2.resize(32, 20)
        btnP2.move(133, 50)
        btnP2.clicked.connect(lambda: self.motRel(.01))

        btnP3 = QPushButton("+100", self)
        btnP3.resize(32, 20)
        btnP3.move(166, 50)
        btnP3.clicked.connect(lambda: self.motRel(.1))


        sVel = QLabel("Vel:", self)
        sVel.resize(60, 20)
        sVel.move(0, 75)
        self.txtVel = QDoubleSpinBox(self)
        self.txtVel.resize(60, 20)
        self.txtVel.move(30, 75)
        #self.txtVel.setMaxLength(7)
        self.txtVel.setRange(0, 2.2)
        self.txtVel.setSingleStep(.1)
        self.txtVel.setValue(0.000)
        self.txtVel.setToolTip("Current Motor Position")
        self.txtVel.setEnabled(False)
        # Go to velocity
        btnGOv = QPushButton("Go", self)
        btnGOv.resize(25, 20)
        btnGOv.move(100, 75)
        btnGOv.clicked.connect(lambda: self._Motor_.setVel(float(self.txtVel.text())))

        sBack = QLabel("Backlash:", self)
        sBack.resize(60, 20)
        sBack.move(130, 75)
        self.cbBacklash = QCheckBox(self)
        self.cbBacklash.resize(60, 20)
        self.cbBacklash.move(180, 75)


        self.show()
コード例 #9
0
ファイル: interface.py プロジェクト: saurabhX9/FROG
class widgetAPT(QWidget):
    def __init__(self,
                 parent=None,
                 serial=00000000,
                 verbose=False):  ##, verbose=False
        super(widgetAPT, self).__init__(parent)
        self.resize(1300, 650)
        self.setWindowTitle('FROG')
        self.setWindowIcon(QIcon('iiserb.png'))

        layout = QGridLayout()
        ##        self.setLayout(layout)

        self.data = np.genfromtxt('N1648.txt',
                                  skip_header=12,
                                  skip_footer=7308)

        # Layout objects
        sStag = QLabel("Stage", self)
        sStag.setStyleSheet("font: 22pt;")
        layout.addWidget(sStag, 2, 2)

        sAuthor = QLabel("Frequency Resolved Optical Gating", self)
        sAuthor.setStyleSheet("font: 40pt; color:green")
        layout.addWidget(sAuthor, 1, 3, 1, 15)

        # Motor Serial Number

        sSer = QLabel("Serial:", self)
        sSer.setStyleSheet("font: 16pt;")
        layout.addWidget(sSer, 3, 1)

        self.txtSerial = QSpinBox(self)
        self.txtSerial.setRange(0, 99999999)
        self.txtSerial.setSingleStep(1)
        self.txtSerial.setValue(27503288)

        layout.addWidget(self.txtSerial, 3, 2)
        self._Motor_ = APTMotor(verbose=verbose)

        # Motor Connect button
        self.btnConnect = QPushButton("Connect", self)
        self.btnConnect.setStyleSheet("background-color: grey")
        self.btnConnect.setText("Connect")
        self.btnConnect.setCheckable(True)
        self.btnConnect.setToolTip("Connect to Motor")
        self.btnConnect.clicked[bool].connect(self.connectAPT)

        layout.addWidget(self.btnConnect, 3, 3)

        sPos = QLabel("Pos:", self)
        sPos.setStyleSheet("font: 16pt;")
        self.txtPos = QDoubleSpinBox(self)
        self.txtPos.setRange(-5, 13)
        self.txtPos.setSingleStep(.1)
        self.txtPos.setDecimals(5)
        self.txtPos.setValue(0.0000000)
        self.txtPos.setToolTip("Current Motor Position")
        self.txtPos.setEnabled(False)
        layout.addWidget(sPos, 4, 1)
        layout.addWidget(self.txtPos, 4, 2)

        # Go to position
        self.btnGOp = QPushButton("Go", self)
        self.btnGOp.clicked.connect(
            lambda: self.motAbs(float(self.txtPos.text())))

        layout.addWidget(self.btnGOp, 4, 3)

        #Home button
        self.btnHome = QPushButton("Home", self)
        self.btnHome.setToolTip("This will take the stage to 6.50")
        layout.addWidget(self.btnHome, 5, 1, 1, 1.5)
        self.btnHome.clicked.connect(lambda: self.motAbs(6.50000))

        #go to zero
        self.btnZero = QPushButton("Go to Zero", self)
        self.btnZero.setToolTip("This will take the stage to absolute 0")
        layout.addWidget(self.btnZero, 5, 2, 1, 1.5)
        self.btnZero.clicked[bool].connect(lambda: self._Motor_.go_home())

        #Velocity buttons

        sVel = QLabel("Velocity:", self)
        sVel.setStyleSheet("font: 14pt;")

        self.txtVel = QDoubleSpinBox(self)
        self.txtVel.setRange(0, 2.2)
        self.txtVel.setSingleStep(.1)
        self.txtVel.setValue(1.5)
        self.txtVel.setToolTip("set the velocity here")
        self.txtVel.setEnabled(False)

        layout.addWidget(sVel, 6, 1)
        layout.addWidget(self.txtVel, 6, 2)

        self.btnGOv = QPushButton("Set", self)
        self.btnGOv.clicked.connect(
            lambda: self._Motor_.setVel(float(self.txtVel.text())))

        layout.addWidget(self.btnGOv, 6, 3)

        sBack = QLabel("Backlash:", self)
        sBack.setStyleSheet("font: 14pt;")

        self.cbBacklash = QCheckBox(self)
        layout.addWidget(sBack, 7, 1)
        layout.addWidget(self.cbBacklash, 7, 2)
        sSpect = QLabel("Spectrometer", self)
        sSpect.setStyleSheet("font: 22pt;")
        sSpect.setFont(QFont('Arial', 20))
        layout.addWidget(sSpect, 8, 2)

        texp = QLabel("Time of Exp.:", self)
        texp.setStyleSheet("font: 14pt;")
        layout.addWidget(texp, 9, 1)

        self.timexp = QDoubleSpinBox(self)
        self.timexp.setRange(0, 100000)
        self.timexp.setSingleStep(1)
        self.timexp.setDecimals(0)
        self.timexp.setValue(10)
        layout.addWidget(self.timexp, 9, 2)
        self.btnCh = QPushButton("Set", self)
        layout.addWidget(self.btnCh, 9, 3)

        nscan = QLabel("Num. of scan:", self)
        nscan.setStyleSheet("font: 14pt;")
        layout.addWidget(nscan, 10, 1)
        self.nscantxt = QDoubleSpinBox(self)
        self.nscantxt.setRange(0, 137)
        self.nscantxt.setSingleStep(1)
        self.nscantxt.setDecimals(0)
        self.nscantxt.setValue(10)
        layout.addWidget(self.nscantxt, 10, 2)
        self.nscan = QPushButton("Set", self)
        layout.addWidget(self.nscan, 10, 3)

        #self.timexp.setEnabled(False)

        ##        self.timeofexposure = c_uint32(1000)

        self.btnCh.clicked[bool].connect(self.assignexp)

        self.nscan.clicked[bool].connect(self.assignnscan)

        sSpos = QLabel("Signal pos.(mm):")
        sSpos.setStyleSheet("font: 14pt;")
        self.txtSpos = QDoubleSpinBox(self)
        self.txtSpos.setRange(0, 12.0000)
        self.txtSpos.setDecimals(5)
        self.txtSpos.setSingleStep(0.00001)
        self.txtSpos.setValue(6.50000)
        layout.addWidget(sSpos, 12, 1)
        layout.addWidget(self.txtSpos, 12, 2)

        self.btnSpos = QPushButton("Set", self)
        layout.addWidget(self.btnSpos, 12, 3)
        self.btnSpos.clicked[bool].connect(
            lambda: self.txtSpos.setValue(float(self.txtSpos.text())))

        sSpectra = QLabel("Spectrum", self)
        sSpectra.setStyleSheet("font: 14pt;")
        sSpectra.setFont(QFont('Arial', 20))
        layout.addWidget(sSpectra, 13, 1)

        #----------------------------Spectromter Plot----------------------------------------------------------------------------------------------------

        #time of exposure box
        self.spectra = create_string_buffer(7500)
        pg.setConfigOption('background', 'w')
        self.plot1 = pg.PlotWidget()
        layout.addWidget(self.plot1, 3, 7, 8, 8)
        self.timer = pg.QtCore.QTimer()

        self.liveb = QPushButton('Live', self)
        layout.addWidget(self.liveb, 13, 2)
        self.liveb.setCheckable(True)

        self.liveb.clicked[bool].connect(self.live)
        self.lbox = QCheckBox(self)

        ##        self.timer.timeout.connect(self.updater)

        ##        self.static = QCheckBox(self)

        layout.addWidget(self.lbox, 13, 3)

        self.fname = QLineEdit(self)
        self.fname.setToolTip("ENTER FILENAME.TXT")
        layout.addWidget(self.fname, 14, 1, 1, 2)
        self.sScan = QPushButton("Start Scan", self)
        layout.addWidget(self.sScan, 14, 3, 1, 1)
        self.sScan.clicked[bool].connect(self.scan)
        self.pbar = QProgressBar(self)

        layout.addWidget(self.pbar, 15, 1, 1, 2)

        ##        self.spectra = create_string_buffer(7500)
        ##        cam.sptdll.getFrame(byref(self.spectra),0xFFFF)
        ##        self.b = np.frombuffer(self.spectra, dtype=np.uint16)
        ##        self.plot1.plot(self.data,self.b[0:3653],pen='b', clear=True)
        ##        pg.QtGui.QApplication.processEvents()

        ##-----------------------------------------------------------------------------------------

        self.figure = Figure()

        self.canvas = FigureCanvas(self.figure)

        # this is the Navigation widget
        # it takes the Canvas widget and a parent
        self.toolbar = NavigationToolbar(self.canvas, self)

        # Just some button connected to `plot` method
        self.button = QPushButton('Plot')
        self.button.clicked.connect(self.graph)

        # set the layout

        layout.addWidget(self.toolbar, 11, 7, 1, 8)
        layout.addWidget(self.canvas, 12, 7, 5, 8)
        layout.addWidget(self.button, 15, 3, 1, 1)
        self.setLayout(layout)

        self.ex = QPushButton('EXIT', self)
        layout.addWidget(self.ex, 16, 2, 2, 1)
        self.ex.clicked.connect(lambda: self._Motor_.cleanUpAPT())


#--------------------------------------------------------------------------------------------------------------------------------
##

    def live(self):

        if self.lbox.isChecked():
            self.timer.timeout.connect(self.updater)
            self.timer.start(5)

        else:
            self.timer.stop()

    def updater(self):
        cam.sptdll.getFrame(byref(self.spectra), 0xFFFF)
        self.b = np.frombuffer(self.spectra, dtype=np.uint16)
        self.plot1.plot(self.data, self.b[0:3653], pen='b', clear=True)

    def scan(self, pressed):

        self.completed = 0

        self.pbar.setValue(self.completed)
        #writing in file
        starting = float(self.txtSpos.text()) - 0.045
        self.motAbs(starting)

        if (self.fname.text() == ""):
            now = datetime.datetime.now()
            self.name = now.strftime("%Y %m %d %H %M")

        else:
            self.name = self.fname.text()
        speed = 3e8
        for i in range(60):  #replaced 60 by 100

            self.completed += 1.66667

            self.pbar.setValue(self.completed)

            self.motRel(0.00150)

            fo = open(
                r"C:\Users\creates\Desktop\Frog\FROG_soft\DATA_ACQUISITION\\" +
                self.name + ".txt", "a+")

            cam.sptdll.getFrame(byref(self.spectra), 0xFFFF)
            self.b = np.frombuffer(self.spectra, dtype=np.uint16)
            fo.write("\t")

            for j in range(3653):
                fo.write(str((i + 1 - 30) * (0.000015) * (1 / speed)))
                fo.write("\t")
                fo.write(str(self.data[j]))
                fo.write("\t")
                fo.write(str(self.b[j]))
                fo.write("\n")
                fo.write("\t")
            fo.close()
        self.completed = 100
        self.pbar.setValue(self.completed)
        return True

    def assignexp(self, pressed):
        e = c_uint32(int(self.timexp.text()))
        cam.sptdll.setExposure(cam.timeofexposure)
        cam.sptdll.setAcquisitionParameters(cam.numScans, cam.numblankscans,
                                            cam.scanmode, e)
        pg.QtGui.QApplication.processEvents()
        return True

    def assignnscan(self, pressed):
        n = c_uint16(int(self.nscantxt.text()))
        cam.sptdll.setAcquisitionParameters(n, cam.numblankscans, cam.scanmode,
                                            cam.timeofexposure)
        pg.QtGui.QApplication.processEvents()
        return True

    def connectAPT(self, pressed):
        if pressed:
            #APT Motor connect
            Serial = int(self.txtSerial.text())
            self._Motor_.setSerialNumber(Serial)
            self._Motor_.initializeHardwareDevice()

            # Success
            self.btnConnect.setStyleSheet("background-color: green")
            self.btnConnect.setText("Connected")

            self.txtSerial.setEnabled(False)
            self.txtPos.setEnabled(True)
            # Update text to show position
            self.txtPos.setValue(self._Motor_.getPos())

            self.txtVel.setEnabled(True)
            _, _, maxVel = self._Motor_.getVelocityParameters()
            self.txtVel.setValue(maxVel)
            self._Motor_.go_home()

            return True
        else:
            self.btnConnect.setStyleSheet("background-color: grey")
            self.btnConnect.setText("Connect")

            self.txtSerial.setEnabled(True)
            self.txtPos.setEnabled(False)
            self.txtVel.setEnabled(False)
            self.txtPos.setValue(0.0000)
            self.txtPos.setToolTip("Current Motor Position")
            return True

    def motRel(self, relDistance):
        self._Motor_.setVel(float(self.txtVel.text()))
        if self.cbBacklash.isChecked():
            self._Motor_.mbRel(relDistance)
        else:
            self._Motor_.mcRel(relDistance)

        self.txtPos.setValue(self._Motor_.getPos())

    def motAbs(self, absDistance):
        self._Motor_.setVel(float(self.txtVel.text()))
        if self.cbBacklash.isChecked():
            self._Motor_.mbAbs(absDistance)
        else:
            self._Motor_.mAbs(absDistance)
        # Update text to show position
        self.txtPos.setValue(self._Motor_.getPos())

    def graph(self):
        ''' plot some random stuff '''
        filename = str("max2_F.txt")

        data = np.loadtxt(filename)
        x = data[:, 0]  #Scan number
        y = data[:, 1]
        z = data[:, 2]  #Intensity
        zmat = z.reshape(60, 3653)
        ##        print("here")
        # create an axis

        ax = self.figure.add_subplot(111)
        ax2 = self.figure.add_subplot(112)
        # discards the old graph
        ax.clear()

        ax.imshow(np.transpose(zmat),
                  cmap=cm.jet,
                  aspect=10,
                  extent=(-150, 150, 370, 430),
                  interpolation='nearest')  ##,aspect=10,extent=(0,300,370,430)

        self.canvas.draw()
コード例 #10
0
class BBD103():
    """
    Thorlabs USB interface to BBD103 controller for a MLS203 stage
    """
    def __init__(self, sn_motor1=94832870, sn_motor2=94832869, **kwds):
        """
        Connect to the thorlabs stage at the specified port.
        """
        self.live = True
        self.unit_to_um = 1000.0  # units are mm
        self.um_to_unit = 1.0 / self.unit_to_um
        self.x = 0.0
        self.y = 0.0

        # sn_motor1 = 94832870
        # sn_motor2 = 94832869
        self.Motor1 = APTMotor(sn_motor1, HWTYPE=44)  # initialize motor 1 "x"
        self.Motor2 = APTMotor(sn_motor2, HWTYPE=44)  # initizalize motor 2 "y"

    ## getStatus
    #
    # @return True/False if we are actually connected to the stage.
    #
    def getStatus(self):
        return self.live

    def goAbsolute(self, x, y):
        x = x * self.um_to_unit
        y = y * self.um_to_unit
        self.Motor1.mAbs(x)  #
        self.Motor2.mAbs(y)  #

    def goRelative(self, x, y):
        x = x * self.um_to_unit
        y = y * self.um_to_unit
        self.Motor1.mRel(x)  #
        self.Motor2.mRel(y)  #

    def jog(self, x_speed,
            y_speed):  # shouldn't this also specify a relative position
        vx = x_speed * self.um_to_unit
        vy = y_speed * self.um_to_unit
        self.Motor1.setVel(x_speed)
        self.Motor2.setVel(y_speed)

    def joystickOnOff(self, on):
        if on:
            self.writeline("!joy 2")
        else:
            self.writeline("!joy 0")

    ## lockout
    #
    # Calls joystickOnOff.
    #
    # @param flag True/False.
    #
    def lockout(self, flag):
        self.joystickOnOff(not flag)

    ## position
    #
    # @return [stage x (um), stage y (um), stage z (um)]
    #
    def position(self):
        if self.live:
            x0 = self.Motor1.getPos()  # query single axis
            y0 = self.Motor2.getPos()  # query single axis
            return {"x": x0, "y": y0}

    def serialNumber(self):
        """
        Return the stages serial number.
        """
        return self.Motor1.getHardwareInformation()

    def setVelocity(self, x_vel, y_vel):
        """
        x_vel - The maximum stage velocity allowed in x.
        y_vel - The maximum stage velocity allowed in y.
        I'm not sure this should be allowed to change the max velocity here. 
        """
        pass

    ## shutDown
    #
    # Disconnect from the stage.
    #
    def shutDown(self):
        # Disconnect from the stage (not sure this is correct)
        if self.live:
            self.Motor1.cleanUpAPT()
            self.Motor2.cleanUpAPT()

    def zero(self):
        pass
コード例 #11
0
# -*- coding: utf-8 -*-
"""
Created on Wed May 24 15:37:18 2017

@author: Neo
"""
import time
import sys
import os
sys.path.append(os.path.abspath('D:\WMP_setup\Python_codes\PyAPT-master'))

from PyAPT import APTMotor

#filter, rot4
try:
    rot4 = APTMotor(83847409,HWTYPE=31)
    rot4.setVelocityParameters(0,25,25)
    
    def move_rot4(ang=None):
        if ang == None:
            return rot4.getPos()
        else:
            rot4.mAbs(ang)  
            return move_rot4(ang=None)
    
    def home_rot4():
        rot4.go_home()

    print 'rot4 online.'
except:
    print('rot4 not connected')
コード例 #12
0
# Connecting to camera
bus = PyCapture2.BusManager()
cam = PyCapture2.Camera()

try:
    uid = bus.getCameraFromSerialNumber(serial_camera)
    cam.connect(uid)
    printCameraInfo(cam)
except PyCapture2.Fc2error:
    print("Error: Failed to connect to camera #", serial_camera)
    sys.exit()

# Connecting to stage
try:
    z_axis = APTMotor(serial_z, HWTYPE=TDC001)
except:
    print("Error: Failed to connec to Z axis #", serial_z)
    sys.exit()

try:
    x_axis = APTMotor(serial_x, HWTYPE=TDC001)
except:
    print("Error: Failed to connec to X axis #", serial_x)
    sys.exit()

# Homing stage
if home:
    print("Homing axis Z...\t", end='')
    z_axis.go_home()
    print("[DONE]\nHoming axis X...\t", end='')
コード例 #13
0
# -*- coding: utf-8 -*-
"""
Created on Wed May 24 15:37:18 2017

@author: Neo
"""
import time
import sys
import os
sys.path.append(os.path.abspath('D:\WMP_setup\Python_codes\PyAPT-master'))

from PyAPT import APTMotor

#unused, rot1
try:
    rot1 = APTMotor(83845997, HWTYPE=31)
    rot1.setVelocityParameters(0, 25, 25)

    def move_rot1(ang=None):
        if ang == None:
            return rot1.getPos()
        else:
            rot1.mAbs(ang)
            return move_rot1(ang=None)

    def home_rot1():
        rot1.go_home()

    print 'rot1 online.'
except:
    print('rot1 not connected')
コード例 #14
0
class widgetAPT(QWidget):
    def __init__(self, parent=None, serial=00000000):
        super(widgetAPT, self).__init__(parent)
        self.resize(200, 200)
        #self.move(100, 100)
        #setGeometry sets both location and size
        #self.setGeometry(50, 50, 1180, 900)
        self.setWindowTitle('APT Motor')
        #self.m = APTMotor(0)

        # QT GridLayout
        # TODO: Implement GridLayout
        #grid = QGridLayout()

        # Layout objects
        sAuthor = QLabel("QT-APT", self)
        sAuthor.resize(100, 20)
        sAuthor.move(100, 0)
        sAuthor.setAlignment(Qt.AlignRight)
        sVersion = QLabel("v1.0.0", self)
        sVersion.resize(100, 20)
        sVersion.move(100, 15)
        sVersion.setAlignment(Qt.AlignRight)
        sEmail = QLabel("Michael Leung", self)
        sEmail.resize(100, 40)
        sEmail.move(100, 35)
        sEmail.setAlignment(Qt.AlignRight)

        # Motor Serial Number
        sSer = QLabel("Serial:", self)
        sSer.resize(60, 20)
        sSer.move(0, 0)
        self.txtSerial = QSpinBox(self)
        self.txtSerial.resize(70, 20)
        self.txtSerial.move(30, 0)
        self.txtSerial.setRange(0, 99999999)
        self.txtSerial.setSingleStep(1)
        self.txtSerial.setValue(83840946)
        # qle.textChanged[str].connect(self.onChanged) #do onChanged when changed
        self._Motor_ = APTMotor()

        # Motor Connect
        self.btnConnect = QPushButton("Connect", self)
        self.btnConnect.setStyleSheet("background-color: grey")
        self.btnConnect.setText("Connect")
        self.btnConnect.setCheckable(True)
        self.btnConnect.setToolTip("Connect to Motor")
        self.btnConnect.resize(50, 20)
        self.btnConnect.move(105, 0)
        self.btnConnect.clicked[bool].connect(self.connectAPT)

        sPos = QLabel("Pos:", self)
        sPos.resize(60, 20)
        sPos.move(0, 25)
        self.txtPos = QDoubleSpinBox(self)
        self.txtPos.resize(60, 20)
        self.txtPos.move(30, 25)
        #self.txtPos.setMaxLength(7)
        self.txtPos.setRange(0, 20)
        self.txtPos.setSingleStep(.1)
        self.txtPos.setDecimals(5)
        self.txtPos.setValue(0.0000000)
        self.txtPos.setToolTip("Current Motor Position")
        #self.txtPos.setValidator( QDoubleValidator(0, 100, 2) )
        self.txtPos.setEnabled(False)

        # Go to position
        btnGOp = QPushButton("Go", self)
        btnGOp.resize(25, 20)
        btnGOp.move(95, 25)
        btnGOp.clicked.connect(lambda: self.motAbs(float(self.txtPos.text())))

        # Movement buttons
        btnN3 = QPushButton("-100", self)
        btnN3.resize(30, 20)
        btnN3.move(0, 50)
        btnN3.clicked.connect(lambda: self.motRel(-.1))

        btnN2 = QPushButton("-10", self)
        btnN2.resize(30, 20)
        btnN2.move(30, 50)
        btnN2.clicked.connect(lambda: self.motRel(-.01))

        btnN1 = QPushButton("-1", self)
        btnN1.resize(30, 20)
        btnN1.move(60, 50)
        btnN1.clicked.connect(lambda: self.motRel(-.001))

        btnP1 = QPushButton("+1", self)
        btnP1.resize(30, 20)
        btnP1.move(100, 50)
        btnP1.clicked.connect(lambda: self.motRel(.001))

        btnP2 = QPushButton("+10", self)
        btnP2.resize(30, 20)
        btnP2.move(130, 50)
        btnP2.clicked.connect(lambda: self.motRel(.01))

        btnP3 = QPushButton("+100", self)
        btnP3.resize(30, 20)
        btnP3.move(160, 50)
        btnP3.clicked.connect(lambda: self.motRel(.1))

        sVel = QLabel("Vel:", self)
        sVel.resize(60, 20)
        sVel.move(0, 75)
        self.txtVel = QDoubleSpinBox(self)
        self.txtVel.resize(60, 20)
        self.txtVel.move(30, 75)
        #self.txtVel.setMaxLength(7)
        self.txtVel.setRange(0, 2.2)
        self.txtVel.setSingleStep(.1)
        self.txtVel.setValue(0.00000)
        self.txtVel.setToolTip("Current Motor Position")
        self.txtVel.setEnabled(False)
        # Go to velocity
        btnGOv = QPushButton("Go", self)
        btnGOv.resize(25, 20)
        btnGOv.move(95, 75)
        btnGOv.clicked.connect(
            lambda: self._Motor_.setVel(float(self.txtVel.text())))

        sBack = QLabel("Backlash:", self)
        sBack.resize(60, 20)
        sBack.move(130, 75)
        self.cbBacklash = QCheckBox(self)
        self.cbBacklash.resize(60, 20)
        self.cbBacklash.move(180, 75)

        self.show()

    def connectAPT(self, pressed):
        if pressed:
            #APT Motor connect
            Serial = int(self.txtSerial.text())
            self._Motor_.setSerialNumber(Serial)
            self._Motor_.initializeHardwareDevice()

            # Success
            self.btnConnect.setStyleSheet("background-color: green")
            self.btnConnect.setText("Connected")

            self.txtSerial.setEnabled(False)
            self.txtPos.setEnabled(True)
            # Update text to show position
            self.txtPos.setValue(self._Motor_.getPos())

            self.txtVel.setEnabled(True)
            _, _, maxVel = self._Motor_.getVelocityParameters()
            self.txtVel.setValue(maxVel)

            return True
        else:
            #APT Motor disconnect
            self._Motor_.cleanUpAPT()
            # Success
            self.btnConnect.setStyleSheet("background-color: grey")
            self.btnConnect.setText("Connect")

            self.txtSerial.setEnabled(True)
            self.txtPos.setEnabled(False)
            self.txtVel.setEnabled(False)
            self.txtPos.setValue(0.0000)
            self.txtPos.setToolTip("Current Motor Position")
            return True

    def motRel(self, relDistance):
        if self.cbBacklash.isChecked():
            self._Motor_.mbRel(relDistance)
        else:
            self._Motor_.mRel(relDistance)
        # Update text to show position
        self.txtPos.setValue(self._Motor_.getPos())

    def motAbs(self, absDistance):
        if self.cbBacklash.isChecked():
            self._Motor_.mbAbs(absDistance)
        else:
            self._Motor_.mAbs(absDistance)
        # Update text to show position
        self.txtPos.setValue(self._Motor_.getPos())
コード例 #15
0
# -*- coding: utf-8 -*-
"""
Created on Wed May 24 15:37:18 2017

@author: Neo
"""
import sys
import os
sys.path.append(os.path.abspath('D:\WMP_setup\Python_codes\PyAPT-master'))

from PyAPT import APTMotor

#analyzer, rot5
try:
    rot5 = APTMotor(28250988,HWTYPE=28)
    
    def move_rot5(ang=None):
        if ang == None:
            ans = rot5.getPos()*360.
            if ans > 64800:
                ans -= 129600
                ans %= -360
            else:
                ans %= 360
            return ans
        else:
            rot5.mAbs((ang/360.)%360) #/360 to convert to correct unit, %360 to keep in 1 rotation  
            return move_rot5(ang=None)
    
    def home_rot5():
        rot5.go_home()
コード例 #16
0
ファイル: Example.py プロジェクト: wwoody827/PyAPT
V1.2
20141125 V1.0    First working version
20141201 V1.0a   Updated to short notation
20150324 V1.1    Added more descriptions
20150417 V1.2    Implemented motor without serial

Michael Leung
[email protected]
"""

# Import APTMotor class from PyAPT
from PyAPT import APTMotor
import time

# Create object corresponding to the motor.83840805
Motor1 = APTMotor(83840805, HWTYPE=31) # The number should correspond to the serial number.
# Use help APTMotor to obtain full list of hardware (HW) supported.

# Note: You can control multiple motors by creating more APTMotor Objects


# Obtain current position of motor
print(Motor1.getPos())

# You can control multiple motors by creating more APTMotor Objects
# Serial numbers can be added later by using setSerialNumber and initializeHardwareDevice
# This functionality is particularly useful in the GUI setup.
Motor2 = APTMotor()
Motor2.setSerialNumber(83829690)
Motor2.initializeHardwareDevice()
print(Motor2.getPos())
コード例 #17
0
def right(d, v=0.3):
    motVel = v  #motor velocity, in mm/sec
    Motor2.mcRel(-d, motVel)  # Negative Right / Positive Left


def up(d, v=0.3):
    motVel = v  #motor velocity, in mm/sec
    Motor1.mcRel(d, motVel)  # negative me / positive knife


def down(d, v=0.3):
    motVel = v  #motor velocity, in mm/sec
    Motor1.mcRel(-d, motVel)  # negative me / positive knife


Motor1 = APTMotor(45844773, HWTYPE=42)
Motor2 = APTMotor(45844576, HWTYPE=42)

# print 'Motor1', Motor1.getPos()
# time.sleep(0.1)
# print 'Motor2', Motor2.getPos()

# offset1 = 0
# offset2 = 0

# print 'Motor1', Motor1.getStageAxisInformation()
# Motor1.setStageAxisInformation(offset1, offset1 + 145)
# print 'Motor1', Motor1.getStageAxisInformation()

# print 'Motor2', Motor2.getStageAxisInformation()
# Motor2.setStageAxisInformation(offset2, offset2 + 145)
コード例 #18
0
from PyAPT import APTMotor
import datetime
import time
import ipdb
#S Focus stage
#SN = 80851661
#HWTYPE = 31
ipdb.set_trace()
#S Iodine stage
SN = 40864672
HWTYPE = 12

motor = APTMotor(SN,HWTYPE)
start = datetime.datetime.now()
motor.initializeHardwareDevice()
end = datetime.datetime.now()
print 'connected :' + str((end-start).total_seconds())

currentPos = motor.getPos()

print currentPos

motor.mAbs(0.0)

#time.sleep(5)

currentPos = motor.getPos()

print currentPos

コード例 #19
0
ファイル: interface.py プロジェクト: saurabhX9/FROG
    def __init__(self,
                 parent=None,
                 serial=00000000,
                 verbose=False):  ##, verbose=False
        super(widgetAPT, self).__init__(parent)
        self.resize(1300, 650)
        self.setWindowTitle('FROG')
        self.setWindowIcon(QIcon('iiserb.png'))

        layout = QGridLayout()
        ##        self.setLayout(layout)

        self.data = np.genfromtxt('N1648.txt',
                                  skip_header=12,
                                  skip_footer=7308)

        # Layout objects
        sStag = QLabel("Stage", self)
        sStag.setStyleSheet("font: 22pt;")
        layout.addWidget(sStag, 2, 2)

        sAuthor = QLabel("Frequency Resolved Optical Gating", self)
        sAuthor.setStyleSheet("font: 40pt; color:green")
        layout.addWidget(sAuthor, 1, 3, 1, 15)

        # Motor Serial Number

        sSer = QLabel("Serial:", self)
        sSer.setStyleSheet("font: 16pt;")
        layout.addWidget(sSer, 3, 1)

        self.txtSerial = QSpinBox(self)
        self.txtSerial.setRange(0, 99999999)
        self.txtSerial.setSingleStep(1)
        self.txtSerial.setValue(27503288)

        layout.addWidget(self.txtSerial, 3, 2)
        self._Motor_ = APTMotor(verbose=verbose)

        # Motor Connect button
        self.btnConnect = QPushButton("Connect", self)
        self.btnConnect.setStyleSheet("background-color: grey")
        self.btnConnect.setText("Connect")
        self.btnConnect.setCheckable(True)
        self.btnConnect.setToolTip("Connect to Motor")
        self.btnConnect.clicked[bool].connect(self.connectAPT)

        layout.addWidget(self.btnConnect, 3, 3)

        sPos = QLabel("Pos:", self)
        sPos.setStyleSheet("font: 16pt;")
        self.txtPos = QDoubleSpinBox(self)
        self.txtPos.setRange(-5, 13)
        self.txtPos.setSingleStep(.1)
        self.txtPos.setDecimals(5)
        self.txtPos.setValue(0.0000000)
        self.txtPos.setToolTip("Current Motor Position")
        self.txtPos.setEnabled(False)
        layout.addWidget(sPos, 4, 1)
        layout.addWidget(self.txtPos, 4, 2)

        # Go to position
        self.btnGOp = QPushButton("Go", self)
        self.btnGOp.clicked.connect(
            lambda: self.motAbs(float(self.txtPos.text())))

        layout.addWidget(self.btnGOp, 4, 3)

        #Home button
        self.btnHome = QPushButton("Home", self)
        self.btnHome.setToolTip("This will take the stage to 6.50")
        layout.addWidget(self.btnHome, 5, 1, 1, 1.5)
        self.btnHome.clicked.connect(lambda: self.motAbs(6.50000))

        #go to zero
        self.btnZero = QPushButton("Go to Zero", self)
        self.btnZero.setToolTip("This will take the stage to absolute 0")
        layout.addWidget(self.btnZero, 5, 2, 1, 1.5)
        self.btnZero.clicked[bool].connect(lambda: self._Motor_.go_home())

        #Velocity buttons

        sVel = QLabel("Velocity:", self)
        sVel.setStyleSheet("font: 14pt;")

        self.txtVel = QDoubleSpinBox(self)
        self.txtVel.setRange(0, 2.2)
        self.txtVel.setSingleStep(.1)
        self.txtVel.setValue(1.5)
        self.txtVel.setToolTip("set the velocity here")
        self.txtVel.setEnabled(False)

        layout.addWidget(sVel, 6, 1)
        layout.addWidget(self.txtVel, 6, 2)

        self.btnGOv = QPushButton("Set", self)
        self.btnGOv.clicked.connect(
            lambda: self._Motor_.setVel(float(self.txtVel.text())))

        layout.addWidget(self.btnGOv, 6, 3)

        sBack = QLabel("Backlash:", self)
        sBack.setStyleSheet("font: 14pt;")

        self.cbBacklash = QCheckBox(self)
        layout.addWidget(sBack, 7, 1)
        layout.addWidget(self.cbBacklash, 7, 2)
        sSpect = QLabel("Spectrometer", self)
        sSpect.setStyleSheet("font: 22pt;")
        sSpect.setFont(QFont('Arial', 20))
        layout.addWidget(sSpect, 8, 2)

        texp = QLabel("Time of Exp.:", self)
        texp.setStyleSheet("font: 14pt;")
        layout.addWidget(texp, 9, 1)

        self.timexp = QDoubleSpinBox(self)
        self.timexp.setRange(0, 100000)
        self.timexp.setSingleStep(1)
        self.timexp.setDecimals(0)
        self.timexp.setValue(10)
        layout.addWidget(self.timexp, 9, 2)
        self.btnCh = QPushButton("Set", self)
        layout.addWidget(self.btnCh, 9, 3)

        nscan = QLabel("Num. of scan:", self)
        nscan.setStyleSheet("font: 14pt;")
        layout.addWidget(nscan, 10, 1)
        self.nscantxt = QDoubleSpinBox(self)
        self.nscantxt.setRange(0, 137)
        self.nscantxt.setSingleStep(1)
        self.nscantxt.setDecimals(0)
        self.nscantxt.setValue(10)
        layout.addWidget(self.nscantxt, 10, 2)
        self.nscan = QPushButton("Set", self)
        layout.addWidget(self.nscan, 10, 3)

        #self.timexp.setEnabled(False)

        ##        self.timeofexposure = c_uint32(1000)

        self.btnCh.clicked[bool].connect(self.assignexp)

        self.nscan.clicked[bool].connect(self.assignnscan)

        sSpos = QLabel("Signal pos.(mm):")
        sSpos.setStyleSheet("font: 14pt;")
        self.txtSpos = QDoubleSpinBox(self)
        self.txtSpos.setRange(0, 12.0000)
        self.txtSpos.setDecimals(5)
        self.txtSpos.setSingleStep(0.00001)
        self.txtSpos.setValue(6.50000)
        layout.addWidget(sSpos, 12, 1)
        layout.addWidget(self.txtSpos, 12, 2)

        self.btnSpos = QPushButton("Set", self)
        layout.addWidget(self.btnSpos, 12, 3)
        self.btnSpos.clicked[bool].connect(
            lambda: self.txtSpos.setValue(float(self.txtSpos.text())))

        sSpectra = QLabel("Spectrum", self)
        sSpectra.setStyleSheet("font: 14pt;")
        sSpectra.setFont(QFont('Arial', 20))
        layout.addWidget(sSpectra, 13, 1)

        #----------------------------Spectromter Plot----------------------------------------------------------------------------------------------------

        #time of exposure box
        self.spectra = create_string_buffer(7500)
        pg.setConfigOption('background', 'w')
        self.plot1 = pg.PlotWidget()
        layout.addWidget(self.plot1, 3, 7, 8, 8)
        self.timer = pg.QtCore.QTimer()

        self.liveb = QPushButton('Live', self)
        layout.addWidget(self.liveb, 13, 2)
        self.liveb.setCheckable(True)

        self.liveb.clicked[bool].connect(self.live)
        self.lbox = QCheckBox(self)

        ##        self.timer.timeout.connect(self.updater)

        ##        self.static = QCheckBox(self)

        layout.addWidget(self.lbox, 13, 3)

        self.fname = QLineEdit(self)
        self.fname.setToolTip("ENTER FILENAME.TXT")
        layout.addWidget(self.fname, 14, 1, 1, 2)
        self.sScan = QPushButton("Start Scan", self)
        layout.addWidget(self.sScan, 14, 3, 1, 1)
        self.sScan.clicked[bool].connect(self.scan)
        self.pbar = QProgressBar(self)

        layout.addWidget(self.pbar, 15, 1, 1, 2)

        ##        self.spectra = create_string_buffer(7500)
        ##        cam.sptdll.getFrame(byref(self.spectra),0xFFFF)
        ##        self.b = np.frombuffer(self.spectra, dtype=np.uint16)
        ##        self.plot1.plot(self.data,self.b[0:3653],pen='b', clear=True)
        ##        pg.QtGui.QApplication.processEvents()

        ##-----------------------------------------------------------------------------------------

        self.figure = Figure()

        self.canvas = FigureCanvas(self.figure)

        # this is the Navigation widget
        # it takes the Canvas widget and a parent
        self.toolbar = NavigationToolbar(self.canvas, self)

        # Just some button connected to `plot` method
        self.button = QPushButton('Plot')
        self.button.clicked.connect(self.graph)

        # set the layout

        layout.addWidget(self.toolbar, 11, 7, 1, 8)
        layout.addWidget(self.canvas, 12, 7, 5, 8)
        layout.addWidget(self.button, 15, 3, 1, 1)
        self.setLayout(layout)

        self.ex = QPushButton('EXIT', self)
        layout.addWidget(self.ex, 16, 2, 2, 1)
        self.ex.clicked.connect(lambda: self._Motor_.cleanUpAPT())
コード例 #20
0
ファイル: MotorController.py プロジェクト: graysomb/Spec2
class MotorController(object):
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        
        correct serial number:
        old 83863559
        83815746
        '''
        self.connectFailed = False
        try:
            self.Motor1 = APTMotor(83863559, HWTYPE=31)
            print self.Motor1.getHardwareInformation()
            print self.Motor1.getStageAxisInformation()
            print self.Motor1.getVelocityParameters()
#             self.degreeConv = 15.0156077
            self.degreeConv = 1
            self.Motor1.setVelocityParameters(0.0, 5.0, 5.99976)
            print self.Motor1.getVelocityParameters()
        except Exception as e:
            import ThreadedGUI
            self.connectFailed = True
            title = "Motor Connection Error"
            text = "Motor connection failed, make sure it is connected"
            p = mp.Process(target = ThreadedGUI.displayError, args =(title, text) )
            p.start()
            p.join()
    
    
    def moveMotor(self, ang):
        self.Motor1.mcRel(ang/self.degreeConv,5.99976)
#         ans = self.Motor1.getPos()*self.degreeConv
#         return ans
        return 1
    
    def Home(self):
        self.Motor1.go_home()
        return True
    
    def BlinkSomeLights(self):
        self.Motor1.identify()
        return True
    
    def getPosition(self):
        return self.Motor1.getPos()*self.degreeConv
    
    def moveTo(self, ang):
        return self.Motor1.mAbs(ang/self.degreeConv)*self.degreeConv