Wiki » History » Version 3

N. Köster, 10/08/2015 02:31 PM

1 2 N. Köster
h1. RSB Lazy Converter
2 1 N. Köster
3 1 N. Köster
4 2 N. Köster
h2. *Warning*: Currently, there is only an implementation for Python! If any other developer feels that this is also a useful extension for other languages, please feel free to contribute!
5 1 N. Köster
6 1 N. Köster
7 2 N. Köster
h3. 1. Description
8 2 N. Köster
9 3 N. Köster
This lib allows you to lazily convert any RSB event payload without creating any converter beforehand. This is realised by creating Participants with a modified RSB configuration which only uses SchemaAndByteArrayConverters for all incoming data. Given the schema of the payload converters are then created at runtime and to allow conversion of the current payload to the desired output format. This allow lazy and flexible receiving of data of any kind (as long as the data types are present/installed). Data can be converted to the actual protobuf object, a programming language pendant object or be kept in binary format.
10 2 N. Köster
11 2 N. Köster
h3. 2. Dependencies
12 2 N. Köster
13 1 N. Köster
h4. Python
14 1 N. Köster
15 1 N. Köster
This lib requires rsb-python>=0.12, rstconverters>=0.12, protobuf_to_dict in order to work.
16 1 N. Köster
17 2 N. Köster
h3. 3. Examples
18 1 N. Köster
19 2 N. Köster
h4. Python
20 2 N. Köster
21 2 N. Köster
Please have a look at the "examples folder":https://code.cor-lab.de/projects/rsb-lazy-converter/repository/revisions/master/show/examples or follow this minimal example:
22 2 N. Köster
23 2 N. Köster
<pre>
24 2 N. Köster
$ ipython
25 2 N. Köster
26 2 N. Köster
In [1]: import rsb_lazy_converter, pprint
27 2 N. Köster
28 2 N. Köster
In [2]: a_listener, incomming_data_queue = rsb_lazy_converter.createLazyListener_queued("/")
29 2 N. Köster
30 2 N. Köster
In [3]: while True:
31 2 N. Köster
   ...:     pprint.pprint(incomming_data_queue.get(True))
32 2 N. Köster
33 2 N. Köster
{'causes': [],
34 2 N. Köster
 'data': {'data': {'id': u'/home/control/motionsensor/testunit_1/',
35 2 N. Köster
                   'label': u'TestUnit_1',
36 2 N. Köster
                   'motion_state': {'value': 200}},
37 2 N. Köster
          'wireschema': '.rst.homeautomation.unit.MotionSensor'},
38 2 N. Köster
 'id': '23c62149-41aa-5c03-a603-5ee8e6eb76ec',
39 2 N. Köster
 'metaData': {'createTime': 1430391438.65,
40 2 N. Köster
              'deliverTime': 1444300372.915713,
41 2 N. Köster
              'receiveTime': 1444300372.915685,
42 2 N. Köster
              'sendTime': 1444300372.914962,
43 2 N. Köster
              'userInfos': {},
44 2 N. Köster
              'userTimes': {}},
45 2 N. Köster
 'method': None,
46 2 N. Köster
 'scope': '/home/control/motionsensor/testunit_1/status/',
47 2 N. Köster
 'type': 'tuple'}
48 3 N. Köster
[...]
49 1 N. Köster
</pre>
50 3 N. Köster
51 3 N. Köster
There are further functions to also create 
52 3 N. Köster
53 3 N. Köster
* lazy listeners (with and without [createLazyListener/createLazyListener_queued] a queue doing automatic conversion) and 
54 3 N. Köster
* lazy informers [createLazyInformer]. 
55 3 N. Köster
56 3 N. Köster
See "code documentation":hhttps://code.cor-lab.de/projects/rsb-lazy-converter/repository/revisions/master/entry/rsb_lazy_converter/__init__.py for details.
57 2 N. Köster
58 2 N. Köster
h3. 4. Versioning
59 2 N. Köster
60 1 N. Köster
Versioning is kept similar to the RSB versioning to make the dependency clear.
61 1 N. Köster
62 1 N. Köster
63 2 N. Köster
h3. 5. Toolkit Project
64 1 N. Köster
65 1 N. Köster
There is a project file in the "Toolkit":https://toolkit.cit-ec.uni-bielefeld.de/ available "here":https://opensource.cit-ec.de/projects/citk/repository/revisions/master/entry/projects/rsb-lazy-converter-python.project. Alternatively you can just add this entry to your distribution file:
66 1 N. Köster
67 1 N. Köster
<pre>
68 1 N. Köster
[ "rsb-lazy-converter-python", "0.12" ]
69 1 N. Köster
</pre>