本文整理匯總了Python中upconvert.writer.kicad.KiCAD類的典型用法代碼示例。如果您正苦於以下問題:Python KiCAD類的具體用法?Python KiCAD怎麽用?Python KiCAD使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了KiCAD類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_write_net
def test_write_net(self):
"""
The write_net method creates the correct kicad wires from an
openjson net.
"""
net = Net('')
p1 = NetPoint('p1', 0, 0)
p2 = NetPoint('p2', 1, 0)
p3 = NetPoint('p3', 0, 1)
net.add_point(p1)
net.add_point(p2)
net.add_point(p3)
net.conn_point(p1, p2)
net.conn_point(p1, p3)
writer = KiCAD()
buf = StringIO()
writer.write_net(buf, net)
self.assertEqual(
buf.getvalue(),
'Wire Wire Line\n\t0 0 0 ' + str(int(-1 / MULT)) +
'\nWire Wire Line\n\t0 0 ' + str(int(1 / MULT)) +
' 0\n')
示例2: test_write_library_footer
def test_write_library_footer(self):
"""
The write_library_footer produces the correct string.
"""
writer = KiCAD()
buf = StringIO()
writer.write_library_footer(buf)
self.assertEqual(buf.getvalue(), '#\n#End Library\n')
示例3: test_write_eelayer
def test_write_eelayer(self):
"""
The write_eelayer method produces the correct string.
"""
writer = KiCAD()
buf = StringIO()
writer.write_eelayer(buf)
self.assertEqual(buf.getvalue(), 'EELAYER 25 0\nEELAYER END\n')
示例4: test_arc
def test_arc(self):
"""
Arcs are output correctly.
"""
writer = KiCAD()
arc = Arc(0, 0, -0.5, 0.5, 1)
line = writer.get_shape_line(arc)
self.assertEqual(line, 'A 0 0 11 900 -900 %(unit)d %(convert)d 0 N\n')
示例5: test_write_libs
def test_write_libs(self):
"""
The write_libs method produces the right string.
"""
writer = KiCAD()
buf = StringIO()
writer.write_libs(buf, 'test-cache.sch')
self.assertEqual(buf.getvalue(), 'LIBS:test-cache\n')
示例6: test_rectangle
def test_rectangle(self):
"""
Rectangles are output correctly.
"""
writer = KiCAD()
rect = Rectangle(10, 20, 5, 10)
line = writer.get_shape_line(rect)
self.assertEqual(line, 'S 111 222 167 111 %(unit)d %(convert)d 0 N\n')
示例7: test_write_footer
def test_write_footer(self):
"""
The write_footer method produces the correct string.
"""
writer = KiCAD()
buf = StringIO()
writer.write_footer(buf)
self.assertEqual(buf.getvalue(), '$EndSCHEMATC\n')
示例8: test_bezier_curve
def test_bezier_curve(self):
"""
BezierCurves are output correctly.
"""
writer = KiCAD()
bezier = BezierCurve((0, 0), (1, 1), (2, 2), (3, 3))
line = writer.get_shape_line(bezier)
self.assertEqual(line, 'P 2 %(unit)d %(convert)d 0 22 22 33 33 N\n')
示例9: test_write_annotation
def test_write_annotation(self):
"""
The write_annotation method produces the correct string.
"""
writer = KiCAD()
buf = StringIO()
ann = Annotation('test', 1, 2, .5, 'true')
writer.write_annotation(buf, ann)
self.assertEqual(buf.getvalue(),
'Text Label 11 -22 900 60 ~ 0\ntest\n')
示例10: test_write_header
def test_write_header(self):
"""
The write_header method produces the right string.
"""
design = Design()
design.design_attributes.metadata.updated_timestamp = 0
writer = KiCAD()
buf = StringIO()
writer.write_header(buf, design)
self.assertEqual(buf.getvalue()[:40], 'EESchema Schematic File Version 2 date ')
示例11: test_write
def test_write(self):
"""
We can write out a complete design file.
"""
design = JSON().parse(TEST_UPV_FILE)
writer = KiCAD()
filedesc, filename = tempfile.mkstemp()
os.close(filedesc)
os.remove(filename)
writer.write(design, filename)
self.assertTrue(os.path.exists(filename))
示例12: test_polygon
def test_polygon(self):
"""
Polygons are output correctly.
"""
writer = KiCAD()
poly = Polygon()
poly.add_point(0, 0)
poly.add_point(0, 10)
poly.add_point(10, 10)
poly.add_point(10, 0)
line = writer.get_shape_line(poly)
self.assertEqual(line, 'P 5 %(unit)d %(convert)d 0 0 0 0 111 111 111 111 0 0 0 N\n')
示例13: test_write
def test_write(self):
"""
We can write out a complete design file.
"""
design = KiCADParser().parse(os.path.join(TEST_DIR, 'test/test.sch'))
writer = KiCAD()
filedesc, filename = tempfile.mkstemp()
os.close(filedesc)
os.remove(filename)
writer.write(design, filename)
self.assertTrue(os.path.exists(filename))
os.remove(filename)
示例14: test_rectangle
def test_rectangle(self):
"""
Rectangles are output correctly.
"""
writer = KiCAD()
rect = Rectangle(10, 20, 5, 10)
line = writer.get_shape_line(rect)
self.assertEqual(line, 'S ' + str(int(10 / MULT)) + ' '
+ str(int(20 / MULT)) + ' '
+ str(int(15 / MULT)) + ' '
+ str(int(10 / MULT)) + ' '
+ '%(unit)d %(convert)d 0 N\n')
示例15: test_write_instance
def test_write_instance(self):
"""
The write_instance method serializes a component instance
correctly.
"""
inst = ComponentInstance('id', 'libid', 1)
inst.add_symbol_attribute(SymbolAttribute(3, 4, 0.5))
writer = KiCAD()
buf = StringIO()
writer.write_instance(buf, inst)
self.assertEqual(buf.getvalue(), '''\
$Comp
L libid id
U 1 1 00000000
P 33 -44
\t1 33 -44
\t0 1 1 0
$EndComp
''')