diff --git a/attic/DataTypes/NextTime.py b/attic/DataTypes/NextTime.py deleted file mode 100644 --- a/attic/DataTypes/NextTime.py +++ /dev/null @@ -1,8 +0,0 @@ -'''Baby, there won't be no next time''' - -class NextTime: - def __init__(self, nextclock, interval=None) - self.nextclock = nextclock - self.interval = interval - def cylic(self): - return interval is not None diff --git a/attic/DataTypes/dmx.py b/attic/DataTypes/dmx.py deleted file mode 100644 --- a/attic/DataTypes/dmx.py +++ /dev/null @@ -1,31 +0,0 @@ - -class DMX(list): - """the signal that goes on a real-life dmx wire. it's up to 512 - un-named channels each with a 8-bit value on each channel. this type - is useful for a DMXOut node or DMXLevelDisplay node. the channels are - stored in a python list where the first channel is at index 0. the - first channel in dmx terminology would be called channel 1.""" - - def __init__(self,dmxlevels): - if len(dmxlevels)>512: - raise TypeError("DMX objects can't have more than 512 channels") - list.extend(dmxlevels) # list.__init__ did't work right - - def append(self,level): - if len(self)==512: - raise TypeError("DMX objects can't have more than 512 channels") - list.append(self,level) - - def extend(self,levels): - if len(self)+len(levels)>512: - raise TypeError("DMX objects can't have more than 512 channels") - list.extend(self,levels) - - def __setslice__(self,i,j,seq): - newlength = len(self)-(max(0,j)-max(0,i))+len(seq) - # we could check if newlength>512, but any length-changing slice is - # probably wrong for this datatype - if newlength!=len(self): - raise NotImplementedError("Different-length setslice would disturb DMX channels") - list.__setslice__(self,i,j,seq) - diff --git a/attic/DataTypes/dmxlevel.py b/attic/DataTypes/dmxlevel.py deleted file mode 100644 --- a/attic/DataTypes/dmxlevel.py +++ /dev/null @@ -1,24 +0,0 @@ -### - -""" -Snippet 0x93.2b: example of outputting a special type - -class DMXLevel(float): - def __init__(self,f): - self.value = min(max(0,f),255) - ... - def __get__(...) # maybe - -output.dmxlevel = DMXLevel(300) - ->>> print output.dmxlevel - 255 - -dmxlevel = DMXLevel(3) -dmxlevel += 800 -d = d + 800 - -There's yer problem: -http://python.org/doc/current/ref/numeric-types.html#l2h-152 - -""" diff --git a/attic/NodeInstance.py b/attic/NodeInstance.py deleted file mode 100644 --- a/attic/NodeInstance.py +++ /dev/null @@ -1,11 +0,0 @@ -'''Internal class for StateManager''' - -# warning: pseduocode -class NodeInstance: - ip_addr? - get_this_nodes_url() - - type = the node type (a subclass of Node) - ops (get from type) - input,output = the ports that are created for the node instance - state = associated state diff --git a/attic/NodeType.py b/attic/NodeType.py deleted file mode 100644 --- a/attic/NodeType.py +++ /dev/null @@ -1,46 +0,0 @@ -"""each node descends from this base class""" - -class NodeType: - def __init__(self): - """TBD""" - self.ops = Ops() - - ''' maybe - self.iports = [] - self.oports = [] - self.params = [] - ''' - def get_state(self, stateaccess): - """This is similar to the pickle.__getstate__ method, except - we need this alternate version in order to give the node - (which holds no state) access to its instance's state. - - If your node keeps some transient items in its state dict - (such as a buffer of recently received inputs), it may want to - return a copy of the state dict without those items. set_state - should restore them properly (if they're missing from the - current state, which they might not be). - - get_state might be called at any time, and it's certainly not - guaranteed that the node instance is going out of service. - get_state might get called to checkpoint the nodes for a - backup, for example. set_state might also get called anytime. - """ - return stateaccess - def set_state(self, stateaccess, dict): - """dict (named after the pickle.__setstate__ argument) is - always a value that was previously returned from - get_state. Don't adjust the current nodetype's state, of course; - use dict to update stateaccess. If there were elements - missing from dict (see the note in get_state for why this - might be the case), you should restore them here as - appropriate. - """ - stateaccess.update(dict) - def get_default_params(self): - '''Returns dictionary of param names and DataType instances. DataTypes - can be given values''' - return {} - def get_default_ports(self): - '''Returns pinless port objects''' - return {} diff --git a/attic/Nodes/delay.py b/attic/Nodes/delay.py deleted file mode 100644 --- a/attic/Nodes/delay.py +++ /dev/null @@ -1,14 +0,0 @@ -"""delay node outputs the input a fixed time later""" - - -class DelayOps(Ops): - def clocked(self, input, output, stateaccess): - stateaccess.buffer - - -class Delay(Node): - def __init__(self): - Node.__init__(self) - - def getnodeparams(self): - return {'delay':State.Time} diff --git a/attic/Nodes/dmxout.py b/attic/Nodes/dmxout.py deleted file mode 100644 --- a/attic/Nodes/dmxout.py +++ /dev/null @@ -1,11 +0,0 @@ - - -class ops(Ops): - def changed(self, input, output, stateaccess): - input.dmx - -class DMXOut(Node): - def get_default_ports(self): - return {'dmx':InputPort(DMX,required=1,maxpins=1)} - def get_default_params(self): - return {'outputrefresh':NextTime,'outputdevice':DMXDevice} diff --git a/attic/Nodes/gamma.py b/attic/Nodes/gamma.py deleted file mode 100644 --- a/attic/Nodes/gamma.py +++ /dev/null @@ -1,32 +0,0 @@ -"""node that performs a simple gamma (exp) function on its input""" - -class GammaOps(Ops): - def started(self, input, output, stateaccess): - self.startmeup(stateaccess) - def changed(self, input, output, stateaccess): - port.output = port.input ** stateaccess.gamma + stateaccess.offset - stateaccess.lastvalue = State.FloatingPoint(port.input) - - output = gamma(input) - # no timed function - def startmeup(self, stateaccess): - # whatever - pass - -class Gamma(Node): - def __init__(self): - Node.__init__(self) - self.node_params = {'gamma':State.FloatingPoint,'offset':State.FloatingPoint} - self.ops = GammaOps() - - def getnodeparams(self): - return self.node_params - - def getports(self): - return (Port('a', optional=1), - Port('b')) - - def __str__(self): - return "3" - -world.register_node(Gamma) diff --git a/attic/Nodes/sine.py b/attic/Nodes/sine.py deleted file mode 100644 --- a/attic/Nodes/sine.py +++ /dev/null @@ -1,21 +0,0 @@ -"""node that generates a sine wave""" - - -class SineGenerator(Node): - def op(self, input, output, stateaccess): - - # input and output have names - output.sin = stateaccess.magnitude * math.sin(stateaccess.phase+input.time) - - """ - # dict-style access for names with spaces - output['sin'] = input['ti me'] - # underscore magic for accessing names with spaces-- the port object makes - # this work - output.sin=input.ti_me - - input.time = input.money - """ - - def getports(self): - return OutputPort('sin'), InputPort('time'), InputPort('money') diff --git a/attic/Op.py b/attic/Op.py deleted file mode 100644 --- a/attic/Op.py +++ /dev/null @@ -1,32 +0,0 @@ -"""each node type has an Op within it""" - -class Op: - """nodes can have several versions of their operation function. - - ops don't return anything! - """ - def __init__(self): - """This should not be overridden without being called.""" - pass - - def inputschanged(self, input, output, stateaccess): - """If you only define one op function body, make it this one. """ - pass - - def created(self, input, output, stateaccess): - """This is called one time when the node is newly created. It's - not called when the node instance is pickled/unpickled. Use this - version to initialize state.""" - # an extra call to changed() should help the outputs get set - # correctly before any real inputs-changed events come around - # (assuming this method doesn't get overridden with a - # specialized version) - self.inputschanged(input, output, stateaccess) - - def statechanged(self, input, output, stateaccess): - '''State might have been changed by a user dragging a parameter or by - a state being hcanged otherwise.''' - self.inputschanged(input, output, stateaccess) - - def clocked(self, input, output, stateaccess): - self.inputschanged(input, output, stateaccess) diff --git a/attic/Port.py b/attic/Port.py deleted file mode 100644 --- a/attic/Port.py +++ /dev/null @@ -1,77 +0,0 @@ -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 -''' diff --git a/attic/README b/attic/README deleted file mode 100644 --- a/attic/README +++ /dev/null @@ -1,2 +0,0 @@ -This is old code from various years, attempting to brainstorm models. -Many of the ideas in them are very outdated. diff --git a/attic/StateManager.py b/attic/StateManager.py deleted file mode 100644 --- a/attic/StateManager.py +++ /dev/null @@ -1,41 +0,0 @@ -''' Database of NodeInstances, part of the Core ''' - -# this will be hard to write until NodeInstances are written, but I'll try -# anyway - -__version__ = "$Id: StateManager.py,v 1.1 2002/07/04 00:21:35 drewp Exp $" - -class StateManager: - '''StateManager is the second of the core to be built. It should be - after the network, then the scheduler. - - After StateManager is constructed, you probably want to do load_state(). - All of the above is taken care of by the Core module. - - Also, in general, 'name' indicates the name of a node, in NRL - (like URL) syntax: - node:group/innergroup/node - - or - - node:node - - if node is in the top level group (the root, or universe, or whatever - you want to call it - ''' - def __init__(self, network): - '''Sets up some dicts, maybe''' - # need some storage locations, etc. - self.network = network - def save_state(self): - '''Save state to disk''' - pass - def load_state(self): - '''Load state from disk''' - pass - def get_input_names(self, name): - '''Get the names of the nodes which are inputs to a node''' - pass - def get_output_names(self, name): - '''Get the names of the nodes which are outputs to a node''' - pass