Changeset - a92b6d1ac072
[Not reviewed]
default
0 2 1
David McClosky - 20 years ago 2005-06-15 04:28:16
dmcc@bigasterisk.com
SubClient created, keyboardcomposer and gyrocontroller use it now
Plus some minor cleanups in keyboardcomposer and gyrocontroller
3 files changed with 30 insertions and 28 deletions:
0 comments (0 inline, 0 general)
bin/gyrocontroller
Show inline comments
 
#!/usr/bin/env python
 
# vi: syntax=python
 

	
 
from __future__ import division
 
import run_local
 
from light9.Submaster import combine_subdict
 
from light9 import dmxclient, showconfig
 
from light9.subclient import SubClient
 

	
 
class circcycle:
 
    """Like itertools.cycle, but with a prev() method too.  You lose
 
@@ -27,7 +26,7 @@ class circcycle:
 
        self._change_index(-1)
 
        return ret
 

	
 
class AbstractSimpleController:
 
class AbstractSimpleController(SubClient):
 
    """Simple controller with minimal input and output:
 
    
 
    Input is 4 directions and 3 buttons.
 
@@ -38,6 +37,7 @@ class AbstractSimpleController:
 
    B3: toggle keep/solo mode
 
    Double-B3: clear kept levels"""
 
    def __init__(self, subnames):
 
        SubClient.__init__(self)
 
        self.subnames = subnames
 
        self.refresh()
 
    def refresh(self):
 
@@ -60,20 +60,15 @@ class AbstractSimpleController:
 
            self.kept_levels[self.current_sub] = self.current_level
 

	
 
        self.current_sub = self.submasters.get_sub_by_name(self.all_subs.prev())
 

	
 
    def get_levels_as_sub(self):
 
        if self.keep_solo_mode == 'keep':
 
            # send all levels in self.kept_levels
 
            levels = combine_subdict(self.kept_levels)
 
            levelsub = combine_subdict(self.kept_levels)
 
        else:
 
            levels = {self.current_sub : self.current_level}
 
            levelsub = self.current_sub * self.current_level
 

	
 
        return levels
 
    def get_dmx_list(self):
 
        maxes = self.get_levels_as_sub()
 
        return maxes.get_dmx_list()
 
    def send_levels(self):
 
        levels = self.get_dmx_list()
 
        dmxclient.outputlevels(levels)
 
        return levelsub
 

	
 
if __name__ == "__main__":
 
    if 0:
bin/keyboardcomposer
Show inline comments
 
@@ -6,7 +6,7 @@ import sys, time
 
from twisted.internet import reactor,tksupport
 
from twisted.web import xmlrpc, server
 
from Tix import *
 
import math, atexit, pickle
 
import pickle
 

	
 
import run_local
 
from light9.Fadable import Fadable
 
@@ -53,11 +53,11 @@ class SubmasterTk(Frame):
 
        levellabel.pack(side=TOP)
 
        self.scale.pack(side=BOTTOM, expand=1, fill=BOTH)
 

	
 
class KeyboardComposer(Frame):
 
    def __init__(self, root, submasters, current_sub_levels=None, dmxdummy=0):
 
class KeyboardComposer(Frame, SubClient):
 
    def __init__(self, root, submasters, current_sub_levels=None):
 
        Frame.__init__(self, root, bg='black')
 
        SubClient.__init__(self)
 
        self.submasters = submasters
 
        self.dmxdummy = dmxdummy
 

	
 
        self.current_sub_levels = {}
 
        if current_sub_levels:
 
@@ -226,17 +226,6 @@ class KeyboardComposer(Frame):
 
            self.send_levels()
 
            self.after(10, self.send_frequent_updates)
 

	
 
    def get_dmx_list(self):
 
        maxes = self.get_levels_as_sub()
 
        return maxes.get_dmx_list()
 
    def send_levels(self):
 
        if not self.dmxdummy:
 
            levels = self.get_dmx_list()
 
            dmxclient.outputlevels(levels)
 
        # print "sending levels", levels
 
    def send_levels_loop(self):
 
        self.send_levels()
 
        self.after(1000, self.send_levels_loop)
 
    def refresh(self):
 
        self.save()
 
        self.submasters = Submasters()
 
@@ -267,7 +256,7 @@ if __name__ == "__main__":
 

	
 
    root = Tk()
 
    tl = toplevelat("Keyboard Composer", existingtoplevel=root)
 
    kc = KeyboardComposer(tl, s, dmxdummy=0)
 
    kc = KeyboardComposer(tl, s)
 
    kc.pack(fill=BOTH, expand=1)
 

	
 
    ls = LevelServer(kc.name_to_subtk)
light9/subclient.py
Show inline comments
 
new file 100644
 
from light9 import dmxclient
 

	
 
# later, this stuff will talk to a SubServer
 
class SubClient:
 
    def get_levels_as_sub(self):
 
        """Subclasses must implement this method and return a Submaster
 
        object."""
 
    def get_dmx_list(self):
 
        maxes = self.get_levels_as_sub()
 
        return maxes.get_dmx_list()
 
    def send_levels(self):
 
        levels = self.get_dmx_list()
 
        dmxclient.outputlevels(levels)
 
    def send_levels_loop(self, delay=1000):
 
        """This function assumes that we are an instance of a Tk object
 
        (or at least that we have an 'after' method)"""
 
        self.send_levels()
 
        self.after(delay, self.send_levels_loop, delay)
0 comments (0 inline, 0 general)