Пример #1
0
        def recursive_update(d1, d2):
            for k, v in d2.items():
                if isinstance(v, collections.abc.Mapping):
                    d1[k] = recursive_update(d1.get(k, {}), v)
                else:
                    d1[k] = v

                # Perform checks for things that need to be recalculated
                if k in [
                        'global_color_temp', 'global_color_r',
                        'global_color_g', 'global_color_b', 'color_temp'
                ]:
                    self._flag_correction = True
                elif k == 'global_brightness':
                    d1[k] = min(d1[k], self._global_brightness_limit)
                elif k == 'scale':
                    self._flag_mapping = True
                elif k == 'function':
                    if v not in self._functions:  # for uncompiled functions
                        self._functions[v] = animfunctions.blank
                    self._check_reset_animation_state()
                elif k in ['range_start', 'range_end']:
                    self._flag_clear = True  # clear LEDs to make range selection less ambiguous
                elif k == 'sacn' and self._enable_sacn:
                    if v:
                        self._receiver = sacn.sACNreceiver()
                        self._receiver.listen_on('universe', universe=1)(
                            self._sacn_callback)
                        self._receiver.start()
                    elif hasattr(self, '_receiver'):
                        self._receiver.stop()

            return d1
Пример #2
0
def run_monitor():
    """Start application"""
    app_monitor = Application()
    receiver = sacn.sACNreceiver()
    receiver.start()
    for univ in UNIVERSES:
        receiver.join_multicast(univ)
        receiver.register_listener("universe", callback, universe=univ)
    app_monitor.run(sys.argv)
    receiver.stop()
Пример #3
0
def startsACN(universeModel, pixelModel, maxUniverses, consoleEnableChannel,
              unicastIP, priority):
    global receiver, sender, running, consoleEnableCh, unicastdest
    consoleEnableCh = consoleEnableChannel
    unicastdest = unicastIP
    receiver = sacn.sACNreceiver()
    sender = sacn.sACNsender()

    receiver.start()
    sender.start()
    createUniverses(universeModel, maxUniverses, priority)
    createMap(pixelModel)
    running = True
Пример #4
0
    def __init__(self, bindAddr, pixelBlazeAddr):
        self.pixels = [0
                       for x in range(512)]  # max size of a dmx universe tuple

        self.pb = Pixelblaze(pixelBlazeAddr)  # create Pixelblaze object
        result = self.pb.getHardwareConfig()
        self.pixelCount = result['pixelCount']

        # bind multicast receiver to specific IP address
        self.receiver = sacn.sACNreceiver(bind_address=bindAddr)
        self.receiver.start()  # start receiver thread

        # define callback functions for the universes we're interested in
        # for this test, we arbitrarily allow 170 pixels per universe, and
        # listen to universes 1-4 for a total of 680 possible pixels.
        # Note that although the e1.31 protocol provides reliable transport,
        # due to throughput constraints, some frames may be dropped and will
        # not be sent to the Pixelblaze.  The goal is that the overall
        # visualization be reasonably smooth, accurate and timely.

        @self.receiver.listen_on('universe', universe=1)
        def callback_one(packet):  # packet is type sacn.DataPacket.
            self.pack_data(packet.dmxData, 0)
            self.dataReady = True

        @self.receiver.listen_on('universe', universe=2)
        def callback_two(packet):
            self.pack_data(packet.dmxData, self.pixelsPerUniverse)
            self.dataReady = True

        @self.receiver.listen_on('universe', universe=3)
        def callback_three(packet):
            self.pack_data(packet.dmxData, self.pixelsPerUniverse * 2)
            self.dataReady = True

        @self.receiver.listen_on('universe', universe=4)
        def callback_four(packet):
            self.pack_data(packet.dmxData, self.pixelsPerUniverse * 3)
            self.dataReady = True
Пример #5
0
import sacn
import time
import colorsys
import threading

print("Running e1.31 Lifx reciever")
# provide an IP-Address to bind to if you are using Windows and want to use multicast
receiver = sacn.sACNreceiver()
receiver.start()  # start the receiving thread

# define a callback function
@receiver.listen_on('universe', universe=1)  # listens on universe 1
def callback(packet):  # packet type: sacn.DataPacket
	print("Recieved DMX data: ==========================")
	print(len(packet.dmxData))  # print the received DMX data
	print(packet.sequence)

# optional: if you want to use multicast use this function with the universe as parameter
receiver.join_multicast(1)

#time.sleep(10)  # receive for 10 seconds
event = threading.Event()
try:
    print('Press Ctrl+C to exit')
    event.wait()
except KeyboardInterrupt:
    print('got Ctrl+C')

receiver.stop()
Пример #6
0
def get_receiver():
    socket = ReceiverSocketTest()
    receiver = sacn.sACNreceiver(socket=socket)
    # wire up for unit test
    receiver._handler.socket._listener = receiver._handler
    return receiver, socket
Пример #7
0
    start = first_channel + idx * channels_per_light
    end = start + channels_per_light
    return start, end


lights.sort(key=lambda l: l.get_label())
for i, l in enumerate(lights):
    startChannel, endChannel = dmx_channels(i)
    print(
        f"{l.label} is assigned to DMX channels {startChannel + 1} to {endChannel}"
    )

print("Running e1.31 Lifx reciever")
# provide an IP-Address to bind to if you are using Windows and want to use multicast
if len(sys.argv) > 1:
    receiver = sacn.sACNreceiver(sys.argv[1])
else:
    receiver = sacn.sACNreceiver()
receiver.start()  # start the receiving thread


# define a callback function
@receiver.listen_on('universe', universe=UNIVERSE)  # listens on universe 1
def callback(packet):  # packet type: sacn.DataPacket
    print(
        "Recieved DMX data: ==> ",
        packet.dmxData[(first_channel):(first_channel +
                                        numb_lights * channels_per_light)])
    for idx, light in enumerate(lights):
        # color is [Hue, Saturation, Brightness, Kelvin], duration in ms
        start, end = dmx_channels(idx)
Пример #8
0
def main():
   # load the device config
   config = configparser.ConfigParser()
   config.read('../config/config.ini')

   status = {}
   if len(sys.argv) > 1:
      cmd = sys.argv[1]
      mydmx = pysimpledmx.DMXConnection('/dev/ttyUSB0')

      if cmd == 'off':
         mydmx.setChannel(11, 0)
         mydmx.setChannel(12, 0)
         mydmx.setChannel(13, 0)
         mydmx.setChannel(14, 0)
         mydmx.setChannel(15, 0)
         mydmx.setChannel(16, 0)
         mydmx.setChannel(17, 0)

         mydmx.setChannel(21, 0)
         mydmx.setChannel(22, 0)
         mydmx.setChannel(23, 0)
         mydmx.setChannel(24, 0)
         mydmx.setChannel(25, 0)
         mydmx.setChannel(26, 0)
         mydmx.setChannel(27, 0)

      elif cmd == 'test':
         mydmx.setChannel(11, 255)
         mydmx.setChannel(12, 0)
         mydmx.setChannel(13, 0)
         mydmx.setChannel(14, 0)
         mydmx.setChannel(15, 255)
         mydmx.setChannel(16, 180)
         mydmx.setChannel(17, 90)

         mydmx.setChannel(21, 255)
         mydmx.setChannel(22, 0)
         mydmx.setChannel(23, 0)
         mydmx.setChannel(24, 0)
         mydmx.setChannel(25, 255)
         mydmx.setChannel(26, 180)
         mydmx.setChannel(27, 90)

      mydmx.render() # render all of the above changes onto the DMX network

   else:
      try:
         # initialization
         mydmx = DMXController()
         par1 = mydmx.addPar(10)
         par2 = mydmx.addPar(20)
         mydmx.render()
         # set white as preset to turn 'ON' works as expected
         mydmx.sceneColor('white')
         mydmx.off()

         client = mymqtt.mymqtt(config, mydmx)
         client.loop_start()

         receiver = sacn.sACNreceiver()
         receiver.start()  # start the receiving thread

         # define a callback function
         @receiver.listen_on('universe', universe=1)  # listens on universe 1
         def callback(packet):  # packet type: sacn.DataPacket
            r,g,b = packet.dmxData[0:3]
            mydmx.renderRGB(r,g,b)

         @receiver.listen_on('availability') # what is the status?
         def e131_avail(universe, changed): # universe number and changed state
            if (changed == 'timeout'):
               mydmx.on()

         # Wait forever for msgs

      except:
         mydmx.off()

   return