The putData-columns syntax is a very simple interface.
import HasyUtils, Spectra import random def main(): if not HasyUtils.isSardanaMonitorAlive(): print "SardanaMonitor is not alive" return MAX = 4 pos = [float(n)/MAX for n in range( MAX)] d1 = [random.random() for n in range( MAX)] d2 = [random.random() for n in range( MAX)] # (1) hsh = { 'putData': {'title': "Important Data", 'symbols': { 'file_name_': 'whatever.fio', 'scan_dir': '/tmp', 'scan_id': 12345, 'scan_date': HasyUtils.getDateTime(), 'scan_cmd': "ascan exp_dmy01 0 1 10 0.1", }, 'columns': [ { 'name': "d1_mot01", 'data' : pos}, { 'name': "d1_c01", 'data' : d1}, { 'name': "d1_c02", 'data' : d2}, ]}} smNode = "haso107d1" # (2) hsh = HasyUtils.toSardanaMonitor( hsh, node = smNode) HasyUtils.dct_print( hsh) if hsh[ 'result'].upper() != 'DONE': print "error" return # (3) hsh = HasyUtils.toSardanaMonitor( { 'getData': True}) HasyUtils.dct_print( hsh) main() --- this is the output { u'result': u'done', } { u'getData': { u'D1_C01': { u'x': [0.0, 0.25, 0.5, 0.75], u'y': [0.8516174328902415, 0.5237435711014458, 0.16418910734083147, 0.7751803196094615], } u'D1_C02': { u'x': [0.0, 0.25, 0.5, 0.75], u'y': [0.3390435366975523, 0.6307144039317708, 0.4623249560242313, 0.5910223249929806], } u'symbols': { u'file_name_': u'whatever.fio', u'scan_cmd': u'ascan exp_dmy01 0 1 10 0.1', u'scan_date': u'06 Dec 2018 13:53:55', u'scan_dir': u'/tmp', u'scan_id': u'12345', } } u'result': u'done', }
The returned dictionary always contains hsh[ 'result']
. It has the value 'done' for
successful operation. Otherwise it contains an error messages:
Symbols: putData allows you to specify certain symbols containg very basic metadata. The SardanaMonitor creates these symbols automatically when receiving data via a door. This way a common interface is created, allowing every application based of getData to make use of it.
Notice the file_name_
has a trailing underscore to avoid conflict with the
keyword file_name.
The first data column is the common x-axis. All columns have to have the same length.
node
is an optional argument.