added setup script
This commit is contained in:
parent
931544572d
commit
2a72572026
|
@ -0,0 +1,35 @@
|
|||
*.py[cod]
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Packages
|
||||
*.egg
|
||||
*.egg-info
|
||||
dist
|
||||
build
|
||||
eggs
|
||||
parts
|
||||
bin
|
||||
var
|
||||
sdist
|
||||
develop-eggs
|
||||
.installed.cfg
|
||||
lib
|
||||
lib64
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
.coverage
|
||||
.tox
|
||||
nosetests.xml
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
||||
# Mr Developer
|
||||
.mr.developer.cfg
|
||||
.project
|
||||
.pydevproject
|
|
@ -21,21 +21,6 @@ except ImportError as e:
|
|||
from chaosc.osc_lib import *
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(prog='psychose_actor')
|
||||
parser.add_argument("-H", '--chaosc_host', required=True,
|
||||
type=str, help='host of chaosc instance to control')
|
||||
parser.add_argument("-p", '--chaosc_port', required=True,
|
||||
type=int, help='port of chaosc instance to control')
|
||||
|
||||
|
||||
args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
connections = list()
|
||||
osc_sock = socket.socket(2, 2, 17)
|
||||
osc_sock.connect((args.chaosc_host, args.chaosc_port))
|
||||
|
||||
|
||||
|
||||
class Forwarder(object):
|
||||
def __init__(self, actor, platform, device):
|
||||
self.actor = actor
|
||||
|
@ -102,50 +87,66 @@ class Pulse2OSC(Forwarder):
|
|||
osc_sock.sendall(osc_message.encode_osc())
|
||||
|
||||
|
||||
naming = {
|
||||
"/dev/ttyUSB0" : ["merle", "ehealth"],
|
||||
"/dev/ttyUSB1" : ["merle", "ekg"],
|
||||
"/dev/ttyUSB2" : ["merle", "pulse"],
|
||||
"/dev/ttyUSB3" : ["bjoern", "ehealth"],
|
||||
"/dev/ttyUSB4" : ["bjoern", "ekg"],
|
||||
"/dev/ttyUSB5" : ["bjoern", "pulse"],
|
||||
"/dev/ttyUSB6" : ["uwe", "ehealth"],
|
||||
"/dev/ttyUSB7" : ["uwe", "ekg"],
|
||||
"/dev/ttyUSB8" : ["uwe", "pulse"]
|
||||
}
|
||||
|
||||
naming = {
|
||||
"/tmp/tty2" : ["merle", "ehealth"],
|
||||
"/tmp/tty4" : ["merle", "pulse"]
|
||||
}
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(prog='psychose_actor')
|
||||
parser.add_argument("-H", '--chaosc_host', required=True,
|
||||
type=str, help='host of chaosc instance to control')
|
||||
parser.add_argument("-p", '--chaosc_port', required=True,
|
||||
type=int, help='port of chaosc instance to control')
|
||||
|
||||
used_devices = dict()
|
||||
|
||||
while 1:
|
||||
for device, description in naming.iteritems():
|
||||
if os.path.exists(device):
|
||||
if device not in used_devices:
|
||||
actor, platform = naming[device]
|
||||
if description[1] == "ehealth":
|
||||
used_devices[device] = EHealth2OSC(actor, platform, device)
|
||||
elif description[1] == "ekg":
|
||||
used_devices[device] = EKG2OSC(actor, platform, device)
|
||||
elif description[1] == "pulse":
|
||||
used_devices[device] = Pulse2OSC(actor, platform, device)
|
||||
else:
|
||||
raise ValueError("unknown description %r for device %r" % (description, device))
|
||||
else:
|
||||
print "device missing", device
|
||||
m = OSCMessage("/DeviceMissing")
|
||||
m.appendTypedArg(description[0], "s")
|
||||
m.appendTypedArg(description[1], "s")
|
||||
osc_sock.sendall(m.encode_osc())
|
||||
args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
read_map = {}
|
||||
for forwarder in used_devices.values():
|
||||
read_map[forwarder.serial] = forwarder.handleRead
|
||||
connections = list()
|
||||
osc_sock = socket.socket(2, 2, 17)
|
||||
osc_sock.connect((args.chaosc_host, args.chaosc_port))
|
||||
|
||||
readers, writers, errors = select.select(read_map, [], [], 0.1)
|
||||
print "readers", readers
|
||||
for reader in readers:
|
||||
read_map[reader](osc_sock)
|
||||
|
||||
naming = {
|
||||
"/dev/ttyUSB0" : ["merle", "ehealth"],
|
||||
"/dev/ttyUSB1" : ["merle", "ekg"],
|
||||
"/dev/ttyUSB2" : ["merle", "pulse"],
|
||||
"/dev/ttyUSB3" : ["bjoern", "ehealth"],
|
||||
"/dev/ttyUSB4" : ["bjoern", "ekg"],
|
||||
"/dev/ttyUSB5" : ["bjoern", "pulse"],
|
||||
"/dev/ttyUSB6" : ["uwe", "ehealth"],
|
||||
"/dev/ttyUSB7" : ["uwe", "ekg"],
|
||||
"/dev/ttyUSB8" : ["uwe", "pulse"]
|
||||
}
|
||||
|
||||
naming = {
|
||||
"/tmp/tty2" : ["merle", "ehealth"],
|
||||
"/tmp/tty4" : ["merle", "pulse"]
|
||||
}
|
||||
|
||||
used_devices = dict()
|
||||
|
||||
while 1:
|
||||
for device, description in naming.iteritems():
|
||||
if os.path.exists(device):
|
||||
if device not in used_devices:
|
||||
actor, platform = naming[device]
|
||||
if description[1] == "ehealth":
|
||||
used_devices[device] = EHealth2OSC(actor, platform, device)
|
||||
elif description[1] == "ekg":
|
||||
used_devices[device] = EKG2OSC(actor, platform, device)
|
||||
elif description[1] == "pulse":
|
||||
used_devices[device] = Pulse2OSC(actor, platform, device)
|
||||
else:
|
||||
raise ValueError("unknown description %r for device %r" % (description, device))
|
||||
else:
|
||||
print "device missing", device
|
||||
m = OSCMessage("/DeviceMissing")
|
||||
m.appendTypedArg(description[0], "s")
|
||||
m.appendTypedArg(description[1], "s")
|
||||
osc_sock.sendall(m.encode_osc())
|
||||
|
||||
read_map = {}
|
||||
for forwarder in used_devices.values():
|
||||
read_map[forwarder.serial] = forwarder.handleRead
|
||||
|
||||
readers, writers, errors = select.select(read_map, [], [], 0.1)
|
||||
print "readers", readers
|
||||
for reader in readers:
|
||||
read_map[reader](osc_sock)
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from distribute_setup import use_setuptools
|
||||
use_setuptools()
|
||||
|
||||
from scripts.version import get_git_version
|
||||
import sys
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
extras['use_2to3'] = True
|
||||
|
||||
setup(
|
||||
name='sensors2osc',
|
||||
version="0.1",
|
||||
packages=find_packages(exclude=["scripts",]),
|
||||
|
||||
include_package_data = True,
|
||||
|
||||
package_data = {
|
||||
"chaosc" : ["config/*",]},
|
||||
|
||||
exclude_package_data = {'': ['.gitignore']},
|
||||
|
||||
install_requires=[
|
||||
"pyserial",],
|
||||
|
||||
# installing unzipped
|
||||
zip_safe = False,
|
||||
|
||||
# predefined extension points, e.g. for plugins
|
||||
entry_points = """
|
||||
[console_scripts]
|
||||
sensors2osc = sensors2osc.main:main
|
||||
""",
|
||||
# pypi metadata
|
||||
author = "Stefan Kögl",
|
||||
|
||||
# FIXME: add author email
|
||||
author_email = "",
|
||||
description = "osc filtering application level gateway",
|
||||
|
||||
# FIXME: add long_description
|
||||
long_description = """
|
||||
""",
|
||||
|
||||
# FIXME: add license
|
||||
license = "LGPL",
|
||||
|
||||
# FIXME: add keywords
|
||||
keywords = "",
|
||||
|
||||
# FIXME: add download url
|
||||
url = "",
|
||||
test_suite='tests'
|
||||
)
|
Loading…
Reference in New Issue