Beispiel #1
0
    def serializeTo(self, pasv_msg: 'ser.Component.Builder') -> None:
        self._serializeTo(pasv_msg.common)
        pasv_msg.init("passive2")

        m = pasv_msg.passive2

        m.symType = self.sym_type.value
        m.bodyType = self.body_type.value
        m.pinD = int(self.pin_d)
        m.bodyCornerVec = serialize_point2(self.body_corner_vec)
        m.pinCornerVec = serialize_point2(self.pin_corner_vec)
Beispiel #2
0
    def serializeTo(self, cmp_msg):
        if self.side == SIDE.Top:
            cmp_msg.side = "top"
        elif self.side == SIDE.Bottom:
            cmp_msg.side = "bottom"
        else:
            raise NotImplementedError()

        cmp_msg.refdes = self.refdes
        cmp_msg.partno = self.partno

        cmp_msg.center = serialize_point2(self.center)
        cmp_msg.theta = float(self.theta)
        cmp_msg.sid = self._project.scontext.sid_for(self)


        cmp_msg.init("pininfo", len(self.get_pads()))
        for n,p in enumerate(self.get_pads()):
            k = p.pad_no
            t = cmp_msg.pininfo[n]

            t.identifier = k
            if k in self.name_mapping:
                t.name = self.name_mapping[k]

            t.net = self._project.scontext.sid_for(self.net_mapping[k])
Beispiel #3
0
    def _serializeTo(self, cmp_msg: 'ser.Component.Builder') -> None:
        if self.side == SIDE.Top:
            cmp_msg.side = "top"
        elif self.side == SIDE.Bottom:
            cmp_msg.side = "bottom"
        else:
            raise NotImplementedError()

        cmp_msg.refdes = self.refdes
        cmp_msg.partno = self.partno

        cmp_msg.center = serialize_point2(self.center)
        cmp_msg.theta = float(self.theta)
        cmp_msg.sid = self._project.scontext.sid_for(self)

        cmp_msg.init("pininfo", len(self.get_pads()))
        for n, p in enumerate(self.get_pads()):
            k = p.pad_no
            t = cmp_msg.pininfo[n]

            t.identifier = k
            if k in self.name_mapping:
                t.name = self.name_mapping[k]

            t.net = self._project.scontext.sid_for(self.net_mapping[k])
Beispiel #4
0
    def test_point2(self):
        # Point2 class is floating (for now), but serialized form is integral units
        pt = Point2(54.3, 72.9)
        msg = serialize_point2(pt)

        pt2 = deserialize_point2(msg)

        self.assertAlmostEqual(pt2.x, round(pt.x))
        self.assertAlmostEqual(pt2.y, round(pt.y))
Beispiel #5
0
    def serialize(self) -> ser.Artwork.Builder:
        _aw = ser.Artwork.new_message()
        _aw.init("vias", len(self.vias))
        _aw.init("traces", len(self.traces))
        _aw.init("polygons", len(self.polygons))
        _aw.init("components", len(self.components))
        _aw.init("airwires", len(self.airwires))

        # Serialization done here to reduce instance size
        for n, i_via in enumerate(self.vias):
            v = _aw.vias[n]
            v.point = serialize_point2(i_via.pt)
            v.r = i_via.r
            v.viapairSid = self.__project.scontext.sid_for(i_via.viapair)
            v.netSid = self.__project.scontext.sid_for(i_via.net)

        #
        for n, i_trace in enumerate(self.traces):
            t = _aw.traces[n]
            t.p0 = serialize_point2(i_trace.p0)
            t.p1 = serialize_point2(i_trace.p1)
            t.thickness = int(i_trace.thickness)
            t.netSid = self.__project.scontext.sid_for(i_trace.net)
            t.layerSid = self.__project.scontext.sid_for(i_trace.layer)

        for n, i_comp in enumerate(self.components):
            t = _aw.components[n]
            i_comp._serializeTo(t)

        for n, i_poly in enumerate(self.polygons):
            p = _aw.polygons[n]

            p_repr = i_poly.get_poly_repr()
            p.init("exterior", len(p_repr.exterior.coords))
            for nn, ii in enumerate(p_repr.exterior.coords):
                p.exterior[nn] = serialize_point2(Point2(ii.x, ii.y))

            p.init("interiors", len(p_repr.interiors))
            for n_interior, interior in enumerate(p_repr.interiors):
                p.interiors.init(n_interior, len(interior.coords))
                for nn, ii in enumerate(interior.coords):
                    p.interiors[n_interior][nn] = serialize_point2(
                        Point2(ii.x, ii.y))

            p.layerSid = self.__project.scontext.sid_for(i_poly.layer)
            p.netSid = self.__project.scontext.sid_for(i_poly.net)

        for n, i_ in enumerate(self.airwires):
            t = _aw.airwires[n]
            t.p0 = serialize_point2(i_.p0)
            t.p1 = serialize_point2(i_.p1)
            t.netSid = self.__project.scontext.sid_for(i_.net)
            t.p0LayerSid = self.__project.scontext.sid_for(i_.p0_layer)
            t.p1LayerSid = self.__project.scontext.sid_for(i_.p1_layer)

        return _aw
Beispiel #6
0
    def serialize(self):
        _aw = ser.Artwork.new_message()
        _aw.init("vias", len(self.vias))
        _aw.init("traces", len(self.traces))
        _aw.init("polygons", len(self.polygons))
        _aw.init("components", len(self.components))
        _aw.init("airwires", len(self.airwires))

        # Serialization done here to reduce instance size
        for n, i in enumerate(self.vias):
            v = _aw.vias[n]
            v.point = serialize_point2(i.pt)
            v.r = i.r
            v.viapairSid = self.__project.scontext.sid_for(i.viapair)
            v.netSid = self.__project.scontext.sid_for(i.net)

        #
        for n, i in enumerate(self.traces):
            t = _aw.traces[n]
            t.p0 = serialize_point2(i.p0)
            t.p1 = serialize_point2(i.p1)
            t.thickness = i.thickness
            t.netSid = self.__project.scontext.sid_for(i.net)
            t.layerSid = self.__project.scontext.sid_for(i.layer)

        for n, i in enumerate(self.components):
            t = _aw.components[n]
            i.serializeTo(t)

        for n, i in enumerate(self.polygons):
            p = _aw.polygons[n]

            p_repr = i.get_poly_repr()
            p.init("exterior", len(p_repr.exterior.coords))
            for nn, ii in enumerate(p_repr.exterior.coords):
                p.exterior[nn] = serialize_point2(Point2(ii))

            p.init("interiors", len(p_repr.interiors))
            for n_interior, interior in enumerate(p_repr.interiors):
                p.interiors.init(n_interior, len(interior.coords))
                for nn, ii in enumerate(interior.coords):
                    p.interiors[n_interior][nn] = serialize_point2(Point2(ii))

            p.layerSid = self.__project.scontext.sid_for(i.layer)
            p.netSid = self.__project.scontext.sid_for(i.net)

        for n, i in enumerate(self.airwires):
            t = _aw.airwires[n]
            t.p0 = serialize_point2(i.p0)
            t.p1 = serialize_point2(i.p1)
            t.netSid = self.__project.scontext.sid_for(i.net)
            t.p0LayerSid = self.__project.scontext.sid_for(i.p0_layer)
            t.p1LayerSid = self.__project.scontext.sid_for(i.p1_layer)

        return _aw
Beispiel #7
0
 def serialize(self):
     msg = ser.Keypoint.new_message()
     msg.sid = self._project.scontext.sid_for(self)
     msg.worldPosition = serialize_point2(self.world_position)
     return msg
Beispiel #8
0
 def serialize(self):
     msg = ser.Keypoint.new_message()
     msg.sid = self._project.scontext.sid_for(self)
     msg.worldPosition = serialize_point2(self.world_position)
     return msg