view Nodes/sine.py @ 289:3b73f0a58a54

Move general use gyro function get_sub to Submaster, make global Submasters object - gyro's error subs now look like normal subs since they might reload and turn into good subs. - Also, add Submaster.fullsub which helps you make subs from channel names.
author David McClosky <dmcc@bigasterisk.com>
date Sat, 18 Jun 2005 01:45:05 +0000
parents 45b12307c695
children
line wrap: on
line source

"""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')