FreeCAD

Форк
0
/
TestPathToolChangeGenerator.py 
71 строка · 3.1 Кб
1
# -*- coding: utf-8 -*-
2
# ***************************************************************************
3
# *   Copyright (c) 2021 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 Path
24
import Path.Base.Generator.toolchange as generator
25
import Tests.PathTestUtils as PathTestUtils
26

27
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())
28
Path.Log.trackModule(Path.Log.thisModule())
29

30

31
class TestPathToolChangeGenerator(PathTestUtils.PathTestBase):
32
    def test00(self):
33
        """Test Basic Tool Change Generator Return"""
34

35
        args = {
36
            "toolnumber": 1,
37
            "toollabel": "My Label",
38
            "spindlespeed": 500,
39
            "spindledirection": generator.SpindleDirection.OFF,
40
        }
41

42
        results = generator.generate(**args)
43

44
        # Get a label
45
        self.assertTrue(len(results) == 2)
46
        commentcommand = results[0]
47
        self.assertTrue(isinstance(commentcommand, Path.Command))
48
        self.assertTrue(commentcommand.toGCode() == "(My Label)")
49

50
        # Get a tool command
51
        toolcommand = results[1]
52
        self.assertTrue(toolcommand.Name == "M6")
53

54
        # Turn on the spindle
55
        args["spindledirection"] = generator.SpindleDirection.CW
56
        results = generator.generate(**args)
57
        self.assertTrue(len(results) == 3)
58

59
        speedcommand = results[2]
60
        self.assertTrue(speedcommand.Name == "M3")
61
        self.assertTrue(speedcommand.Parameters["S"] == 500)
62

63
        # speed zero with spindle on
64
        args["spindlespeed"] = 0
65
        results = generator.generate(**args)
66
        self.assertTrue(len(results) == 2)
67
        Path.Log.track(results)
68

69
        # negative spindlespeed
70
        args["spindlespeed"] = -10
71
        self.assertRaises(ValueError, generator.generate, **args)
72

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

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

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

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