view Port.py @ 167:79bc84310e80

changes from tonight's rehearsal: changes from tonight's rehearsal: - CueFader is closer to actually running the show, computes DMX levels to send. - KeyboardComposer is not a dummy. Use DMXDUMMY=1 to disable it. - Submaster: subs can now be "temporary" -- i.e. they shouldn't be saved or loaded. to save a temporary sub, make a copy of it with a proper name since the computed name will be ugly. Also, get_normalized_copy() and crossfade() methods added. linear_fade helper (shouldn't be in Submaster, probably) added too. - dmxchanedit: longer labels - cuelist1 now has some bogus data in it and some crap removed - dmxclient: now listens to the $DMXHOST and $DMXDUMMY env variables. - patchdata: now up to date with this year's show - danshow subs song{01..19}: removed. maybe we'll re-add them in an archive directory.
author dmcc
date Tue, 08 Jul 2003 16:19:55 +0000
parents 8856efb6516c
children
line wrap: on
line source

from nodetypes import DiscoType

ANY = -1

class Port:
    def __setattr__(self, key, value):
        '''Alias for __setitem___'''
        self[key] = value
    def __setitem__(self, key, value):
        pass
    def __getattr__(self, key):
        '''Alias for __getitem___'''
        return self[key]
    def __getitem__(self, key):
        pass

class InputPort(Port):
    def __init__(self, allowedtype, required=1, maxpins=ANY):
        self.pins = []

class OutputPort(Port):
    def __init__(self):
        self.pins = []

class Pin:
    def __init__(self, connection, value=DiscoType):
        pass

'''
Snippet Pi=3: RFC 2: New port semantics

# an example of the max node's op
def changed(self, inputs):
    # note how this function does not use stateaccess, as it doesn't use state
    return max(inputs.values())

# so, how the heck does this work?
# we check the function to get the names of kw args in the function.
# we always pass self, but everything else is optional
# the node asked for inputs, which looks like this:
# inputs = {'portname' : PortObj, 'portname2', PortObj}
# somehow, the PortObjs are max'ible.
# the node has only one output so it can just return the value to set the 
# output.  (maybe)
# alteratively, if we decide that you always return a new dict of outputs:
# return {'outputportname' : max(inputs.values())}
# which isn't horrible, but not great

# another example: an adder.  the node has ports A and B, and an output C:
# C also gets capped at stateaccess[min].
def changed(self, a, b, c, stateaccess):
    c.set(max(stateaccess['min'], a + b))
    return {}

# or:
def changed(self, a, b, stateaccess):
    c = max(stateaccess['min'], a + b)
    return {'c' : c}

# which i think is clearer.  doing all port changes at the end has some
# book-keeping advantages (we can detect easily which ports are changed)
# the counter node could work this way:

def changed(self, someoutput):
    return {'someoutput' : someoutput + 1}
'''

'''
type 1: a, b, d, e
type 2: b, c, d, f

conversion maps:
a -> [ ]
b -> b
d -> d
e -> f
'''