def test_bezier_curve(self): """ Convert bezier to lines shape """ bezier = BezierCurve((0, 0), (1, 1), (2, 2), (3, 3)) writer = Specctra() writer.resolution = specctraobj.Resolution() writer.resolution.unit = 'mil' writer.resolution.resolution = 10 obj = writer._convert_shape(bezier) self.assertEqual( to_string(writer, obj), '( (path signal 10.416667 20.833333 20.833333 20.833333 20.833333)' + ' (path signal 10.416667 20.833333 20.833333 10.416667 10.416667)' + ' (path signal 10.416667 10.416667 10.416667 10.416667 10.416667)' + ' (path signal 10.416667 10.416667 10.416667 10.416667 10.416667)' + ' (path signal 10.416667 10.416667 10.416667 10.416667 10.416667)' + ' (path signal 10.416667 10.416667 10.416667 10.416667 10.416667)' + ' (path signal 10.416667 10.416667 10.416667 10.416667 10.416667)' + ' (path signal 10.416667 10.416667 10.416667 20.833333 20.833333)' + ' (path signal 10.416667 20.833333 20.833333 20.833333 20.833333)' + ' (path signal 10.416667 20.833333 20.833333 20.833333 20.833333)' + ' (path signal 10.416667 20.833333 20.833333 31.250000 31.250000) )' )
def test_rectangle(self): """ Convert rectangle shape """ rect = Rectangle(10, 20, 5, 10) writer = Specctra() writer.resolution = specctraobj.Resolution() writer.resolution.unit = 'mil' writer.resolution.resolution = 10 obj = writer._convert_shape(rect) self.assertEqual( to_string(writer, obj), '( (rect signal 104.166667 208.333333 156.250000 104.166667) )')
def test_circle(self): """ Convert circle shape """ circle = Circle(10, 20, 10) writer = Specctra() writer.resolution = specctraobj.Resolution() writer.resolution.unit = 'mil' writer.resolution.resolution = 10 obj = writer._convert_shape(circle) self.assertEqual( to_string(writer, obj), '( (circle signal 208.333333 104.166667 208.333333) )')
def test_write_instance(self): """ Convert component instance """ inst = ComponentInstance('id', None, 'libid', 1) inst.add_symbol_attribute(SymbolAttribute(3, 4, 0.5, False)) writer = Specctra() writer.resolution = specctraobj.Resolution() writer.resolution.unit = 'mil' writer.resolution.resolution = 10 obj = writer._convert_component_instance(inst) self.assertEqual( to_string(writer, obj), '(component libid-1 (place id 31.250000 41.666667 front 270) )')
def test_polygon(self): """ Convert polygon shape """ poly = Polygon() poly.add_point(0, 0) poly.add_point(0, 10) poly.add_point(10, 10) poly.add_point(10, 0) writer = Specctra() writer.resolution = specctraobj.Resolution() writer.resolution.unit = 'mil' writer.resolution.resolution = 10 obj = writer._convert_shape(poly) self.assertEqual( to_string(writer, obj), '( (polygon signal 10.416667 0.000000 0.000000 0.000000 104.166667 104.166667' + ' 104.166667 104.166667 0.000000) )')
def test_arc(self): """ Convert arc to lines shape """ arc = Arc(0, 0, -0.5, 0.5, 1) writer = Specctra() writer.resolution = specctraobj.Resolution() writer.resolution.unit = 'mil' writer.resolution.resolution = 10 obj = writer._convert_shape(arc) self.assertEqual( to_string(writer, obj), '( (path signal 10.416667 -0.000000 -10.416667 -6.122763 -8.427260)' + ' (path signal 10.416667 -6.122763 -8.427260 -9.906839 -3.218927)' + ' (path signal 10.416667 -9.906839 -3.218927 -9.906839 3.218927)' + ' (path signal 10.416667 -9.906839 3.218927 -6.122763 8.427260)' + ' (path signal 10.416667 -6.122763 8.427260 -0.000000 10.416667) )' )
def _make_pcb(self, design): pcb = specctraobj.Pcb() pcb.library = specctraobj.Library() pcb.placement = specctraobj.Placement() pcb.network = specctraobj.Network() pcb.wiring = specctraobj.Wiring() pcb.parser.host_cad = specctraobj.HostCad() pcb.parser.host_cad.value = design.version.get('exporter') pcb.parser.host_version = specctraobj.HostVersion() pcb.parser.host_version.value = design.version.get('file_version') pcb.resolution = specctraobj.Resolution() pcb.resolution.unit = 'mil' pcb.resolution.resolution = 10 self.resolution = pcb.resolution pcb.unit = specctraobj.Unit() pcb.unit.value = 'mil' return pcb