DmxOscServer


NameDmxOscServer JSON
Version 1.0.5 PyPI version JSON
download
home_pagehttps://dmxoscserver.readthedocs.io/en/latest/
SummaryA Python Lib to create a DMX compatible OSC server with handlers
upload_time2023-08-11 10:34:02
maintainer
docs_urlNone
authorMiniontoby
requires_python>=3.5
license
keywords dmx osc server
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # DMX OSC Server

DMX OSC Server is a python lib to make it easier to create OSC Servers for the DMX Protocol.

It allows you to register fixtures are the wanted universe, starting address and channels.
You will also be able to add an handler which will be called when a message is received for that fixture.


Originally designed for QLC+, but it should work with any program that sends to the `/<universe>/dmx/<addr>` path

It can receive single argument messages, like `/<universe>/dmx/<addr> <value>` (so you can set the channels to 3 and do channel 1 for red, 2 for green and 3 for blue)

It can also receive an array argument, like `/<universe>/dmx/<addr> [<R>, <G>, <B>]`

And it can also receive 3 arguments, like `/<universe>/dmx/<addr> <R> <G> <B>`


## Installation

```bash
pip install DmxOscServer
```

## Get Started

To create a simple DMX OSC Server that will listen on 0.0.0.0:9000 you can use this code:

```py
from DmxOscServer import DmxOscServer

server = DmxOscServer()

# Define a 3 channel Fixture at address 0 at universe 0 which will execute my_rgb_handler when called
@server.define_fixture(0, 0, 3)
def my_rgb_handler(fixture, address, *args):
    print ("{} got {}".format(address, args))

server.run()
```

To make the define more readable, you can use the argument names

```py
# Define a 3 channel Fixture at address 0 at universe 0 which will execute my_rgb_handler when called
@server.define_fixture(universe=0, starting_addr=0, channels=3)
def my_rgb_handler(fixture, address, *args):
    print ("{} has been set to {}".format(address, args))
```


To change the IP and/or port, you can specify that at the `.run()` method

```py
server.run("10.10.123.5", 1234) # Will listen on 10.10.123.5:1234
```


If your addresses receive arrays or multiple args, add the `channel_as_array=True` argument

```py
# Define a 3 channel array based Fixture at address 0 at universe 0 which will execute my_rgb_handler when called
@server.define_fixture(universe=0, starting_addr=0, channels=3, channel_as_array=True)
def my_rgb_handler(fixture, address, *args):
    print ("{} has been set to {}".format(address, args))
```


It is also possible to use the `Fixture` class and the `add_fixture` method

```py
from DmxOscServer import DmxOscServer, Fixture

def my_rgb_handler(fixture, address, *args):
    print ("{} has been set to {}".format(address, args))

server = DmxOscServer()
server.add_fixture(Fixture(0, 0, 3, my_rgb_handler)) # Register a 3 channel not array based Fixture at address 0 at universe 0
server.add_fixture(Fixture(0, 3, 3, my_rgb_handler, True)) # Register a 3 channel array based Fixture at address 0 at universe 0
```


And for the `add_fixture` method, you can also add multiple fixtures at once using:

```py
from DmxOscServer import DmxOscServer, Fixture
server = DmxOscServer()
server.add_fixtures(
    Fixture(0, 0, 3, my_rgb_handler), # Register a 3 channel not array based Fixture at address 0 of universe 0
    Fixture(0, 3, 3, my_rgb_handler, True), # Register a 3 channel array based Fixture at address 3 of universe 0
)
```


You can use the `fixture.values` property to see all the current values

```py
@server.define_fixture(0, 0, 3)
def my_rgb_handler(fixture, address, *args):
    print (fixture.values)
```


# The handler

The handler receives a call when a message is received for that fixture
Arguments: `(fixture, address, *args)`
- `fixture` is the fixture, so you have a reference
- `address` is the message address (it starts at the starting_address, so use `address - fixture.starting_addr` if you want to have the internal address)
- `*args` are the args of the message. It is almost always 1 int going from 0 to 1, so you can just use `args[0]` in your code and multiply it by your max value

The handler should never receive an address out of its address range, if the fixture is called correctly

# More Documentation

More Documentation can be found at https://dmxoscserver.readthedocs.io/en/latest/

            

Raw data

            {
    "_id": null,
    "home_page": "https://dmxoscserver.readthedocs.io/en/latest/",
    "name": "DmxOscServer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "dmx,osc,server",
    "author": "Miniontoby",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/0b/34/5356641d95ed6b7b860e45a9da5611f4b5e0ac823271b5a0e981a722fc5e/DmxOscServer-1.0.5.tar.gz",
    "platform": null,
    "description": "# DMX OSC Server\n\nDMX OSC Server is a python lib to make it easier to create OSC Servers for the DMX Protocol.\n\nIt allows you to register fixtures are the wanted universe, starting address and channels.\nYou will also be able to add an handler which will be called when a message is received for that fixture.\n\n\nOriginally designed for QLC+, but it should work with any program that sends to the `/<universe>/dmx/<addr>` path\n\nIt can receive single argument messages, like `/<universe>/dmx/<addr> <value>` (so you can set the channels to 3 and do channel 1 for red, 2 for green and 3 for blue)\n\nIt can also receive an array argument, like `/<universe>/dmx/<addr> [<R>, <G>, <B>]`\n\nAnd it can also receive 3 arguments, like `/<universe>/dmx/<addr> <R> <G> <B>`\n\n\n## Installation\n\n```bash\npip install DmxOscServer\n```\n\n## Get Started\n\nTo create a simple DMX OSC Server that will listen on 0.0.0.0:9000 you can use this code:\n\n```py\nfrom DmxOscServer import DmxOscServer\n\nserver = DmxOscServer()\n\n# Define a 3 channel Fixture at address 0 at universe 0 which will execute my_rgb_handler when called\n@server.define_fixture(0, 0, 3)\ndef my_rgb_handler(fixture, address, *args):\n    print (\"{} got {}\".format(address, args))\n\nserver.run()\n```\n\nTo make the define more readable, you can use the argument names\n\n```py\n# Define a 3 channel Fixture at address 0 at universe 0 which will execute my_rgb_handler when called\n@server.define_fixture(universe=0, starting_addr=0, channels=3)\ndef my_rgb_handler(fixture, address, *args):\n    print (\"{} has been set to {}\".format(address, args))\n```\n\n\nTo change the IP and/or port, you can specify that at the `.run()` method\n\n```py\nserver.run(\"10.10.123.5\", 1234) # Will listen on 10.10.123.5:1234\n```\n\n\nIf your addresses receive arrays or multiple args, add the `channel_as_array=True` argument\n\n```py\n# Define a 3 channel array based Fixture at address 0 at universe 0 which will execute my_rgb_handler when called\n@server.define_fixture(universe=0, starting_addr=0, channels=3, channel_as_array=True)\ndef my_rgb_handler(fixture, address, *args):\n    print (\"{} has been set to {}\".format(address, args))\n```\n\n\nIt is also possible to use the `Fixture` class and the `add_fixture` method\n\n```py\nfrom DmxOscServer import DmxOscServer, Fixture\n\ndef my_rgb_handler(fixture, address, *args):\n    print (\"{} has been set to {}\".format(address, args))\n\nserver = DmxOscServer()\nserver.add_fixture(Fixture(0, 0, 3, my_rgb_handler)) # Register a 3 channel not array based Fixture at address 0 at universe 0\nserver.add_fixture(Fixture(0, 3, 3, my_rgb_handler, True)) # Register a 3 channel array based Fixture at address 0 at universe 0\n```\n\n\nAnd for the `add_fixture` method, you can also add multiple fixtures at once using:\n\n```py\nfrom DmxOscServer import DmxOscServer, Fixture\nserver = DmxOscServer()\nserver.add_fixtures(\n    Fixture(0, 0, 3, my_rgb_handler), # Register a 3 channel not array based Fixture at address 0 of universe 0\n    Fixture(0, 3, 3, my_rgb_handler, True), # Register a 3 channel array based Fixture at address 3 of universe 0\n)\n```\n\n\nYou can use the `fixture.values` property to see all the current values\n\n```py\n@server.define_fixture(0, 0, 3)\ndef my_rgb_handler(fixture, address, *args):\n    print (fixture.values)\n```\n\n\n# The handler\n\nThe handler receives a call when a message is received for that fixture\nArguments: `(fixture, address, *args)`\n- `fixture` is the fixture, so you have a reference\n- `address` is the message address (it starts at the starting_address, so use `address - fixture.starting_addr` if you want to have the internal address)\n- `*args` are the args of the message. It is almost always 1 int going from 0 to 1, so you can just use `args[0]` in your code and multiply it by your max value\n\nThe handler should never receive an address out of its address range, if the fixture is called correctly\n\n# More Documentation\n\nMore Documentation can be found at https://dmxoscserver.readthedocs.io/en/latest/\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Python Lib to create a DMX compatible OSC server with handlers",
    "version": "1.0.5",
    "project_urls": {
        "Bug Reports": "https://github.com/Miniontoby/DmxOscServer/issues",
        "Homepage": "https://dmxoscserver.readthedocs.io/en/latest/",
        "Source": "https://github.com/Miniontoby/DmxOscServer"
    },
    "split_keywords": [
        "dmx",
        "osc",
        "server"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c09af0b10206d6d44d707576d9932004098b9bc66e2b62b4e7f526e552a5aeb4",
                "md5": "96277fb4600718af03655156da6b10e4",
                "sha256": "e302f480e17ab6bbefbc3df9db69784153f5b182af9a7d41515dd4ac3779a795"
            },
            "downloads": -1,
            "filename": "DmxOscServer-1.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "96277fb4600718af03655156da6b10e4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 5638,
            "upload_time": "2023-08-11T10:33:58",
            "upload_time_iso_8601": "2023-08-11T10:33:58.904379Z",
            "url": "https://files.pythonhosted.org/packages/c0/9a/f0b10206d6d44d707576d9932004098b9bc66e2b62b4e7f526e552a5aeb4/DmxOscServer-1.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b345356641d95ed6b7b860e45a9da5611f4b5e0ac823271b5a0e981a722fc5e",
                "md5": "0fcb1ff52ae65ea0508fa2b04440866a",
                "sha256": "6da7ac3be419719550692b51694a4cc1cc8a951cf18d90b247b4c8b90f27175a"
            },
            "downloads": -1,
            "filename": "DmxOscServer-1.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "0fcb1ff52ae65ea0508fa2b04440866a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 4752,
            "upload_time": "2023-08-11T10:34:02",
            "upload_time_iso_8601": "2023-08-11T10:34:02.025098Z",
            "url": "https://files.pythonhosted.org/packages/0b/34/5356641d95ed6b7b860e45a9da5611f4b5e0ac823271b5a0e981a722fc5e/DmxOscServer-1.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-11 10:34:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Miniontoby",
    "github_project": "DmxOscServer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dmxoscserver"
}
        
Elapsed time: 0.10472s