2021-02-28 00:18:56 +00:00
|
|
|
import unittest
|
|
|
|
import pcbnew
|
|
|
|
|
|
|
|
class TestTracks(unittest.TestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
2022-03-18 21:30:17 +00:00
|
|
|
self.pcb = pcbnew.LoadBoard("data/pcbnew/tracks_arcs_vias.kicad_pcb")
|
2021-02-28 00:18:56 +00:00
|
|
|
|
|
|
|
def test_tracks(self):
|
2021-06-13 15:19:19 +00:00
|
|
|
tracks = [t for t in self.pcb.Tracks() if t.GetClass() == 'PCB_TRACK']
|
2021-02-28 00:18:56 +00:00
|
|
|
self.assertEqual(16, len(tracks))
|
|
|
|
track = sorted(tracks, key=lambda t: [t.GetStart()[0], t.GetStart()[1]])[0]
|
|
|
|
self.assertEqual([27000000, 27585787], [track.GetStart()[0], track.GetStart()[1]])
|
|
|
|
self.assertEqual([27000000, 26500000], [track.GetEnd()[0], track.GetEnd()[1]])
|
|
|
|
self.assertEqual(250000, track.GetWidth())
|
|
|
|
self.assertEqual('McNetty', track.GetNetname())
|
|
|
|
|
2023-04-12 15:04:07 +00:00
|
|
|
dup_track = track.Duplicate()
|
|
|
|
self.assertTrue( dup_track.m_Uuid != track.m_Uuid )
|
|
|
|
|
|
|
|
|
2021-02-28 00:18:56 +00:00
|
|
|
def test_arcs(self):
|
2021-06-13 15:19:19 +00:00
|
|
|
arcs = [t.Cast() for t in self.pcb.Tracks() if t.GetClass() == 'PCB_ARC']
|
2021-02-28 00:18:56 +00:00
|
|
|
self.assertEqual(13, len(arcs))
|
|
|
|
arc = sorted(arcs, key=lambda t: [t.GetStart()[0], t.GetStart()[1]])[0]
|
2022-03-07 08:31:08 +00:00
|
|
|
self.assertEqual([29414200, 26500000], [arc.GetCenter()[0], arc.GetCenter()[1]])
|
2022-01-18 12:49:30 +00:00
|
|
|
self.assertEqual([1800, 2250], [round(arc.GetArcAngleStart().AsTenthsOfADegree()),
|
|
|
|
round(arc.GetArcAngleEnd().AsTenthsOfADegree())])
|
2022-03-07 08:31:08 +00:00
|
|
|
self.assertEqual(2414200, round(arc.GetRadius()))
|
2021-02-28 00:18:56 +00:00
|
|
|
|
2023-04-12 15:04:07 +00:00
|
|
|
dup_arc = arc.Duplicate()
|
|
|
|
self.assertTrue( dup_arc.m_Uuid != arc.m_Uuid )
|
|
|
|
|
2021-02-28 00:18:56 +00:00
|
|
|
def test_vias(self):
|
2021-06-13 15:19:19 +00:00
|
|
|
vias = [t.Cast() for t in self.pcb.Tracks() if t.GetClass() == 'PCB_VIA']
|
2021-02-28 00:18:56 +00:00
|
|
|
self.assertEqual(2, len(vias))
|
|
|
|
via = sorted(vias, key=lambda t: [t.GetStart()[0], t.GetStart()[1]])[0]
|
|
|
|
self.assertEqual([29000000, 41000000], [via.GetStart()[0], via.GetStart()[1]])
|
|
|
|
self.assertEqual(400000, via.GetDrillValue())
|
2023-04-12 15:04:07 +00:00
|
|
|
|
|
|
|
dup_via = via.Duplicate()
|
|
|
|
self.assertTrue( dup_via.m_Uuid != via.m_Uuid )
|