Changeset - 3d28b1a54a29
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 6 years ago 2019-06-09 21:56:03
drewp@bigasterisk.com
2 files changed with 26 insertions and 17 deletions:
0 comments (0 inline, 0 general)
bin/collector
Show inline comments
 
@@ -65,13 +65,16 @@ class Attrs(PrettyErrorHandler, cyclone.
 

	
 
def launch(graph, doLoadTest=False):
 
    try:
 
        # todo: drive outputs with config files
 
        rate = 30
 
        outputs = [
 
            ArtnetDmx(L9['output/dmxA/'], host='127.0.0.1', port=6445, rate=rate),
 
            ArtnetDmx(L9['output/dmxA/'],
 
                      host='127.0.0.1',
 
                      port=6445,
 
                      rate=rate),
 
            #DummyOutput(L9['output/dmxA/']),
 
        ]
 
    except Exception:
 
        log.error("setting up outputs:")
 
        traceback.print_exc()
 
        raise
bin/patchserver
Show inline comments
 
@@ -24,47 +24,53 @@ from greplin.scales.cyclonehandler impor
 
from light9.effect.settings import DeviceSettings
 
from rdfdb.patch import Patch
 

	
 
stats = scales.collection('/webServer', scales.PmfStat('setAttr',
 
                                                       recalcPeriod=1))
 

	
 

	
 
def launch(graph):
 
    if 0:
 
        reactor.listenTCP(networking.captureDevice.port,
 
                          cyclone.web.Application(handlers=[
 
                              (r'/()', cyclone.web.StaticFileHandler, {
 
                                  "path": "light9/web",
 
                                  "default_filename": "patchServer.html"
 
                              }),
 
                              (r'/stats/(.*)', StatsHandler, {
 
                                  'serverName': 'patchServer'
 
                              }),
 
                          ]),
 
                          interface='::',
 
                          )
 
        reactor.listenTCP(
 
            networking.captureDevice.port,
 
            cyclone.web.Application(handlers=[
 
                (r'/()', cyclone.web.StaticFileHandler, {
 
                    "path": "light9/web",
 
                    "default_filename": "patchServer.html"
 
                }),
 
                (r'/stats/(.*)', StatsHandler, {
 
                    'serverName': 'patchServer'
 
                }),
 
            ]),
 
            interface='::',
 
        )
 
        log.info('serving http on %s', networking.captureDevice.port)
 

	
 
    def prn():
 
        width = {}
 
        for dc in graph.subjects(RDF.type, L9['DeviceClass']):
 
            for attr in graph.objects(dc, L9['attr']):
 
                width[dc] = max(width.get(dc, 0), graph.value(attr, L9['dmxOffset']).toPython() + 1)
 
        
 
        user = {} # chan: [dev]
 
                width[dc] = max(
 
                    width.get(dc, 0),
 
                    graph.value(attr, L9['dmxOffset']).toPython() + 1)
 

	
 
        user = {}  # chan: [dev]
 
        for dev in set(graph.subjects(L9['dmxBase'], None)):
 
            dc = graph.value(dev, RDF.type)
 
            base = graph.value(dev, L9['dmxBase']).toPython()
 
            for offset in range(0, width[dc]):
 
                chan = base + offset
 
                user.setdefault(chan, []).append(dev)
 

	
 
        for chan in range(1, max(user) + 1):
 
            dev = user.get(chan, None)
 
            print(f'chan {chan} used by {dev}')
 

	
 
    graph.addHandler(prn)
 
    
 

	
 

	
 
def main():
 
    parser = optparse.OptionParser()
 
    parser.add_option("-v",
 
                      "--verbose",
 
                      action="store_true",
 
                      help="logging.DEBUG")
0 comments (0 inline, 0 general)