How to write a 1D controller

This chapter provides the necessary information to write a one dimensional (1D) experimental channel controller in Sardana.

General guide

1D experimental channels together with 2D experimental channels and counter/timers belong to the same family of timerable experimental channels.

To write a 1D controller class you can follow the How to write a counter/timer controller guide keeping in mind differences explained in continuation.

Get 1D shape

1D controller should provide a shape of the spectrum which will be produced by acquisition. The shape can be either static e.g. defined by the detector’s sensor size or dynamic e.g. depending on the detector’s (or an intermediate control software layer e.g. LImA) configuration like RoI or binning.

In any case you should provide the shape in the format of a one-element sequence with the length of the spectrum using the GetAxisPar() method.

Here is an example of the possible implementation of GetAxisPar():

class SpringfieldOneDController(TwoDController):

    def GetAxisPar(self, axis, par):
        if par == "shape":
            return self.springfield.getShape(axis)

For backwards compatibility, in case of not implementing the shape axis parameter, shape will be determined from the MaxDimSize of the Value attribute, currently (4096,).

Differences with counter/timer controller

Class definition

The basics of the counter/timer controller chapter explains how to define the counter/timer controller class. Here you need to simply inherit from the OneDController class:

from sardana.pool.controller import OneDController

class SpringfieldOneDController(OneDController):

   def __init__(self, inst, props, *args, **kwargs):
        super().__init__(inst, props, *args, **kwargs)

Get 1D value

Get counter value chapter explains how to read a counter/timer value using the ReadOne() method. Here you need to implement the same method but:

  • its return value must be a one-dimensional numpy.array (or eventually a SardanaValue object) containing the spectrum instead of a scalar value

  • sardana will not call ReadOne() at a given frequency during the acquisition to get the still changing result

Get 1D values

Get counter values chapter explains how to read counter/timer values using the ReadOne() method while acquiring with external (hardware) synchronization. Here you need to implement the same method but its return value must be a sequence with one-dimensional numpy.array objects (or eventually with SardanaValue objects) containing spectrums instead of scalar values.

Advanced topics

Working with value referencing

1D experimental channels may produce significant arrays of data at high frame rate. Reading this data and storing it using sardana is not always optimal. SEP2 introduced data saving duality, optionally, leaving the data storage at the responsibility of the detector (or an intermediate software layer e.g. LImA). In this case sardana just deals with the reference to the data.

Please refer to Working with value referencing chapter from How to write a 2D controller guide in order to implement this feature for 1D controller.