{ "info": { "author": "Andrew Ramsay", "author_email": "andrew.ramsay@glasgow.ac.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5" ], "description": "# pytia\n\npytia is a basic Python implementation of a TOBI interface A (TiA) server. TiA is a data transmission protocol developed as part of the [TOBI project](http://www.tobi-project.org). It is designed to allow a server acquiring data from multiple sensors to stream that data efficiently to one or more clients over TCP or UDP. For more information see [here](http://tools4bci.sourceforge.net/tia.html) and [here](http://tools4bci.sourceforge.net/signalserver.html).\n\n# Basic example\n\nThe bulk of the code in pytia implements a TiA server, but it also contains a \nusable client class for testing or basic streaming. A minimal example of a TiA\nclient/server setup would look like this:\n\n## Server\n\nCreate a server listening on a local port:\n```python\nfrom pytia import TiAServer, TiAConnectionHandler, TiASignalConfig\nserver = TiAServer(('', 9000), TiAConnectionHandler)\n```\nBefore starting the server, you must define at least 1 \"signal\", a source of data\nthat the server can poll and stream to clients. Signals are defined using a \nlist of TiASignalConfig objects:\n```python\ndef sig_callback(id):\n return [random.uniform(-10, 10) for x in range(3)]\n# create a 50Hz, 3 channel signal with 1 sample per channel per packet.\n# \"signal_callback\" is a callable the server will call to retrieve data for\n# this signal. You shouldn't do long-running work in it! \nserver.start([TiASignalConfig(channels=3, sample_rate=50, blocksize=1, callback=sig_callback, id=0, is_master=True, sigtype=TIA_SIG_USER_1)])\n```\n\n## Client\n\nNow the server is running, a client can connect to it as follows:\n```python\nfrom pytia import TiAClient\n\nserver_address = '127.0.0.1'\nclient = TiAClient(server_address, 9000)\nif not client.connect():\n # handle error\n\n# TiA clients should start by checking the server protocol version matches their own...\nif not client.cmd_check_protocol_version():\n client.disconnect()\n # handle error\n\n# to begin streaming data, a client should request a data connection from the\n# server. The server will send back a port number and the client then connects\n# to that port to obtain the connection. \nstatus, dport = client.cmd_get_data_connection_tcp()\nif not status:\n client.disconnect()\n # handle error\n\nif not client.start_streaming_data_tcp(server_address, dport):\n client.disconnect()\n # handle error\n\n# now we can retrieve the data being streamed from the server\n# the get_data method returns a list of packets. The number of packets can \n# vary from call to call depending on when you call it and the number of\n# signals the server is sending. \npackets = client.get_data()\n\n# each packet is an instance of TiAPacket. It contains:\n# - packet.signals (a list of the data for each signal in the packet)\n# - packet.blocksizes (a list of the block sizes for each signal)\n# - packet.channels (a list of the number of channels in each signal)\n# - packet.packet_number (sequence number)\n# - packet.timestamp (timestamp set on transmission)\n# - packet.packet_id (currently set to the same as sequence number)\n\n# example of extracting some data from a packet\nif len(packets) > 0:\n packet = packets[0]\n\n print('Packet contains %d signals' % (len(packet.signals)))\n print('Number/timestamp/ID: ', packet.packet_number, packet.timestamp, packet.packet_id)\n print('Channel counts: ', packet.channels)\n\n # access some data by channel\n data = packet.get_channel(0, 1) # channel 1 from signal 0 \n print('Signal 0/channel 1 = ', data)\n\n # or just get all the data from a selected signal\n data = packet.get_channel(0)\n print('Signal 0 = ', data)\n\n\n# disconnect from the server when done streaming\nclient.stop_streaming_data()\nclient.disconnect()\n```", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/andrewramsay/pytia", "keywords": "tobi tia acquisition signals", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pytia", "package_url": "https://pypi.org/project/pytia/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pytia/", "project_urls": { "Homepage": "https://github.com/andrewramsay/pytia" }, "release_url": "https://pypi.org/project/pytia/0.1.0/", "requires_dist": null, "requires_python": "", "summary": "TOBI interface A server and client", "version": "0.1.0" }, "last_serial": 2198091, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "3eb3a9d155eb6d0e8cbb01afad37ad62", "sha256": "c64a0520c3bf0656c6c83f9461d596856658b5afcb09d01ee4502ee847d8a2e2" }, "downloads": -1, "filename": "pytia-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3eb3a9d155eb6d0e8cbb01afad37ad62", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13513, "upload_time": "2016-07-01T14:56:55", "url": "https://files.pythonhosted.org/packages/03/80/3547f7cad1c0808c4861002d9e3c56a45bfa51e075181fe648cfec45c5e3/pytia-0.1.0-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3eb3a9d155eb6d0e8cbb01afad37ad62", "sha256": "c64a0520c3bf0656c6c83f9461d596856658b5afcb09d01ee4502ee847d8a2e2" }, "downloads": -1, "filename": "pytia-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3eb3a9d155eb6d0e8cbb01afad37ad62", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13513, "upload_time": "2016-07-01T14:56:55", "url": "https://files.pythonhosted.org/packages/03/80/3547f7cad1c0808c4861002d9e3c56a45bfa51e075181fe648cfec45c5e3/pytia-0.1.0-py2.py3-none-any.whl" } ] }