示例#1
0
文件: tow.py 项目: petebachant/Tow
 def closeEvent(self, event):
     acsc.stopBuffer(self.hcomm, 5)
     acsc.closeComm(self.hcomm)
     acsc.unregisterEmergencyStop()
     self.settings["Last window location"] = [self.pos().x(),
                                              self.pos().y()]
     self.settings["Mode index"] = self.ui.tabWidgetMode.currentIndex()
     for key, val in self.traverse_offset_actions.items():
         if val.isChecked():
             offset = key
     self.settings["Traverse offset"] = offset
     self.settings["Point-to-point"] = {
         "absolute": self.ui.rbAbsolute.isChecked(),
         "pos": self.ui.posSpinBox.value(),
         "vel": self.ui.velSpinBox.value(),
         "acc": self.ui.accSpinBox.value()}
     self.settings["Back-and-forth"] = {
         "absolute": self.ui.rbAbsolute_baf.isChecked(),
         "p1": self.ui.posSpinBox_baf1.value(),
         "p2": self.ui.posSpinBox_baf2.value(),
         "v1": self.ui.velSpinBox_baf1.value(),
         "v2": self.ui.velSpinBox_baf2.value(),
         "a1": self.ui.accSpinBox_baf1.value(),
         "a2": self.ui.accSpinBox_baf2.value(),
         "loop": self.ui.checkBox_loop.isChecked()}
     with open(self.settings_fpath, "w") as f:
         json.dump(self.settings, f, indent=4)
示例#2
0
 def abort(self):
     """This should stop everything."""
     acsc.stopBuffer(self.hc, 19)
     acsc.halt(self.hc, 4)
     self.acsdaqthread.stop()
     self.daqthread.clear()
     self.aborted = True
示例#3
0
文件: tow.py 项目: petebachant/Tow
 def on_JogPendant(self):
     if self.jogmode == False:
         self.jogmode = True
         acsc.runBuffer(self.hcomm, 5, None)
     elif self.jogmode == True:
         acsc.stopBuffer(self.hcomm, 5)
         self.jogmode = False
示例#4
0
 def abort(self):
     """This should stop everything."""
     acsc.stopBuffer(self.hc, 19)
     acsc.halt(self.hc, 4)
     self.acsdaqthread.stop()
     self.daqthread.clear()
     self.aborted = True
示例#5
0
 def abort(self):
     """This should stop everything."""
     print("Aborting turbine tow")
     self.aborted = True
     acsc.stopBuffer(self.hc, 19)
     acsc.halt(self.hc, 0)
     acsc.halt(self.hc, 1)
     acsc.halt(self.hc, 4)
     acsc.halt(self.hc, 5)
示例#6
0
 def abort(self):
     """This should stop everything."""
     print("Aborting turbine tow")
     self.aborted = True
     acsc.stopBuffer(self.hc, 19)
     acsc.halt(self.hc, 0)
     acsc.halt(self.hc, 1)
     acsc.halt(self.hc, 4)
     acsc.halt(self.hc, 5)
示例#7
0
 def autoabort(self):
     """This should stop everything and return carriage and turbine back
     to zero."""
     self.autoaborted = True
     acsc.stopBuffer(self.hc, 19)
     acsc.halt(self.hc, 0)
     acsc.halt(self.hc, 1)
     acsc.halt(self.hc, 4)
     acsc.halt(self.hc, 5)
     acsc.toPoint(self.hc, None, 4, 0.0)
     acsc.setVelocity(self.hc, 5, 0.5)
     acsc.toPoint(self.hc, None, 5, 0.0)
示例#8
0
 def autoabort(self):
     """This should stop everything and return carriage and turbine back
     to zero."""
     self.autoaborted = True
     acsc.stopBuffer(self.hc, 19)
     acsc.halt(self.hc, 0)
     acsc.halt(self.hc, 1)
     acsc.halt(self.hc, 4)
     acsc.halt(self.hc, 5)
     acsc.toPoint(self.hc, None, 4, 0.0)
     acsc.setVelocity(self.hc, 5, 0.5)
     acsc.toPoint(self.hc, None, 5, 0.0)
示例#9
0
文件: tow.py 项目: petebachant/Tow
    def on_timer_slow(self):
        self.axis_enabled = acsc.getMotorEnabled(self.hcomm, self.axis)

        if self.axis_enabled:
            self.ui.enableAxis.setChecked(True)
            self.ui.enableAxis.setText("Disable")
            self.ui.enableAxis.setIcon(QIcon(":icons/cancelx.png"))
        else:
            self.ui.enableAxis.setChecked(False)
            self.ui.enableAxis.setText("Enable")
            self.ui.enableAxis.setIcon(QIcon(":icons/checkmark.png"))
            self.jogmode = False
            acsc.stopBuffer(self.hcomm, 5)

        if self.simulator == False:
            self.homecounter = acsc.readInteger(self.hcomm, None,
                                                "homeCounter_tow")
示例#10
0
文件: tow.py 项目: petebachant/Tow
 def on_halt(self):
     acsc.writeInteger(self.hcomm, "move", 0)
     acsc.stopBuffer(self.hcomm, 19)
     acsc.halt(self.hcomm, self.axis)
示例#11
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()