qgpib_plotter.py

changeset 28
0a7270d439d0
parent 27
0f8f2621418f
--- a/qgpib_plotter.py	Fri Jan 25 20:25:39 2008 +0100
+++ b/qgpib_plotter.py	Fri Jan 25 20:48:49 2008 +0100
@@ -6,8 +6,10 @@
 from PyQt4 import QtGui, QtCore, uic
 from PyQt4.QtCore import SIGNAL, Qt
 
-#from gpib_plotter import GPIBplotter
-from gpib_plotter_mockup import GPIBplotter
+if "-m" in sys.argv:
+    from gpib_plotter_mockup import GPIBplotter
+else:
+    from gpib_plotter import GPIBplotter
 from hpgl_qt import QHPGLPlotterWidget
 
 form_class, base_class = uic.loadUiType(os.path.join(os.path.dirname(__file__), "qhpgl_plotter.ui"))
@@ -110,7 +112,6 @@
             self.plotsView.setCurrentIndex(self.plotsView.model().index(0, 0))
 
     def plotReceived(self, num):
-        print "plot received", num
         self._receiving = False
         self.setReceivingLed()
         plot, timestamp = self.captureThread.getPlot(num)
@@ -250,9 +251,28 @@
         
             
 
-if __name__ == '__main__':
-    a = QtGui.QApplication([])
+def main():
+    import optparse
+    opt = optparse.OptionParser('A simple PyQt4 HP7470A GPIB plotter emulator for USB-GPIB bundle (ProLogix)')
+    opt.add_option('-m', '--mockup', default=False,
+                   action="store_true",
+                   dest='mockup',
+                   help='Use a pseudo GPIB connection (for test purpose)',
+                   )
+    opt.add_option('-v', '--verbose', default=False,
+                   action="store_true",
+                   dest="verbose",
+                   help="Verbose mode",)
+    
+    options, argv = opt.parse_args(sys.argv)
+
+    if options.verbose:
+        sys.stderr.write('connection established\n')
+
+    a = QtGui.QApplication(argv)
     w = QtHPGLPlotter()
     w.show()
     a.exec_()
         
+if __name__ == '__main__':
+    main()

mercurial