示例#1
0
    def test_vias(self):
        p = self.__setup_via_pairs_layers()

        n1 = Net()
        p.nets.add_net(n1)

        n2 = Net()
        p.nets.add_net(n2)

        v = Via(Point2(3700, 2100), p.stackup.via_pairs[0], 31337, n1)
        v2 = Via(Point2(1234, 5678), p.stackup.via_pairs[1], 31339, n2)

        p.artwork.add_artwork(v)
        p.artwork.add_artwork(v2)

        p_new = self.__saverestore(p)

        v2_new = sorted(p_new.artwork.vias, key=lambda x: x.pt.x)[0]
        v_new = sorted(p_new.artwork.vias, key=lambda x: x.pt.x)[1]
        self.assertEqual(v_new._project, p_new)
        self.assertEqual(v2_new._project, p_new)

        for a, b in ((v, v_new), (v2, v2_new)):
            self.cmpMat(a.pt, b.pt)
            self.assertEqual(p.stackup.via_pairs.index(a.viapair),
                             p_new.stackup.via_pairs.index(b.viapair))
            self.assertEqual(a.r, b.r)
            self.assertEqual(p.nets.nets.index(a.net), p_new.nets.nets.index(b.net))
示例#2
0
    def test_trace(self):
        p = self.__setup_via_pairs_layers()

        n1 = Net()
        p.nets.add_net(n1)

        n2 = Net()
        p.nets.add_net(n2)

        t1 = Trace(Point2(61, -300), Point2(848, 1300), 775, p.stackup.layers[0], n1)
        t2 = Trace(Point2(1234, 5678), Point2(90210, 84863), 775, p.stackup.layers[0], n2)

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

        self.assertEqual(t1._project, p)

        p_new = self.__saverestore(p)

        self.assertEqual(len(p_new.artwork.traces), 2)
        self.assertIs(list(p_new.artwork.traces)[0]._project, p_new)

        # Walk ordered traces
        l_old = sorted(p.artwork.traces, key=lambda x: x.p0.x)
        l_new = sorted(p_new.artwork.traces, key=lambda x: x.p0.x)
        for t_old, t_new in zip(l_old, l_new):
            self.cmpMat(t_old.p0, t_new.p0)
            self.cmpMat(t_old.p1, t_new.p1)
            self.assertEqual(t_old.thickness, t_new.thickness)

            # Check links to layer object and net object are restored
            self.assertEqual(p.nets.nets.index(t_old.net), p_new.nets.nets.index(t_new.net))
            self.assertEqual(p.stackup.layers.index(t_old.layer),
                             p_new.stackup.layers.index(t_new.layer))
示例#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
示例#4
0
文件: project.py 项目: pcbre/pcbre
    def add_net(self, net: Net) -> None:
        """
        Add a net to the project. Sets a transient unused net ID
        :param net: net to be added
        :return:
        """
        assert net._project is None or net._project is self.__project

        net._project = self.__project
        self.__max_id += 1
        net._id = self.__max_id

        self.__nets.append(net)
示例#5
0
    def test_airwires(self):
        p = self.__setup_via_pairs_layers()

        n1 = Net()
        p.nets.add_net(n1)

        v = Via(Point2(3700, 2100), p.stackup.via_pairs[0], 31337, n1)
        v2 = Via(Point2(1234, 5678), p.stackup.via_pairs[1], 31339, n1)

        airwire = Airwire(v.pt, v2.pt, v.viapair.layers[0], v2.viapair.layers[0], n1)

        p.artwork.add_artwork(v)
        p.artwork.add_artwork(v2)
        p.artwork.add_artwork(airwire)

        p_new = self.__saverestore(p)

        aw_new = list(p_new.artwork.airwires)[0]

        v2_new = sorted(p_new.artwork.vias, key=lambda x: x.pt.x)[0]
        v_new = sorted(p_new.artwork.vias, key=lambda x: x.pt.x)[1]

        self.cmpMat(aw_new.p0, airwire.p0)
        self.cmpMat(aw_new.p1, airwire.p1)

        self.assertEqual(aw_new.p0_layer, v_new.viapair.layers[0])
        self.assertEqual(aw_new.p1_layer, v2_new.viapair.layers[0])
        self.assertEqual(aw_new.net, v_new.net)
示例#6
0
文件: project.py 项目: pcbre/pcbre
    def deserialize(self, msg: ser.Nets) -> None:
        assert self.__project is not None

        for i in msg.netList:
            n = Net(name=i.name, net_class=i.nclass)
            self.__project.scontext.set_sid(i.sid, n)
            self.add_net(n)
示例#7
0
    def merge_aw_nets(self, new_geom: QueryableGeom) -> None:
        """
        Perform net merges that would occur if new_geom is added to the project
        :param new_geom:
        :return:
        """
        qr = self.query_intersect(new_geom)

        nets = set()
        if new_geom.net is not None:
            nets.add(new_geom.net)

        for _, geom in qr:
            net = geom.net
            # When added to a project, the net should never be Null
            assert net is not None
            nets.add(net)

        if len(nets) > 1:
            new_net = self.merge_nets_many(nets)
        elif len(nets) == 1:
            new_net = list(nets)[0]
        else:
            new_net = Net()
            self.__project.nets.add_net(new_net)

        new_geom.net = new_net
示例#8
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)
示例#9
0
    def test_polyons(self):
        p = self.__setup_via_pairs_layers()
        n1 = Net()
        p.nets.add_net(n1)
        n2 = Net()
        p.nets.add_net(n2)

        ext = [Point2(0,0), Point2(10,0), Point2(10,10), Point2(0, 10)]
        int1 = [Point2(1,1), Point2(2,1), Point2(2,2), Point2(1,2)]
        int2 = [Point2(4,1), Point2(5,1), Point2(5,2), Point2(4,2)]


        po = Polygon(p.stackup.layers[0], ext, [int1, int2], n1)

        p.artwork.add_artwork(po)

        p_new = self.__saverestore(p)

        pols = p_new.artwork.polygons

        self.assertEqual(len(pols), 1)
        pol_new = list(pols)[0]
        self.assertIsInstance(pol_new, Polygon)

        r = pol_new.get_poly_repr()

        # All LineRings contain the first element as the last, so we drop during the comparison

        pb = po.get_poly_repr()
        self.assertListEqual(list(r.exterior.coords), [tuple(i) for i in pb.exterior.coords])
        interiors = r.interiors
        self.assertEqual(len(interiors), 2)
        self.assertListEqual(list(interiors[0].coords), [tuple(i) for i in pb.interiors[0].coords])
        self.assertListEqual(list(interiors[1].coords), [tuple(i) for i in pb.interiors[1].coords])

        self.assertIsNotNone(pol_new.net)
        self.assertIsNotNone(pol_new.layer)
示例#10
0
    def test_add_via(self):
        p = self.p
        l1 = S.Layer(name="Top", color=(1, 1, 1, 0))
        l2 = S.Layer(name="Bot", color=(1, 1, 1, 0))

        vp = S.ViaPair(l1, l2)

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

        p.stackup.add_via_pair(vp)

        n = Net()
        p.nets.add_net(n)
        via = Via(Point2(0, 0), vp, 1, net=n)
        p.artwork.add_artwork(via)
示例#11
0
    def merge_aw_nets(self, new_geom):
        """
        Perform net merges that would occur if new_geom is added to the project
        :param new_geom:
        :return:
        """
        qr = self.query_intersect(new_geom)

        nets = set()
        if new_geom.net is not None:
            nets.add(new_geom.net)

        if len(qr) > 0:
            nets.update(i[1].net for i in qr)

        if len(nets) > 1:
            new_net = self.merge_nets_many(nets)
        elif len(nets) == 1:
            new_net = list(nets)[0]
        else:
            new_net = Net()
            self.__project.nets.add_net(new_net)

        new_geom.net = new_net
示例#12
0
        def net_gen():
            yield geom.net

            newnet = Net()
            self.__project.nets.add_net(newnet)
            yield newnet
示例#13
0
 def deserialize(self, msg):
     for i in msg.netList:
         n = Net(name=i.name, net_class=i.nclass)
         self.__project.scontext.set_sid(i.sid, n)
         self.add_net(n)
示例#14
0
 def new(self):
     n = Net()
     self.add_net(n)
     return n
示例#15
0
        def net_gen() -> Generator[Optional[Net], None, None]:
            yield geom.net

            newnet = Net()
            self.__project.nets.add_net(newnet)
            yield newnet