Exemplo n.º 1
0
class TF(inter.SignalDevice):
    def __init__(self, nodes, equation=None, **parameters):
        inter.SignalDevice.__init__(self, nodes, **parameters)

        self.equation = equation
        if not self.equation:
            self.equation = "1 / (s + 1)"

        self.tf = None
        self.tf = TransferFunction(self.equation.lower())

    def connect(self):
        if len(self.nodes) == 2:
            input, output = self.nodes
            self.port2node = {0: self.get_node_index(input),
                              1: self.get_node_index(output)}

    def update(self):
        pass

    def start(self, dt):
        self.tf.reset(dt)

    def step(self, dt, t):
        input = self.get_port_value(0)
        output = self.tf.step(input, dt, t)[0][0]
        self.set_port_value(1, output)

    def post_step(self, dt, t):
        pass
Exemplo n.º 2
0
    def __init__(self, nodes, equation=None, **parameters):
        inter.SignalDevice.__init__(self, nodes, **parameters)

        self.equation = equation
        if not self.equation:
            self.equation = "1 / (s + 1)"

        self.tf = None
        self.tf = TransferFunction(self.equation.lower())