Commit 0c202935 authored by Vincent Michel's avatar Vincent Michel Committed by U-ESRF\opid00
Browse files

Add deadtime to Stats

parent bc8ae970
Pipeline #967 passed with stages
in 1 minute and 16 seconds
......@@ -34,7 +34,7 @@ MAX_STRING_LENGTH = 80
# Helpers
Stats = namedtuple('Stats', 'realtime livetime triggers events icr ocr')
Stats = namedtuple('Stats', 'realtime livetime triggers events icr ocr deadtime')
def to_bytes(arg):
......@@ -160,6 +160,7 @@ def is_running():
# Statistics
def get_module_statistics(module):
# Get raw data
channels = get_module_channels(module)
data_size = 7 * len(channels)
master = next(c for c in channels if c != -1)
......@@ -167,15 +168,20 @@ def get_module_statistics(module):
data = ffi.cast('double *', array.ctypes.data)
code = handel.xiaGetRunData(master, b'module_statistics', data)
check_error(code)
return {channel: Stats(
array[index * 7 + 0], # Realtime
array[index * 7 + 1], # Livetime
int(array[index * 7 + 3]), # Triggers
int(array[index * 7 + 4]), # MCA events
int(array[index * 7 + 5]), # Input count rate
int(array[index * 7 + 6])) # Output count rate
for index, channel in enumerate(channels)
if channel != -1}
# Parse raw data
result = {}
for index, channel in enumerate(channels):
if channel != -1:
realtime = array[index * 7 + 0]
livetime = array[index * 7 + 1]
triggers = int(array[index * 7 + 3])
events = int(array[index * 7 + 4])
icr = int(array[index * 7 + 5])
ocr = int(array[index * 7 + 6])
deadtime = 1 - float(ocr) / icr if icr != 0 else 1.
result[channel] = Stats(
realtime, livetime, triggers, events, icr, ocr, deadtime)
return result
def get_statistics():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment