diff options
Diffstat (limited to 'LightInstallation.py')
-rw-r--r-- | LightInstallation.py | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/LightInstallation.py b/LightInstallation.py index e6e5a26..5882806 100644 --- a/LightInstallation.py +++ b/LightInstallation.py @@ -1,15 +1,18 @@ from xml.etree.ElementTree import ElementTree from pixelcore.Screen import * from pixelcore.PixelStrip import * -import pdb, sys, time, Util, thread +import pdb, sys, time, thread from pygame.locals import * import util.TimeOps as clock import util.Config as configGetter import util.ComponentRegistry as compReg +from logger import main_log #Python class to instantiate and drive a Screen through different patterns, #and effects. class LightInstallation: def __init__(self, configFileName): + main_log.critical("hi russell, i'm sending info to the log files") + main_log.critical("initializing based on file: " + str(configFileName)) self.timer = clock.Stopwatch() self.timer.start() self.inputs = {} #dict of inputs and their bound behaviors, keyed by InputId @@ -20,11 +23,8 @@ class LightInstallation: self.componentDict = {} self.inputBehaviorRegistry = {} #inputid -> behaviors listening to that #input - #give Util a pointer to our componentRegistry and screen so that everyone can use - #it - #Util.setComponentDict(self.componentDict) self.screen = Screen() - #Util.setScreen(self.screen) + compReg.initRegistry() compReg.registerComponent(self.screen, 'Screen') #TODO: move to constants file config = configGetter.loadConfigFile(configFileName) #read configs from xml @@ -33,25 +33,33 @@ class LightInstallation: inputConfig = config.find('InputConfiguration') behaviorConfig = config.find('BehaviorConfiguration') mapperConfig = config.find('PixelMapperConfiguration') + + installationConfig = config.find('InstallationConfiguration') #inits self.initializeScreen(pixelConfig) self.initializeRenderers(rendererConfig) self.initializeInputs(inputConfig) self.initializeBehaviors(behaviorConfig) self.initializeMapper(mapperConfig) - - self.screen.setMapper(self.mapper) #registration in dict self.registerComponents(self.renderers) self.registerComponents(self.inputs) self.registerComponents(self.behaviors) + self.registerComponents(self.mappers) + self.configureInstallation(installationConfig) #Done initializing. Lets start this thing! self.timer.stop() print 'Initialization done. Time: ', self.timer.elapsed(), 'ms' self.mainLoop() + def configureInstallation(self, installationConfig): + defaults = configGetter.generateArgDict(installationConfig.find('Defaults')) + for defaultSelection in defaults: + componentToMap = compReg.getComponent(defaults[defaultSelection]) + compReg.registerComponent(compReg.getComponent(defaults[defaultSelection]),\ + 'Default'+defaultSelection) + def initializeMapper(self, mapperConfig): - self.mapper = self.initializeComponent(mapperConfig)[0] #TODO: support - #multiple mappers + self.mappers = self.initializeComponent(mapperConfig) def initializeScreen(self, layoutConfig): pixelAssemblers = self.initializeComponent(layoutConfig) [self.addPixelStrip(l) for l in pixelAssemblers] @@ -72,7 +80,6 @@ class LightInstallation: cid = component['Id'] if cid == None: raise Exception('Components must have Ids!') - #self.componentDict[cid] = component compReg.registerComponent(component) def initializeComponent(self, config): components = [] @@ -125,9 +132,6 @@ class LightInstallation: self.behaviors = self.initializeComponent(behaviorConfig) for behavior in self.behaviors: self.addBehavior(behavior) - #TODO: we probably don't need this anymore :( - def topologicalBehaviorSort(self): - return Util.topologicalSort(self.behaviorDependencies) #Does work needed to add a behavior: currently -- maps behavior inputs into #the input behavior registry. def addBehavior(self, behavior): @@ -141,7 +145,8 @@ class LightInstallation: try: [compReg.getComponent(b).addInput(responseDict) for b in boundBehaviorIds] except: - print 'Behaviors not initialized yet. WAIT!' + pass + #print 'Behaviors not initialized yet. WAIT!' def main(argv): print argv if len(argv) == 1: |