nxswriter package

Submodules

nxswriter.ClientSource module

Definitions of CLIENT datasource

class nxswriter.ClientSource.ClientSource(streams=None, name=None)[source]

Bases: DataSource

Client data source

constructor

Brief:

It sets all member variables to None

Parameters:
getData()[source]

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

(str) data name

setJSON(globalJSON, localJSON=None)[source]

sets JSON string

Brief:

It sets the currently used JSON string

Parameters:
setup(xml)[source]

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)[source]

Bases: DataSource

DataBase data source

constructor

Brief:

It sets all member variables to None

Parameters:
dbname

(str) database name

dbtype

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

dsn

(str) DSN string

format

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

getData()[source]

provides access to the data

Returns:

dictionary with collected data

Return type:

dict <str, any>

hostname

(str) name of the host with the data source

mode

(str) oracle database mode

mycnf

(str) mysql database configuration file

passwd

(str) database password

port

(str) port related to the host

query

(str) database query

setup(xml)[source]

sets the parrameters up from xml

Parameters:

xml (str) – datasource parameters

Raises:

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

user

(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)[source]

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.LatestDeviceImpl) – tango-like steamset class

cast(dtype)[source]

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

pool with decoding algorithm

encoding

(str) encoding type of Tango DevEncoded varibles

format

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

shape

(list <int>) data shape

tangoDType

(str) tango data type

value

(any) data value

nxswriter.DataSourceFactory module

factory with datasources

class nxswriter.DataSourceFactory.DataSourceFactory(attrs, last, streams=None)[source]

Bases: Element

Data source creator

constructor

Parameters:
setDataSources(datasources)[source]

sets the used datasources

Parameters:

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

setDecoders(decoders)[source]

sets the used decoders

Parameters:

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

store(xml=None, globalJSON=None)[source]

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)[source]

Bases: object

DataSource pool

constructor

Brief:

It creates know datasources

Parameters:

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

append(datasource, name)[source]

adds additional datasource

Parameters:
Returns:

name of datasource

Return type:

str

appendUserDataSources(configJSON)[source]

loads user datasources

Parameters:

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

canfail

(bool) can fail switch

common

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

counter

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

get(datasource)[source]

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)[source]

checks if the datasource is registered

Parameters:

datasource (str) – the given datasource

Returns:

True if it the datasource is registered

Return type:

bool

lock

(threading.Lock) pool lock

nxroot

(nxswriter.FileWriter.FTGroup) H5 file handle

pop(name)[source]

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)[source]

Bases: object

Data source

constructor

Brief:

It cleans all member variables

Parameters:
getData()[source]

access to data

Brief:

It is an abstract method providing data

isValid()[source]

checks if the data is valid

Returns:

True if the data is valid

Return type:

bool

setup(xml)[source]

sets the parrameters up from xml

Parameters:

xml (str) – datasource parameters

nxswriter.DecoderPool module

Provides a pool with data decoders

class nxswriter.DecoderPool.DATAARRAYdecoder[source]

Bases: object

DATA ARRAY LIMA decoder

constructor

Brief:

It clears the local variables

decode()[source]

provides the decoded data

Returns:

the decoded data if data was loaded

Return type:

numpy.ndarray

dtype

(str) data type

format

(str) decoder format

frameNumber()[source]

no data

load(data)[source]

loads encoded data

Parameters:

data ([str, str]) – encoded data

name

(str) decoder name

shape()[source]

provides the data shape

Returns:

the data shape if data was loaded

Return type:

list <int >

steps()[source]

provides the data steps

Returns:

the data steps if data was loaded

Return type:

list <int >

class nxswriter.DecoderPool.DecoderPool(configJSON=None)[source]

Bases: object

Decoder pool

constructor

Brief:

It creates know decoders

Parameters:

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

append(decoder, name)[source]

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)[source]

loads user decoders

Parameters:

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

get(decoder)[source]

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)[source]

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)[source]

adds additional decoder

Parameters:

name (str) – name of the adding decoder

class nxswriter.DecoderPool.UINT32decoder[source]

Bases: object

INT decoder

constructor

Brief:

It clears the local variables

decode()[source]

provides the decoded data

Returns:

the decoded data if data was loaded

Return type:

numpy.ndarray

dtype

(str) data type

format

(str) decoder format

load(data)[source]

loads encoded data

Parameters:

data ([str, bytes]) – encoded data

name

(str) decoder name

shape()[source]

provides the data shape

Returns:

the data shape if data was loaded

Return type:

list <int >

class nxswriter.DecoderPool.UTF8decoder[source]

Bases: object

UTF8 decoder

constructor

Brief:

It clears the local variables

decode()[source]

provides the decoded data

Returns:

the decoded data if data was loaded

Return type:

bytes

dtype

(str) data type

format

(str) decoder format

load(data)[source]

loads encoded data

Parameters:

data ([str, bytes]) – encoded data

name

(str) decoder name

shape()[source]

provides the data shape

Returns:

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

Return type:

list <int >

class nxswriter.DecoderPool.VDEOdecoder[source]

Bases: object

VIDEO IMAGE LIMA decoder

constructor

Brief:

It clears the local variables

decode()[source]

provides the decoded data

Returns:

the decoded data if data was loaded

Return type:

numpy.ndarray

dtype

(str) data type

format

(str) decoder format

load(data)[source]

loads encoded data

Parameters:

data ([str, str]) – encoded data

name

(str) decoder name

shape()[source]

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)[source]

Bases: FElement

attribute tag element

constructor

Parameters:
lengths

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

markFailed(error=None)[source]

marks the field as failed

Brief:

It marks the field as failed

Parameters:

error (str) – error string

name

(str) attribute name

rank

(str) rank of the attribute

run()[source]

runner

Brief:

During its thread run it fetches the data from the source

store(xml=None, globalJSON=None)[source]

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

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

trigger

(str) trigger for asynchronous writting

nxswriter.EField module

Definitions of field tag evaluation classes

class nxswriter.EField.EField(attrs, last, streams=None, reloadmode=False)[source]

Bases: FElementWithAttr

field H5 tag element

constructor

Parameters:
compression

(bool) compression algorithm id

compression_opts

(int) compression rate

filters

(dict <int, (int, str, str, str) >) index filter lists, i.e. {index: (filter_id, name, id, cd_values, availability)}

grows

(int) growing dimension

lengths

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

markFailed(error=None)[source]

marks the field as failed

Brief:

It marks the field as failed

Parameters:

error (str) – error string

postrun

(str) label for postprocessing data

rank

(str) rank of the field

rate

(list < int >) compression algorithm options

run()[source]

runner

Brief:

During its thread run it fetches the data from the source

shuffle

(bool) compression shuffle

store(xml=None, globalJSON=None)[source]

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

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

trigger

(str) trigger for asynchronous writing

nxswriter.EGroup module

Definitions of group tag evaluation classes

class nxswriter.EGroup.EGroup(attrs, last, streams=None, reloadmode=False)[source]

Bases: FElementWithAttr

group H5 tag element

constructor

Parameters:
store(xml=None, globalJSON=None)[source]

stores the tag content

Parameters:
  • xml (str) – xml setting

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

nxswriter.EStrategy module

Definitions of strategy evaluation classes

class nxswriter.EStrategy.EStrategy(attrs, last, streams=None)[source]

Bases: Element

strategy tag element

constructor

Parameters:
setCanFail()[source]

sets can fail flag

store(xml=None, globalJSON=None)[source]

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)[source]

Bases: object

Tag element stored on our stack

constructor

Parameters:
content

(list <str>) stored tag content

doc

(str) doc string

last

(nxswriter.Element.Element) the previous element

store(xml=None, globalJSON=None)[source]

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

(str) stored tag name

nxswriter.ElementThread module

Implementation of element thread for tag evaluation

class nxswriter.ElementThread.ElementThread(index, queue)[source]

Bases: 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

(int) thread index

run()[source]

runner

Brief:

It runs the defined thread

nxswriter.Errors module

Tango Data Writer errors

exception nxswriter.Errors.CorruptedFieldArrayError[source]

Bases: Exception

exception for corrupted FieldArray

exception nxswriter.Errors.DataSourceError[source]

Bases: Exception

exception for fetching data from data source

exception nxswriter.Errors.DataSourceSetupError[source]

Bases: Exception

exception for setting data source

exception nxswriter.Errors.PackageError[source]

Bases: Exception

exception for fetching data from data source

exception nxswriter.Errors.ThreadError[source]

Bases: Exception

exception for problems in thread

exception nxswriter.Errors.UnsupportedTagError[source]

Bases: Exception

unsupported tag exception

exception nxswriter.Errors.XMLSettingSyntaxError[source]

Bases: Exception

exception for syntax in XML settings

exception nxswriter.Errors.XMLSyntaxError[source]

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)[source]

Bases: 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.LatestDeviceImpl) – tango-like steamset class

canfail

(bool) flag for devices for which is allowed to failed

error

(str) notification of error in the run method

h5Object

(nxswriter.FileWriter.FTObject) stored H5 file object

run()[source]

runner

Brief:

During its thread run it fetches the data from the source

runtime

(float) runtime

setMessage(exceptionMessage=None)[source]

creates the error message

Parameters:

exceptionMessage (str) – additional message of exception

Returns:

error message

Return type:

str

source

(nxswriter.DataSources.DataSource) data source

class nxswriter.FElement.FElementWithAttr(name, attrs, last, h5object=None, streams=None, reloadmode=False)[source]

Bases: 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.LatestDeviceImpl) – tango-like steamset class

  • reloadmode (bool) – reload mode

h5Attribute(name)[source]

provides attribute h5 object

Parameters:

name (str) – attribute name

Returns:

instance of the attribute object if created

Return type:

nxswriter.FileWriter.FTObject

tagAttributes

(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)[source]

Bases: ContentHandler

SAX2 parser

constructor

Brief:

It constructs parser handler for fetching group names

Parameters:

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

characters(content)[source]

adds the tag content

Parameters:

content (str) – partial content of the tag

endElement(name)[source]

parses an closing tag

Parameters:

name (str) – tag name

groupTypes

(TNObject) tree of TNObjects with names and types

startElement(name, attrs)[source]

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)[source]

Bases: object

Type Name object

constructor

Brief:

It sets default values of TNObject

Parameters:
child(name='', nxtype='')[source]

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

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

name

(str) object name

nxtype

(str) object Nexus type

parent

(nxswriter.Element.Element) object parent

nxswriter.H5Elements module

Definitions of tag evaluation classes

class nxswriter.H5Elements.EDim(attrs, last, streams=None)[source]

Bases: Element

dim tag element

constructor

Parameters:
content

(list <str>) tag content

source

(nxswriter.DataSources.DataSource) data source

store(xml=None, globalJSON=None)[source]

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)[source]

Bases: Element

dimensions tag element

constructor

Parameters:
class nxswriter.H5Elements.EDoc(attrs, last, streams=None)[source]

Bases: Element

doc tag element

constructor

Parameters:
store(xml=None, globalJSON=None)[source]

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)[source]

Bases: FElement

file H5 element

constructor

Parameters:
class nxswriter.H5Elements.EFilter(attrs, last, streams=None)[source]

Bases: Element

filter tag element

constructor

Parameters:
class nxswriter.H5Elements.ESymbol(attrs, last, streams=None)[source]

Bases: Element

symbol tag element

constructor

Parameters:
store(xml=None, globalJSON=None)[source]

stores the tag content

Parameters:
  • xml – xml setting2

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

symbols

(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)[source]

Bases: ContentHandler

Inner SAX2 parser

constructor

Brief:

It constructs parser handler for taking xml of datasources

Parameters:
characters(content)[source]

adds the tag content

Parameters:

content (str) – partial content of the tag

endElement(name)[source]

parses an closing tag

Parameters:

name (str) – tag name

startElement(name, attrs)[source]

parses the opening tag

Parameters:
  • name (str) – tag name

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

xml

(str) xml string

nxswriter.NXSWriter module

Nexus Data Writer - Tango Server

class nxswriter.NXSWriter.CommandThread(server, command, finalState, args=None)[source]

Bases: Thread

thread with server command

constructor

Parameters:
args

(list <str>) command arguments

command

(__callable__) command

estate

(tango.DevState) error state

fstate

(tango.DevState) final state

run()[source]

runs the given command on the server and changes the state on exit

server

(tango.LatestDeviceImpl) tango server

class nxswriter.NXSWriter.NXSDataWriter(cl, name)[source]

Bases: LatestDeviceImpl

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()[source]

CloseEntry command

Brief:

Closes the entry

CloseEntryAsynch()[source]

CloseEntryAsynch command

Brief:

Closes the entry is asynchronous mode

CloseFile()[source]

CloseFile command

Brief:

Close the H5 file

OpenEntry()[source]

OpenEntry command

Brief:

Creates the new entry

OpenEntryAsynch()[source]

OpenEntryAsynch command

Brief:

Creates the new entry in asynchronous mode

OpenFile()[source]

OpenFile command

Brief:

Opens the H5 file

Record(argin)[source]

Record command

Brief:

Records data for one scan step

Parameters:

argin (str) – JSON string with data

RecordAsynch(argin)[source]

RecordAsynch command

Brief:

Records data for one scan step in asynchronous mode

Parameters:

argin (str) – DevString JSON string with data

always_executed_hook()[source]

Always excuted hook method

cthread

(CommandThread) closentry thread

delete_device()[source]

Device destructor

dev_state()[source]

dev_state method

Returns:

State Code

Return type:

tango.DevState

dev_status()[source]

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

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

init_device()[source]

Device initialization

is_CanFail_allowed(_)[source]

CanFail attribute State Machine

Returns:

True if the operation allowed

Return type:

bool

is_CanFail_write_allowed()[source]

CanFail attribute Write State Machine

Returns:

True if the operation allowed

Return type:

bool

is_CloseEntryAsynch_allowed()[source]

CloseEntryAsynch command State Machine

Returns:

True if the operation allowed

Return type:

bool

is_CloseEntry_allowed()[source]

CloseEntry command State Machine

Returns:

True if the operation allowed

Return type:

bool

is_CloseFile_allowed()[source]

CloseFile command State Machine

Returns:

True if the operation allowed

Return type:

bool

is_FileName_allowed(_)[source]

FileName attribute State Machine

Returns:

True if the operation allowed

Return type:

bool

is_FileName_write_allowed()[source]

FileName attribute Write State Machine

Returns:

True if the operation allowed

Return type:

bool

is_JSONRecord_allowed(_)[source]

JSONRecord attribute State Machine

Returns:

True if the operation allowed

Return type:

bool

is_OpenEntryAsynch_allowed()[source]

OpenEntryAsynch command State Machine

Returns:

True if the operation allowed

Return type:

bool

is_OpenEntry_allowed()[source]

OpenEntry command State Machine

Returns:

True if the operation allowed

Return type:

bool

is_OpenFile_allowed()[source]

OpenFile command State Machine

Returns:

True if the operation allowed

Return type:

bool

is_RecordAsynch_allowed()[source]

RecordAsynch command State Machine

Returns:

True if the operation allowed

Return type:

bool

is_Record_allowed()[source]

Record command State Machine

Returns:

True if the operation allowed

Return type:

bool

is_SkipAcquisition_allowed(_)[source]

SkipAcquisition attribute State Machine

Returns:

True if the operation allowed

Return type:

bool

is_SkipAcquisition_write_allowed()[source]

SkipAcquisition attribute Write State Machine

Returns:

True if the operation allowed

Return type:

bool

is_StepsPerFile_allowed(_)[source]

StepsPerFile attribute State Machine

Returns:

True if the operation allowed

Return type:

bool

is_StepsPerFile_write_allowed()[source]

StepsPerFile attribute Write State Machine

Returns:

True if the operation allowed

Return type:

bool

is_XMLSettings_allowed(_)[source]

XMLSettings attribute State Machine

Returns:

True if the operation allowed

Return type:

bool

lock

(threading.Lock) thread lock

othread

(CommandThread) openentry thread

read_CanFail(attr)[source]

Read CanFail attribute

Parameters:

attr (tango.Attribute) – attribute object

read_CurrentFileId(attr)[source]

Read CurrentFileId

Parameters:

attr (tango.Attribute) – attribute object

read_Errors(attr)[source]

Read Errors attribute

Parameters:

attr (tango.Attribute) – attribute object

read_FileName(attr)[source]

Read FileName attribute

Parameters:

attr (tango.Attribute) – attribute object

read_JSONRecord(attr)[source]

Read JSONRecord attribute

Parameters:

attr (tango.Attribute) – attribute object

read_SkipAcquisition(attr)[source]

Read SkipAcquisition attribute

Parameters:

attr (tango.Attribute) – attribute object

read_StepsPerFile(attr)[source]

Read StepsPerFile attribute

Parameters:

attr (tango.Attribute) – attribute object

read_XMLSettings(attr)[source]

Read XMLSettings attribute

Parameters:

attr (tango.Attribute) – attribute object

read_attr_hardware(_)[source]

Read Attribute Hardware

rthread

(CommandThread) record thread

set_state(state)[source]

set_state method

Parameters:

state (tango.DevState) – State Code

state_flag

(tango.DevState) state flag

tdw

(nxswriter.TangoDataWriter.TangoDataWriter) Tango Data Writer

write_CanFail(attr)[source]

Write CanFail attribute

Parameters:

attr (tango.Attribute) – attribute object

write_FileName(attr)[source]

Write FileName attribute

Parameters:

attr (tango.Attribute) – attribute object

write_JSONRecord(attr)[source]

Write JSONRecord attribute

Parameters:

attr (tango.Attribute) – attribute object

write_SkipAcquisition(attr)[source]

Write SkipAcquisition attribute

Parameters:

attr (tango.Attribute) – attribute object

write_StepsPerFile(attr)[source]

Write StepsPerFile attribute

Parameters:

attr (tango.Attribute) – attribute object

write_XMLSettings(attr)[source]

Write XMLSettings attribute

Parameters:

attr (tango.Attribute) – attribute object

class nxswriter.NXSWriter.NXSDataWriterClass(name)[source]

Bases: 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)[source]

Bases: ContentHandler

SAX2 parser

constructor

Brief:

It constructs parser and defines the H5 output file

Parameters:
characters(content)[source]

adds the tag content

Parameters:

content (str) – partial content of the tag

close()[source]

closes the elements

Brief:

It goes through all stack elements closing them

elementClass

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

endElement(name)[source]

parses the closing tag

Parameters:

name (str) – tag name

entryAttrs

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

finalPool

(nxswriter.ThreadPool.ThreadPool) thread pool with FINAL elements

initPool

(nxswriter.ThreadPool.ThreadPool) thread pool with INIT elements

raiseUnsupportedTag

(bool) True if raise exception on unsupported tag

startElement(name, attrs)[source]

parses the opening tag

Parameters:
  • name (str) – tag name

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

stepPool

(nxswriter.ThreadPool.ThreadPool) thread pool with STEP elements

transparentTags

(list <str>) transparent tags

triggerPools

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

withAttr

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

withXMLinput

(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)[source]

Bases: DataSource

Python Eval data source

constructor

Brief:

It cleans all member variables

Parameters:
getData()[source]

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)[source]

sets the datasources

Parameters:

pool (nxswriter.DataSourcePool.DataSourcePool) – datasource pool

setDecoders(decoders)[source]

sets the used decoders

Parameters:

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

setJSON(globalJSON, localJSON=None)[source]

sets JSON string

Brief:

It sets the currently used JSON string

Parameters:
setup(xml)[source]

sets the parrameters up from xml

Parameters:

xml (str) – datasource parameters

class nxswriter.PyEvalSource.Variables[source]

Bases: object

Variables for PyEval datasource

nxswriter.StreamSet module

labels to Tango Streams

class nxswriter.StreamSet.StreamSet(streams)[source]

Bases: object

streamset constractor

Parameters:

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

debug(message, std=None)[source]

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=None)[source]

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=None)[source]

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=None)[source]

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

(tango.log4tango.TangoStream) Tango debug log stream

log_error

(tango.log4tango.TangoStream) Tango error log stream

log_fatal

(tango.log4tango.TangoStream) Tango fatal log stream

log_info

(tango.log4tango.TangoStream) Tango info log stream

log_warn

(tango.log4tango.TangoStream) Tango warn log stream

warn(message, std=None)[source]

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)[source]

Bases: object

NeXuS data writer

constructor

Brief:

It initialize the data writer for the H5 output file

Parameters:

server (tango.LatestDeviceImpl) – Tango server

addingLogs

(str) adding logs

property canfail

the global can fail flag

closeEntry()[source]

closes the data entry

Brief:

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

closeFile()[source]

the H5 file closing

Brief:

It closes the H5 file

property currentfileid

the json data string

property defaultCanFail

the global can fail flag

property fileName

the parent nexus path

getFile()[source]

the H5 file handle

Returns:

the H5 file handle

Return type:

nxswriter.FileWriter.FTFile

property jsonrecord

the json data string

maxElementRuntime

(float) maximal element record time in sec

maxRecordRuntime

(float) maximal record time in sec

metadataOutput

(str) metadata output

numberOfThreads

(int) maximal number of threads

openEntry()[source]

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()[source]

the H5 file opening

Brief:

It opens the H5 file

record(jsonstring=None)[source]

runs threads form the STEP pool

Brief:

It runs threads from the STEP pool

Parameters:

jsonstring (str) – local JSON string with data records

skipacquisition

(bool) skip acquisition flag

stepsperfile

(int) steps per file

writer

(str) writer type

property 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[source]

Bases: object

tools for proxy

classmethod isProxyValid(proxy)[source]

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)[source]

sets the Tango proxy up

Parameters:
  • device (str) – tango device

  • streams (StreamSet or tango.LatestDeviceImpl) – 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)[source]

Bases: DataSource

Tango data source

constructor

Brief:

It cleans all member variables

Parameters:
client

(str) client datasource for mixed CLIENT/TANGO mode

device

(str) full device name

fullclient

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

getData()[source]

data provider

Returns:

dictionary with collected data

Return type:

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

group

(TgGroup) datasource tango group

member

(TgMember) Tango device member

setDataSources(pool)[source]

sets the datasources

Parameters:

pool (nxswriter.DataSourcePool.DataSourcePool) – datasource pool

setDecoders(decoders)[source]

sets the used decoders

Parameters:

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

setJSON(globalJSON, localJSON=None)[source]

sets JSON string

Brief:

It sets the currently used JSON string

Parameters:
setup(xml)[source]

sets the parrameters up from xml

Parameters:

xml (str) – datasource parameters

class nxswriter.TangoSource.TgDevice(device, proxy=None, streams=None)[source]

Bases: object

tango device

default constructor

Parameters:
attributes

(list <str>) device attribute names

commands

(list <str>) device command names

device

(str) tango device name

members

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

properties

(list <str>) device property names

proxy

(tango.DeviceProxy) device proxy

setMember(member)[source]

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)[source]

Bases: object

Group of tango devices

default constructor

Parameters:
counter

(int) counter of steps

devices

(dict <str, TgDevice> ) TANGO devices

getData(counter, proxy=None, member=None)[source]

reads data from device proxy

Parameters:
getDevice(device)[source]

provides tango device

Parameters:

device (str) – tango device name

Returns:

TgDevice instance of tango device

Return type:

TgDevice

lock

(threading.Lock) threading lock

class nxswriter.TangoSource.TgMember(name, memberType='attribute', encoding=None, streams=None)[source]

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.LatestDeviceImpl) – tango-like steamset class

encoding

(str) encoding type of Tango DevEncoded variables

getData(proxy)[source]

reads data from device proxy

Parameters:

proxy (tango.DeviceProxy) – device proxy

getValue(decoders=None)[source]

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()[source]

checks if data is set

Returns:

True if data is set

Return type:

str

memberType

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

name

(str) name of data record

reset()[source]

cleans output value

setData(data, cmd=None)[source]

sets tango data

Parameters:

nxswriter.ThreadPool module

Provides a pool with element threads

class nxswriter.ThreadPool.ThreadPool(numberOfThreads=None, streams=None, maxruntime=0)[source]

Bases: object

Pool with threads

constructor

Brief:

It cleans the member variables

Parameters:
  • numberOfThreads (int) – number of threads

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

  • maxruntime (int) – maxruntime

append(elem)[source]

appends the thread element

Parameters:

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

checkErrors()[source]

checks errors from threads

close()[source]

closer

Brief:

It close the threads from the pool

join(timeout=None)[source]

waits for all thread from the pool

Parameters:

timeout (int) – the maximal waiting time

maxRuntime

(float) maximal runtime

numberOfThreads

(int) maximal number of threads

run()[source]

thread runner

Brief:

It runs the threads from the pool

runAndWait()[source]

runner with waiting

Brief:

It runs and waits the threads from the pool

setJSON(globalJSON, localJSON=None)[source]

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[source]

Bases: object

set of converters

classmethod toBool(value)[source]

converts to bool

Parameters:

value (any) – variable to convert

Returns:

result in bool type

Return type:

bool

class nxswriter.Types.NTP[source]

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)[source]

array rank

Brief:

It calculates the rank of the array

Parameters:

array (any) – given array

Returns:

rank

Return type:

int

arrayRankRShape(array)[source]

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)[source]

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)[source]
creates python array from the given array with applied

the given function to it elements

Parameters:
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)[source]

converts to numpy types

Parameters:

dtype (str) – h5 writer type type

Returns:

nupy type

Return type:

str

Module contents

Tango Data Writer

nxswriter.globallock = <unlocked _thread.lock object>

(threading.Lock) global lock

nxswriter.run(argv)[source]

launches the TANGO server

Parameters:

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