nxsblisswriter package

Submodules

nxsblisswriter.NXSFile module

Provides the access to a database with NDTS configuration files

class nxsblisswriter.NXSFile.NXSFile(scan, fpath, streams, default_nexus_path='/scan{serialno}:NXentry/instrument:NXinstrument/collection', max_write_interval=1)[source]

Bases: object

constructor

Parameters:
  • scan (blissdata.redis_engine.scan.Scan) – blissdata scan

  • fpath (pathlib.Path) – nexus file path

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

  • default_nexus_path (str) – default nexus path

  • max_write_interval (int) – max write interval

property channels
close()[source]

close file

create_field(grp, name, dtype, value=None, shape=None, chunk=None)[source]

create field

Parameters:
  • n (str) – group name

  • type_code (str) – nexus field type

  • shape (list < int >) – shape

  • chunk (list < int >) – chunk

  • dfilter (H5CppDataFilter) – filter deflater

Returns:

file tree field

Return type:

H5CppField

create_file_structure()[source]

create nexus structure

create_groupfield(root, lnxpath, dtype, value=None, shape=None, chunk=None)[source]

create field

Parameters:
  • root (nxgroup) – root object

  • lnxpath (list <str>) – nexus path list

  • dtype (str) – nexus field type

  • value (any) – field value

  • shape (list < int >) – shape

  • chunk (list < int >) – chunk

Returns:

nexus field

Return type:

nxfield

property labels
prepareChannels()[source]

prepare cursors

write_attr(am, name, dtype, value, item=None)[source]

write attribute

write_final_snapshot()[source]

write final data

write_init_snapshot()[source]

write init data

write_scan_points()[source]

write step data

write_snapshot_item(root, item, default_nexus_path=None)[source]

write snapshot item

nxsblisswriter.NXSFile.create_nexus_file(scan, streams, default_nexus_path='/scan{serialno}:NXentry/instrument:NXinstrument/collection')[source]

open nexus file

Parameters:
  • scan (blissdata.redis_engine.scan.Scan) – blissdata scan

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

  • default_nexus_path (str) – default nexus path

Returns:

nexus file object

Return type:

NXSFile

nxsblisswriter.NXSFile.first(array)[source]

get first element if the only

Parameters:

array (any) – numpy array

Returns:

first element of the array

nxsblisswriter.Release module

release version module

nxsblisswriter.NXSBlissWriter module

NeXus Bliss Writer

NeXus Bliss Writer stores (meta)data from blissdata provided by NXSDataWriter

class nxsblisswriter.NXSBlissWriter.NXSBlissWriter(cl, name)[source]

Bases: Device

NeXus Bliss Writer stores (meta)data from blissdata provided by NXSDataWriter

Properties:

  • Device Property
    RedisUrl
    • Dlissdata redis url

    • Type:’str’

    Session
    • session to be recorder

    • Type:’str’

    NextScanTimeout
    • timeout for next scan writing

    • Type:’int’

    DefaultNeXusPath
    • default NeXus path

    • Type:’str’

    PointSleepTime
    • sleep time between write_point command calls

    • Type:’float’

DefaultNeXusPath

default NeXus path

NextScanTimeout

timeout for next scan writing

PointSleepTime

sleep time between write_point command calls

RedisUrl

Blissdata redis url

Session

session to be recorder

Start()[source]

‘Start’ TANGO command

Parameters:

arg (DevVoid) – (not documented)

Returns:

(not documented)

Return type:

DevVoid

Stop()[source]

‘Stop’ TANGO command

Parameters:

arg (DevVoid) – (not documented)

Returns:

(not documented)

Return type:

DevVoid

TangoClassClass

alias of NXSBlissWriterClass

TangoClassName = 'NXSBlissWriter'
delete_device()[source]

Destructs the attributes and properties of the NXSBlissWriter.

dev_status(self) str[source]

Get device status.

Default method to get device status. It returns the contents of the device dev_status field. If the device state is ALARM, alarm messages are added to the device status. This method can be redefined in sub-classes in case of the default behaviour does not fullfill the needs.

Returns:

the device status

Return type:

str

Raises:

DevFailed – If it is necessary to read attribute(s) and a problem occurs during the reading

init_device()[source]

Initializes the attributes and properties of the NXSBlissWriter.

nxsblisswriter.NXSWriterService module

Provides the access to a database with NDTS configuration files

class nxsblisswriter.NXSWriterService.NXSWriterService(redis_url, session, next_scan_timeout, default_nexus_path='/scan{serialno}:NXentry/instrument:NXinstrument/collection', point_sleep_time=0.01, server=None)[source]

Bases: object

constructor

Parameters:
  • redis_url (str) – blissdata redis url

  • session (str) – blissdata session name

  • next_scan_timeout (int) – timeout between the scans in seconds

  • default_nexus_path (str) – default nexus path

  • point_sleep_time (float) – sleep time between write point calls

  • server (tango.LatestDeviceImpl) – NXSConfigServer instance

get_status()[source]

get writer service status

start()[source]

start writer service

stop()[source]

stop writer service

write_scan(scan)[source]

write scan data

Parameters:

scan – blissdata scan

nxsblisswriter.NXSWriterService.main()[source]

main function

Module contents

Implementation of NexDaTaS Configuration Server

nxsblisswriter.run(classes, args=None, msg_stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, verbose=False, util=None, event_loop=None, pre_init_callback=None, post_init_callback=None, green_mode=None, raises=False, err_stream=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)[source]

Provides a simple way to run a tango server. It handles exceptions by writting a message to the msg_stream.

Examples:

Example 1: registering and running a PowerSupply inheriting from Device:

from tango.server import Device, run

class PowerSupply(Device):
    pass

run((PowerSupply,))

Example 2: registering and running a MyServer defined by tango classes MyServerClass and MyServer:

from tango import Device_4Impl, DeviceClass
from tango.server import run

class MyServer(Device_4Impl):
    pass

class MyServerClass(DeviceClass):
    pass

run({'MyServer': (MyServerClass, MyServer)})

Example 3: registering and running a MyServer defined by tango classes MyServerClass and MyServer:

from tango import Device_4Impl, DeviceClass
from tango.server import Device, run

class PowerSupply(Device):
    pass

class MyServer(Device_4Impl):
    pass

class MyServerClass(DeviceClass):
    pass

run([PowerSupply, [MyServerClass, MyServer]])
# or: run({'MyServer': (MyServerClass, MyServer)})

Note

the order of registration of tango classes defines the order tango uses to initialize the corresponding devices. if using a dictionary as argument for classes be aware that the order of registration becomes arbitrary. If you need a predefined order use a sequence or an OrderedDict.

Parameters:
  • classes (Sequence[tango.server.Device] | dict) –

    Defines for which Tango Device Classes the server will run. If dict is provided, it’s key is the tango class name and value is either:

    two element sequence: DeviceClass, DeviceImpl
    three element sequence: DeviceClass, DeviceImpl, tango class name str

  • args (list) – list of command line arguments [default: None, meaning use sys.argv]

  • msg_stream – stream where to put messages [default: sys.stdout]

  • util (Util) – PyTango Util object [default: None meaning create a Util instance]

  • event_loop (callable) – event_loop callable

  • pre_init_callback (callable or tuple) – an optional callback that is executed between the calls Util.init and Util.server_init The optional pre_init_callback can be a callable (without arguments) or a tuple where the first element is the callable, the second is a list of arguments (optional) and the third is a dictionary of keyword arguments (also optional).

  • post_init_callback (callable or tuple) – an optional callback that is executed between the calls Util.server_init and Util.server_run The optional post_init_callback can be a callable (without arguments) or a tuple where the first element is the callable, the second is a list of arguments (optional) and the third is a dictionary of keyword arguments (also optional).

  • raises (bool) – Disable error handling and propagate exceptions from the server

  • err_stream – stream where to put catched exceptions [default: sys.stderr]

Returns:

The Util singleton object

Return type:

Util

New in version 8.1.2.

Changed in version 8.1.4: when classes argument is a sequence, the items can also be a sequence <TangoClass, TangoClassClass>[, tango class name]

Changed in version 9.2.2: raises argument has been added

Changed in version 9.5.0: pre_init_callback argument has been added

Changed in version 10.0.0: err_stream argument has been added