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

Add Stats namedtuple

parent fa505425
Pipeline #966 passed with stages
in 1 minute and 18 seconds
......@@ -3,6 +3,7 @@
from __future__ import absolute_import
import os
from collections import namedtuple
import numpy
......@@ -33,6 +34,9 @@ MAX_STRING_LENGTH = 80
# Helpers
Stats = namedtuple('Stats', 'realtime livetime triggers events icr ocr')
def to_bytes(arg):
if isinstance(arg, bytes):
return arg
......@@ -163,7 +167,13 @@ 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: array[index:index+7].tolist()
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}
......
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