Beispiel #1
0
class AccuFloat(Node):
    """ Float Accumulator

    Add to a Float (in datapool) the receive value

    :param inputs: a list containing the value to append and
        the name of the datapool variable

    """

    def __init__(self, inputs, outputs):

        Node.__init__(self, inputs, outputs)
        self.pool = DataPool()

    def __call__(self, inputs):

        varname = inputs[1]
        value = inputs[0]
        if(not varname):
            varname = "AccuFloat_%i" % (id(self))

        # Create datapool variable if necessary
        if(not self.pool.has_key(varname) or
           not isinstance(self.pool[varname], float)):
            self.pool[varname] = 0.

        self.set_caption("float accumulator : %s" % (repr(str(varname))))
        self.pool[varname] += float(value)
        return (self.pool[varname], )