FreeCAD

Форк
0
/
TestPathToolController.py 
98 строк · 4.3 Кб
1
# -*- coding: utf-8 -*-
2
# ***************************************************************************
3
# *   Copyright (c) 2017 sliptonic <shopinthewoods@gmail.com>               *
4
# *                                                                         *
5
# *   This program is free software; you can redistribute it and/or modify  *
6
# *   it under the terms of the GNU Lesser General Public License (LGPL)    *
7
# *   as published by the Free Software Foundation; either version 2 of     *
8
# *   the License, or (at your option) any later version.                   *
9
# *   for detail see the LICENCE text file.                                 *
10
# *                                                                         *
11
# *   This program is distributed in the hope that it will be useful,       *
12
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
# *   GNU Library General Public License for more details.                  *
15
# *                                                                         *
16
# *   You should have received a copy of the GNU Library General Public     *
17
# *   License along with this program; if not, write to the Free Software   *
18
# *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
19
# *   USA                                                                   *
20
# *                                                                         *
21
# ***************************************************************************
22

23
import FreeCAD
24
import Path
25
import Path.Tool.Bit as PathToolBit
26
import Path.Tool.Controller as PathToolController
27

28
from Tests.PathTestUtils import PathTestBase
29

30

31
class TestPathToolController(PathTestBase):
32
    def setUp(self):
33
        self.doc = FreeCAD.newDocument("TestPathToolController")
34
        FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True")
35

36
    def tearDown(self):
37
        FreeCAD.closeDocument(self.doc.Name)
38
        FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "")
39

40
    def createTool(self, name="t1", diameter=1.75):
41
        attrs = {
42
            "shape": None,
43
            "name": name,
44
            "parameter": {"Diameter": diameter},
45
            "attribute": [],
46
        }
47
        return PathToolBit.Factory.CreateFromAttrs(attrs, name)
48

49
    def test00(self):
50
        """Verify ToolController templateAttrs"""
51
        t = self.createTool("T1")
52
        tc = PathToolController.Create("TC0", t)
53

54
        tc.Label = "ToolController"
55
        tc.ToolNumber = 7
56
        tc.VertFeed = "3 in/s"
57
        tc.VertFeed = round(tc.VertFeed, 1)
58
        tc.HorizFeed = "10 mm/s"
59
        tc.VertRapid = 40
60
        tc.HorizRapid = 28
61
        tc.SpindleDir = "Reverse"
62
        tc.SpindleSpeed = 12000
63

64
        attrs = tc.Proxy.templateAttrs(tc)
65

66
        self.assertEqual(attrs["name"], "TC0")
67
        self.assertEqual(attrs["label"], "ToolController")
68
        self.assertEqual(attrs["nr"], 7)
69
        self.assertEqual(attrs["vfeed"], "76.2 mm/s")
70
        self.assertEqual(attrs["hfeed"], "10.0 mm/s")
71
        self.assertEqual(attrs["vrapid"], "40.0 mm/s")
72
        self.assertEqual(attrs["hrapid"], "28.0 mm/s")
73
        self.assertEqual(attrs["dir"], "Reverse")
74
        self.assertEqual(attrs["speed"], 12000)
75
        self.assertEqual(attrs["tool"], t.Proxy.templateAttrs(t))
76

77
        return tc
78

79
    def test01(self):
80
        """Verify ToolController template roundtrip."""
81

82
        tc0 = self.test00()
83
        tc1 = PathToolController.FromTemplate(tc0.Proxy.templateAttrs(tc0))
84

85
        self.assertNotEqual(tc0.Name, tc1.Name)
86
        self.assertNotEqual(tc0.Label, tc1.Label)
87
        self.assertEqual(tc0.ToolNumber, tc1.ToolNumber)
88
        self.assertRoughly(tc0.VertFeed, tc1.VertFeed)
89
        self.assertRoughly(tc0.HorizFeed, tc1.HorizFeed)
90
        self.assertRoughly(tc0.VertRapid, tc1.VertRapid)
91
        self.assertRoughly(tc0.HorizRapid, tc1.HorizRapid)
92
        self.assertEqual(tc0.SpindleDir, tc1.SpindleDir)
93
        self.assertRoughly(tc0.SpindleSpeed, tc1.SpindleSpeed)
94
        # These are not valid because the name & label get adjusted if there
95
        # is a conflict. No idea how this could work with the C implementation
96
        # self.assertEqual(tc0.Tool.Name, tc1.Tool.Name)
97
        # self.assertEqual(tc0.Tool.Label, tc1.Tool.Label)
98
        self.assertRoughly(tc0.Tool.Diameter, tc1.Tool.Diameter)
99

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.