|
|
@@ -140,8 +140,8 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
self.CBD.addBlock(ConstantBlock(block_name="c2", value=3.0))
|
|
|
self.CBD.addBlock(RootBlock(block_name="g"))
|
|
|
|
|
|
- self.CBD.addConnection("c1", "g")
|
|
|
- self.CBD.addConnection("c2", "g")
|
|
|
+ self.CBD.addConnection("c1", "g", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c2", "g", input_port_name="IN2")
|
|
|
self._run(1)
|
|
|
self.assertEqual(self._getSignal("g"), [2.0])
|
|
|
|
|
|
@@ -150,8 +150,8 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
self.CBD.addBlock(ConstantBlock(block_name="c2", value=2.0))
|
|
|
self.CBD.addBlock(RootBlock(block_name="g"))
|
|
|
|
|
|
- self.CBD.addConnection("c1", "g")
|
|
|
- self.CBD.addConnection("c2", "g")
|
|
|
+ self.CBD.addConnection("c1", "g", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c2", "g", input_port_name="IN2")
|
|
|
self._run(1)
|
|
|
self.assertEqual(self._getSignal("g"), [3.0])
|
|
|
|
|
|
@@ -160,8 +160,8 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
self.CBD.addBlock(ConstantBlock(block_name="c2", value=2.0))
|
|
|
self.CBD.addBlock(RootBlock(block_name="root"))
|
|
|
|
|
|
- self.CBD.addConnection("c2", "root")
|
|
|
- self.CBD.addConnection("c1", "root")
|
|
|
+ self.CBD.addConnection("c2", "root", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c1", "root", input_port_name="IN2")
|
|
|
self.assertRaises(ZeroDivisionError, self._run, NUM_DISCR_TIME_STEPS)
|
|
|
|
|
|
def testPowerBlock(self):
|
|
|
@@ -169,8 +169,8 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
self.CBD.addBlock(ConstantBlock(block_name="c2", value=3.0))
|
|
|
self.CBD.addBlock(PowerBlock(block_name="g"))
|
|
|
|
|
|
- self.CBD.addConnection("c1", "g")
|
|
|
- self.CBD.addConnection("c2", "g")
|
|
|
+ self.CBD.addConnection("c1", "g", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c2", "g", input_port_name="IN2")
|
|
|
self._run(1)
|
|
|
self.assertEqual(self._getSignal("g"), [512.0])
|
|
|
|
|
|
@@ -243,9 +243,9 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
|
|
|
self.CBD.addConnection("time", "sum")
|
|
|
self.CBD.addConnection("c1", "sum")
|
|
|
- self.CBD.addConnection("sum", "clamp")
|
|
|
- self.CBD.addConnection("c2", "clamp")
|
|
|
- self.CBD.addConnection("c3", "clamp")
|
|
|
+ self.CBD.addConnection("sum", "clamp", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c2", "clamp", input_port_name="IN2")
|
|
|
+ self.CBD.addConnection("c3", "clamp", input_port_name="IN3")
|
|
|
self._run(5)
|
|
|
self.assertEqual(self._getSignal("clamp"), [max(min(float(x), 2.0), -1.0) for x in range(-2, 3)])
|
|
|
|
|
|
@@ -258,8 +258,8 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
self.CBD.addBlock(SequenceBlock(block_name="c3", sequence=s))
|
|
|
self.CBD.addBlock(MultiplexerBlock(block_name="mux"))
|
|
|
|
|
|
- self.CBD.addConnection("c1", "mux")
|
|
|
- self.CBD.addConnection("c2", "mux")
|
|
|
+ self.CBD.addConnection("c1", "mux", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c2", "mux", input_port_name="IN2")
|
|
|
self.CBD.addConnection("c3", "mux", input_port_name="select")
|
|
|
self._run(10)
|
|
|
self.assertEqual(self._getSignal("mux"), [0, 99, 98, 3, 4, 5, 94, 93, 92, 9])
|
|
|
@@ -278,8 +278,8 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
self.CBD.addBlock(ConstantBlock(block_name="c2", value=6))
|
|
|
self.CBD.addBlock(LessThanBlock(block_name="lt"))
|
|
|
|
|
|
- self.CBD.addConnection("c1", "lt")
|
|
|
- self.CBD.addConnection("c2", "lt")
|
|
|
+ self.CBD.addConnection("c1", "lt", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c2", "lt", input_port_name="IN2")
|
|
|
self._run(1)
|
|
|
self.assertEqual(self._getSignal("lt"), [1])
|
|
|
|
|
|
@@ -288,8 +288,8 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
self.CBD.addBlock(ConstantBlock(block_name="c2", value=7))
|
|
|
self.CBD.addBlock(LessThanBlock(block_name="lt"))
|
|
|
|
|
|
- self.CBD.addConnection("c1", "lt")
|
|
|
- self.CBD.addConnection("c2", "lt")
|
|
|
+ self.CBD.addConnection("c1", "lt", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c2", "lt", input_port_name="IN2")
|
|
|
self._run(1)
|
|
|
self.assertEqual(self._getSignal("lt"), [0])
|
|
|
|
|
|
@@ -298,8 +298,8 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
self.CBD.addBlock(ConstantBlock(block_name="c2", value=5))
|
|
|
self.CBD.addBlock(LessThanBlock(block_name="lt"))
|
|
|
|
|
|
- self.CBD.addConnection("c1", "lt")
|
|
|
- self.CBD.addConnection("c2", "lt")
|
|
|
+ self.CBD.addConnection("c1", "lt", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c2", "lt", input_port_name="IN2")
|
|
|
self._run(1)
|
|
|
self.assertEqual(self._getSignal("lt"), [0])
|
|
|
|
|
|
@@ -308,8 +308,8 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
self.CBD.addBlock(ConstantBlock(block_name="c2", value=6))
|
|
|
self.CBD.addBlock(LessThanOrEqualsBlock(block_name="leq"))
|
|
|
|
|
|
- self.CBD.addConnection("c1", "leq")
|
|
|
- self.CBD.addConnection("c2", "leq")
|
|
|
+ self.CBD.addConnection("c1", "leq", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c2", "leq", input_port_name="IN2")
|
|
|
self._run(1)
|
|
|
self.assertEqual(self._getSignal("leq"), [1])
|
|
|
|
|
|
@@ -318,8 +318,8 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
self.CBD.addBlock(ConstantBlock(block_name="c2", value=7))
|
|
|
self.CBD.addBlock(LessThanOrEqualsBlock(block_name="leq"))
|
|
|
|
|
|
- self.CBD.addConnection("c1", "leq")
|
|
|
- self.CBD.addConnection("c2", "leq")
|
|
|
+ self.CBD.addConnection("c1", "leq", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c2", "leq", input_port_name="IN2")
|
|
|
self._run(1)
|
|
|
self.assertEqual(self._getSignal("leq"), [0])
|
|
|
|
|
|
@@ -328,8 +328,8 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
self.CBD.addBlock(ConstantBlock(block_name="c2", value=5))
|
|
|
self.CBD.addBlock(LessThanOrEqualsBlock(block_name="leq"))
|
|
|
|
|
|
- self.CBD.addConnection("c1", "leq")
|
|
|
- self.CBD.addConnection("c2", "leq")
|
|
|
+ self.CBD.addConnection("c1", "leq", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c2", "leq", input_port_name="IN2")
|
|
|
self._run(1)
|
|
|
self.assertEqual(self._getSignal("leq"), [1])
|
|
|
|
|
|
@@ -402,8 +402,8 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
self.CBD.addBlock(ConstantBlock(block_name="c2", value=3.0))
|
|
|
self.CBD.addBlock(ModuloBlock(block_name="g"))
|
|
|
|
|
|
- self.CBD.addConnection("c1", "g")
|
|
|
- self.CBD.addConnection("c2", "g")
|
|
|
+ self.CBD.addConnection("c1", "g", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c2", "g", input_port_name="IN2")
|
|
|
self._run(1)
|
|
|
self.assertEqual(self._getSignal("g"), [2.0])
|
|
|
|
|
|
@@ -412,8 +412,8 @@ class StdCBDTestCase(unittest.TestCase):
|
|
|
self.CBD.addBlock(ConstantBlock(block_name="c2", value=8.0))
|
|
|
self.CBD.addBlock(ModuloBlock(block_name="g"))
|
|
|
|
|
|
- self.CBD.addConnection("c1", "g")
|
|
|
- self.CBD.addConnection("c2", "g")
|
|
|
+ self.CBD.addConnection("c1", "g", input_port_name="IN1")
|
|
|
+ self.CBD.addConnection("c2", "g", input_port_name="IN2")
|
|
|
self._run(1)
|
|
|
self.assertEqual(self._getSignal("g"), [0.0])
|
|
|
|