Skip to content
Snippets Groups Projects
Commit 727979e2 authored by Martyn Gigg's avatar Martyn Gigg
Browse files

Add finally clause to live data usage tests

This guarantees that background algorithms get
cancelled should StartLiveData raise an exception
parent 15f2c71a
No related branches found
No related tags found
No related merge requests found
...@@ -45,20 +45,22 @@ Usage ...@@ -45,20 +45,22 @@ Usage
def captureLive(): def captureLive():
ConfigService.setFacility("TEST_LIVE") ConfigService.setFacility("TEST_LIVE")
# start a Live data listener updating every second, that rebins the data try:
# and replaces the results each time with those of the last second. # start a Live data listener updating every second, that rebins the data
StartLiveData(Instrument='ISIS_Event', OutputWorkspace='wsOut', UpdateEvery=1, # and replaces the results each time with those of the last second.
ProcessingAlgorithm='Rebin', ProcessingProperties='Params=10000,1000,20000;PreserveEvents=1', StartLiveData(Instrument='ISIS_Event', OutputWorkspace='wsOut', UpdateEvery=1,
AccumulationMethod='Add', PreserveEvents=True) ProcessingAlgorithm='Rebin', ProcessingProperties='Params=10000,1000,20000;PreserveEvents=1',
AccumulationMethod='Add', PreserveEvents=True)
# give it a couple of seconds before stopping it
time.sleep(2) # give it a couple of seconds before stopping it
time.sleep(2)
# This will cancel both algorithms finally:
# you can do the same in the GUI # This will cancel both algorithms
# by clicking on the details button on the bottom right # you can do the same in the GUI
AlgorithmManager.newestInstanceOf("MonitorLiveData").cancel() # by clicking on the details button on the bottom right
AlgorithmManager.newestInstanceOf("FakeISISEventDAE").cancel() AlgorithmManager.newestInstanceOf("MonitorLiveData").cancel()
AlgorithmManager.newestInstanceOf("FakeISISEventDAE").cancel()
time.sleep(1)
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
oldFacility = ConfigService.getFacility().name() oldFacility = ConfigService.getFacility().name()
......
...@@ -36,20 +36,21 @@ Usage ...@@ -36,20 +36,21 @@ Usage
def captureLive(): def captureLive():
ConfigService.setFacility("TEST_LIVE") ConfigService.setFacility("TEST_LIVE")
# start a Live data listener updating every second, that rebins the data try:
# and replaces the results each time with those of the last second. # start a Live data listener updating every second, that rebins the data
StartLiveData(Instrument='ISIS_Histogram', OutputWorkspace='wsOut', UpdateEvery=1, # and replaces the results each time with those of the last second.
AccumulationMethod='Replace') StartLiveData(Instrument='ISIS_Histogram', OutputWorkspace='wsOut', UpdateEvery=1,
AccumulationMethod='Replace')
# give it a couple of seconds before stopping it
time.sleep(2) # give it a couple of seconds before stopping it
time.sleep(2)
# This will cancel both algorithms finally:
# you can do the same in the GUI # This will cancel both algorithms
# by clicking on the details button on the bottom right # you can do the same in the GUI
AlgorithmManager.newestInstanceOf("MonitorLiveData").cancel() # by clicking on the details button on the bottom right
AlgorithmManager.newestInstanceOf("FakeISISHistoDAE").cancel() AlgorithmManager.newestInstanceOf("MonitorLiveData").cancel()
time.sleep(1) # give them time to cancel AlgorithmManager.newestInstanceOf("FakeISISHistoDAE").cancel()
time.sleep(1)
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
oldFacility = ConfigService.getFacility().name() oldFacility = ConfigService.getFacility().name()
......
...@@ -123,20 +123,22 @@ Usage ...@@ -123,20 +123,22 @@ Usage
def captureLive(): def captureLive():
ConfigService.setFacility("TEST_LIVE") ConfigService.setFacility("TEST_LIVE")
# start a Live data listener updating every second, that rebins the data try:
# and replaces the results each time with those of the last second. # start a Live data listener updating every second, that rebins the data
StartLiveData(Instrument='ISIS_Event', OutputWorkspace='wsOut', UpdateEvery=1, # and replaces the results each time with those of the last second.
ProcessingAlgorithm='Rebin', ProcessingProperties='Params=10000,1000,20000;PreserveEvents=1', StartLiveData(Instrument='ISIS_Event', OutputWorkspace='wsOut', UpdateEvery=1,
AccumulationMethod='Add', PreserveEvents=True) ProcessingAlgorithm='Rebin', ProcessingProperties='Params=10000,1000,20000;PreserveEvents=1',
AccumulationMethod='Add', PreserveEvents=True)
# give it a couple of seconds before stopping it
time.sleep(2) # give it a couple of seconds before stopping it
time.sleep(2)
# This will cancel both algorithms finally:
# you can do the same in the GUI # This will cancel both algorithms
# by clicking on the details button on the bottom right # you can do the same in the GUI
AlgorithmManager.newestInstanceOf("MonitorLiveData").cancel() # by clicking on the details button on the bottom right
AlgorithmManager.newestInstanceOf("FakeISISEventDAE").cancel() AlgorithmManager.newestInstanceOf("MonitorLiveData").cancel()
AlgorithmManager.newestInstanceOf("FakeISISEventDAE").cancel()
time.sleep(1)
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
oldFacility = ConfigService.getFacility().name() oldFacility = ConfigService.getFacility().name()
...@@ -187,20 +189,22 @@ Output: ...@@ -187,20 +189,22 @@ Output:
def captureLive(): def captureLive():
ConfigService.setFacility("TEST_LIVE") ConfigService.setFacility("TEST_LIVE")
# Start a Live data listener updating every second, try:
# that replaces the results each time with those of the last second. # Start a Live data listener updating every second,
# Load only spectra 2,4, and 6 from periods 1 and 3 # that replaces the results each time with those of the last second.
StartLiveData(Instrument='ISIS_Histogram', OutputWorkspace='wsOut', UpdateEvery=1, # Load only spectra 2,4, and 6 from periods 1 and 3
AccumulationMethod='Replace', PeriodList=[1,3],SpectraList=[2,4,6]) StartLiveData(Instrument='ISIS_Histogram', OutputWorkspace='wsOut', UpdateEvery=1,
AccumulationMethod='Replace', PeriodList=[1,3],SpectraList=[2,4,6])
# give it a couple of seconds before stopping it
time.sleep(2) # give it a couple of seconds before stopping it
time.sleep(2)
# This will cancel both algorithms finally:
# you can do the same in the GUI # This will cancel both algorithms
# by clicking on the details button on the bottom right # you can do the same in the GUI
AlgorithmManager.newestInstanceOf("MonitorLiveData").cancel() # by clicking on the details button on the bottom right
AlgorithmManager.newestInstanceOf("FakeISISHistoDAE").cancel() AlgorithmManager.newestInstanceOf("MonitorLiveData").cancel()
AlgorithmManager.newestInstanceOf("FakeISISHistoDAE").cancel()
time.sleep(1)
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
oldFacility = ConfigService.getFacility().name() oldFacility = ConfigService.getFacility().name()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment