示例#1
0
 def connect(self, address=None):
     if self.contype == "simulator":
         self.hc = acsc.openCommDirect()
     elif self.contype == "ethernet":
         self.hc = acsc.openCommEthernetTCP(address="10.0.0.100", port=701)
示例#2
0
            MC.SetParamStr(channel, 'ChannelState', 'READY')
            data = np.fromstring(imageBuffer, np.uint16)
            image_npy = np.reshape(data, (height, width))
        else:
            mmc.snapImage()
            image_npy = mmc.getImage()
        proj_32bit_filler = proj_32bit_filler + image_npy
    return proj_32bit_filler


##################
####stage calls###
##################
if load_stages:
    #initiate connection
    hcomm = acsc.openCommEthernetTCP(address="10.0.0.100", port=701)
    if scan_gain:
        acsc.enable(hcomm, 0)  #z
        # acsc.toPoint(hcomm, None,0,110) #YIFU CHECK THIS
        acsc.setVelocity(hcomm, 0, 5)  #velocity in mm/sec
        r_pos_0 = acsc.getRPosition(hcomm, 0)
        f_pos_0 = acsc.getFPosition(hcomm, 0)

    acsc.enable(hcomm, 1)  #theta
    acsc.setVelocity(hcomm, 1, 5)  #velocity in degrees/sec
    r_pos_1 = acsc.getRPosition(hcomm, 1)
    f_pos_1 = acsc.getFPosition(hcomm, 1)
    # acsc.toPoint(hcomm, None,1,0)
    print("z-stage F pos: %f \n z-stage R pos: %f" % (f_pos_0, r_pos_0))
    print("theta-stage F pos: %f \n theta-stage R pos: %f" %
          (f_pos_1, r_pos_1))
示例#3
0
文件: tow.py 项目: petebachant/Tow
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Set up some parameters
        self.axis = 5
        self.homecounter = 0
        self.jogmode = False
        self.leftlimit = 24.9
        self.platform = 9.0
        self.override = False
        self.axis_enabled = False

        # Set maximum velocities to 2 m/s
        self.ui.velSpinBox.setMaximum(2.0)
        self.ui.velSpinBox_baf1.setMaximum(2.0)
        self.ui.velSpinBox_baf2.setMaximum(2.0)

        # Set initial states of all buttons
        self.ui.rbAbsolute.setEnabled(False)
        self.ui.rbAbsolute_baf.setEnabled(False)
        self.ui.enableAxis.setEnabled(False)
        self.ui.actionRunHoming.setEnabled(False)
        self.ui.dock_jog.setEnabled(False)
        self.ui.groupBox_shortcuts.setEnabled(False)
        self.ui.tabWidgetMode.setEnabled(False)
        self.ui.toolBar_Jog.setEnabled(False)
        self.ui.enableAxis.setIcon(QIcon())
        self.ui.posSpinBox.setMinimum(-self.leftlimit)
        self.ui.posSpinBox.setMaximum(self.leftlimit)
        self.ui.posSpinBox_baf1.setMinimum(-self.leftlimit)
        self.ui.posSpinBox_baf1.setMaximum(self.leftlimit)
        self.ui.posSpinBox_baf2.setMinimum(-self.leftlimit)
        self.ui.posSpinBox_baf2.setMaximum(self.leftlimit)
        self.ui.posSpinBox_baf2.setDisabled(True)

        # Add some labels to the status bar
        self.hlabel = QLabel()
        self.hlabel.setText("Not homed ")
        self.ui.statusBar.addWidget(self.hlabel)
        self.poslabel = QLabel()
        self.poslabel.setText("Pos. (m): ")
        self.ui.statusBar.addWidget(self.poslabel)
        self.vellabel = QLabel()
        self.vellabel.setText("Vel. (m/s): ")
        self.ui.statusBar.addWidget(self.vellabel)

        # Add a button to the toolbar
        self.ui.toolBar_Jog.addWidget(self.ui.pbJogPlus)
        self.ui.toolBar_Jog.addWidget(self.ui.pbJogMinus)
        self.ui.pbJogMinus.setFixedHeight(27)
        self.ui.pbJogPlus.setFixedHeight(27)
        self.ui.pbJogMinus.setFixedWidth(32)
        self.ui.pbJogPlus.setFixedWidth(32)
        self.ui.dock_jog.close()

        # Set up timers
        self.timer_slow = QTimer()
        self.timer_slow.timeout.connect(self.on_timer_slow)
        self.timer_fast = QTimer()
        self.timer_fast.timeout.connect(self.on_timer_fast)

        # Connect to the controller
        self.simulator = False
        self.retry = True
        if self.simulator:
            self.hcomm = acsc.openCommDirect()
        else:
            self.hcomm = acsc.openCommEthernetTCP("10.0.0.100", 701)

        # If connection fails, bring up error message box
        while self.hcomm == acsc.INVALID and self.retry:
            msgtxt = "Unable to connect to controller.\n\n"
            msgtxt += "Check that controller is powered-on and "
            msgtxt += "SPiiPlus User Mode Driver is running."
            c_err_box = QMessageBox()
            c_err_box.setIcon(QMessageBox.Critical)
            c_err_box.setWindowIcon(QIcon(':/icons/tow_icon.svg'))
            c_err_box.setWindowTitle("Connection Error")
            c_err_box.setText(msgtxt)
            c_err_box.setStandardButtons(QMessageBox.Retry | QMessageBox.Abort)
            c_err_box.setDefaultButton(QMessageBox.Retry)
            c_err_box.addButton("Use &Simulator",
                                QMessageBox.AcceptRole)

            ret = c_err_box.exec_()

            if ret == QMessageBox.Retry:
                if self.simulator: self.hcomm = acsc.openCommDirect()
                else: self.hcomm = acsc.openCommEthernetTCP("10.0.0.100", 701)
            elif ret == QMessageBox.Abort:
                self.connectfail = True
                self.retry = False
                self.timer_fast.start(10)
            elif ret == QMessageBox.AcceptRole:
                self.simulator = True
                self.hcomm = acsc.openCommDirect()

        if self.hcomm != acsc.INVALID:
            self.timer_slow.start(150)
            self.timer_fast.start(50)
            self.ui.enableAxis.setEnabled(True)
            self.ui.actionRunHoming.setEnabled(True)

        # Register the emergency stop button
        acsc.registerEmergencyStop()

        # Make sure jog program is not running
        acsc.stopBuffer(self.hcomm, 5)

        # Create the jog group action group
        self.offset_group = QActionGroup(self)
        self.ui.traverseOff.setActionGroup(self.offset_group)
        self.ui.traverse1m.setActionGroup(self.offset_group)
        self.ui.traverse2m.setActionGroup(self.offset_group)
        self.ui.traverse3m.setActionGroup(self.offset_group)
        self.ui.traverse4m.setActionGroup(self.offset_group)
        self.traverse_offset_actions = {"off": self.ui.traverseOff,
                                        "1m": self.ui.traverse1m,
                                        "2m": self.ui.traverse2m,
                                        "3m": self.ui.traverse3m,
                                        "4m": self.ui.traverse4m}

        # Create TCP server for remote control
        remoteserver = QtNetwork.QTcpServer()
        print(str(remoteserver.serverAddress().toString()))

        # Connect signals and slots
        self.connectslots()

        # Load settings
        self.load_settings()
示例#4
0
 def connect(self, address="10.0.0.100", port=701):
     if self.contype == "simulator":
         self.hc = acsc.openCommDirect()
     elif self.contype == "ethernet":
         self.hc = acsc.openCommEthernetTCP(address=address, port=port)
示例#5
0
    def initialization(self):

        print "Waiting for Motorized Stage (ACS) Initialization"
        self.hc = acsc.openCommEthernetTCP(address="10.0.0.100",
                                           port=701)  ## craete comminucation

        acsc.runBuffer(self.hc, 0)
        acsc.runBuffer(self.hc, 1)
        acsc.runBuffer(self.hc, 2)
        acsc.runBuffer(self.hc, 4)
        acsc.runBuffer(self.hc, 5)
        acsc.runBuffer(self.hc, 6)

        time.sleep(30)

        ## Homing process

        ## Axis 6
        acsc.waitMotionEnd(self.hc, axis=6)  ## stop at left limit
        if acsc.setFPosition(self.hc, axis=6, fposition=0) != 0:
            print 'Axis 6 (Receiver Z): Homing completed'
        else:
            print 'Axis 6 (Receiver Z): Homing failed'

        ## Axis 0
        acsc.waitMotionEnd(self.hc, axis=0)
        acsc.toPoint(self.hc, flags=acsc.AMF_RELATIVE, axis=0, target=47.5)
        acsc.waitMotionEnd(self.hc, axis=0)
        if acsc.setFPosition(self.hc, axis=0, fposition=0) == 1:
            print 'Axis 0 (Sample X): Homing completed'
        else:
            print 'Axis 0 (Sample X): Homing failed'

        ## Axis 1
        acsc.waitMotionEnd(self.hc, axis=1)
        acsc.toPoint(self.hc, flags=acsc.AMF_RELATIVE, axis=1, target=19.51)
        acsc.waitMotionEnd(self.hc, axis=1)
        if acsc.setFPosition(self.hc, axis=1, fposition=0) == 1:
            print 'Axis 1 (Sample Y): Homing completed'
        else:
            print 'Axis 1 (Sample Y): Homing failed'

        ## Axis 2
        acsc.waitMotionEnd(self.hc, axis=2)  ## stop at left limit
        acsc.toPoint(self.hc, flags=0, axis=2, target=2.8915)
        print 'Axis 2 (Lens array): Homing completed'

        ## Axis 4
        acsc.waitMotionEnd(self.hc, axis=4)  ## stop at left limit
        acsc.toPoint(self.hc, flags=acsc.AMF_RELATIVE, axis=4, target=4.42)
        acsc.waitMotionEnd(self.hc, axis=4)
        if acsc.setFPosition(self.hc, axis=4, fposition=0) == 1:
            print 'Axis 4 (Receiver X): Homing completed'
        else:
            print 'Axis 4 (Receiver X): Homing failed'

        ## Axis5
        acsc.waitMotionEnd(self.hc, axis=5)  ## stop at left limit
        acsc.toPoint(self.hc, flags=acsc.AMF_RELATIVE, axis=5, target=23.8)
        acsc.waitMotionEnd(self.hc, axis=5)
        if acsc.setFPosition(self.hc, axis=5, fposition=0) == 1:
            print 'Axis 5 (Receiver Y): Homing completed'
        else:
            print 'Axis 5 (Receiver Y): Homing failed'

        ## parameter setting
        acsc.setVelocity(self.hc, 0, 30)  ## axis 0 (linear X)
        acsc.setAcceleration(self.hc, 0, 100)
        acsc.setDeceleration(self.hc, 0, 100)
        acsc.setJerk(self.hc, 0, 1000)

        acsc.setVelocity(self.hc, 1, 30)  ## axis1 (linear Y)
        acsc.setAcceleration(self.hc, 1, 100)

        acsc.setDeceleration(self.hc, 1, 100)
        acsc.setJerk(self.hc, 1, 1000)

        acsc.setVelocity(self.hc, 2, 30)  ## axis 2 (revolver)
        acsc.setAcceleration(self.hc, 2, 100)
        acsc.setDeceleration(self.hc, 2, 100)
        acsc.setJerk(self.hc, 2, 1000)

        acsc.setVelocity(self.hc, 4, 30)  ## axis4 (step X)
        acsc.setAcceleration(self.hc, 4, 100)
        acsc.setDeceleration(self.hc, 4, 100)
        acsc.setJerk(self.hc, 4, 1000)

        acsc.setVelocity(self.hc, 5, 30)  ## axis 5 (step Y)
        acsc.setAcceleration(self.hc, 5, 100)
        acsc.setDeceleration(self.hc, 5, 100)
        acsc.setJerk(self.hc, 5, 1000)

        acsc.setVelocity(self.hc, 6, 5)  ## axis 6 (step Z)
        acsc.setAcceleration(self.hc, 6, 50)
        acsc.setDeceleration(self.hc, 6, 50)
        acsc.setJerk(self.hc, 1, 100)