Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
NPeriods | Input | number | 1 | Number of periods. |
NSpectra | Input | number | 100 | Number of spectra. |
Rate | Input | number | 20 | Rate of sending the data: stream of NEvents events is sent every Rate milliseconds. |
NEvents | Input | number | 1000 | Number of events in each packet. |
Port | Input | number | 59876 | The port to broadcast on (default 59876, ISISDAE 10000). |
Simulates ISIS event DAE. It runs continuously until canceled and listens to port 10000 for connection. When connected starts sending event packets.
Events are randomly distributed between the following
Example:
from threading import Thread
import time
def startFakeDAE():
# This will generate 2000 events roughly every 20ms, so about 50,000 events/sec
# They will be randomly shared across the 100 spectra
# and have a time of flight between 10,000 and 20,000
try:
FakeISISEventDAE(NPeriods=1,NSpectra=100,Rate=20,NEvents=1000)
except RuntimeError:
pass
def captureLive():
ConfigService.setFacility("TEST_LIVE")
# start a Live data listener updating every second, that rebins the data
# and replaces the results each time with those of the last second.
StartLiveData(Instrument='ISIS_Event', OutputWorkspace='wsOut', UpdateEvery=1,
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)
# This will cancel both algorithms
# you can do the same in the GUI
# by clicking on the details button on the bottom right
AlgorithmManager.newestInstanceOf("MonitorLiveData").cancel()
AlgorithmManager.newestInstanceOf("FakeISISEventDAE").cancel()
#--------------------------------------------------------------------------------------------------
oldFacility = ConfigService.getFacility().name()
thread = Thread(target = startFakeDAE)
thread.start()
time.sleep(2) # give it a small amount of time to get ready
if not thread.is_alive():
raise RuntimeError("Unable to start FakeDAE")
try:
captureLive()
except:
print("Error occurred starting live data")
finally:
thread.join() # this must get hit
# put back the facility
ConfigService.setFacility(oldFacility)
#get the ouput workspace
wsOut = mtd["wsOut"]
print("The workspace contains %i events" % wsOut.getNumberEvents())
Output:
The workspace contains ... events
Categories: Algorithms | DataHandling\DataAcquisition
C++ source: FakeISISEventDAE.cpp (last modified: 2016-08-20)
C++ header: FakeISISEventDAE.h (last modified: 2016-08-20)