from CBDMultipleOutput.Source.CBD import *

class CircleCBDDerivative(CBD):
    def __init__(self, blockName, delta_t):
        CBD.__init__(self,blockName, [], [])
        self.delta=delta_t;
        self.addBlock(ConstantBlock(block_name="one", value=1.0))
        self.addBlock(ConstantBlock(block_name="zero", value=0.0))
        self.addBlock(ConstantBlock(block_name="delta", value=self.delta))
        self.addBlock(NegatorBlock(block_name="neg"))
        self.addBlock(DerivatorBlock(block_name="derxv"))
        self.addBlock(DerivatorBlock(block_name="derva"))
        
        self.addConnection("delta", "derxv",  input_port_name="delta_t")
        self.addConnection("delta", "derva",  input_port_name="delta_t")
        self.addConnection("zero", "derva",  input_port_name="IC")
        self.addConnection("one", "derxv",  input_port_name="IC")
        self.addConnection("derva", "neg")
        self.addConnection("neg", "derxv")
        self.addConnection("derxv", "derva")
        
