def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) loop = asyncio.get_event_loop() loop.set_debug(True) self.node = ArtNetNode('127.0.0.1') self.node.start() self.univ = self.node.add_universe(0)
async def load(): # Init fixture array & node dict fixtures = [] nodes = {} for dirpath, dirs, files in os.walk("./active/"): for filename in files: # Load config file fname = os.path.join(dirpath, filename) config = configparser.ConfigParser() config.read(fname) # Init fixtureconfig object fixtureconfig = {} # Load values from config to fixtureconfig # Needs to made prettier for key in config['position']: fixtureconfig[key] = float(config['position'][key]) for key in config['channels']: fixtureconfig[key] = int(config['channels'][key]) for key in config['location']: fixtureconfig[key] = float(config['location'][key]) fixtureconfig['start_channel'] = int( config['DMX']['start_channel']) fixtureconfig['universe'] = int(config['DMX']['universe']) fixtureconfig['node_ip'] = config['DMX']['node_ip'] fixtureconfig['prefer_tilt'] = config['misc'].getboolean( 'prefer_tilt') fixtureconfig['default_fade_time'] = int( config['misc']['default_fade_time']) fixtureconfig['invert_tilt'] = config['misc'].getboolean( 'invert_tilt') fixtureconfig['invert_pan'] = config['misc'].getboolean( 'invert_pan') node_ip = fixtureconfig['node_ip'] universe = fixtureconfig['universe'] # Create node, universe and fixture objects if not node_ip in nodes: # Create new node if it doesn't exist nodeobj = ArtNetNode(node_ip, max_fps=44, refresh_every=5) await nodeobj.start() nodes[node_ip] = {'node': nodeobj, 'universes': {}} if not universe in nodes[node_ip]['universes']: # Create new universe if it doesn't exist nodeobj = nodes[node_ip]['node'] universeobj = nodeobj.add_universe(universe) nodes[node_ip]['universes'][universe] = universeobj # Create fixture and init fixture = Fixture(fixtureconfig) fixture.start(nodes[node_ip]['universes'][universe]) fixtures.append(fixture) return (fixtures, nodes)
def __init__(self, universe): self.node = ArtNetNode('127.0.0.1') self.node.start() self.univ = self.node.add_universe(universe) self.channel = self.univ.add_channel(1, 400) async def run_test(): vals = [255] * 400 self.channel.add_fade(vals, 2000) vals = [0] * 400 self.channel.add_fade(vals, 2000)
async def main(): if False: await raw_wave() return node = ArtNetNode(ip) await node.start() universe = node.add_universe(0) channel = universe.add_channel(start=1, width=18) # await test_reset(channel) await test_static(channel) # await raw_wave() # await test_reset(channel) print("done")
def add_universe(self, universe, fixtures, ip, role='slave', log=False): self.universes[universe] = {} self.universes[universe]['cmd_queue'] = asyncio.Queue() self.universes[universe]['role'] = role self.universes[universe]['spike'] = asyncio.Event() self.universes[universe]['spike'].set() self.universes[universe]['rand_spike'] = False self.universes[universe]['log'] = log if role == 'slave': if ip in self.nodes.keys(): node = self.nodes[ip] else: node = ArtNetNode(ip, max_fps=120) node.start() self.universes[universe]['addresses'] = fixtures * 4 self.universes[universe]['univ'] = node.add_universe(universe) self.universes[universe]['channel'] = \ self.universes[universe]['univ'].add_channel(1, self.universes[universe]['addresses'])
async def raw_wave(): node = ArtNetNode(ip, max_fps=1500, refresh_every=0) node.max_fps = 1500 node.sleep_time = 1 / node.max_fps print('max fps:', node.max_fps) print('sleep time:', node.sleep_time) await node.start() universe = node.add_universe(0) channel = universe.add_channel(start=1, width=1 + leds * 3) tick = 0 while True: tick += 1 data = [255] for i in range(leds): i += tick offset = leds // 3 data += [wave(i), wave(i + offset), wave(i + 2 * offset)] #data += [255 if i == tick % leds else 0, 0, 0] channel.add_fade(data, delay) await channel.wait_till_fade_complete()
from pyartnet import ArtNetNode import asyncio node = ArtNetNode('2.0.0.2') # define universe and channels globally universe0 = node.add_universe(0) universe1 = node.add_universe(1) universe2 = node.add_universe(2) universe3 = node.add_universe(3) strip1_a = universe0.add_channel(start=1, width=24) strip1_b = universe0.add_channel(start=25, width=24) strip1_c = universe0.add_channel(start=49, width=24) strip1_d = universe0.add_channel(start=73, width=23) # omdat strip 2 bovenaan begint keer ik expres de namen van de channels om strip2_d = universe0.add_channel(start=97, width=24) strip2_c = universe0.add_channel(start=121, width=24) strip2_b = universe0.add_channel(start=145, width=25) strip2_a = universe1.add_channel(start=1, width=23) # strip 3 begint weer onderaan strip3_a = universe1.add_channel(start=24, width=24) strip3_b = universe1.add_channel(start=48, width=24) strip3_c = universe1.add_channel(start=72, width=24) strip3_d = universe1.add_channel(start=96, width=22) #strip 4 begint bovenaan strip4_d = universe2.add_channel(start=1, width=24) strip4_c = universe2.add_channel(start=25, width=24) strip4_b = universe2.add_channel(start=49, width=24) strip4_a = universe2.add_channel(start=73, width=23) # strip 5 begint weer onderaan strip5_a = universe2.add_channel(start=97, width=24)
class TestConfig(unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) loop = asyncio.get_event_loop() loop.set_debug(True) self.node = ArtNetNode('127.0.0.1') self.node.start() self.univ = self.node.add_universe(0) def tearDown(self): asyncio.get_event_loop().create_task(self.node.stop()) time.sleep(0.2) self.node = None self.univ = None def __run_fades(self): async def run_test(): channel = self.univ.add_channel(1, 3) soll = [0, 255, 0] channel.add_fade(soll, 1000) await channel.wait_till_fade_complete() self.assertListEqual(channel.get_channel_values(), soll) for i in range(3): self.assertEqual(self.univ.data[128 + i], soll[i]) soll = [255, 0, 255] channel.add_fade(soll, 2000) await channel.wait_till_fade_complete() self.assertListEqual(channel.get_channel_values(), soll) for i in range(3): self.assertEqual(self.univ.data[128 + i], soll[i]) soll = [0, 0, 0] channel.add_fade(soll, 2000) await channel.wait_till_fade_complete() self.assertListEqual(channel.get_channel_values(), soll) for i in range(3): self.assertEqual(self.univ.data[128 + i], soll[i]) asyncio.gather(run_test()) def simple_fade(self): async def run_test(): channel = self.univ.add_channel(0, 3) soll = [0, 255, 0] channel.add_fade(soll, 10000) await channel.wait_till_fade_complete() async def run_test2(): channel = self.univ.add_channel(4, 3) soll = [0, 255, 0] channel.add_fade(soll, 10000) await channel.wait_till_fade_complete() async def main(): await asyncio.gather(run_test(), run_test2()) asyncio.get_event_loop().run_until_complete(main()) def test_linear(self): self.__run_fades() def test_quadratic(self): self.univ.output_correction = output_correction.quadratic self.__run_fades() def test_cubic(self): self.univ.output_correction = output_correction.cubic self.__run_fades() def test_quadrouple(self): self.univ.output_correction = output_correction.quadruple self.__run_fades()
from pyartnet import ArtNetNode, output_correction import asyncio import time import subprocess import re #dit stukje is om de dmx nodes aan te geven node0 = ArtNetNode('2.0.0.2') node1= ArtNetNode('2.0.0.2') node2= ArtNetNode('2.0.0.2') node3= ArtNetNode('2.0.0.2') universe0 = node0.add_universe(0) universe1 = node1.add_universe(1) universe2 = node2.add_universe(2) universe3 = node3.add_universe(3) universe0.output_correction = output_correction.cubic universe1.output_correction = output_correction.cubic universe2.output_correction = output_correction.cubic universe3.output_correction = output_correction.cubic #hier zorgen we dat alle leds een naam krijgen en geadreseerd zijn binnen hun eigen universe. #strip a fixturea1 = universe0.add_channel(start=1, width=6) fixturea2 = universe0.add_channel(start=7, width=6) fixturea3 = universe0.add_channel(start=13, width=6) fixturea4 = universe0.add_channel(start=19, width=6) fixturea5 = universe0.add_channel(start=25, width=6) fixturea6 = universe0.add_channel(start=31, width=6)
from pyartnet import ArtNetNode import asyncio import random node = ArtNetNode('2.0.0.2') async def functie(): await node.start() universe = node.add_universe(0) multiverse = node.add_universe(1) # dit zou een range van channels kunnen requesten # channel = universe.get_channel('1/3') one = random.randint(0, 500) two = random.randint(0, 500) three = random.randint(0, 500) four = random.randint(0, 500) channel = universe.add_channel(start=one, width=6) channel1 = universe.add_channel(start=two, width=6) channel2 = universe.add_channel(start=three, width=6) channel3 = universe.add_channel(start=four, width=6) channel4 = multiverse.add_channel(start=four, width=6) channel5 = multiverse.add_channel(start=three, width=6) channel6 = multiverse.add_channel(start=two, width=6) channel7 = multiverse.add_channel(start=one, width=6) ha = random.randint(0, 25) ja = random.randint(0, 25) bla = random.randint(0, 50)
import time from pyartnet import ArtNetNode, DmxChannel, DmxUniverse, output_correction node = ArtNetNode('192.168.11.4') node.start() universe = node.add_universe(0) channel = universe.add_channel(4, 3) channel.add_fade([255, 0, 0], 1000) channel.add_fade([200, 0, 0], 1000) time.sleep(0.5) channel.add_fade([150, 33, 0], 1000) time.sleep(0.5) channel.add_fade([100, 65, 0], 1000) time.sleep(0.5) channel.add_fade([50, 98, 0], 1000) time.sleep(0.5) channel.add_fade([100, 132, 0], 1000) time.sleep(0.5) channel.add_fade([150, 152, 0], 1000) time.sleep(0.5) channel.add_fade([200, 0, 0], 1000) time.sleep(0.5) channel.add_fade([255, 0, 0], 1000)