Mon, 04 Jun 2018 22:28:05 +0200
[plotter] add a --mockup option to the demo main function
pygpibtoolkit/plotter/gpib_plotter.py | file | annotate | diff | comparison | revisions |
--- a/pygpibtoolkit/plotter/gpib_plotter.py Mon Jun 04 22:27:41 2018 +0200 +++ b/pygpibtoolkit/plotter/gpib_plotter.py Mon Jun 04 22:28:05 2018 +0200 @@ -97,7 +97,9 @@ 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 @@ 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 @@ 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 @@ nloop += 1 fname, ext = os.path.splitext(options.filename) outf = open(fname + "_%d" % nloop + ext, 'w') + + +if __name__ == '__main__': + main()