RSB Lazy Converter¶
0. 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!¶
1. Description¶
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.
5. Installation¶
Toolkit Project¶
There is a project file in the Toolkit available here. Alternatively you can just add this entry to your distribution file:
[ "rsb-lazy-converter-python", "0.12" ]
The boring way¶
$ python setup.py install --prefix=/PATH/TO/YOUR/PREFIX
2. Dependencies¶
Python¶
This lib requires rsb-python>=0.12, rstconverters>=0.12, protobuf_to_dict in order to work.
3. Examples¶
Python¶
Please have a look at the examples folder or follow this minimal example. Copy&Paste the following into iPython:
%cpaste import rsb_lazy_converter, pprint a_listener, incomming_data_queue = rsb_lazy_converter.createLazyListener_queued("/") while True: pprint.pprint(incomming_data_queue.get(True)) --
Expected result will look like this (assuming that there are events...):
{'causes': [], 'data': {'data': {'id': u'/home/control/motionsensor/testunit_1/', 'label': u'TestUnit_1', 'motion_state': {'value': 200}}, 'wireschema': '.rst.homeautomation.unit.MotionSensor'}, 'id': '23c62149-41aa-5c03-a603-5ee8e6eb76ec', 'metaData': {'createTime': 1430391438.65, 'deliverTime': 1444300372.915713, 'receiveTime': 1444300372.915685, 'sendTime': 1444300372.914962, 'userInfos': {}, 'userTimes': {}}, 'method': None, 'scope': '/home/control/motionsensor/testunit_1/status/', 'type': 'tuple'} [...]
There are further functions to also create
- lazy listeners (with and without [createLazyListener/createLazyListener_queued] a queue doing automatic conversion) and
- lazy informers [createLazyInformer].
See code documentation for details.
4. Versioning¶
Versioning is kept similar to the RSB versioning to make the dependency clear.