Exemplo n.º 1
0
    def test_sorted_query_regression(self):
        # Attempt to
        p = Project()

        l = Layer("t1", (1, 1, 1))

        p.stackup.add_layer(l)

        cx = Point2(30000, 30000)
        ts = []
        for i in range(100):
            r = 5000 - 40 * i
            r1 = 5000 - 40 * (i + 1)

            t = math.radians(30 * i)
            t1 = math.radians(30 * (i + 1))

            v = Point2(math.cos(t) * r, math.sin(t) * r)
            v1 = Point2(math.cos(t1) * r1, math.sin(t1) * r1)

            t1 = Trace(v + cx, v1 + cx, 100, l)
            t1.STUFFED_ID = i
            p.artwork.merge_artwork(t1)
            ts.append(t1)

        t0 = ts[0]
        for n, a in enumerate(ts[1:], start=1):
            self.assertEqual(t0.net, a.net, "mismatch on %d" % n)

        self.assertIsNotNone(t0.net)

        p.save('/tmp/wtf.pcbre', False)
Exemplo n.º 2
0
    def test_sorted_query_regression(self):
        # Attempt to
        p = Project()

        l = Layer("t1", (1,1,1))

        p.stackup.add_layer(l)

        cx = Point2(30000, 30000)
        ts = []
        for i in range(100):
            r = 5000 - 40 * i
            r1 = 5000 - 40 * (i+1)

            t = math.radians(30 * i)
            t1 = math.radians(30 * (i+1))

            v = Point2(math.cos(t) * r, math.sin(t) * r)
            v1 = Point2(math.cos(t1) * r1, math.sin(t1) * r1)

            t1 = Trace(v + cx, v1 + cx, 100, l)
            t1.STUFFED_ID = i
            p.artwork.merge_artwork(t1)
            ts.append(t1)

        t0 = ts[0]
        for n, a in enumerate(ts[1:], start=1):
            self.assertEqual(t0.net, a.net, "mismatch on %d" % n)

        self.assertIsNotNone(t0.net)

        p.save('/tmp/wtf.pcbre', False)
Exemplo n.º 3
0
    def setUp(self):
        world = Project()

        for i in range(4):
            world.stackup.add_layer(Layer("l%d" % i, None))

        world.stackup.add_via_pair(
            ViaPair(world.stackup.layers[0], world.stackup.layers[1]))
        world.stackup.add_via_pair(
            ViaPair(world.stackup.layers[2], world.stackup.layers[3]))
        world.stackup.add_via_pair(
            ViaPair(world.stackup.layers[0], world.stackup.layers[3]))
        world.stackup.add_via_pair(
            ViaPair(world.stackup.layers[1], world.stackup.layers[2]))

        #   0 1 2 3
        # 0 x   x x
        # 1   x x x
        # 2 x x x x
        # 3 x x x x

        n1 = Net()
        n2 = Net()
        world.nets.add_net(n1)
        world.nets.add_net(n2)
        self.v1 = Via(Point2(3, 3), world.stackup.via_pairs[0], 2, n1)
        world.artwork.add_artwork(self.v1)
        self.v2 = Via(Point2(11, 11), world.stackup.via_pairs[1], 2, n2)
        world.artwork.add_artwork(self.v2)
        self.world = world
Exemplo n.º 4
0
    def test_save_pin_names_nets(self):
        p = Project()
        l = Layer("test", [1,1,1])
        p.stackup.add_layer(l)
        d = DIPComponent(Point2(64, 54), 33.5, SIDE.Top, p, 12, 512, 640, 1111)
        d.refdes = "UFOO"
        d.partno = "BLAH"


        pads = d.get_pads()
        pads[0].pad_name = "NAME1"
        pads[1].pad_name = "NAME2"
        p.artwork.merge_component(d)

        p_new = self.__saverestore(p)


        self.assertEqual(len(p_new.artwork.components), 1)
        c = next(iter(p_new.artwork.components))

        self.assertEqual(d.refdes, c.refdes)
        self.assertEqual(d.partno, c.partno)

        pads_new = c.get_pads()

        for p_old, p_new in zip(pads, pads_new):
            self.assertEqual(p_old.net.name, p_new.net.name)

        self.assertEqual(pads_new[0].pad_name, "NAME1")
        self.assertEqual(pads_new[1].pad_name, "NAME2")
Exemplo n.º 5
0
    def setUp(self):
        self.p = Project()
        self.l1 = Layer("l1", None)
        self.l2 = Layer("l2", None)

        self.p.stackup.add_layer(self.l1)
        self.p.stackup.add_layer(self.l2)
Exemplo n.º 6
0
    def test_save_smd(self):
        p = Project()
        l = Layer("test", [1,1,1])
        p.stackup.add_layer(l)
        d = SMD4Component(Point2(64, 54), 33.5, SIDE.Top, p,
                          32, 46,17,55, 801,914,3232, 604, 123, 456, 17)
                          
        d.refdes = "UFOO"

        p.artwork.merge_component(d)

        p_new = self.__saverestore(p)
        
        self.assertEqual(len(p_new.artwork.components), 1)
        c = next(iter(p_new.artwork.components))

        self.assertEqual(d.side_pins, c.side_pins)

        self.assertEqual(d.dim_1_body, c.dim_1_body)
        self.assertEqual(d.dim_1_pincenter, c.dim_1_pincenter)
        self.assertEqual(d.dim_2_body, c.dim_2_body)
        self.assertEqual(d.dim_2_pincenter, c.dim_2_pincenter)

        self.assertEqual(d.pin_contact_length, c.pin_contact_length)
        self.assertEqual(d.pin_contact_width, c.pin_contact_width)
        self.assertEqual(d.pin_spacing, c.pin_spacing)
Exemplo n.º 7
0
    def __saverestore(self, p):
        with TemporaryFile(buffering=0) as fd:

            p.save_fd(fd)
            fd.seek(0)

            p_new = Project.open_fd(fd)
        return p_new
Exemplo n.º 8
0
    def __setup_layers(self, n):
        names = ["foo","bar","quux", "sed","a"] + list("abcdefghijklmnop")
        p = Project.create()
        for i, name in zip(range(n), names):
            color = (random.random(), random.random(), random.random())
            l0 = Layer(name, color)
            p.stackup.add_layer(l0)

        return p
Exemplo n.º 9
0
def setup2Layer(obj):
    obj.p = Project()
    obj.top_layer = Layer("top", (1, 0, 0))
    obj.bottom_layer = Layer("bottom", (0, 0, 1))

    obj.p.stackup.add_layer(obj.top_layer)
    obj.p.stackup.add_layer(obj.bottom_layer)

    obj.via_pair = ViaPair(obj.top_layer, obj.bottom_layer)
    obj.p.stackup.add_via_pair(obj.via_pair)
Exemplo n.º 10
0
    def setUp(self):
        self.p = Project()
        self.l1 = Layer("l1", None)
        self.l2 = Layer("l2", None)

        self.p.stackup.add_layer(self.l1)
        self.p.stackup.add_layer(self.l2)

        self.ext1 = [Point2(0, 0), Point2(1, 0), Point2(1, 1), Point2(0, 1)]
        self.ext2 = [Point2(1, 0), Point2(2, 0), Point2(2, 1), Point2(1, 1)]
        self.ext3 = [Point2(2, 0), Point2(3, 0), Point2(3, 1), Point2(2, 1)]
Exemplo n.º 11
0
    def test_point_insert(self):
        p = Project()
        l1 = Layer("l1", None)
        l2 = Layer("l2", None)
        p.stackup.add_layer(l1)
        p.stackup.add_layer(l2)
        vp = ViaPair(l1, l2)
        p.stackup.add_via_pair(vp)

        t1 = Trace(Point2(200, 1000), Point2(2000, 1000), 10, l1)
        p.artwork.merge_artwork(t1)

        t2 = Trace(Point2(400, 0), Point2(400, 2000), 10, l2)
        p.artwork.merge_artwork(t2)

        # Should be two objects, not connected
        self.assertIsNotNone(t1.net)
        self.assertIsNotNone(t2.net)
        self.assertNotEqual(t1.net, t2.net)

        # Add two more traces, make sure they're connected to nets
        t3 = Trace(Point2(2000, 1001), Point2(2000, 3000), 10, l1)
        p.artwork.merge_artwork(t3)
        self.assertEqual(t1.net, t3.net)

        t4 = Trace(Point2(401, -1), Point2(-1000, -1000), 10, l2)
        p.artwork.merge_artwork(t4)
        self.assertEqual(t2.net, t4.net)

        # Now put a via between the two
        v = Via(Point2(400, 1000), vp, 10)
        p.artwork.merge_artwork(v)
        # Make sure net is not none
        self.assertIsNotNone(v.net)

        # Make sure net is all the same
        self.assertEqual(v.net, t1.net)
        self.assertEqual(v.net, t2.net)
        self.assertEqual(v.net, t3.net)
        self.assertEqual(v.net, t4.net)

        # Should only be one net in the project now, and it should be v.net
        self.assertEqual(len(p.nets.nets), 1)
        self.assertEqual(p.nets.nets[0], v.net)

        # Ok, now remove the via from the artwork.
        # via should then have no net, and the traces on each layer should split off
        p.artwork.remove_artwork(v)

        # We should now have two nets on separate layers
        self.assertEqual(len(p.nets.nets), 2)
        self.assertEqual(t1.net, t3.net)
        self.assertEqual(t2.net, t4.net)
        self.assertNotEqual(t1.net, t2.net)
Exemplo n.º 12
0
    def setUp(self):
        self.p = p = Project()
        l = Layer("foo", [])
        p.stackup.add_layer(l)

        self.l1 = Trace(Point2(-5, 0), Point2(-1, 0), thickness=1, layer=l)
        self.l2 = Trace(Point2(1, 0), Point2(5, 0), thickness=1, layer=l)
        p.artwork.merge_artwork(self.l1)
        p.artwork.merge_artwork(self.l2)

        self.assertIsNotNone(self.l1.net)
        self.assertIsNotNone(self.l2.net)
        self.assertNotEqual(self.l1.net, self.l2.net)

        class Dummy(Component):
            pass

        cmp = Dummy(Point2(0,0), 0, SIDE.Top, side_layer_oracle=p)
        self.pad = Pad(cmp, 0, Point2(0, 0), 0, 3, 3, th_diam=1)
Exemplo n.º 13
0
    def setUp(self):
        self.p = Project.create()

        l1 = Layer(name="Top", color=(0, 0, 0))
        l2 = Layer(name="Bot", color=(0, 0, 1))
        vp = ViaPair(l1, l2)

        self.net0 = Net()
        self.net1 = Net()

        self.v1 = Via(Point2(0, 0), r=1, viapair=vp, net=self.net0)
        self.v2 = Via(Point2(0, 0), r=1, viapair=vp, net=self.net1)

        self.p.stackup.add_layer(l1)
        self.p.stackup.add_layer(l2)

        self.p.stackup.add_via_pair(vp)

        self.p.nets.add_net(self.net0)
        self.p.nets.add_net(self.net1)

        self.p.artwork.add_artwork(self.v1)
        self.p.artwork.add_artwork(self.v2)
Exemplo n.º 14
0
    def test_save_dip(self):
        p = Project()
        l = Layer("test", [1,1,1])
        p.stackup.add_layer(l)
        d = DIPComponent(Point2(64, 54), 33.5, SIDE.Top, p, 12, 512, 640, 1111)
        d.refdes = "UFOO"

        p.artwork.merge_component(d)

        p_new = self.__saverestore(p)

        self.assertEqual(len(p_new.artwork.components), 1)
        c = next(iter(p_new.artwork.components))
        
        self.assertIsInstance(c, DIPComponent)
        self.assertEqual(d.body_length(), c.body_length())
        self.assertEqual(d.body_width(), c.body_width())
        self.assertEqual(d.pin_count, c.pin_count)
        self.assertEqual(d.pin_space, c.pin_space)
        self.assertEqual(d.pin_width, c.pin_width)
        self.assertEqual(d.pad_size, c.pad_size)
        self.assertEqual(d.theta, c.theta)
        self.assertEqual(d.refdes, c.refdes)
Exemplo n.º 15
0
    def setUp(self):
        self.p = Project.create()

        l1 = Layer(name="Top", color=(0,0,0))
        l2 = Layer(name="Bot", color=(0,0,1))
        vp = ViaPair(l1,l2)

        self.net0 = Net()
        self.net1 = Net()

        self.v1 = Via(Point2(0, 0), r=1, viapair=vp, net=self.net0)
        self.v2 = Via(Point2(0, 0), r=1, viapair=vp, net=self.net1)


        self.p.stackup.add_layer(l1)
        self.p.stackup.add_layer(l2)

        self.p.stackup.add_via_pair(vp)

        self.p.nets.add_net(self.net0)
        self.p.nets.add_net(self.net1)

        self.p.artwork.add_artwork(self.v1)
        self.p.artwork.add_artwork(self.v2)
Exemplo n.º 16
0
    def test_fixup_broken_nets(self):
        p = Project()

        l = Layer("t1", (1, 1, 1))

        p.stackup.add_layer(l)

        n1 = p.nets.new()
        n2 = p.nets.new()
        n3 = p.nets.new()

        # T1 and T2 should be joined
        # T2 and T3 should be split
        # T4 should stay the same

        t1 = Trace(Point2(0, 0), Point2(100, 100), 10, l, n1)
        t2 = Trace(Point2(200, 200), Point2(100, 100), 10, l, n2)
        t3 = Trace(Point2(400, 400), Point2(500, 500), 10, l, n2)
        t4 = Trace(Point2(600, 600), Point2(700, 700), 10, l, n3)

        p.artwork.add_artwork(t1)
        p.artwork.add_artwork(t2)
        p.artwork.add_artwork(t3)
        p.artwork.add_artwork(t4)

        self.assertNotEqual(t1.net, t2.net)
        p.artwork.rebuild_connectivity()
        self.assertEqual(t1.net, t2.net)
        self.assertNotEqual(t2.net, t3.net)
        self.assertEqual(t4.net, n3)

        # And all objects must have nets
        self.assertIsNotNone(t1.net)
        self.assertIsNotNone(t2.net)
        self.assertIsNotNone(t3.net)
        self.assertIsNotNone(t4.net)
Exemplo n.º 17
0
 def test_basic_save_restore(self):
     p = Project.create()
     p_new = self.__saverestore(p)
Exemplo n.º 18
0
 def setUp(self):
     self.p = Project.create()
Exemplo n.º 19
0
 def setUp(self):
     self.p = Project.create()