Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for OLA? #36

Open
gorenje opened this issue Aug 3, 2020 · 4 comments
Open

Support for OLA? #36

gorenje opened this issue Aug 3, 2020 · 4 comments
Labels
⚙️ Controllers Related to the controllers module 🆕 Enhancement New feature or request help wanted Extra attention is needed

Comments

@gorenje
Copy link

gorenje commented Aug 3, 2020

Hi,

There isn't support for the Open Lighting Architecture if I see that right? I was wondering whether it would make sense
to have a controller that interfaces with OLA via their Python APIs?

I'm new to DMX and OLA but I've got a setup working with OLA and a BitWizard usb dongle (http://www.bitwizard.nl/shop/raspberry-pi?product_id=154). What I'm looking for is a QLCplus-like web interface for
managing my lights.

So I'm kinda wondering if this is the right project for me!

Cheers!

@MattIPv4
Copy link
Owner

MattIPv4 commented Aug 4, 2020

Hey!

You are correct, this currently doesn't have support for OLA. If you're familiar with OLA it'd be great to have someone implement a controller for it, similar to how the uDMX controller is implemeneted! :)

@gorenje
Copy link
Author

gorenje commented Aug 4, 2020

Ok, then I'll have a look and see what I can do!

I was looking at their API (https://www.openlighting.org/ola/developer-documentation/python-api/) and it seems that, roughly speaking, the controller would do something like:

### import and initalise OLA
from array import array
from ola.ClientWrapper import ClientWrapper

def DmxSent(state):
    wrapper.Stop()

### ... in the controller ...

def _send_data(self):
      # Get the data
      data = self.get_frame()

      # Attempt to send data max 5 times, then 2 more with reconnect to device
      # Thanks to Dave Hocker (pyudmx author) for giving me this solution to the random usb errors
      success = False
      retry_count = 0
      while not success:
          try:
              wrapper = ClientWrapper()
              client = wrapper.Client()
              client.SendDmx(4, array('B', data), DmxSent)
              success = True
          except Exception as e:
              retry_count += 1
              if retry_count > 7:
                  raise e

But I don't know what data consists of. OLA assumes an arrray with one entry per channel ... I assume that's the same here.

@MattIPv4
Copy link
Owner

MattIPv4 commented Aug 4, 2020

That looks roughly correct -- You'll probably want to persist the wrapper/client in the controller rather than creating them each time & off the top of my head (haven't touched this in-depth for a while), yeah, data should be a list containing values for the entire universe.

@gorenje
Copy link
Author

gorenje commented Aug 4, 2020

Had a play around and got some working code together --> gorenje@eb551e7

As you said, I persisted the wrapper and client but I also prevented the controller from bombarding the OLA daemon since OLA remembers it's state. To keep things simple, I removed the error handling and retry, don't know what the consequence
of doing that is.

This basically "works for me"(TM) - running OLA and PyDMXControl on a Raspberry Pi 3+.

@MattIPv4 MattIPv4 added help wanted Extra attention is needed ⚙️ Controllers Related to the controllers module 🆕 Enhancement New feature or request labels Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙️ Controllers Related to the controllers module 🆕 Enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants