From 365b51c54076c42e6c88db11bb43425b4c62c2f7 Mon Sep 17 00:00:00 2001 From: x03daop Date: Wed, 12 Apr 2017 11:54:44 +0200 Subject: [PATCH] Script execution --- script/MultiRegionScan.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/script/MultiRegionScan.py b/script/MultiRegionScan.py index db1772d2..ff5e794f 100644 --- a/script/MultiRegionScan.py +++ b/script/MultiRegionScan.py @@ -41,7 +41,8 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray): if self.scan_index != get_exec_pars().index: self.scan_index = get_exec_pars().index self.create_datasets() - print "scan {0}".format(self.scan_index) + if self.region_index == 0: + print "scan {0}".format(self.scan_index) ephot = Eph.read() try: @@ -99,18 +100,24 @@ class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix): # plotting current spectrum names = "Scienta spectrum" plots = plot(None, names) -global online_spectrum_plot +global spectrum_series spectrum_series = plots[0].getSeries(0) task = None def plot_cur_spectrum(): global spectrum_series try: - while get_context().state.running: - y = Scienta.spectrum.take(100) - x = Scienta.spectrumX - spectrum_series.setData(x, y) - time.sleep(1.0) + while get_context().state.running: + if spectrum_series is None: + print "create new plot" + names = "Scienta spectrum" + plots = plot(None, names) + spectrum_series = plots[0].getSeries(0) + + y = Scienta.spectrum.take(100) + x = Scienta.spectrumX + spectrum_series.setData(x, y) + time.sleep(1.0) finally: print "Stopping spectrum plotting" @@ -144,7 +151,7 @@ def do_scan(motors, positions, regions, latency): try: #set_preference(Preference.PLOT_TYPES, {'ScientaSpectrum1':1}) - #task = fork(plot_cur_spectrum) + task = fork(plot_cur_spectrum) do_scan(MOTORS, POSITIONS, REGIONS, LATENCY) finally: if CLOSE_SHUTTER_AT_END: