Add initial support for DMX lighting
This commit is contained in:
42
gig.py
42
gig.py
@@ -10,12 +10,16 @@ from pyglet.window import key
|
||||
|
||||
import factory
|
||||
import display
|
||||
import dmx
|
||||
|
||||
import yaml
|
||||
import time
|
||||
|
||||
import dbus
|
||||
|
||||
from ola.ClientWrapper import ClientWrapper
|
||||
from ola.DMXConstants import (DMX_MIN_SLOT_VALUE, DMX_MAX_SLOT_VALUE, DMX_UNIVERSE_SIZE)
|
||||
|
||||
class EventRunner:
|
||||
def __init__(self, gigconfig):
|
||||
self._gigconfig = gigconfig
|
||||
@@ -31,6 +35,9 @@ class EventRunner:
|
||||
for item in self._gigconfig['items']:
|
||||
self._gigconfig['items'][item].set_audiencecontent(audiencecontent)
|
||||
|
||||
def get_config(self, section):
|
||||
return self._gigconfig[section]
|
||||
|
||||
def select(self, pos):
|
||||
self._selected = pos
|
||||
self._playing = None
|
||||
@@ -335,14 +342,22 @@ class AudienceWindow(pyglet.window.Window):
|
||||
self.audiencebatch.draw()
|
||||
|
||||
def process_config(config):
|
||||
items = factory.MakeItems(config['items'])
|
||||
setlist = factory.MakeSet(config['set'], items)
|
||||
preshow = factory.MakeSet(config['preshow'], items)
|
||||
if 'defaults' in config:
|
||||
defaults = config['defaults']
|
||||
else:
|
||||
defaults = {}
|
||||
return {'items' : items, 'setlist' : setlist, 'preshow' : preshow}
|
||||
items = factory.MakeItems(config.get('items'))
|
||||
setlist = factory.MakeSet(config.get('set'), items)
|
||||
defaults = config.get('defaults')
|
||||
fixture_types = factory.MakeFixtureTypes(config.get('fixture_types'))
|
||||
fixtures = factory.MakeFixtures(config.get('fixtures'), fixture_types)
|
||||
groups = factory.MakeGroups(config.get('groups'), fixtures)
|
||||
scenes = factory.MakeScenes(config.get('scenes'), fixtures, groups)
|
||||
return {
|
||||
'items' : items,
|
||||
'setlist' : setlist,
|
||||
'defaults' : defaults,
|
||||
'fixture_types' : fixture_types,
|
||||
'fixtures' : fixtures,
|
||||
'groups' : groups,
|
||||
'scenes' : scenes,
|
||||
}
|
||||
|
||||
def load_config(filename):
|
||||
with open(filename, encoding='utf8') as file:
|
||||
@@ -360,6 +375,7 @@ def main():
|
||||
parser = argparse.ArgumentParser(prog='gig.py', description='Gig showrunning')
|
||||
parser.add_argument('filename')
|
||||
parser.add_argument('-w', '--window', action='store_true', help='Run in a window')
|
||||
parser.add_argument('-u', '--universe', default=0, type=int, help='DMX universe')
|
||||
args = parser.parse_args()
|
||||
config = load_config(args.filename)
|
||||
display = pyglet.display.get_display()
|
||||
@@ -376,6 +392,16 @@ def main():
|
||||
|
||||
audiencecontent = AudienceContent(gigconfig=config, eventrunner=eventrunner)
|
||||
|
||||
# try:
|
||||
wrapper = ClientWrapper()
|
||||
DMX_DATA_SIZE = DMX_UNIVERSE_SIZE
|
||||
dmx_object = dmx.DMX(args.universe, wrapper, DMX_DATA_SIZE)
|
||||
# except Exception:
|
||||
# pass
|
||||
|
||||
fixtureoutput = dmx.FixtureOutput(fixtures=[config['fixtures'][x] for x in config['fixtures']], dmx=dmx_object)
|
||||
pyglet.clock.schedule_interval(fixtureoutput.tick, 1/30.0)
|
||||
|
||||
if audiencescreen is not None:
|
||||
window2 = AudienceWindow(audiencecontent=audiencecontent, fullscreen=False, screen=audiencescreen, resizable=True)
|
||||
if not args.window:
|
||||
|
||||
Reference in New Issue
Block a user