Commits

iorodeo committed 6eb9371 Draft

Modifications to demo GUI.

  • Participants
  • Parent commits e386424

Comments (0)

Files changed (3)

File flyherder_demo_gui/flyherder_demo_gui/flyherder_gui.py

 DEFAULT_SPEED = 10 # mm/s
 DEFAULT_SEP = 200 # mm
 NUM_AXIS = 4
+INDEX_TO_AXIS = {0:'x0', 1: 'y0', 2: 'x1', 3: 'y1'}
 DEFAULT_POS = {'x0':-1,'y0':-1,'x1':-1,'y1':-1}
 DEFAULT_POS_LABELS = {'x0':'','y0':'','x1':'','y1':''}
 DEFAULT_ORIENT = {'x0':'-','y0':'-','x1':'+','y1':'+'}
             for i in range(n):
                 le = getattr(self,'posLineEdit_{0}'.format(i))
                 le.editingFinished.connect(self.updatePos_Callback)
-                axis = str(le.accessibleName())
+                axis = INDEX_TO_AXIS[i]
                 if (axis.find('y')>=0):
                     posValidator = QtGui.QIntValidator(MIN_POS,self.maxPos['y'],le)
                 else:
             for i in range(n):
                 le = getattr(self,'posLineEdit_{0}'.format(i))
                 le.textChanged.connect(self.updatePos_Callback)
-                axis = str(le.accessibleName())
+                axis = INDEX_TO_AXIS[i]
                 if (axis.find('y')>=0):
                     posValidator = QtGui.QIntValidator(MIN_POS,self.maxPos['y'],le)
                 else:
             self.stopPushButton.setEnabled(True)
             try:
                 pos = self.dev.getPosition()
-                self.updatePosLabels(pos)
             except Exception, e:
                 QtGui.QMessageBox.critical(self,'Error', str(e).title())
+            self.updatePosLabels(pos)
         else:
             self.powerOffDrive()
             self.statusbar.showMessage('Connected: Power Off')
     def updatePos_Callback(self):
         for i in range(self.NUM_AXIS):
             le_pos = getattr(self,'posLineEdit_{0}'.format(i))
-            axis = str(le_pos.accessibleName())
+            axis = INDEX_TO_AXIS[i]
             pos = le_pos.text()
             if not (len(pos)>0):
                 return
     def updateOrient_Callback(self):
         for i in range(self.NUM_AXIS):
             cb_orient = getattr(self,'orientCheckBox_{0}'.format(i))
-            axis = str(cb_orient.accessibleName())
+            axis = INDEX_TO_AXIS[i]
             if cb_orient.isChecked():
                 self.axisOrient[axis] = '-'
             else:
         if self.isHomed:
             try:
                 self.timer.start()
+                self.statusbar.showMessage('Connected: Moving...')
                 self.dev.setOrientation(self.axisOrient)        
                 self.dev.setSpeed(self.moveSpeed)        
                 self.dev.moveToPosition(self.axisPos)
             
     def updatePosLabels(self,pos):
         if self.pwrCheckBox.isChecked():
-            self.posLabel_0.setText(str(int(round(pos['x0']))))
-            self.posLabel_1.setText(str(int(round(pos['y0']))))
-            self.posLabel_2.setText(str(int(round(pos['x1']))))
-            self.posLabel_3.setText(str(int(round(pos['y1']))))
-        else:
-            self.posLabel_0.setText('')
-            self.posLabel_1.setText('')
-            self.posLabel_2.setText('')
-            self.posLabel_3.setText('')
+            try:
+                self.posLabel_0.setText(str(int(round(pos['x0']))))
+                self.posLabel_1.setText(str(int(round(pos['y0']))))
+                self.posLabel_2.setText(str(int(round(pos['x1']))))
+                self.posLabel_3.setText(str(int(round(pos['y1']))))
+                return
+            except TypeError:
+                pass
+        self.posLabel_0.setText('')
+        self.posLabel_1.setText('')
+        self.posLabel_2.setText('')
+        self.posLabel_3.setText('')
 
     def stopClicked_Callback(self):
         if self.dev is None:
             return
+        pos = None
         try:
             self.dev.stop()        
             pos = self.dev.getPosition()
-            self.updatePosLabels(pos)
         except IOError, e:
             msgTitle = 'Unable to stop:'
             QtGui.QMessageBox.warning(self,msgTitle, e)           
                 self.statusbar.showMessage('Connected: Power On, Homed')
             else:
                 self.statusbar.showMessage('Connected: Power On, Not Homed')
+        if pos is not None:
+            self.updatePosLabels(pos)
 
     def timer_Callback(self):
+        running = True
         try:
             if not self.dev.isRunning():
+                running = False
                 self.timer.stop()
-                pos = self.dev.getPosition()
-                if (self.dev.isInHomePosition()) and (not self.isHomed):
-                    self.isHomed = True
-                self.updatePosLabels(pos)
-                self.setWidgetEnabledOnStop()
-            else:
-                self.setWidgetDisabledOnRun()
         except IOError, e:
             msgTitle = 'Unable to query the device'
             QtGui.QMessageBox.warning(self,msgTitle, e)           
+            running = False
+            self.timer.stop()
+        if not running: 
+            try:
+                pos = self.dev.getPosition()
+                isInHomePosition = self.dev.isInHomePosition()
+            except IOError, e:
+                msgTitle = 'Unable to query the device'
+                QtGui.QMessageBox.warning(self,msgTitle, e)           
+                return
+
+            if isInHomePosition and (not self.isHomed):
+                self.isHomed = True
+            self.updatePosLabels(pos)
+            self.setWidgetEnabledOnStop()
+        else:
+            self.setWidgetDisabledOnRun()
 
     def setWidgetDisabledOnRun(self):
         self.paramGroupBox.setEnabled(False)

File flyherder_demo_gui/flyherder_demo_gui/flyherder_gui.ui

                     <enum>Qt::NoContextMenu</enum>
                    </property>
                    <property name="accessibleName">
-                    <string>x0</string>
+                    <string/>
                    </property>
                    <property name="text">
                     <string/>
                     </font>
                    </property>
                    <property name="accessibleName">
-                    <string>y0</string>
+                    <string/>
                    </property>
                    <property name="text">
                     <string/>
                     </font>
                    </property>
                    <property name="accessibleName">
-                    <string>x1</string>
+                    <string/>
                    </property>
                    <property name="text">
                     <string/>
                     </font>
                    </property>
                    <property name="accessibleName">
-                    <string>y1</string>
+                    <string/>
                    </property>
                    <property name="text">
                     <string/>
                     </font>
                    </property>
                    <property name="accessibleName">
-                    <string>x0</string>
+                    <string/>
                    </property>
                    <property name="layoutDirection">
                     <enum>Qt::LeftToRight</enum>
                     </font>
                    </property>
                    <property name="accessibleName">
-                    <string>y0</string>
+                    <string/>
                    </property>
                    <property name="layoutDirection">
                     <enum>Qt::LeftToRight</enum>
                     </font>
                    </property>
                    <property name="accessibleName">
-                    <string>x1</string>
+                    <string/>
                    </property>
                    <property name="layoutDirection">
                     <enum>Qt::LeftToRight</enum>
                     </font>
                    </property>
                    <property name="accessibleName">
-                    <string>y1</string>
+                    <string/>
                    </property>
                    <property name="layoutDirection">
                     <enum>Qt::LeftToRight</enum>

File flyherder_demo_gui/flyherder_demo_gui/flyherder_gui_ui.py

 
 # Form implementation generated from reading ui file 'flyherder_gui.ui'
 #
-# Created: Fri Aug 31 11:23:10 2012
+# Created: Fri Aug 31 12:44:58 2012
 #      by: PyQt4 UI code generator 4.7.2
 #
 # WARNING! All changes made in this file will be lost!
         font.setFamily("Sans Serif")
         self.orientCheckBox_0.setFont(font)
         self.orientCheckBox_0.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
+        self.orientCheckBox_0.setAccessibleName("")
         self.orientCheckBox_0.setText("")
         self.orientCheckBox_0.setChecked(True)
         self.orientCheckBox_0.setObjectName("orientCheckBox_0")
         font = QtGui.QFont()
         font.setFamily("Sans Serif")
         self.orientCheckBox_1.setFont(font)
+        self.orientCheckBox_1.setAccessibleName("")
         self.orientCheckBox_1.setText("")
         self.orientCheckBox_1.setChecked(True)
         self.orientCheckBox_1.setObjectName("orientCheckBox_1")
         font = QtGui.QFont()
         font.setFamily("Sans Serif")
         self.orientCheckBox_2.setFont(font)
+        self.orientCheckBox_2.setAccessibleName("")
         self.orientCheckBox_2.setText("")
         self.orientCheckBox_2.setObjectName("orientCheckBox_2")
         self.horizontalLayout_3.addWidget(self.orientCheckBox_2)
         font = QtGui.QFont()
         font.setFamily("Sans Serif")
         self.orientCheckBox_3.setFont(font)
+        self.orientCheckBox_3.setAccessibleName("")
         self.orientCheckBox_3.setText("")
         self.orientCheckBox_3.setObjectName("orientCheckBox_3")
         self.horizontalLayout_3.addWidget(self.orientCheckBox_3)
         font = QtGui.QFont()
         font.setPointSize(10)
         self.posLineEdit_0.setFont(font)
+        self.posLineEdit_0.setAccessibleName("")
         self.posLineEdit_0.setLayoutDirection(QtCore.Qt.LeftToRight)
         self.posLineEdit_0.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
         self.posLineEdit_0.setObjectName("posLineEdit_0")
         font = QtGui.QFont()
         font.setPointSize(10)
         self.posLineEdit_1.setFont(font)
+        self.posLineEdit_1.setAccessibleName("")
         self.posLineEdit_1.setLayoutDirection(QtCore.Qt.LeftToRight)
         self.posLineEdit_1.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
         self.posLineEdit_1.setObjectName("posLineEdit_1")
         font = QtGui.QFont()
         font.setPointSize(10)
         self.posLineEdit_2.setFont(font)
+        self.posLineEdit_2.setAccessibleName("")
         self.posLineEdit_2.setLayoutDirection(QtCore.Qt.LeftToRight)
         self.posLineEdit_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
         self.posLineEdit_2.setObjectName("posLineEdit_2")
         font = QtGui.QFont()
         font.setPointSize(10)
         self.posLineEdit_3.setFont(font)
+        self.posLineEdit_3.setAccessibleName("")
         self.posLineEdit_3.setLayoutDirection(QtCore.Qt.LeftToRight)
         self.posLineEdit_3.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
         self.posLineEdit_3.setObjectName("posLineEdit_3")
         self.label_15.setText(QtGui.QApplication.translate("MainWindow", "[mm]", None, QtGui.QApplication.UnicodeUTF8))
         self.label_8.setText(QtGui.QApplication.translate("MainWindow", "Axis Orientation (check to reverse) ", None, QtGui.QApplication.UnicodeUTF8))
         self.label_34.setText(QtGui.QApplication.translate("MainWindow", "X0", None, QtGui.QApplication.UnicodeUTF8))
-        self.orientCheckBox_0.setAccessibleName(QtGui.QApplication.translate("MainWindow", "x0", None, QtGui.QApplication.UnicodeUTF8))
         self.label_20.setText(QtGui.QApplication.translate("MainWindow", "Y0", None, QtGui.QApplication.UnicodeUTF8))
-        self.orientCheckBox_1.setAccessibleName(QtGui.QApplication.translate("MainWindow", "y0", None, QtGui.QApplication.UnicodeUTF8))
         self.label_13.setText(QtGui.QApplication.translate("MainWindow", "X1", None, QtGui.QApplication.UnicodeUTF8))
-        self.orientCheckBox_2.setAccessibleName(QtGui.QApplication.translate("MainWindow", "x1", None, QtGui.QApplication.UnicodeUTF8))
         self.label_21.setText(QtGui.QApplication.translate("MainWindow", "Y1", None, QtGui.QApplication.UnicodeUTF8))
-        self.orientCheckBox_3.setAccessibleName(QtGui.QApplication.translate("MainWindow", "y1", None, QtGui.QApplication.UnicodeUTF8))
         self.tabWidget.setTabText(self.tabWidget.indexOf(self.setupTab), QtGui.QApplication.translate("MainWindow", "Device Setup", None, QtGui.QApplication.UnicodeUTF8))
         self.pwrCheckBox.setText(QtGui.QApplication.translate("MainWindow", "Drive Power", None, QtGui.QApplication.UnicodeUTF8))
         self.moveGroupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Move To Position [mm]", None, QtGui.QApplication.UnicodeUTF8))
         self.label_35.setText(QtGui.QApplication.translate("MainWindow", "X0 ", None, QtGui.QApplication.UnicodeUTF8))
-        self.posLineEdit_0.setAccessibleName(QtGui.QApplication.translate("MainWindow", "x0", None, QtGui.QApplication.UnicodeUTF8))
         self.posLineEdit_0.setText(QtGui.QApplication.translate("MainWindow", "-1", None, QtGui.QApplication.UnicodeUTF8))
         self.label_22.setText(QtGui.QApplication.translate("MainWindow", "Y0", None, QtGui.QApplication.UnicodeUTF8))
-        self.posLineEdit_1.setAccessibleName(QtGui.QApplication.translate("MainWindow", "y0", None, QtGui.QApplication.UnicodeUTF8))
         self.posLineEdit_1.setText(QtGui.QApplication.translate("MainWindow", "-1", None, QtGui.QApplication.UnicodeUTF8))
         self.label_24.setText(QtGui.QApplication.translate("MainWindow", "X1", None, QtGui.QApplication.UnicodeUTF8))
-        self.posLineEdit_2.setAccessibleName(QtGui.QApplication.translate("MainWindow", "x1", None, QtGui.QApplication.UnicodeUTF8))
         self.posLineEdit_2.setText(QtGui.QApplication.translate("MainWindow", "-1", None, QtGui.QApplication.UnicodeUTF8))
         self.label_23.setText(QtGui.QApplication.translate("MainWindow", "Y1", None, QtGui.QApplication.UnicodeUTF8))
-        self.posLineEdit_3.setAccessibleName(QtGui.QApplication.translate("MainWindow", "y1", None, QtGui.QApplication.UnicodeUTF8))
         self.posLineEdit_3.setText(QtGui.QApplication.translate("MainWindow", "-1", None, QtGui.QApplication.UnicodeUTF8))
         self.movePushButton.setText(QtGui.QApplication.translate("MainWindow", "Move", None, QtGui.QApplication.UnicodeUTF8))
         self.label_9.setText(QtGui.QApplication.translate("MainWindow", "Note, the system must be homed ", None, QtGui.QApplication.UnicodeUTF8))