NXSWRITER(1)

NAME
nxswriter - nxswriter Documentation

Authors: Jan Kotanski, Eugen Wintersberger, Halil Pasic

INTRODUCTION

NXSDataWriter is a Tango server which allows to store NeXuS Data in H5 files.

The server provides storing data from other Tango devices, various databases as well as passed by a user client via JSON strings.

Tango Server API: https://nexdatas.github.io/nxsdatawriter/doc_html
Source code: https://github.com/nexdatas/nxsdatawriter
Project Web page: https://nexdatas.github.io/nxsdatawriter
NexDaTaS Web page: https://nexdatas.github.io

INSTALLATION

Install the dependencies:
pninexus or h5py, tango, numpy, nxstools, sphinx

  From sources

Download the latest NexDaTaS version from
https://github.com/nexdatas/nxsdatawriter

Extract sources and run

$ python setup.py install

  Debian packages

Debian bullseye, buster, stretch or Ubuntu focal, bionic packages can be found in the HDRI repository.

To install the debian packages, add the PGP repository key

$ sudo su
$ curl -s http://repos.pni-hdri.de/debian_repo.pub.gpg | gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/debian-hdri-repo.gpg --import
$ chmod 644 /etc/apt/trusted.gpg.d/debian-hdri-repo.gpg

and then download the corresponding source list

$ cd /etc/apt/sources.list.d
$ wget http://repos.pni-hdri.de/bullseye-pni-hdri.list

To install tango server

$ apt-get update
$ apt-get install nxswriter

or

$ apt-get update
$ apt-get install nxswriter3

for older python3 releases.

To install only the python3 package

$ apt-get update
$ apt-get install python3-nxswriter

and for python2

$ apt-get update
$ apt-get install python-nxswriter

if exists.

  From pip

To install it from pip you can

$ python3 -m venv myvenv
$ . myvenv/bin/activate
$ pip install nxswriter

Moreover it is also good to install

$ pip install pytango
$ pip install pymysqldb
$ pip install psycopg2-binary
$ pip install cx-oracle

  Setting NeXus Writer Server

To set up NeXus Writer Server run

$ nxsetup -x NXSDataWriter

The nxsetup command comes from the python-nxstools package.

CLIENT CODE

In order to use Nexus Data Server one has to write a client code. Some simple client codes are in the nexdatas repository. In this section we add some comments related to the client code.

# To use the Tango Server we must import the tango module and
# create DeviceProxy for the server.
import tango
device = "p09/tdw/r228"
dpx = tango.DeviceProxy(device)
dpx.set_timeout_millis(10000)
dpx.Init()
# Here device corresponds to a name of our Nexus Data Server.
# The Init() method resets the state of the server.
dpx.FileName = "test.h5"
dpx.OpenFile()
# We set the name of the output HDF5 file and open it.
# Now we are ready to pass the XML settings describing a structure of
# the output file as well as defining a way of data storing.
# Examples of the XMLSettings can be found in the XMLExamples directory.
with open("test.xml", 'r') as fl:
    xml = fl.read()
dpx.XMLSettings = xml
dpx.JSONRecord = '{"data": {"parameterA":0.2},
                      "decoders":{"DESY2D":"desydecoders.desy2Ddec.desy2d"},
                      "datasources":{
                           "MCLIENT":"sources.DataSources.LocalClientSource"}
}'
dpx.OpenEntry()
# We read our XML settings settings from a file and pass them to the server via
# the XMLSettings attribute. Then we open an entry group related to the XML
# configuration. Optionally, we can also set JSONRecord, i.e. an attribute
# which contains a global JSON string with data needed to store during opening
# the entry and also other stages of recording. If external decoder for
# DevEncoded data is need one can registred it passing its packages and
# class names in JSONRecord,
# e.g. "desy2d" class of "DESY2D" label in "desydecoders.desy2Ddec" package.
# Similarly making use of "datasources" records of the JSON string one can
# registred additional datasources. The OpenEntry method stores data defined
# in the XML string with strategy=INIT.
# The JSONRecord attribute can be changed during recording our data.
# After finalization of the configuration process we can start recording
# the main experiment data in a STEP mode.
dpx.Record('{"data": {"p09/counter/exp.01":0.1, "p09/counter/exp.02":1.1}}')
# Every time we call the Record method all nexus fields defined with
# strategy=STEP are extended by one record unit and the assigned to them data
# is stored. As the method argument we pass a local JSON string with the client
# data. To record the client data one can also use the global JSONRecord string.
# Contrary to the global JSON string the local one is only
# valid during one record step.
dpx.Record('{"data": {"emittance_x": 0.1},  "triggers":["trigger1", "trigger2"]  }')
# If you denote in your XML configuration string some fields by additional
# trigger attributes you may ask the server to store your data only in specific
# record steps. This can be helpful if you want to store your data in
# asynchronous mode. To this end you define in the local JSON string a list of
# triggers which are used in the current record step.
dpx.JSONRecord = '{"data": {"parameterB":0.3}}'
dpx.CloseEntry()
# After scanning experiment data in 'STEP' mode we close the entry.
# To this end we call the CloseEntry method which also stores data defined
# with strategy=FINAL. Since our HDF5 file can contain many entries we can again
# open the entry and repeat our record procedure. If we define more than one entry
# in one XML setting string the defined entries are recorded parallel
# with the same steps.
# Finally, we can close our output file by
dpx.CloseFile()

Additionally, one can use asynchronous versions of OpenEntry, Record, CloseEntry, i.e. OpenEntryAsynch, RecordAsynch, CloseEntryAsynch. In this case data is stored in a background thread and during this writing Tango Data Server has a state RUNNING.

In order to build the XML configurations in the easy way the authors of the server provide for this purpose a specialized GUI tool, Component Designer. The attached to the server XML examples was created by XMLFile class defined in XMLCreator/simpleXML.py.

NXSWRITER PACKAGE

  Submodules

  nxswriter.ClientSource module

Definitions of CLIENT datasource

class nxswriter.ClientSource.ClientSource(streams=None, name=None)
    Bases: nxswriter.DataSources.DataSource

    Client data source

    constructor

Brief
    It sets all member variables to None

Parameters

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

•   name (str) – datasource name

getData()
    provides access to the data

Returns
    dictionary with collected data

Return type
    {‘rank’: str, ‘value’: any, ‘tangoDType’: str, : ‘shape’: list <int>, ‘encoding’: str, : ‘decoders’: str} )

name = None
    (str) data name

setJSON(globalJSON, localJSON=None)
    sets JSON string

Brief
    It sets the currently used JSON string

Parameters

•   globalJSON (dict : <str, dict <str, any>>) – static JSON string

•   localJSON (dict <str, dict <str, any>>) – dynamic JSON string

setup(xml)
    sets the parrameters up from xml

Parameters
    xml (str) – datasource parameters

Raises
    nxswriter.Errors.DataSourceSetupError : if name is not defined

  nxswriter.DBaseSource module

Definitions of DB datasource

nxswriter.DBaseSource.DB_AVAILABLE = ['MYSQL', 'PGSQL']
    (list) list of available databases

class nxswriter.DBaseSource.DBaseSource(streams=None, name=None)
    Bases: nxswriter.DataSources.DataSource

    DataBase data source

    constructor

Brief
    It sets all member variables to None

Parameters

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

•   name (str) – datasource name

dbname = None
    (str) database name

dbtype = None
    (str) database type, i.e. MYSQL, PGSQL, ORACLE

dsn = None
    (str) DSN string

format = None
    (str) record format, i.e. SCALAR, SPECTRUM, IMAGE

getData()
    provides access to the data

Returns
    dictionary with collected data

Return type
    dict <str, any>

hostname = None
    (str) name of the host with the data source

mode = None
    (str) oracle database mode

mycnf = None
    (str) mysql database configuration file

passwd = None
    (str) database password

port = None
    (str) port related to the host

query = None
    (str) database query

setup(xml)
    sets the parrameters up from xml

Parameters
    xml (str) – datasource parameters

Raises
    nxswriter.Errors.DataSourceSetupError if format or query is not defined

user = None
    (str) database user

  nxswriter.DataHolder module

definition of a data holder with casting methods

class nxswriter.DataHolder.DataHolder(rank, value, tangoDType, shape, encoding=None, decoders=None, streams=None)
    Bases: object

    Holder for passing data

    constructor

Parameters

•   rank (str) – format of the data, i.e. SCALAR, SPECTRUM, IMAGE, VERTEX

•   value (any) – value of the data. It may be also 1D and 2D array

•   tangoDType (str) – type of the data

•   shape (list <int>) – shape of the data

•   encoding (str) – encoding type of Tango DevEncoded varibles

•   decoders (nxswriter.DecoderPool.DecoderPool) – poll with decoding classes

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

cast(dtype)
    casts the data into given type

Parameters
    dtype (str) – given type of data

Returns
    numpy array of defined type or list for strings or value for SCALAR

Return type
    numpy.ndarray

decoders = None
    pool with decoding algorithm

encoding = None
    (str) encoding type of Tango DevEncoded varibles

format = None
    (str) data format, i.e. SCALAR, SPECTRUM, IMAGE, VERTEX

shape = None
    (list <int>) data shape

tangoDType = None
    (str) tango data type

value = None
    (any) data value

  nxswriter.DataSourceFactory module

factory with datasources

class nxswriter.DataSourceFactory.DataSourceFactory(attrs, last, streams=None)
    Bases: nxswriter.Element.Element

    Data source creator

    constructor

Parameters

•   attrs (dict <str, str>) – dictionary with the tag attributes

•   last (nxswriter.Element.Element) – the last element on the stack

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

setDataSources(datasources)
    sets the used datasources

Parameters
    datasources (nxswriter.DataSourcePool.DataSourcePool) – pool to be set

setDecoders(decoders)
    sets the used decoders

Parameters
    decoders (nxswriter.DecoderPool.DecoderPool) – pool to be set

store(xml=None, globalJSON=None)
    sets the datasource form xml string

Parameters

•   xml (str) – input parameter

•   globalJSON (: dict <str, dict <str, any>>) – global JSON string

  nxswriter.DataSourcePool module

pool with datasource evaluation classes

class nxswriter.DataSourcePool.DataSourcePool(configJSON=None)
    Bases: object

    DataSource pool

    constructor

Brief
    It creates know datasources

Parameters
    configJSON (: dict <str, dict <str, any>>) – JSON dictionary with datasources

append(datasource, name)
    adds additional datasource

Parameters

•   name (str) – name of the adding datasource

•   datasource (nxswriter.DataSources.DataSource) – instance of the adding datasource

Returns
    name of datasource

Return type
    str

appendUserDataSources(configJSON)
    loads user datasources

Parameters
    configJSON (: dict <str, dict <str, any>>) – string with datasources

canfail = None
    (bool) can fail switch

common = None
    (dict <str, dict <str, any>>) global variables for specific datasources

counter = None
    (int) step counter: INIT: -1; STEP: 1,2,3…; FINAL: -2;

get(datasource)
    checks it the datasource is registered

Parameters
    datasource (str) – the given datasource name

Returns
    datasource type if it the datasource is registered

Return type
    nxswriter.DataSources.DataSource

hasDataSource(datasource)
    checks if the datasource is registered

Parameters
    datasource (str) – the given datasource

Returns
    True if it the datasource is registered

Return type
    bool

lock = None
    (threading.Lock) pool lock

nxroot = None
    (nxswriter.FileWriter.FTGroup) H5 file handle

pop(name)
    adds additional datasource

Parameters
    name (str) – name of the adding datasource

  nxswriter.DataSources module

Definitions of various datasources

class nxswriter.DataSources.DataSource(streams=None, name=None)
    Bases: object

    Data source

    constructor

Brief
    It cleans all member variables

Parameters

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

•   name (str) – datasource name

getData()
    access to data

Brief
    It is an abstract method providing data

isValid()
    checks if the data is valid

Returns
    True if the data is valid

Return type
    bool

setup(xml)
    sets the parrameters up from xml

Parameters
    xml (str) – datasource parameters

  nxswriter.DecoderPool module

Provides a pool with data decoders

class nxswriter.DecoderPool.DATAARRAYdecoder
    Bases: object

    DATA ARRAY LIMA decoder

    constructor

Brief
    It clears the local variables

decode()
    provides the decoded data

Returns
    the decoded data if data was loaded

Return type
    numpy.ndarray

dtype = None
    (str) data type

format = None
    (str) decoder format

frameNumber()
    no data

load(data)
    loads encoded data

Parameters
    data ([str, str]) – encoded data

name = None
    (str) decoder name

shape()
    provides the data shape

Returns
    the data shape if data was loaded

Return type
    list <int >

steps()
    provides the data steps

Returns
    the data steps if data was loaded

Return type
    list <int >

class nxswriter.DecoderPool.DecoderPool(configJSON=None)
    Bases: object

    Decoder pool

    constructor

Brief
    It creates know decoders

Parameters
    configJSON (: dict <str, dict <str, any>>) – string with decoders

append(decoder, name)
    adds additional decoder

Parameters

•   name (str) – name of the adding decoder

•   decoder (object) – instance of the adding decoder

Returns
    name of decoder

Return type
    str

appendUserDecoders(configJSON)
    loads user decoders

Parameters
    configJSON (: dict <str, dict <str, any>>) – string with decoders

get(decoder)
    checks it the decoder is registered

Parameters
    decoder (str) – the given decoder

Returns
    True if it the decoder is registered

Return type
    object

hasDecoder(decoder)
    checks it the decoder is registered

Parameters
    decoder (str) – the given decoder

Returns
    True if it the decoder is registered

Return type
    bool

pop(name)
    adds additional decoder

Parameters
    name (str) – name of the adding decoder

class nxswriter.DecoderPool.UINT32decoder
    Bases: object

    INT decoder

    constructor

Brief
    It clears the local variables

decode()
    provides the decoded data

Returns
    the decoded data if data was loaded

Return type
    numpy.ndarray

dtype = None
    (str) data type

format = None
    (str) decoder format

load(data)
    loads encoded data

Parameters
    data ([str, bytes]) – encoded data

name = None
    (str) decoder name

shape()
    provides the data shape

Returns
    the data shape if data was loaded

Return type
    list <int >

class nxswriter.DecoderPool.UTF8decoder
    Bases: object

    UTF8 decoder

    constructor

Brief
    It clears the local variables

decode()
    provides the decoded data

Returns
    the decoded data if data was loaded

Return type
    bytes

dtype = None
    (str) data type

format = None
    (str) decoder format

load(data)
    loads encoded data

Parameters
    data ([str, bytes]) – encoded data

name = None
    (str) decoder name

shape()
    provides the data shape

Returns
    the data shape i.e. [1, 0]

Return type
    list <int >

class nxswriter.DecoderPool.VDEOdecoder
    Bases: object

    VIDEO IMAGE LIMA decoder

    constructor

Brief
    It clears the local variables

decode()
    provides the decoded data

Returns
    the decoded data if data was loaded

Return type
    numpy.ndarray

dtype = None
    (str) data type

format = None
    (str) decoder format

load(data)
    loads encoded data

Parameters
    data ([str, str]) – encoded data

name = None
    (str) decoder name

shape()
    provides the data shape

Returns
    the data shape if data was loaded

Return type
    list <int >

  nxswriter.EAttribute module

Definitions of attribute tag evaluation classes

class nxswriter.EAttribute.EAttribute(attrs, last, streams=None)
    Bases: nxswriter.FElement.FElement

    attribute tag element

    constructor

Parameters

•   attrs (dict <str, str>) – dictionary of the tag attributes

•   last (nxswriter.Element.Element) – the last element from the stack

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

lengths = None
    (dict <str, str>) shape of the attribute, i.e. {index: length}

markFailed(error=None)
    marks the field as failed

Brief
    It marks the field as failed

Parameters
    error (str) – error string

name = None
    (str) attribute name

rank = None
    (str) rank of the attribute

run()
    runner

Brief
    During its thread run it fetches the data from the source

store(xml=None, globalJSON=None)
    stores the tag content

Parameters

•   xml (str) – xml setting

•   globalJSON (: dict <str, dict <str, any>>) – global JSON string

Returns
    (strategy,trigger)

Return type
    (str, str)

strategy = None
    (str) strategy, i.e. INIT, STEP, FINAL

trigger = None
    (str) trigger for asynchronous writting

  nxswriter.EField module

Definitions of field tag evaluation classes

class nxswriter.EField.EField(attrs, last, streams=None, reloadmode=False)
    Bases: nxswriter.FElement.FElementWithAttr

    field H5 tag element

    constructor

Parameters

•   attrs (dict <str, str>) – dictionary of the tag attributes

•   last (nxswriter.Element.Element) – the last element from the stack

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

•   reloadmode (bool) – reload mode

compression = None
    (bool) compression algorithm id

compression_opts = None
    (int) compression rate

grows = None
    (int) growing dimension

lengths = None
    (dict <str, str>) shape of the field, i.e. {index: length}

markFailed(error=None)
    marks the field as failed

Brief
    It marks the field as failed

Parameters
    error (str) – error string

postrun = None
    (str) label for postprocessing data

rank = None
    (str) rank of the field

rate = None
    (list < int >) compression algorithm options

run()
    runner

Brief
    During its thread run it fetches the data from the source

shuffle = None
    (bool) compression shuffle

store(xml=None, globalJSON=None)
    stores the tag content

Parameters

•   xml (str) – xml setting

•   globalJSON (: dict <str, dict <str, any>>) – global JSON string

Returns
    (strategy, trigger)

Return type
    (str, str)

strategy = None
    (str) strategy, i.e. INIT, STEP, FINAL, POSTRUN

trigger = None
    (str) trigger for asynchronous writing

  nxswriter.EGroup module

Definitions of group tag evaluation classes

class nxswriter.EGroup.EGroup(attrs, last, streams=None, reloadmode=False)
    Bases: nxswriter.FElement.FElementWithAttr

    group H5 tag element

    constructor

Parameters

•   attrs (dict <str, str>) – dictionary of the tag attributes

•   last (nxswriter.Element.Element) – the last element from the stack

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

•   reloadmode (bool) – reload mode

store(xml=None, globalJSON=None)
    stores the tag content

Parameters

•   xml (str) – xml setting

•   globalJSON (: dict <str, dict <str, any>>) – global JSON string

  nxswriter.ELink module

Definitions of link tag evaluation classes

class nxswriter.ELink.ELink(attrs, last, streams=None)
    Bases: nxswriter.FElement.FElement

    link H5 tag element

    constructor

Parameters

•   attrs (dict <str, str>) – dictionary of the tag attributes

•   last (nxswriter.Element.Element) – the last element from the stack

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

createLink(groupTypes=None, target=None)
    creates the link the H5 file

Parameters

•   groupTypes (dict <str , str >) – dictionary with type:name group pairs

•   target – NeXus target path

h5Object = None
    (nxswriter.FileWriter.FTLink) stored H5 file object (defined in base class)

run()
    runner

Brief
    During its thread run it fetches the data from the source

store(xml=None, globalJSON=None)
    stores the tag content

Parameters

•   xml (str) – xml setting

•   globalJSON (: dict <str, dict <str, any>>) – global JSON string

Returns
    (strategy, trigger)

Return type
    (str, str)

strategy = None
    (str) strategy, i.e. INIT, STEP, FINAL

trigger = None
    (str) trigger for asynchronous writting

  nxswriter.EStrategy module

Definitions of strategy evaluation classes

class nxswriter.EStrategy.EStrategy(attrs, last, streams=None)
    Bases: nxswriter.Element.Element

    strategy tag element

    constructor

Parameters

•   attrs (dict <str, str>) – dictionary of the tag attributes

•   last (nxswriter.Element.Element) – the last element from the stack

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

setCanFail()
    sets can fail flag

store(xml=None, globalJSON=None)
    stores the tag content

Parameters

•   xml (str) – xml setting

•   globalJSON (: dict <str, dict <str, any>>) – global JSON string

  nxswriter.Element module

Provides the base class Element for xml tags

class nxswriter.Element.Element(name, attrs, last=None, streams=None)
    Bases: object

    Tag element stored on our stack

    constructor

Parameters

•   name (str) – tag name

•   attrs (dict <str, str>) – dictionary of the tag attributes

•   last (nxswriter.Element.Element) – the last element from the stack

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

content = None
    (list <str>) stored tag content

doc = None
    (str) doc string

last = None
    (nxswriter.Element.Element) the previous element

store(xml=None, globalJSON=None)
    stores the tag

Brief
    abstract method to store the tag element

Parameters

•   xml (str) – tuple of xml code

•   globalJSON (: dict <str, dict <str, any>>) – global JSON string

tagName = None
    (str) stored tag name

  nxswriter.ElementThread module

Implementation of element thread for tag evaluation

class nxswriter.ElementThread.ElementThread(index, queue)
    Bases: threading.Thread

    single thread element

    constructor

Brief
    It creates ElementThread from the runnable element

Parameters

•   index (int) – the current thread index

•   queue (Queue.Queue) – queue with tasks

index = None
    (int) thread index

run()
    runner

Brief
    It runs the defined thread

  nxswriter.Errors module

Tango Data Writer errors

exception nxswriter.Errors.CorruptedFieldArrayError
    Bases: Exception

    exception for corrupted FieldArray

exception nxswriter.Errors.DataSourceError
    Bases: Exception

    exception for fetching data from data source

exception nxswriter.Errors.DataSourceSetupError
    Bases: Exception

    exception for setting data source

exception nxswriter.Errors.PackageError
    Bases: Exception

    exception for fetching data from data source

exception nxswriter.Errors.ThreadError
    Bases: Exception

    exception for problems in thread

exception nxswriter.Errors.UnsupportedTagError
    Bases: Exception

    unsupported tag exception

exception nxswriter.Errors.XMLSettingSyntaxError
    Bases: Exception

    exception for syntax in XML settings

exception nxswriter.Errors.XMLSyntaxError
    Bases: Exception

    exception for syntax in XML settings

  nxswriter.FElement module

Definitions of file tag evaluation classes

class nxswriter.FElement.FElement(name, attrs, last, h5object=None, streams=None)
    Bases: nxswriter.Element.Element

    NeXuS runnable tag element tag element corresponding to one of H5 objects

    constructor

Parameters

•   name – tag name

•   attrs (dict <str, str>) – dictionary of the tag attributes

•   last (nxswriter.Element.Element) – the last element from the stack

•   h5object (nxswriter.FileWriter.FTObject) – H5 file object

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

canfail = None
    (bool) flag for devices for which is allowed to failed

error = None
    (str) notification of error in the run method

h5Object = None
    (nxswriter.FileWriter.FTObject) stored H5 file object

run()
    runner

Brief
    During its thread run it fetches the data from the source

runtime = None
    (float) runtime

setMessage(exceptionMessage=None)
    creates the error message

Parameters
    exceptionMessage (str) – additional message of exception

Returns
    error message

Return type
    str

source = None
    (nxswriter.DataSources.DataSource) data source

class nxswriter.FElement.FElementWithAttr(name, attrs, last, h5object=None, streams=None, reloadmode=False)
    Bases: nxswriter.FElement.FElement

    NeXuS runnable tag element with attributes tag element corresponding to one of H5 objects with attributes

    constructor

Parameters

•   name (str) – tag name

•   attrs (dict <str, str>) – dictionary of the tag attributes

•   last (nxswriter.Element.Element) – the last element from the stack

•   h5object (nxswriter.FileWriter.FTObject) – H5 file object

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

•   reloadmode (bool) – reload mode

h5Attribute(name)
    provides attribute h5 object

Parameters
    name (str) – attribute name

Returns
    instance of the attribute object if created

Return type
    nxswriter.FileWriter.FTObject

tagAttributes = None
    (dict <str, (str, str, tuple)> or dict <str, (str, str) > ) dictionary with attribures from sepatare attribute tags written as (name, value, shape)

  nxswriter.FetchNameHandler module

SAX parser for fetching name attributes of tags

class nxswriter.FetchNameHandler.FetchNameHandler(streams=None)
    Bases: xml.sax.handler.ContentHandler

    SAX2 parser

    constructor

Brief
    It constructs parser handler for fetching group names

Parameters
    streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

characters(content)
    adds the tag content

Parameters
    content (str) – partial content of the tag

endElement(name)
    parses an closing tag

Parameters
    name (str) – tag name

groupTypes = None
    (TNObject) tree of TNObjects with names and types

startElement(name, attrs)
    parses the opening tag

Parameters

•   name (str) – tag name

•   attrs (dict <str, str>) – attribute dictionary

class nxswriter.FetchNameHandler.TNObject(name='root', nxtype=None, parent=None)
    Bases: object

    Type Name object

    constructor

Brief
    It sets default values of TNObject

Parameters

•   name (str) – name of the object

•   nxtype (str) – Nexus type of the object

•   parent (nxswriter.Element.Element) – object parent

child(name='', nxtype='')
    get child by name or nxtype

Parameters

•   name (str) – group name

•   nxtype (str) – nexus group type

Returns
    child instance

Return type
    nxswriter.Element.Element

children = None
    (:obj`:list` <nxswriter.Element.Element>) object children

name = None
    (str) object name

nxtype = None
    (str) object Nexus type

parent = None
    (nxswriter.Element.Element) object parent

  nxswriter.H5Elements module

Definitions of tag evaluation classes

class nxswriter.H5Elements.EDim(attrs, last, streams=None)
    Bases: nxswriter.Element.Element

    dim tag element

    constructor

Parameters

•   attrs (dict <str, str>) – dictionary of the tag attributes

•   last (nxswriter.Element.Element) – the last element from the stack

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

content = None
    (list <str>) tag content

source = None
    (nxswriter.DataSources.DataSource) data source

store(xml=None, globalJSON=None)
    stores the tag content

Parameters

•   xml – xml setting

•   globalJSON (: dict <str, dict <str, any>>) – global JSON string

class nxswriter.H5Elements.EDimensions(attrs, last, streams=None)
    Bases: nxswriter.Element.Element

    dimensions tag element

    constructor

Parameters

•   attrs (dict <str, str>) – dictionary of the tag attributes

•   last (nxswriter.Element.Element) – the last element from the stack

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

class nxswriter.H5Elements.EDoc(attrs, last, streams=None)
    Bases: nxswriter.Element.Element

    doc tag element

    constructor

Parameters

•   attrs (dict <str, str>) – dictionary of the tag attributes

•   last (nxswriter.Element.Element) – the last element from the stack

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

store(xml=None, globalJSON=None)
    stores the tag content

Parameters

•   xml – xml setting

•   globalJSON (: dict <str, dict <str, any>>) – global JSON string

class nxswriter.H5Elements.EFile(attrs, last, h5fileObject, streams=None)
    Bases: nxswriter.FElement.FElement

    file H5 element

    constructor

Parameters

•   attrs (dict <str, str>) – dictionary of the tag attributes

•   last (nxswriter.Element.Element) – the last element from the stack

•   h5fileObject (nxswriter.FileWriter.FTfile) – H5 file object

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

class nxswriter.H5Elements.ESymbol(attrs, last, streams=None)
    Bases: nxswriter.Element.Element

    symbol tag element

    constructor

Parameters

•   attrs (dict <str, str>) – dictionary of the tag attributes

•   last (nxswriter.Element.Element) – the last element from the stack

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

store(xml=None, globalJSON=None)
    stores the tag content

Parameters

•   xml – xml setting2

•   globalJSON (: dict <str, dict <str, any>>) – global JSON string

symbols = None
    (dict <str, str>) dictionary with symbols4

  nxswriter.InnerXMLParser module

SAX parser for taking XML string inside specified tag

class nxswriter.InnerXMLParser.InnerXMLHandler(xmlReader, contentHandler, name, attrs)
    Bases: xml.sax.handler.ContentHandler

    Inner SAX2 parser

    constructor

Brief
    It constructs parser handler for taking xml of datasources

Parameters

•   xmlReader (xml.sax.xmlreader.XMLReader) – NeXus xml sax reader

•   contentHandler (nxswriter.NexusXMLHandler.NexusXMLHandler) – NeXus XML content handler

•   name (str) – tag name

•   attrs (dict <str, str>) – dictionary of the tag attributes

characters(content)
    adds the tag content

Parameters
    content (str) – partial content of the tag

endElement(name)
    parses an closing tag

Parameters
    name (str) – tag name

startElement(name, attrs)
    parses the opening tag

Parameters

•   name (str) – tag name

•   attrs (dict <str, str>) – attribute dictionary

xml = None
    (str) xml string

  nxswriter.NXSWriter module

Nexus Data Writer - Tango Server

class nxswriter.NXSWriter.CommandThread(server, command, finalState, args=None)
    Bases: threading.Thread

    thread with server command

    constructor

Parameters

•   server (tango.Device_4Impl) – Tango server implementation

•   command (str) – Thread command

•   finalState (tango.DevState) – Final State Code

•   args (list <str>) – List of command arguments

args = None
    (list <str>) command arguments

command = None
    (__callable__) command

estate = None
    (tango.DevState) error state

fstate = None
    (tango.DevState) final state

run()
    runs the given command on the server and changes the state on exit

server = None
    (tango.Device_4Impl) tango server

class nxswriter.NXSWriter.NXSDataWriter(cl, name)
    Bases: tango._tango.Device_4Impl

    Tango Server to store data in H5 files

Brief
    Device States Description: DevState.ON : NeXuS Data Server is switch on DevState.OFF : NeXuS Data Writer is switch off DevState.EXTRACT : H5 file is open DevState.OPEN : XML configuration is initialized DevState.RUNNING : NeXus Data Server is writing DevState.FAULT : Error state

    Device constructor

Parameters

•   cl (str) – class name

•   name (str) – device name

CloseEntry()
    CloseEntry command

Brief
    Closes the entry

CloseEntryAsynch()
    CloseEntryAsynch command

Brief
    Closes the entry is asynchronous mode

CloseFile()
    CloseFile command

Brief
    Close the H5 file

OpenEntry()
    OpenEntry command

Brief
    Creates the new entry

OpenEntryAsynch()
    OpenEntryAsynch command

Brief
    Creates the new entry in asynchronous mode

OpenFile()
    OpenFile command

Brief
    Opens the H5 file

Record(argin)
    Record command

Brief
    Records data for one scan step

Parameters
    argin (str) – JSON string with data

RecordAsynch(argin)
    RecordAsynch command

Brief
    Records data for one scan step in asynchronous mode

Parameters
    argin (str) – DevString JSON string with data

always_executed_hook()
    Always excuted hook method

cthread = None
    (CommandThread) closentry thread

delete_device()
    Device destructor

dev_state()
    dev_state method

Returns
    State Code

Return type
    tango.DevState

dev_status()
    Status command

Brief
    This command gets the device status (stored in its <i>device_status</i> data member) and returns it to the caller.

Returns
    Status description

Return type
    str

errors = None
    (list`<:obj:`str>) list with errors

init_device()
    Device initialization

is_CanFail_allowed(_)
    CanFail attribute State Machine

Returns
    True if the operation allowed

Return type
    bool

is_CanFail_write_allowed()
    CanFail attribute Write State Machine

Returns
    True if the operation allowed

Return type
    bool

is_CloseEntryAsynch_allowed()
    CloseEntryAsynch command State Machine

Returns
    True if the operation allowed

Return type
    bool

is_CloseEntry_allowed()
    CloseEntry command State Machine

Returns
    True if the operation allowed

Return type
    bool

is_CloseFile_allowed()
    CloseFile command State Machine

Returns
    True if the operation allowed

Return type
    bool

is_FileName_allowed(_)
    FileName attribute State Machine

Returns
    True if the operation allowed

Return type
    bool

is_FileName_write_allowed()
    FileName attribute Write State Machine

Returns
    True if the operation allowed

Return type
    bool

is_JSONRecord_allowed(_)
    JSONRecord attribute State Machine

Returns
    True if the operation allowed

Return type
    bool

is_OpenEntryAsynch_allowed()
    OpenEntryAsynch command State Machine

Returns
    True if the operation allowed

Return type
    bool

is_OpenEntry_allowed()
    OpenEntry command State Machine

Returns
    True if the operation allowed

Return type
    bool

is_OpenFile_allowed()
    OpenFile command State Machine

Returns
    True if the operation allowed

Return type
    bool

is_RecordAsynch_allowed()
    RecordAsynch command State Machine

Returns
    True if the operation allowed

Return type
    bool

is_Record_allowed()
    Record command State Machine

Returns
    True if the operation allowed

Return type
    bool

is_SkipAcquisition_allowed(_)
    SkipAcquisition attribute State Machine

Returns
    True if the operation allowed

Return type
    bool

is_SkipAcquisition_write_allowed()
    SkipAcquisition attribute Write State Machine

Returns
    True if the operation allowed

Return type
    bool

is_StepsPerFile_allowed(_)
    StepsPerFile attribute State Machine

Returns
    True if the operation allowed

Return type
    bool

is_StepsPerFile_write_allowed()
    StepsPerFile attribute Write State Machine

Returns
    True if the operation allowed

Return type
    bool

is_XMLSettings_allowed(_)
    XMLSettings attribute State Machine

Returns
    True if the operation allowed

Return type
    bool

lock = None
    (threading.Lock) thread lock

othread = None
    (CommandThread) openentry thread

read_CanFail(attr)
    Read CanFail attribute

Parameters
    attr (tango.Attribute) – attribute object

read_CurrentFileId(attr)
    Read CurrentFileId

Parameters
    attr (tango.Attribute) – attribute object

read_Errors(attr)
    Read Errors attribute

Parameters
    attr (tango.Attribute) – attribute object

read_FileName(attr)
    Read FileName attribute

Parameters
    attr (tango.Attribute) – attribute object

read_JSONRecord(attr)
    Read JSONRecord attribute

Parameters
    attr (tango.Attribute) – attribute object

read_SkipAcquisition(attr)
    Read SkipAcquisition attribute

Parameters
    attr (tango.Attribute) – attribute object

read_StepsPerFile(attr)
    Read StepsPerFile attribute

Parameters
    attr (tango.Attribute) – attribute object

read_XMLSettings(attr)
    Read XMLSettings attribute

Parameters
    attr (tango.Attribute) – attribute object

read_attr_hardware(_)
    Read Attribute Hardware

rthread = None
    (CommandThread) record thread

set_state(state)
    set_state method

Parameters
    state (tango.DevState) – State Code

state_flag = None
    (tango.DevState) state flag

tdw = None
    (nxswriter.TangoDataWriter.TangoDataWriter) Tango Data Writer

write_CanFail(attr)
    Write CanFail attribute

Parameters
    attr (tango.Attribute) – attribute object

write_FileName(attr)
    Write FileName attribute

Parameters
    attr (tango.Attribute) – attribute object

write_JSONRecord(attr)
    Write JSONRecord attribute

Parameters
    attr (tango.Attribute) – attribute object

write_SkipAcquisition(attr)
    Write SkipAcquisition attribute

Parameters
    attr (tango.Attribute) – attribute object

write_StepsPerFile(attr)
    Write StepsPerFile attribute

Parameters
    attr (tango.Attribute) – attribute object

write_XMLSettings(attr)
    Write XMLSettings attribute

Parameters
    attr (tango.Attribute) – attribute object

class nxswriter.NXSWriter.NXSDataWriterClass(name)
    Bases: tango._tango.DeviceClass

    NXSDataWriterClass class definition

    NXSDataWriterClass Constructor

attr_list = {'CanFail': [[tango._tango.CmdArgType.DevBoolean, tango._tango.AttrDataFormat.SCALAR, tango._tango.AttrWriteType.READ_WRITE], {'label': 'Can fail', 'description': 'Global can fail flag. By default it is False'}], 'CurrentFileId': [[tango._tango.CmdArgType.DevLong, tango._tango.AttrDataFormat.SCALAR, tango._tango.AttrWriteType.READ], {'label': 'Current file id', 'description': 'current file id'}], 'Errors': [[tango._tango.CmdArgType.DevString, tango._tango.AttrDataFormat.SPECTRUM, tango._tango.AttrWriteType.READ, 1000], {'label': 'List of errors', 'description': 'list of errors'}], 'FileName': [[tango._tango.CmdArgType.DevString, tango._tango.AttrDataFormat.SCALAR, tango._tango.AttrWriteType.READ_WRITE], {'label': 'Output file with its path', 'description': 'A name of H5 output file with its full path'}], 'JSONRecord': [[tango._tango.CmdArgType.DevString, tango._tango.AttrDataFormat.SCALAR, tango._tango.AttrWriteType.READ_WRITE], {'label': 'JSON string with client data', 'description': 'A JSON string with global client data.', 'Display level': tango._tango.DispLevel.EXPERT}], 'SkipAcquisition': [[tango._tango.CmdArgType.DevBoolean, tango._tango.AttrDataFormat.SCALAR, tango._tango.AttrWriteType.READ_WRITE], {'label': 'Skip acquisition', 'description': 'Skip acquisition. It is set to default False value after excuting the OpenEntry, Record or CloseEntry'}], 'StepsPerFile': [[tango._tango.CmdArgType.DevLong, tango._tango.AttrDataFormat.SCALAR, tango._tango.AttrWriteType.READ_WRITE], {'label': 'Steps per file', 'description': 'Number of steps per file', 'Memorized': 'true'}], 'XMLSettings': [[tango._tango.CmdArgType.DevString, tango._tango.AttrDataFormat.SCALAR, tango._tango.AttrWriteType.READ_WRITE], {'label': 'XML Configuration', 'description': 'An XML string with Nexus configuration.', 'Display level': tango._tango.DispLevel.EXPERT}]}
    (dict <str, [[ tango.CmdArgType, tango.AttrDataFormat, tango.AttrWriteType], dict <str, any> ] > ) Attribute definitions

class_property_list = {}
    (dict <str, [ str, tango.CmdArgType, [ list <int> ] ] > ) Class Properties

cmd_list = {'CloseEntry': [[tango._tango.CmdArgType.DevVoid, ''], [tango._tango.CmdArgType.DevVoid, '']], 'CloseEntryAsynch': [[tango._tango.CmdArgType.DevVoid, ''], [tango._tango.CmdArgType.DevVoid, '']], 'CloseFile': [[tango._tango.CmdArgType.DevVoid, ''], [tango._tango.CmdArgType.DevVoid, '']], 'OpenEntry': [[tango._tango.CmdArgType.DevVoid, ''], [tango._tango.CmdArgType.DevVoid, '']], 'OpenEntryAsynch': [[tango._tango.CmdArgType.DevVoid, ''], [tango._tango.CmdArgType.DevVoid, '']], 'OpenFile': [[tango._tango.CmdArgType.DevVoid, ''], [tango._tango.CmdArgType.DevVoid, '']], 'Record': [[tango._tango.CmdArgType.DevString, 'JSON string with data'], [tango._tango.CmdArgType.DevVoid, '']], 'RecordAsynch': [[tango._tango.CmdArgType.DevString, 'JSON string with data'], [tango._tango.CmdArgType.DevVoid, '']]}
    (dict <str, [[ tango.CmdArgType, str]] >) Command definitions

device_property_list = {'AddingLogs': [tango._tango.CmdArgType.DevBoolean, 'Add XML logs', [True]], 'DefaultCanFail': [tango._tango.CmdArgType.DevBoolean, 'Default value of CanFail attribute', [True]], 'MaxElementRuntime': [tango._tango.CmdArgType.DevDouble, 'maximal runtime for a thread element in seconds', [0.0]], 'MaxRecordRuntime': [tango._tango.CmdArgType.DevDouble, 'maximal runtime for a record command in seconds', [0.0]], 'MetadataOutput': [tango._tango.CmdArgType.DevString, 'metadata output', ['']], 'NumberOfThreads': [tango._tango.CmdArgType.DevLong, 'maximal number of threads', [100]], 'Writer': [tango._tango.CmdArgType.DevString, 'writer module', ['']]}
    (dict <str, [ str, tango.CmdArgType, [ list <int> ] ] > ) Device Properties

  nxswriter.NexusXMLHandler module

SAX parser for interpreting content of XML configuration string

class nxswriter.NexusXMLHandler.NexusXMLHandler(fileElement, datasources=None, decoders=None, groupTypes=None, parser=None, globalJSON=None, streams=None, reloadmode=False)
    Bases: xml.sax.handler.ContentHandler

    SAX2 parser

    constructor

Brief
    It constructs parser and defines the H5 output file

Parameters

•   fileElement (nxswriter.H5Elements.EFile) – file element

•   decoders (nxswriter.DecoderPool.DecoderPool) – decoder pool

•   datasources (nxswriter.DataSourcePool.DataSourcePool) – datasource pool

•   groupTypes (nxswriter.FetchNameHandler.TNObject) – map of NXclass : name

•   parser (xml.sax.xmlreader.XMLReader) – instance of sax.xmlreader

•   globalJSON (: dict <str, dict <str, any>>) – global json string

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

•   reloadmode – reload mode

characters(content)
    adds the tag content

Parameters
    content (str) – partial content of the tag

close()
    closes the elements

Brief
    It goes through all stack elements closing them

elementClass = None
    (dict <str, type > ) map of tag names to related classes

endElement(name)
    parses the closing tag

Parameters
    name (str) – tag name

entryAttrs = None
    (list <dict <str, str > >) list of entry group attributes

finalPool = None
    (nxswriter.ThreadPool.ThreadPool) thread pool with FINAL elements

initPool = None
    (nxswriter.ThreadPool.ThreadPool) thread pool with INIT elements

raiseUnsupportedTag = None
    (bool) True if raise exception on unsupported tag

startElement(name, attrs)
    parses the opening tag

Parameters

•   name (str) – tag name

•   attrs (dict <str, str>) – attribute dictionary

stepPool = None
    (nxswriter.ThreadPool.ThreadPool) thread pool with STEP elements

transparentTags = None
    (list <str>) transparent tags

triggerPools = None
    (dict <str, nxswriter.ThreadPool.ThreadPool> ) collection of thread pool with triggered STEP elements

withAttr = None
    (dict <str, type > ) map of tag names to related classes

withXMLinput = None
    (dict <str: nxswriter.Element.Element > ) tags with inner xml as its input

  nxswriter.PyEvalSource module

Definitions of PYEVAL datasource

class nxswriter.PyEvalSource.PyEvalSource(streams=None, name=None)
    Bases: nxswriter.DataSources.DataSource

    Python Eval data source

    constructor

Brief
    It cleans all member variables

Parameters

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

•   name (str) – datasource name

getData()
    provides access to the data

Returns
    dictionary with collected data

Return type
    {‘rank’: str, ‘value’: any, ‘tangoDType’: str, : ‘shape’: list <int>, ‘encoding’: str, : ‘decoders’: str} )

setDataSources(pool)
    sets the datasources

Parameters
    pool (nxswriter.DataSourcePool.DataSourcePool) – datasource pool

setDecoders(decoders)
    sets the used decoders

Parameters
    decoders (nxswriter.DecoderPool.DecoderPool) – pool to be set

setJSON(globalJSON, localJSON=None)
    sets JSON string

Brief
    It sets the currently used JSON string

Parameters

•   globalJSON (: dict <str , dict <str, any>>) – static JSON string

•   localJSON (: dict <str , dict <str, any>>) – dynamic JSON string

setup(xml)
    sets the parrameters up from xml

Parameters
    xml (str) – datasource parameters

class nxswriter.PyEvalSource.Variables
    Bases: object

    Variables for PyEval datasource

  nxswriter.StreamSet module

labels to Tango Streams

class nxswriter.StreamSet.StreamSet(streams)
    Bases: object

    streamset constractor

Parameters
    streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

debug(message, std=False)
    writes debug message

Parameters

•   message (str) – debug message

•   std (bool) – True if it writes to sys stream when log stream does not exist

error(message, std=True)
    writes error message

Parameters

•   message (str) – error message

•   std (bool) – True if it writes to sys stream when log stream does not exist

fatal(message, std=True)
    writes fatal error message

Parameters

•   message (str) – error message

•   std (bool) – True if it writes to sys stream when log stream does not exist

info(message, std=False)
    writes info message

Parameters

•   message (str) – info message

•   std (bool) – True if it writes to sys stream when log stream does not exist

log_debug = None
    (tango.log4tango.TangoStream) Tango debug log stream

log_error = None
    (tango.log4tango.TangoStream) Tango error log stream

log_fatal = None
    (tango.log4tango.TangoStream) Tango fatal log stream

log_info = None
    (tango.log4tango.TangoStream) Tango info log stream

log_warn = None
    (tango.log4tango.TangoStream) Tango warn log stream

warn(message, std=True)
    writes warning message

Parameters

•   message (str) – warning message

•   std (bool) – True if it writes to sys stream when log stream does not exist

  nxswriter.TangoDataWriter module

Tango Data Writer implementation

nxswriter.TangoDataWriter.PYTG_BUG_213 = False
    (bool) tango bug #213 flag related to EncodedAttributes in python3

class nxswriter.TangoDataWriter.TangoDataWriter(server=None)
    Bases: object

    NeXuS data writer

    constructor

Brief
    It initialize the data writer for the H5 output file

Parameters
    server (tango.Device_4Impl) – Tango server

addingLogs = None
    (str) adding logs

canfail
    the global can fail flag

closeEntry()
    closes the data entry

Brief
    It runs threads from the FINAL pool and removes the thread pools

closeFile()
    the H5 file closing

Brief
    It closes the H5 file

currentfileid
    the json data string

defaultCanFail
    the global can fail flag

fileName
    the parent nexus path

getFile()
    the H5 file handle

Returns
    the H5 file handle

Return type
    nxswriter.FileWriter.FTFile

jsonrecord
    the json data string

maxElementRuntime = None
    (float) maximal element record time in sec

maxRecordRuntime = None
    (float) maximal record time in sec

metadataOutput = None
    (str) metadata output

numberOfThreads = None
    (int) maximal number of threads

openEntry()
    opens the data entry corresponding to a new XML settings

Brief
    It parse the XML settings, creates thread pools and runs the INIT pool.

openFile()
    the H5 file opening

Brief
    It opens the H5 file

record(jsonstring=None)
    runs threads form the STEP pool

Brief
    It runs threads from the STEP pool

Parameters
    jsonstring (str) – local JSON string with data records

skipacquisition = None
    (bool) skip acquisition flag

stepsperfile = None
    (int) steps per file

writer = None
    (str) writer type

xmlsettings
    the xmlsettings

  nxswriter.TangoSource module

Definitions of TANGO datasource

nxswriter.TangoSource.PYTANGO_AVAILABLE = True
    (str) global variable if tango module installed

class nxswriter.TangoSource.ProxyTools
    Bases: object

    tools for proxy

classmethod isProxyValid(proxy)
    checks if proxy is valid

Parameters
    proxy (tango.DeviceProxy) – tango proxy

Returns
    True if proxy is valid else false

Return type
    bool

classmethod proxySetup(device, streams=None, maxcount=10)
    sets the Tango proxy up

Parameters

•   device (str) – tango device

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

•   maxcount (int) – a number of tries

Returns
    proxy if proxy is set up

Return type
    tango.DeviceProxy

class nxswriter.TangoSource.TangoSource(streams=None, name=None)
    Bases: nxswriter.DataSources.DataSource

    Tango data source

    constructor

Brief
    It cleans all member variables

Parameters

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

•   name (str) – datasource name

client = None
    (str) client datasource for mixed CLIENT/TANGO mode

device = None
    (str) full device name

fullclient = None
    (str) client datasource for mixed CLIENT/TANGO mode with fqdn

getData()
    data provider

Returns
    dictionary with collected data

Return type
    {‘rank’: str, ‘value’: any, ‘tangoDType’: str, : ‘shape’: list <int>, ‘encoding’: str, : ‘decoders’: str}

group = None
    (TgGroup) datasource tango group

member = None
    (TgMember) Tango device member

setDataSources(pool)
    sets the datasources

Parameters
    pool (nxswriter.DataSourcePool.DataSourcePool) – datasource pool

setDecoders(decoders)
    sets the used decoders

Parameters
    decoders (nxswriter.DecoderPool.DecoderPool) – pool to be set

setJSON(globalJSON, localJSON=None)
    sets JSON string

Brief
    It sets the currently used JSON string

Parameters

•   globalJSON (: dict <str , dict <str, any>>) – static JSON string

•   localJSON (: dict <str, dict <str, any>>) – dynamic JSON string

setup(xml)
    sets the parrameters up from xml

Parameters
    xml (str) – datasource parameters

class nxswriter.TangoSource.TgDevice(device, proxy=None, streams=None)
    Bases: object

    tango device

    default constructor

Parameters

•   device (str) – tango device name

•   proxy (tango.DeviceProxy) – device proxy

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

attributes = None
    (list <str>) device attribute names

commands = None
    (list <str>) device command names

device = None
    (str) tango device name

members = None
    (dict <str , TgMember > ) dictionary with tango members

properties = None
    (list <str>) device property names

proxy = None
    (tango.DeviceProxy) device proxy

setMember(member)
    provides tango device member

Parameters
    member (TgMember) – tango device member

Returns
    TgMember instance of tango device member

Return type
    TgMember

class nxswriter.TangoSource.TgGroup(counter=0, streams=None)
    Bases: object

    Group of tango devices

    default constructor

Parameters

•   counter (int) – counts of steps

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

counter = None
    (int) counter of steps

devices = None
    (dict <str, TgDevice> ) TANGO devices

getData(counter, proxy=None, member=None)
    reads data from device proxy

Parameters

•   counter (int) – counts of scan steps

•   proxy (tango.DeviceProxy) – device proxy

•   member (TgMember) – required member

getDevice(device)
    provides tango device

Parameters
    device (str) – tango device name

Returns
    TgDevice instance of tango device

Return type
    TgDevice

lock = None
    (threading.Lock) threading lock

class nxswriter.TangoSource.TgMember(name, memberType='attribute', encoding=None, streams=None)
    Bases: object

    tango device member

    default constructor

Parameters

•   name (str) – name of data record

•   memberType (str) – member type of the data

•   encoding (str) – encoding type of Tango DevEncoded variables

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

encoding = None
    (str) encoding type of Tango DevEncoded variables

getData(proxy)
    reads data from device proxy

Parameters
    proxy (tango.DeviceProxy) – device proxy

getValue(decoders=None)
    provides value of tango member

Parameters
    decoders (nxswriter.DecoderPool.DecoderPool) – decoder pool

Returns
    dictionary with {“rank”:, “value”:, “tangoDType”:, “shape”:, “encoding”:, “decoders”:}

Returns
    dictionary with collected data

Return type
    {‘rank’: str, ‘value’: any, ‘tangoDType’: str, : ‘shape’: list <int>, ‘encoding’: str, : ‘decoders’: str}

isDataSet()
    checks if data is set

Returns
    True if data is set

Return type
    str

memberType = None
    (str) member type of the data, i.e. attribute, property,…

name = None
    (str) name of data record

reset()
    cleans output value

setData(data, cmd=None)
    sets tango data

Parameters

•   data (tango.DeviceAttribute) – output tango data

•   cmd (tango.CommandInfo) – input command data

  nxswriter.ThreadPool module

Provides a pool with element threads

class nxswriter.ThreadPool.ThreadPool(numberOfThreads=None, streams=None, maxruntime=0)
    Bases: object

    Pool with threads

    constructor

Brief
    It cleans the member variables

Parameters

•   numberOfThreads (int) – number of threads

•   streams (StreamSet or tango.Device_4Impl) – tango-like steamset class

•   maxruntime (int) – maxruntime

append(elem)
    appends the thread element

Parameters
    elem (nxswriter.Element.Element) – the thread element

checkErrors()
    checks errors from threads

close()
    closer

Brief
    It close the threads from the pool

join(timeout=None)
    waits for all thread from the pool

Parameters
    timeout (int) – the maximal waiting time

maxRuntime = None
    (float) maximal runtime

numberOfThreads = None
    (int) maximal number of threads

run()
    thread runner

Brief
    It runs the threads from the pool

runAndWait()
    runner with waiting

Brief
    It runs and waits the threads from the pool

setJSON(globalJSON, localJSON=None)
    sets the JSON string to threads

Parameters

•   globalJSON (: dict <str , dict <str, any>>) – the static JSON string

•   localJSON (: dict <str, dict <str, any>>) – the dynamic JSON string

Returns
    self object

Return type
    ThreadPool

  nxswriter.Types module

Types converters

class nxswriter.Types.Converters
    Bases: object

    set of converters

classmethod toBool(value)
    converts to bool

Parameters
    value (any) – variable to convert

Returns
    result in bool type

Return type
    bool

class nxswriter.Types.NTP
    Bases: object

    type converter

aTn = {'axis': 'NX_INT', 'file_time': 'NX_DATE_TIME', 'file_update_time': 'NX_DATE_TIME', 'ignoreExtraAttributes': 'NX_BOOLEAN', 'ignoreExtraFields': 'NX_BOOLEAN', 'ignoreExtraGroups': 'NX_BOOLEAN', 'maxOccus': 'NX_INT', 'minOccus': 'NX_INT', 'offset': 'NX_INT', 'primary': 'NX_INT32', 'restricts': 'NX_INT', 'signal': 'NX_INT', 'stride': 'NX_INT'}
    (dict <str , str >) map of tag attribute types

aTnv = {'vector': 'NX_FLOAT'}
    (dict <str , str >) map of vector tag attribute types

arrayRank(array)
    array rank

Brief
    It calculates the rank of the array

Parameters
    array (any) – given array

Returns
    rank

Return type
    int

arrayRankRShape(array)
    array rank, inverse shape and type

Brief
    It calculates the rank, inverse shape and type of the first element of the list array

Parameters
    array (any) – given array

Returns
    (rank, inverse shape, type)

Return type
    (int , list <int > , str )

arrayRankShape(array)
    array rank, shape and type

Brief
    It calculates the rank, shape and type of the first element of the list array

Parameters
    array (any) – given array

Returns
    (rank, shape, type)

Return type
    (int , list <int > , str )

convert = {'bool': <bound method Converters.toBool of <class 'nxswriter.Types.Converters'>>, 'float': <class 'float'>, 'float16': <class 'float'>, 'float32': <class 'float'>, 'float64': <class 'float'>, 'int': <class 'int'>, 'int16': <class 'int'>, 'int32': <class 'int'>, 'int64': <class 'int'>, 'int8': <class 'int'>, 'str': <class 'str'>, 'string': <class 'str'>, 'uint': <class 'int'>, 'uint16': <class 'int'>, 'uint32': <class 'int'>, 'uint64': <class 'int'>, 'uint8': <class 'int'>}
    (dict <str , type or types.MethodType >) map of type : converting function

createArray(value, fun=None)

creates python array from the given array with applied
    the given function to it elements

Parameters

•   value – given array

•   fun (type or types.MethodType) – applied function

Returns
    created array

Return type
    list <any>

nTnp = {'ISO8601': 'string', 'NX_BOOLEAN': 'bool', 'NX_CHAR': 'string', 'NX_DATE_TIME': 'string', 'NX_FLOAT': 'float64', 'NX_FLOAT32': 'float32', 'NX_FLOAT64': 'float64', 'NX_INT': 'int64', 'NX_INT16': 'int16', 'NX_INT32': 'int32', 'NX_INT64': 'int64', 'NX_INT8': 'int8', 'NX_NUMBER': 'float64', 'NX_POSINT': 'uint64', 'NX_UINT': 'uint64', 'NX_UINT16': 'uint16', 'NX_UINT32': 'uint32', 'NX_UINT64': 'uint64', 'NX_UINT8': 'uint8'}
    (dict <str , str >) map of NEXUS : numpy types

pTt = {'bool': 'DevBoolean', 'float': 'DevDouble', 'float16': 'DevFloat', 'float32': 'DevFloat', 'float64': 'DevDouble', 'int': 'DevLong64', 'int16': 'DevShort', 'int32': 'DevLong', 'int64': 'DevLong64', 'int8': 'DevUChar', 'long': 'DevLong64', 'str': 'DevString', 'string': 'DevString', 'uint': 'DevULong64', 'uint16': 'DevUShort', 'uint32': 'DevULong', 'uint64': 'DevULong64', 'uint8': 'DevUChar', 'unicode': 'DevString'}
    (dict <str ,:obj:str >) map of Python:Tango types

rTf = {0: 'SCALAR', 1: 'SPECTRUM', 2: 'IMAGE', 3: 'VERTEX'}
    (dict <int , str >) map of rank : data format

nxswriter.Types.nptype(dtype)
    converts to numpy types

Parameters
    dtype (str) – h5 writer type type

Returns
    nupy type

Return type
    str

  Module contents

Tango Data Writer

nxswriter.run(argv)
    launches the TANGO server

Parameters
    argv (list <str>) – command-line arguments

nxswriter.globallock = <unlocked _thread.lock object>
    (threading.Lock) global lock

•   genindex

•   modindex

•   search

AUTHOR
Author

COPYRIGHT
2012-2017 DESY, Jan Kotanski <jkotan@mail.desy.de> GNU GENERAL PUBLIC LICENSE, version 3