c2d93abebab3 — David Douard tip 5 years ago
[plotter] add a --mockup option to the demo main function
1 files changed, 15 insertions(+), 1 deletions(-)

M pygpibtoolkit/plotter/gpib_plotter.py
M pygpibtoolkit/plotter/gpib_plotter.py +15 -1
@@ 97,7 97,9 @@ class GPIBplotter(GPIB):
         return res
 
 
-if __name__ == '__main__':
+def main():
+    global GPIBplotter
+
     import optparse
     opt = optparse.OptionParser(
         'A simple HP7470A GPIB plotter emulator for '

          
@@ 125,6 127,11 @@ if __name__ == '__main__':
         action="store_true",
         dest="verbose",
         help="Verbose mode")
+    opt.add_option(
+        '-m', '--mockup', default=False,
+        action="store_true",
+        dest='mockup',
+        help='Use a pseudo GPIB connection (for test purpose)')
 
     options, argv = opt.parse_args(sys.argv)
 

          
@@ 136,6 143,9 @@ if __name__ == '__main__':
     else:
         outf = sys.stdout
 
+    if options.mockup:
+        from pygpibtoolkit.plotter.gpib_plotter_mockup import GPIBplotter
+
     try:
         plotter = GPIBplotter(
             device=options.device, address=int(options.address),

          
@@ 166,3 176,7 @@ if __name__ == '__main__':
                 nloop += 1
                 fname, ext = os.path.splitext(options.filename)
                 outf = open(fname + "_%d" % nloop + ext, 'w')
+
+
+if __name__ == '__main__':
+    main()