changeset 2:022e35e17182

bunch of renaming; some additions to the files
author drewp
date Thu, 04 Jul 2002 08:21:35 +0000
parents d8a11a5981e2
children 8856efb6516c
files Port.py nodetype.py op.py port.py
diffstat 4 files changed, 1 insertions(+), 134 deletions(-) [+]
line wrap: on
line diff
--- a/Port.py	Wed Jul 03 09:43:24 2002 +0000
+++ b/Port.py	Thu Jul 04 08:21:35 2002 +0000
@@ -15,7 +15,7 @@
         pass
 
 class InputPort(Port):
-    def __init__(self, allowedtype, required=1, maxpins=ANY):
+    def __init__(self, required=1, maxpins=ANY):
         self.pins = []
 
 class OutputPort(Port):
--- a/nodetype.py	Wed Jul 03 09:43:24 2002 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-"""each node descends from this base class"""
-
-class Node:
-    def __init__(self):
-        """TBD"""
-        self.ops = Ops()
-        ''' there should be default ports, just to give people a template:
-        self.iports = [InputPort("default")]
-        self.oports = [OutputPort("default")]
-
-        # no params
-        self.params = []
-
-        # initialize state with created op?  no way
-        # here's why: 1. we would need to pass stateaccess into this function
-        # and they would be allowed to initialize their state here
-        # 2. scheduler/statemanager will call created when it's good and ready,
-        # ok?  no need to push it!
-        # unless... we should put real init code in NodeType or Node(Instance)
-        # inits.  that might be better than having a whole op for it.
-        
-        '''
-    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 node'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)
-
-# 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
-
-    
--- a/op.py	Wed Jul 03 09:43:24 2002 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +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 parameterschanged(self, input, output, stateaccess):
-        self.inputschanged(input, output, stateaccess)        
-
-    def clocked(self, input, output, stateaccess):
-        self.inputschanged(input, output, stateaccess)        
--- a/port.py	Wed Jul 03 09:43:24 2002 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-
-'''
-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}
-
-