コード例 #1
0
    def test_pcb_get_pad(self):
        pcb = kc('newboard board')
        # pcb = BOARD()
        module = kc('MODULE swap newadd')
        #MODULE board list copy pcbnew list swap list 3 pick callargs 1 pick 1 pick list Add callargs pop swap pop swap pop delist
        # module = MODULE(pcb)
        # pcb.Add(module)
        pad = kc('D_PAD swap newadd')

        #pad = D_PAD(module)
        #kc('list list Add callargs pop pop')
        #module.Add(pad)
        # newboard board MODULE swap newadd delist D_PAD swap newadd delist
        try:
            pad.SetShape(PAD_SHAPE_OVAL)  # 5.x nightly
        except:
            pad.SetShape(PAD_OVAL)  # 4.0.7
        pad.SetSize(wxSizeMM(2.0, 3.0))
        pad.SetPosition(wxPointMM(0, 0))

        # easy case
        p1 = pcb.GetPad(wxPointMM(0, 0))

        # top side
        p2 = pcb.GetPad(wxPointMM(0.9, 0.0))

        # bottom side
        p3 = pcb.GetPad(wxPointMM(0, 1.4))

        # TODO: get pad == p1 evaluated as true instead
        #       of relying in the internal C++ object pointer
        self.assertEqual(pad.this, p1.this)
        self.assertEqual(pad.this, p2.this)
        self.assertEqual(pad.this, p3.this)
コード例 #2
0
 def test_pcb_layer_name_set_get(self):
     pcb = kc(
         'newboard board list 31 int list %s list append list SetLayerName callargs board'
         % BACK_COPPER)
     # pcb = BOARD()
     # pcb.SetLayerName(31, BACK_COPPER)
     self.assertEqual(pcb.GetLayerName(31), BACK_COPPER)
コード例 #3
0
ファイル: test_001_pcb_load.py プロジェクト: Vman45/KiCommand
    def test_pcb_module_references(self):

        self.assertTrue(
            kc('Q1,R4,Q3,Q2,Q5,Q4,Q7,Q6,Q8,U1,U3,U2,R7,C12,C11,C10,C14,R16,'
               'R17,R14,R15,R12,R13,R10,R11,R3,R18,R19,C9,C8,U4,C3,C2,C1,C7,'
               'C6,C5,C4,P2,P3,R6,P1,P6,P4,P5,R28,R8,R9,R23,RV1,R27,R26,R5,R25,'
               'R24,RV2,R20,R22,D8,D9,D6,D7,D4,D5,D2,D3,R21,D1 '
               'split iset list referencetext iset ='))
コード例 #4
0
 def setUp(self):
     file = os.path.join(
         KICAD_INSTALL,
         r'share\kicad\demos\complex_hierarchy\complex_hierarchy.kicad_pcb')
     self.pcb = kc('clear pcbnew list "%s" list list LoadBoard callargs '
                   'delist Board spush board' % file)
     #self.pcb = LoadBoard("data/complex_hierarchy.kicad_pcb")
     self.TITLE = "Test Board"
     self.COMMENT1 = "For load/save test"
     self.FILENAME = tempfile.mktemp() + ".kicad_pcb"
コード例 #5
0
    def test_pcb_layer_id_get(self):
        # pcb = BOARD()
        pcb = kc('newboard board')
        b_cu_id = kc('%s layernums delist' % B_CU)

        #b_cu_id = pcb.GetLayerID(B_CU)
        #pcb.SetLayerName(b_cu_id, NEW_NAME)
        kc('%d,%s' % (b_cu_id, NEW_NAME))
        kc('board list swap int list SetLayerName callargs pop')

        # ensure we can get the ID for the new name
        self.assertEqual(pcb.GetLayerID(NEW_NAME), b_cu_id)

        # ensure we can get to the ID via the STD name too
        self.assertEqual(pcb.GetLayerID(B_CU), b_cu_id)
コード例 #6
0
    def test_pcb_bounding_box(self):
        kc(':persist newboard "Elements Create a new empty board and make it the current board." pcbnew list BOARD call delist Board spush ;'
           )
        pcb = kc('clear newboard board')
        track = kc('clear 0.5 mm t param F.Cu l param 10,10,20,30 mm '
                   'drawpoly delist delist')
        wval, hval = kc(
            'list GetClearance call '
            'copy append copy 30,-10,0.5 mm append sum swap '
            '20,-10,0.5 mm append sum',
            returnval=-1)

        #             float is because integer doesn't compare to float in assertAlmostEqual----+
        #             ilist is to create a list from the wxRect---------------------------+     |
        #             copy is to keep bb reference in memory----------v                   v     v
        height, width = kc(
            'board list ComputeBoundingBox call GetSize call delist ilist float'
        )

        #height, width = bounding_box.GetSize()
        self.assertAlmostEqual(ToMM(height), ToMM(hval), 2)
        self.assertAlmostEqual(ToMM(width), ToMM(wval), 2)

        # pcb = BOARD()
        # track = TRACK(pcb)
        # pcb.Add(track)

        # track.SetStartEnd(wxPointMM(10.0, 10.0),
        # wxPointMM(20.0, 30.0))

        # track.SetStart(wxPointMM(10.0, 10.0))
        # track.SetEnd  (wxPointMM(20.0, 30.0))

        # track.SetWidth(FromMM(0.5))

        #!!! THIS FAILS? == 0.0 x 0.0 ??
        height, width = ToMM(pcb.ComputeBoundingBox().GetSize())
        # bounding_box = pcb.ComputeBoundingBox()
        # height, width = ToMM(bounding_box.GetSize())

        clearance = ToMM(track.GetClearance() * 2)
        self.assertAlmostEqual(width, (30 - 10) + 0.5 + clearance, 2)
        self.assertAlmostEqual(height, (20 - 10) + 0.5 + clearance, 2)
コード例 #7
0
    def test_pcb_get_track_count(self):
        # :persist newboard "Elements Create a new empty board and make it the current board." pcbnew list BOARD call delist Board spush ;
        # : newtrack "Elements Create bare, undefined track on current board" pcbnew list board list list TRACK callargs board list swap list Add callargs ;

        # new board
        pcb = kc('clear pcbnew list BOARD call delist Board spush board')

        num = kc('list GetNumSegmTrack call delist')
        self.assertEqual(num, 0)

        # Creates a new track
        kc('clear pcbnew list board list list TRACK callargs')

        # Adds track to Board
        kc('Board scopy list swap list Add callargs')

        # Obtain the number of tracks on this board
        num = kc('board list GetNumSegmTrack call delist')
        self.assertEqual(num, 1)

        #kc(':persist newadd "Elements [TYPE PARENT] Add create a element of TYPE (TRACK, PAD) and add it to the PARENT." pcbnew list swap board list list swap stack')
        # Creates a new track
        # Adds track to Board
        kc('clear pcbnew list board list list TRACK callargs')
        kc('board list swap list Add callargs')
        num = kc('board list GetNumSegmTrack call delist')
        self.assertEqual(num, 2)
コード例 #8
0
 def test_pcb_find_module(self):
     reference = kc(
         'board list P1 list list FindModule callargs GetReference call delist'
     )
     self.assertEqual(reference, 'P1')
コード例 #9
0
ファイル: test_001_pcb_load.py プロジェクト: Vman45/KiCommand
    def test_pcb_netcount(self):
        #self.assertTrue(kc('board list GetNetCount call 51 int = delist')[-1])

        self.assertEqual(kc('board list GetNetCount call delist'), 53)
コード例 #10
0
ファイル: test_001_pcb_load.py プロジェクト: Vman45/KiCommand
    def test_pcb_modules(self):
        #self.assertEqual(len(modules), 72)

        self.assertTrue(kc('clear modules ilist len list 68 int = delist'))
コード例 #11
0
ファイル: test_001_pcb_load.py プロジェクト: Vman45/KiCommand
    def test_pcb_track_count(self):
        # self.assertEqual(len(tracks),361)

        #self.assertTrue(kc('clear tracks ilist len list 360 int = delist')[-1])
        self.assertEqual(kc('clear tracks ilist len'), 360)
コード例 #12
0
ファイル: test_001_pcb_load.py プロジェクト: Vman45/KiCommand
 def setUp(self):
     file = os.path.join(
         KICAD_INSTALL,
         r'share\kicad\demos\complex_hierarchy\complex_hierarchy.kicad_pcb')
     self.pcb = kc('clear pcbnew list "%s" list list LoadBoard callargs '
                   'delist Board spush Board scopy' % file)
コード例 #13
0
ファイル: test_001_pcb_load.py プロジェクト: Vman45/KiCommand
 def tearDown(self):
     kc('Board spop clear')