Commit 72df5c87 authored by Georg Brandl's avatar Georg Brandl
Browse files

add live-histogramming for DNS detector

Change-Id: I6198df9a2147e30cd75e0cf54f9f3ec3bfe3887b
parent df1dcece
......@@ -53,5 +53,6 @@ MLZ specific devices
.. autodev:: mlz.sans1ccm.Magnet
.. autodev:: fzj.sis_dns.TOFChannel
.. autodev:: fzj.psd_dns.ImageChannel
.. autodev:: fzj.box_special.HeaterInterlock
# -*- coding: utf-8 -*-
# *****************************************************************************
# MLZ library of Tango servers
# Copyright (c) 2015-2017 by the authors, see LICENSE
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Module authors:
# Georg Brandl <>
# *****************************************************************************
import numpy
import cffi
from entangle import base
from entangle.core import Prop, Attr, ON
from entangle.core.errors import NotSupported
ffi = cffi.FFI()
unsigned int start_histo(char *, uintptr_t, unsigned int, int, int, int, int);
void stop_histo();
class ImageChannel(base.TOFChannel):
"""Live TOF histogramming for DNS PSD data."""
properties = {
'chopper': Prop(int, 'Chopper input ID.'),
'tubes': Prop(int, 'Number of tubes.'),
'pixels': Prop(int, 'Pixels per tube.'),
attributes = {
'filename': Attr(str, 'Current filename.', writable=True),
_fn = ''
_interval = 1
_tchannels = 1
_delay = 0 # TODO use this
def init(self):
self.lib = ffi.dlopen('')
# this is just an initialization size
self._data = numpy.zeros((1, self.pixels, self.tubes),
def delete(self):
def state(self):
return ON, ''
def Clear(self):
self._data[:] = 0
def Start(self):
self._interval, self.chopper, self._tchannels,
self.pixels, self.tubes)
def Stop(self):
def Reset(self):
def Resume(self):
def Prepare(self):
def write_filename(self, val):'new filename: %s', val)
self._fn = val
def read_filename(self):
return self._fn
def get_filename_unit(self):
return ''
def read_active(self):
return False
def write_active(self, value):
def write_preselection(self, value):
raise NotSupported('preselection not implemented')
def read_preselection(self):
raise NotSupported('preselection not implemented')
def read_value(self):
if self._tchannels == 1:
return self._data.sum(axis=0).ravel()
return self._data.sum(axis=1).ravel()
def write_timeChannels(self, value):
self._tchannels = value
self._data = numpy.zeros((self._tchannels, self.pixels, self.tubes),
def read_timeChannels(self):
return self._tchannels
def write_timeInterval(self, value):
self._interval = value
def read_timeInterval(self):
return self._interval
def write_binning(self, value):
raise NotSupported('cannot write binning')
def read_binning(self):
return [1, 1]
def read_delay(self):
return self._delay
def write_delay(self, value):
self._delay = value
def read_detectorSize(self):
if self._tchannels == 1:
return [self.tubes, self.pixels]
return [self.tubes, self._tchannels]
def read_roiOffset(self):
return [0, 0]
def read_roiSize(self):
return self.read_detectorSize()
def read_zeroPoint(self):
return [0, 0]
def GetBlock(self, arg):
raise NotSupported('GetBlock not implemented')
def write_roiOffset(self, value):
raise NotSupported('ROI not implemented')
def write_roiSize(self, value):
raise NotSupported('ROI not implemented')
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