FreeCAD

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

24
import FreeCAD
25

26
import Path
27
import Tests.PathTestUtils as PathTestUtils
28
from Path.Post.scripts import refactored_test_post as postprocessor
29

30

31
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())
32
Path.Log.trackModule(Path.Log.thisModule())
33

34

35
class TestRefactoredTestPostGCodes(PathTestUtils.PathTestBase):
36
    """Test the refactored_test_post.py postprocessor G codes."""
37

38
    @classmethod
39
    def setUpClass(cls):
40
        """setUpClass()...
41

42
        This method is called upon instantiation of this test class.  Add code
43
        and objects here that are needed for the duration of the test() methods
44
        in this class.  In other words, set up the 'global' test environment
45
        here; use the `setUp()` method to set up a 'local' test environment.
46
        This method does not have access to the class `self` reference, but it
47
        is able to call static methods within this same class.
48
        """
49
        # Open existing FreeCAD document with test geometry
50
        FreeCAD.newDocument("Unnamed")
51

52
    @classmethod
53
    def tearDownClass(cls):
54
        """tearDownClass()...
55

56
        This method is called prior to destruction of this test class.  Add
57
        code and objects here that cleanup the test environment after the
58
        test() methods in this class have been executed.  This method does
59
        not have access to the class `self` reference.  This method is able
60
        to call static methods within this same class.
61
        """
62
        # Close geometry document without saving
63
        FreeCAD.closeDocument(FreeCAD.ActiveDocument.Name)
64

65
    # Setup and tear down methods called before and after each unit test
66

67
    def setUp(self):
68
        """setUp()...
69

70
        This method is called prior to each `test()` method.  Add code and
71
        objects here that are needed for multiple `test()` methods.
72
        """
73
        self.doc = FreeCAD.ActiveDocument
74
        self.con = FreeCAD.Console
75
        self.docobj = FreeCAD.ActiveDocument.addObject("Path::Feature", "testpath")
76
        #
77
        # Re-initialize all of the values before doing a test.
78
        #
79
        postprocessor.UNITS = "G21"
80
        postprocessor.init_values(postprocessor.global_values)
81

82
    def tearDown(self):
83
        """tearDown()...
84

85
        This method is called after each test() method. Add cleanup instructions here.
86
        Such cleanup instructions will likely undo those in the setUp() method.
87
        """
88
        FreeCAD.ActiveDocument.removeObject("testpath")
89

90
    def single_compare(self, path, expected, args, debug=False):
91
        """Perform a test with a single comparison."""
92
        nl = "\n"
93
        self.docobj.Path = Path.Path(path)
94
        postables = [self.docobj]
95
        gcode = postprocessor.export(postables, "-", args)
96
        if debug:
97
            print(f"--------{nl}{gcode}--------{nl}")
98
        self.assertEqual(gcode, expected)
99

100
    def compare_third_line(self, path_string, expected, args, debug=False):
101
        """Perform a test with a single comparison to the third line of the output."""
102
        nl = "\n"
103
        if path_string:
104
            self.docobj.Path = Path.Path([Path.Command(path_string)])
105
        else:
106
            self.docobj.Path = Path.Path([])
107
        postables = [self.docobj]
108
        gcode = postprocessor.export(postables, "-", args)
109
        if debug:
110
            print(f"--------{nl}{gcode}--------{nl}")
111
        self.assertEqual(gcode.splitlines()[2], expected)
112

113
    #############################################################################
114
    #
115
    # The tests are organized into groups:
116
    #
117
    #   00000 - 00099  tests that don't fit any other category
118
    #   00100 - 09999  tests for all of the various arguments/options
119
    #   10000 - 19999  tests for the various G codes at 10000 + 10 * g_code_value
120
    #   20000 - 29999  tests for the various M codes at 20000 + 10 * m_code_value
121
    #
122
    #############################################################################
123

124
    def test10000(self):
125
        """Test G0 command Generation."""
126
        self.compare_third_line(
127
            "G0 X10 Y20 Z30 A40 B50 C60 U70 V80 W90",
128
            ("G0 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 " "U70.000 V80.000 W90.000"),
129
            "",
130
        )
131
        self.compare_third_line(
132
            "G00 X10 Y20 Z30 A40 B50 C60 U70 V80 W90",
133
            ("G00 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 " "U70.000 V80.000 W90.000"),
134
            "",
135
        )
136

137
    #############################################################################
138

139
    def test10010(self):
140
        """Test G1 command Generation."""
141
        self.compare_third_line(
142
            "G1 X10 Y20 Z30 A40 B50 C60 U70 V80 W90 F1.23456",
143
            (
144
                "G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 "
145
                "U70.000 V80.000 W90.000 F74.074"
146
            ),
147
            "",
148
        )
149
        self.compare_third_line(
150
            "G01 X10 Y20 Z30 A40 B50 C60 U70 V80 W90 F1.23456",
151
            (
152
                "G01 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 "
153
                "U70.000 V80.000 W90.000 F74.074"
154
            ),
155
            "",
156
        )
157
        # Test argument order
158
        self.compare_third_line(
159
            "G1 F1.23456 Z30 V80 C60 W90 X10 B50 U70 Y20 A40",
160
            (
161
                "G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 "
162
                "U70.000 V80.000 W90.000 F74.074"
163
            ),
164
            "",
165
        )
166
        self.compare_third_line(
167
            "G1 X10 Y20 Z30 A40 B50 C60 U70 V80 W90 F1.23456",
168
            (
169
                "G1 X0.3937 Y0.7874 Z1.1811 A1.5748 B1.9685 C2.3622 "
170
                "U2.7559 V3.1496 W3.5433 F2.9163"
171
            ),
172
            "--inches",
173
        )
174

175
    #############################################################################
176

177
    def test10020(self):
178
        """Test G2 command Generation."""
179
        #
180
        self.compare_third_line(
181
            "G2 X10 Y20 Z30 I40 J50 P60 F1.23456",
182
            "G2 X10.000 Y20.000 Z30.000 I40.000 J50.000 P60 F74.074",
183
            "",
184
        )
185
        self.compare_third_line(
186
            "G02 X10 Y20 Z30 I40 J50 P60 F1.23456",
187
            "G02 X10.000 Y20.000 Z30.000 I40.000 J50.000 P60 F74.074",
188
            "",
189
        )
190
        self.compare_third_line(
191
            "G2 X10 Y20 Z30 R40 P60 F1.23456",
192
            "G2 X10.000 Y20.000 Z30.000 R40.000 P60 F74.074",
193
            "",
194
        )
195
        self.compare_third_line(
196
            "G2 X10 Y20 Z30 I40 J50 P60 F1.23456",
197
            "G2 X0.3937 Y0.7874 Z1.1811 I1.5748 J1.9685 P60 F2.9163",
198
            "--inches",
199
        )
200
        self.compare_third_line(
201
            "G2 X10 Y20 Z30 R40 P60 F1.23456",
202
            "G2 X0.3937 Y0.7874 Z1.1811 R1.5748 P60 F2.9163",
203
            "--inches",
204
        )
205

206
    #############################################################################
207

208
    def test10030(self):
209
        """Test G3 command Generation."""
210
        self.compare_third_line(
211
            "G3 X10 Y20 Z30 I40 J50 P60 F1.23456",
212
            "G3 X10.000 Y20.000 Z30.000 I40.000 J50.000 P60 F74.074",
213
            "",
214
        )
215
        self.compare_third_line(
216
            "G03 X10 Y20 Z30 I40 J50 P60 F1.23456",
217
            "G03 X10.000 Y20.000 Z30.000 I40.000 J50.000 P60 F74.074",
218
            "",
219
        )
220
        self.compare_third_line(
221
            "G3 X10 Y20 Z30 R40 P60 F1.23456",
222
            "G3 X10.000 Y20.000 Z30.000 R40.000 P60 F74.074",
223
            "",
224
        )
225
        self.compare_third_line(
226
            "G3 X10 Y20 Z30 I40 J50 P60 F1.23456",
227
            "G3 X0.3937 Y0.7874 Z1.1811 I1.5748 J1.9685 P60 F2.9163",
228
            "--inches",
229
        )
230
        self.compare_third_line(
231
            "G3 X10 Y20 Z30 R40 P60 F1.23456",
232
            "G3 X0.3937 Y0.7874 Z1.1811 R1.5748 P60 F2.9163",
233
            "--inches",
234
        )
235

236
    #############################################################################
237

238
    def test10040(self):
239
        """Test G4 command Generation."""
240
        # Should some sort of "precision" be applied to the P parameter?
241
        # The code as currently written does not do so intentionally.
242
        # The P parameter indicates "time to wait" where a 0.001 would
243
        # be a millisecond wait, so more than 3 or 4 digits of precision
244
        # might be useful.
245
        self.compare_third_line("G4 P1.23456", "G4 P1.23456", "")
246
        self.compare_third_line("G04 P1.23456", "G04 P1.23456", "")
247
        self.compare_third_line("G4 P1.23456", "G4 P1.23456", "--inches")
248

249
    #############################################################################
250

251
    def test10070(self):
252
        """Test G7 command Generation."""
253
        self.compare_third_line("G7", "G7", "")
254

255
    #############################################################################
256

257
    def test10080(self):
258
        """Test G8 command Generation."""
259
        self.compare_third_line("G8", "G8", "")
260

261
    #############################################################################
262

263
    def test10100(self):
264
        """Test G10 command Generation."""
265
        self.compare_third_line("G10 L1 P2 Z1.23456", "G10 L1 Z1.235 P2", "")
266
        self.compare_third_line(
267
            "G10 L1 P2 R1.23456 I2.34567 J3.456789 Q3",
268
            "G10 L1 I2.346 J3.457 R1.235 P2 Q3",
269
            "",
270
        )
271
        self.compare_third_line(
272
            "G10 L2 P3 X1.23456 Y2.34567 Z3.456789",
273
            "G10 L2 X1.235 Y2.346 Z3.457 P3",
274
            "",
275
        )
276
        self.compare_third_line("G10 L2 P0 X0 Y0 Z0", "G10 L2 X0.000 Y0.000 Z0.000 P0", "")
277
        self.compare_third_line(
278
            "G10 L10 P1 X1.23456 Y2.34567 Z3.456789",
279
            "G10 L10 X1.235 Y2.346 Z3.457 P1",
280
            "",
281
        )
282
        self.compare_third_line(
283
            "G10 L10 P2 R1.23456 I2.34567 J3.456789 Q3",
284
            "G10 L10 I2.346 J3.457 R1.235 P2 Q3",
285
            "",
286
        )
287
        self.compare_third_line(
288
            "G10 L11 P1 X1.23456 Y2.34567 Z3.456789",
289
            "G10 L11 X1.235 Y2.346 Z3.457 P1",
290
            "",
291
        )
292
        self.compare_third_line(
293
            "G10 L11 P2 R1.23456 I2.34567 J3.456789 Q3",
294
            "G10 L11 I2.346 J3.457 R1.235 P2 Q3",
295
            "",
296
        )
297
        self.compare_third_line(
298
            "G10 L20 P9 X1.23456 Y2.34567 Z3.456789",
299
            "G10 L20 X1.235 Y2.346 Z3.457 P9",
300
            "",
301
        )
302

303
    #############################################################################
304

305
    def test10170(self):
306
        """Test G17 command Generation."""
307
        self.compare_third_line("G17", "G17", "")
308

309
    #############################################################################
310

311
    def test10171(self):
312
        """Test G17.1 command Generation."""
313
        self.compare_third_line("G17.1", "G17.1", "")
314

315
    #############################################################################
316

317
    def test10180(self):
318
        """Test G18 command Generation."""
319
        self.compare_third_line("G18", "G18", "")
320

321
    #############################################################################
322

323
    def test10181(self):
324
        """Test G18.1 command Generation."""
325
        self.compare_third_line("G18.1", "G18.1", "")
326

327
    #############################################################################
328

329
    def test10190(self):
330
        """Test G19 command Generation."""
331
        self.compare_third_line("G19", "G19", "")
332

333
    #############################################################################
334

335
    def test10191(self):
336
        """Test G19.1 command Generation."""
337
        self.compare_third_line("G19.1", "G19.1", "")
338

339
    #############################################################################
340

341
    def test10200(self):
342
        """Test G20 command Generation."""
343
        self.compare_third_line("G20", "G20", "")
344

345
    #############################################################################
346

347
    def test10210(self):
348
        """Test G21 command Generation."""
349
        self.compare_third_line("G21", "G21", "")
350

351
    #############################################################################
352

353
    def test10280(self):
354
        """Test G28 command Generation."""
355
        self.compare_third_line("G28", "G28", "")
356
        self.compare_third_line(
357
            "G28 X10 Y20 Z30 A40 B50 C60 U70 V80 W90",
358
            ("G28 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 " "U70.000 V80.000 W90.000"),
359
            "",
360
        )
361

362
    #############################################################################
363

364
    def test10281(self):
365
        """Test G28.1 command Generation."""
366
        self.compare_third_line("G28.1", "G28.1", "")
367

368
    #############################################################################
369

370
    def test10300(self):
371
        """Test G30 command Generation."""
372
        self.compare_third_line("G30", "G30", "")
373
        self.compare_third_line(
374
            "G30 X10 Y20 Z30 A40 B50 C60 U70 V80 W90",
375
            ("G30 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 " "U70.000 V80.000 W90.000"),
376
            "",
377
        )
378

379
    #############################################################################
380

381
    def test10382(self):
382
        """Test G38.2 command Generation."""
383
        self.compare_third_line(
384
            "G38.2 X10 Y20 Z30 A40 B50 C60 U70 V80 W90 F123",
385
            (
386
                "G38.2 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 "
387
                "U70.000 V80.000 W90.000 F7380.000"
388
            ),
389
            "",
390
        )
391

392
    #############################################################################
393

394
    def test10383(self):
395
        """Test G38.3 command Generation."""
396
        self.compare_third_line(
397
            "G38.3 X10 Y20 Z30 A40 B50 C60 U70 V80 W90 F123",
398
            (
399
                "G38.3 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 "
400
                "U70.000 V80.000 W90.000 F7380.000"
401
            ),
402
            "",
403
        )
404

405
    #############################################################################
406

407
    def test10384(self):
408
        """Test G38.4 command Generation."""
409
        self.compare_third_line(
410
            "G38.4 X10 Y20 Z30 A40 B50 C60 U70 V80 W90 F123",
411
            (
412
                "G38.4 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 "
413
                "U70.000 V80.000 W90.000 F7380.000"
414
            ),
415
            "",
416
        )
417

418
    #############################################################################
419

420
    def test10385(self):
421
        """Test G38.5 command Generation."""
422
        self.compare_third_line(
423
            "G38.5 X10 Y20 Z30 A40 B50 C60 U70 V80 W90 F123",
424
            (
425
                "G38.5 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 "
426
                "U70.000 V80.000 W90.000 F7380.000"
427
            ),
428
            "",
429
        )
430

431
    #############################################################################
432

433
    def test10301(self):
434
        """Test G30.1 command Generation."""
435
        self.compare_third_line("G30.1", "G30.1", "")
436

437
    #############################################################################
438

439
    def test10400(self):
440
        """Test G40 command Generation."""
441
        self.compare_third_line("G40", "G40", "")
442
        self.compare_third_line("G40", "G40", "--inches")
443

444
    #############################################################################
445

446
    def test10410(self):
447
        """Test G41 command Generation."""
448
        self.compare_third_line("G41 D1.23456", "G41 D1", "")
449
        self.compare_third_line("G41 D0", "G41 D0", "")
450
        self.compare_third_line("G41 D1.23456", "G41 D1", "--inches")
451

452
    #############################################################################
453

454
    def test10411(self):
455
        """Test G41.1 command Generation."""
456
        self.compare_third_line("G41.1 D1.23456 L3", "G41.1 D1.235 L3", "")
457
        self.compare_third_line("G41.1 D1.23456 L3", "G41.1 D0.0486 L3", "--inches")
458

459
    #############################################################################
460

461
    def test10420(self):
462
        """Test G42 command Generation."""
463
        self.compare_third_line("G42 D1.23456", "G42 D1", "")
464
        self.compare_third_line("G42 D0", "G42 D0", "")
465
        self.compare_third_line("G42 D1.23456", "G42 D1", "--inches")
466

467
    #############################################################################
468

469
    def test10421(self):
470
        """Test G42.1 command Generation."""
471
        self.compare_third_line("G42.1 D1.23456 L3", "G42.1 D1.235 L3", "")
472
        self.compare_third_line("G42.1 D1.23456 L3", "G42.1 D0.0486 L3", "--inches")
473

474
    #############################################################################
475

476
    def test10430(self):
477
        """Test G43 command Generation."""
478
        self.compare_third_line("G43", "G43", "")
479
        self.compare_third_line("G43 H1.23456", "G43 H1", "")
480
        self.compare_third_line("G43 H0", "G43 H0", "")
481
        self.compare_third_line("G43 H1.23456", "G43 H1", "--inches")
482

483
    #############################################################################
484

485
    def test10431(self):
486
        """Test G43.1 command Generation."""
487
        self.compare_third_line(
488
            (
489
                "G43.1 X1.234567 Y2.345678 Z3.456789 A4.567891 B5.678912 C6.789123 "
490
                "U7.891234 V8.912345 W9.123456"
491
            ),
492
            "G43.1 X1.235 Y2.346 Z3.457 A4.568 B5.679 C6.789 U7.891 V8.912 W9.123",
493
            "",
494
        )
495
        self.compare_third_line(
496
            (
497
                "G43.1 X1.234567 Y2.345678 Z3.456789 A4.567891 B5.678912 C6.789123 "
498
                "U7.891234 V8.912345 W9.123456"
499
            ),
500
            ("G43.1 X0.0486 Y0.0923 Z0.1361 A0.1798 B0.2236 C0.2673 " "U0.3107 V0.3509 W0.3592"),
501
            "--inches",
502
        )
503

504
    #############################################################################
505

506
    def test10432(self):
507
        """Test G43.2 command Generation."""
508
        self.compare_third_line("G43.2 H1.23456", "G43.2 H1", "")
509

510
    #############################################################################
511

512
    def test10490(self):
513
        """Test G49 command Generation."""
514
        self.compare_third_line("G49", "G49", "")
515

516
    #############################################################################
517

518
    def test10520(self):
519
        """Test G52 command Generation."""
520
        self.single_compare(
521
            [
522
                Path.Command(
523
                    (
524
                        "G52 X1.234567 Y2.345678 Z3.456789 A4.567891 B5.678912 "
525
                        "C6.789123 U7.891234 V8.912345 W9.123456"
526
                    )
527
                ),
528
                Path.Command("G52 X0 Y0.0 Z0.00 A0.000 B0.0000 C0.00000 U0.000000 V0 W0"),
529
            ],
530
            """G90
531
G21
532
G52 X1.235 Y2.346 Z3.457 A4.568 B5.679 C6.789 U7.891 V8.912 W9.123
533
G52 X0.000 Y0.000 Z0.000 A0.000 B0.000 C0.000 U0.000 V0.000 W0.000
534
""",
535
            "",
536
        )
537
        self.single_compare(
538
            [
539
                Path.Command(
540
                    (
541
                        "G52 X1.234567 Y2.345678 Z3.456789 A4.567891 B5.678912 "
542
                        "C6.789123 U7.891234 V8.912345 W9.123456"
543
                    )
544
                ),
545
                Path.Command("G52 X0 Y0.0 Z0.00 A0.000 B0.0000 C0.00000 U0.000000 V0 W0"),
546
            ],
547
            """G90
548
G20
549
G52 X0.0486 Y0.0923 Z0.1361 A0.1798 B0.2236 C0.2673 U0.3107 V0.3509 W0.3592
550
G52 X0.0000 Y0.0000 Z0.0000 A0.0000 B0.0000 C0.0000 U0.0000 V0.0000 W0.0000
551
""",
552
            "--inches",
553
        )
554

555
    #############################################################################
556

557
    #     def test10530(self):
558
    #         """Test G53 command Generation."""
559
    #         #
560
    #         # G53 is handled differently in different gcode interpreters.
561
    #         # It always means "absolute machine coordinates", but it is
562
    #         # used like G0 in Centroid and Mach4, and used in front of
563
    #         # G0 or G1 on the same line in Fanuc, Grbl, LinuxCNC, and Tormach.
564
    #         # It is not modal in any gcode interpreter I currently know about.
565
    #         # The current FreeCAD code treats G53 as modal (like G54-G59.9).
566
    #         # The current refactored postprocessor code does not
567
    #         # handle having two G-commands on the same line.
568
    #         #
569
    #         c = Path.Command("G53 G0 X10 Y20 Z30 A40 B50 C60 U70 V80 W90")
570

571
    #         self.docobj.Path = Path.Path([c])
572
    #         postables = [self.docobj]
573

574
    #         expected = """G90
575
    # G21
576
    # G53 G0 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000
577
    # """
578
    #         args = ""
579
    #         gcode = postprocessor.export(postables, "-", args)
580
    #         print("--------\n" + gcode + "--------\n")
581
    #         self.assertEqual(gcode, expected)
582

583
    #############################################################################
584

585
    def test10540(self):
586
        """Test G54 command Generation."""
587
        self.compare_third_line("G54", "G54", "")
588

589
    #############################################################################
590

591
    def test10541(self):
592
        """Test G54.1 command Generation."""
593
        #
594
        # Some gcode interpreters use G54.1 P- to select additional
595
        # work coordinate systems.
596
        #
597
        self.compare_third_line("G54.1 P2.34567", "G54.1 P2", "")
598

599
    #############################################################################
600

601
    def test10550(self):
602
        """Test G55 command Generation."""
603
        self.compare_third_line("G55", "G55", "")
604

605
    #############################################################################
606

607
    def test10560(self):
608
        """Test G56 command Generation."""
609
        self.compare_third_line("G56", "G56", "")
610

611
    #############################################################################
612

613
    def test10570(self):
614
        """Test G57 command Generation."""
615
        self.compare_third_line("G57", "G57", "")
616

617
    #############################################################################
618

619
    def test10580(self):
620
        """Test G58 command Generation."""
621
        self.compare_third_line("G58", "G58", "")
622

623
    #############################################################################
624

625
    def test10590(self):
626
        """Test G59 command Generation."""
627
        self.compare_third_line("G59", "G59", "")
628
        #
629
        # Some gcode interpreters use G59 P- to select additional
630
        # work coordinate systems.  This is considered somewhat
631
        # obsolete and is being replaced by G54.1 P- instead.
632
        #
633
        self.compare_third_line("G59 P2.34567", "G59 P2", "")
634

635
    #############################################################################
636

637
    def test10591(self):
638
        """Test G59.1 command Generation."""
639
        self.compare_third_line("G59.1", "G59.1", "")
640

641
    #############################################################################
642

643
    def test10592(self):
644
        """Test G59.2 command Generation."""
645
        self.compare_third_line("G59.2", "G59.2", "")
646

647
    #############################################################################
648

649
    def test10593(self):
650
        """Test G59.3 command Generation."""
651
        self.compare_third_line("G59.3", "G59.3", "")
652

653
    #############################################################################
654

655
    def test10594(self):
656
        """Test G59.4 command Generation."""
657
        self.compare_third_line("G59.4", "G59.4", "")
658

659
    #############################################################################
660

661
    def test10595(self):
662
        """Test G59.5 command Generation."""
663
        self.compare_third_line("G59.5", "G59.5", "")
664

665
    #############################################################################
666

667
    def test10596(self):
668
        """Test G59.6 command Generation."""
669
        self.compare_third_line("G59.6", "G59.6", "")
670

671
    #############################################################################
672

673
    def test10597(self):
674
        """Test G59.7 command Generation."""
675
        self.compare_third_line("G59.7", "G59.7", "")
676

677
    #############################################################################
678

679
    def test10598(self):
680
        """Test G59.8 command Generation."""
681
        self.compare_third_line("G59.8", "G59.8", "")
682

683
    #############################################################################
684

685
    def test10599(self):
686
        """Test G59.9 command Generation."""
687
        self.compare_third_line("G59.9", "G59.9", "")
688

689
    #############################################################################
690

691
    def test10610(self):
692
        """Test G61 command Generation."""
693
        self.compare_third_line("G61", "G61", "")
694

695
    #############################################################################
696

697
    def test10611(self):
698
        """Test G61.1 command Generation."""
699
        self.compare_third_line("G61.1", "G61.1", "")
700

701
    #############################################################################
702

703
    def test10640(self):
704
        """Test G64 command Generation."""
705
        self.compare_third_line("G64", "G64", "")
706
        self.compare_third_line("G64 P3.456789", "G64 P3.457", "")
707
        self.compare_third_line("G64 P3.456789 Q4.567891", "G64 P3.457 Q4.568", "")
708
        self.compare_third_line("G64 P3.456789 Q4.567891", "G64 P0.1361 Q0.1798", "--inches")
709

710
    #############################################################################
711

712
    def test10730(self):
713
        """Test G73 command Generation."""
714
        path = [
715
            Path.Command("G0 X1 Y2"),
716
            Path.Command("G0 Z8"),
717
            Path.Command("G90"),
718
            Path.Command("G99"),
719
            Path.Command("G73 X1 Y2 Z0 F123 Q1.5 R5"),
720
            Path.Command("G80"),
721
            Path.Command("G90"),
722
        ]
723
        self.single_compare(
724
            path,
725
            """G90
726
G21
727
G0 X1.000 Y2.000
728
G0 Z8.000
729
G90
730
G99
731
G73 X1.000 Y2.000 Z0.000 R5.000 Q1.500 F7380.000
732
G80
733
G90
734
""",
735
            "",
736
        )
737
        self.single_compare(
738
            path,
739
            """G90
740
G21
741
G0 X1.000 Y2.000
742
G0 Z8.000
743
G90
744
G0 X1.000 Y2.000
745
G1 Z5.000 F7380.000
746
G1 Z3.500 F7380.000
747
G0 Z3.750
748
G0 Z3.575
749
G1 Z2.000 F7380.000
750
G0 Z2.250
751
G0 Z2.075
752
G1 Z0.500 F7380.000
753
G0 Z0.750
754
G0 Z0.575
755
G1 Z0.000 F7380.000
756
G0 Z5.000
757
G90
758
""",
759
            "--translate_drill",
760
        )
761
        self.single_compare(
762
            path,
763
            """(Begin preamble)
764
G90
765
G21
766
(Begin operation)
767
G0 X1.000 Y2.000
768
G0 Z8.000
769
G90
770
( G99 )
771
( G73 X1.000 Y2.000 Z0.000 R5.000 Q1.500 F7380.000 )
772
G0 X1.000 Y2.000
773
G1 Z5.000 F7380.000
774
G1 Z3.500 F7380.000
775
G0 Z3.750
776
G0 Z3.575
777
G1 Z2.000 F7380.000
778
G0 Z2.250
779
G0 Z2.075
780
G1 Z0.500 F7380.000
781
G0 Z0.750
782
G0 Z0.575
783
G1 Z0.000 F7380.000
784
G0 Z5.000
785
( G80 )
786
G90
787
(Finish operation: testpath)
788
(Begin postamble)
789
""",
790
            "--comments --translate_drill",
791
        )
792
        #
793
        # Re-initialize all of the values before doing more tests.
794
        #
795
        postprocessor.UNITS = "G21"
796
        postprocessor.init_values(postprocessor.global_values)
797
        #
798
        # Test translate_drill with G83 and G91.
799
        path = [
800
            Path.Command("G0 X1 Y2"),
801
            Path.Command("G0 Z8"),
802
            Path.Command("G91"),
803
            Path.Command("G99"),
804
            Path.Command("G73 X1 Y2 Z0 F123 Q1.5 R5"),
805
            Path.Command("G80"),
806
            Path.Command("G90"),
807
        ]
808
        self.single_compare(
809
            path,
810
            """G90
811
G21
812
G0 X1.000 Y2.000
813
G0 Z8.000
814
G91
815
G99
816
G73 X1.000 Y2.000 Z0.000 R5.000 Q1.500 F7380.000
817
G80
818
G90
819
""",
820
            "--no-comments --no-translate_drill",
821
        )
822
        self.single_compare(
823
            path,
824
            """G90
825
G21
826
G0 X1.000 Y2.000
827
G0 Z8.000
828
G91
829
G90
830
G0 Z13.000
831
G0 X2.000 Y4.000
832
G1 Z11.500 F7380.000
833
G0 Z11.750
834
G0 Z11.575
835
G1 Z10.000 F7380.000
836
G0 Z10.250
837
G0 Z10.075
838
G1 Z8.500 F7380.000
839
G0 Z8.750
840
G0 Z8.575
841
G1 Z8.000 F7380.000
842
G0 Z13.000
843
G91
844
G90
845
""",
846
            "--translate_drill",
847
        )
848
        self.single_compare(
849
            path,
850
            """(Begin preamble)
851
G90
852
G21
853
(Begin operation)
854
G0 X1.000 Y2.000
855
G0 Z8.000
856
G91
857
( G99 )
858
( G73 X1.000 Y2.000 Z0.000 R5.000 Q1.500 F7380.000 )
859
G90
860
G0 Z13.000
861
G0 X2.000 Y4.000
862
G1 Z11.500 F7380.000
863
G0 Z11.750
864
G0 Z11.575
865
G1 Z10.000 F7380.000
866
G0 Z10.250
867
G0 Z10.075
868
G1 Z8.500 F7380.000
869
G0 Z8.750
870
G0 Z8.575
871
G1 Z8.000 F7380.000
872
G0 Z13.000
873
G91
874
( G80 )
875
G90
876
(Finish operation: testpath)
877
(Begin postamble)
878
""",
879
            "--comments --translate_drill",
880
        )
881

882
    #############################################################################
883

884
    def test10810(self):
885
        """Test G81 command Generation."""
886
        path = [
887
            Path.Command("G0 X1 Y2"),
888
            Path.Command("G0 Z8"),
889
            Path.Command("G90"),
890
            Path.Command("G99"),
891
            Path.Command("G81 X1 Y2 Z0 F123 R5"),
892
            Path.Command("G80"),
893
            Path.Command("G90"),
894
        ]
895
        self.single_compare(
896
            path,
897
            """G90
898
G21
899
G0 X1.000 Y2.000
900
G0 Z8.000
901
G90
902
G99
903
G81 X1.000 Y2.000 Z0.000 R5.000 F7380.000
904
G80
905
G90
906
""",
907
            "",
908
        )
909
        self.single_compare(
910
            path,
911
            """G90
912
G21
913
G0 X1.000 Y2.000
914
G0 Z8.000
915
G90
916
G0 X1.000 Y2.000
917
G1 Z5.000 F7380.000
918
G1 Z0.000 F7380.000
919
G0 Z5.000
920
G90
921
""",
922
            "--translate_drill",
923
        )
924
        self.single_compare(
925
            path,
926
            """(Begin preamble)
927
G90
928
G21
929
(Begin operation)
930
G0 X1.000 Y2.000
931
G0 Z8.000
932
G90
933
( G99 )
934
( G81 X1.000 Y2.000 Z0.000 R5.000 F7380.000 )
935
G0 X1.000 Y2.000
936
G1 Z5.000 F7380.000
937
G1 Z0.000 F7380.000
938
G0 Z5.000
939
( G80 )
940
G90
941
(Finish operation: testpath)
942
(Begin postamble)
943
""",
944
            "--comments --translate_drill",
945
        )
946
        #
947
        # Re-initialize all of the values before doing more tests.
948
        #
949
        postprocessor.UNITS = "G21"
950
        postprocessor.init_values(postprocessor.global_values)
951
        #
952
        # Test translate_drill with G81 and G91.
953
        path = [
954
            Path.Command("G0 X1 Y2"),
955
            Path.Command("G0 Z8"),
956
            Path.Command("G91"),
957
            Path.Command("G99"),
958
            Path.Command("G81 X1 Y2 Z0 F123 R5"),
959
            Path.Command("G80"),
960
            Path.Command("G90"),
961
        ]
962
        self.single_compare(
963
            path,
964
            """G90
965
G21
966
G0 X1.000 Y2.000
967
G0 Z8.000
968
G91
969
G99
970
G81 X1.000 Y2.000 Z0.000 R5.000 F7380.000
971
G80
972
G90
973
""",
974
            "--no-comments --no-translate_drill",
975
        )
976
        self.single_compare(
977
            path,
978
            """G90
979
G21
980
G0 X1.000 Y2.000
981
G0 Z8.000
982
G91
983
G90
984
G0 Z13.000
985
G0 X2.000 Y4.000
986
G1 Z8.000 F7380.000
987
G0 Z13.000
988
G91
989
G90
990
""",
991
            "--translate_drill",
992
        )
993
        self.single_compare(
994
            path,
995
            """(Begin preamble)
996
G90
997
G21
998
(Begin operation)
999
G0 X1.000 Y2.000
1000
G0 Z8.000
1001
G91
1002
( G99 )
1003
( G81 X1.000 Y2.000 Z0.000 R5.000 F7380.000 )
1004
G90
1005
G0 Z13.000
1006
G0 X2.000 Y4.000
1007
G1 Z8.000 F7380.000
1008
G0 Z13.000
1009
G91
1010
( G80 )
1011
G90
1012
(Finish operation: testpath)
1013
(Begin postamble)
1014
""",
1015
            "--comments --translate_drill",
1016
        )
1017

1018
    #############################################################################
1019

1020
    def test10820(self):
1021
        """Test G82 command Generation."""
1022
        path = [
1023
            Path.Command("G0 X1 Y2"),
1024
            Path.Command("G0 Z8"),
1025
            Path.Command("G90"),
1026
            Path.Command("G99"),
1027
            Path.Command("G82 X1 Y2 Z0 F123 R5 P1.23456"),
1028
            Path.Command("G80"),
1029
            Path.Command("G90"),
1030
        ]
1031
        self.single_compare(
1032
            path,
1033
            """G90
1034
G21
1035
G0 X1.000 Y2.000
1036
G0 Z8.000
1037
G90
1038
G99
1039
G82 X1.000 Y2.000 Z0.000 R5.000 P1.23456 F7380.000
1040
G80
1041
G90
1042
""",
1043
            "",
1044
        )
1045
        self.single_compare(
1046
            path,
1047
            """G90
1048
G21
1049
G0 X1.000 Y2.000
1050
G0 Z8.000
1051
G90
1052
G0 X1.000 Y2.000
1053
G1 Z5.000 F7380.000
1054
G1 Z0.000 F7380.000
1055
G4 P1.23456
1056
G0 Z5.000
1057
G90
1058
""",
1059
            "--translate_drill",
1060
        )
1061
        self.single_compare(
1062
            path,
1063
            """(Begin preamble)
1064
G90
1065
G21
1066
(Begin operation)
1067
G0 X1.000 Y2.000
1068
G0 Z8.000
1069
G90
1070
( G99 )
1071
( G82 X1.000 Y2.000 Z0.000 R5.000 P1.23456 F7380.000 )
1072
G0 X1.000 Y2.000
1073
G1 Z5.000 F7380.000
1074
G1 Z0.000 F7380.000
1075
G4 P1.23456
1076
G0 Z5.000
1077
( G80 )
1078
G90
1079
(Finish operation: testpath)
1080
(Begin postamble)
1081
""",
1082
            "--comments --translate_drill",
1083
        )
1084
        #
1085
        # Re-initialize all of the values before doing more tests.
1086
        #
1087
        postprocessor.UNITS = "G21"
1088
        postprocessor.init_values(postprocessor.global_values)
1089
        #
1090
        # Test translate_drill with G82 and G91.
1091
        path = [
1092
            Path.Command("G0 X1 Y2"),
1093
            Path.Command("G0 Z8"),
1094
            Path.Command("G91"),
1095
            Path.Command("G99"),
1096
            Path.Command("G82 X1 Y2 Z0 F123 R5 P1.23456"),
1097
            Path.Command("G80"),
1098
            Path.Command("G90"),
1099
        ]
1100
        self.single_compare(
1101
            path,
1102
            """G90
1103
G21
1104
G0 X1.000 Y2.000
1105
G0 Z8.000
1106
G91
1107
G99
1108
G82 X1.000 Y2.000 Z0.000 R5.000 P1.23456 F7380.000
1109
G80
1110
G90
1111
""",
1112
            "--no-comments --no-translate_drill",
1113
        )
1114
        self.single_compare(
1115
            path,
1116
            """G90
1117
G21
1118
G0 X1.000 Y2.000
1119
G0 Z8.000
1120
G91
1121
G90
1122
G0 Z13.000
1123
G0 X2.000 Y4.000
1124
G1 Z8.000 F7380.000
1125
G4 P1.23456
1126
G0 Z13.000
1127
G91
1128
G90
1129
""",
1130
            "--translate_drill",
1131
        )
1132
        self.single_compare(
1133
            path,
1134
            """(Begin preamble)
1135
G90
1136
G21
1137
(Begin operation)
1138
G0 X1.000 Y2.000
1139
G0 Z8.000
1140
G91
1141
( G99 )
1142
( G82 X1.000 Y2.000 Z0.000 R5.000 P1.23456 F7380.000 )
1143
G90
1144
G0 Z13.000
1145
G0 X2.000 Y4.000
1146
G1 Z8.000 F7380.000
1147
G4 P1.23456
1148
G0 Z13.000
1149
G91
1150
( G80 )
1151
G90
1152
(Finish operation: testpath)
1153
(Begin postamble)
1154
""",
1155
            "--comments --translate_drill",
1156
        )
1157

1158
    #############################################################################
1159

1160
    def test10830(self):
1161
        """Test G83 command Generation."""
1162
        path = [
1163
            Path.Command("G0 X1 Y2"),
1164
            Path.Command("G0 Z8"),
1165
            Path.Command("G90"),
1166
            Path.Command("G99"),
1167
            Path.Command("G83 X1 Y2 Z0 F123 Q1.5 R5"),
1168
            Path.Command("G80"),
1169
            Path.Command("G90"),
1170
        ]
1171
        self.single_compare(
1172
            path,
1173
            """G90
1174
G21
1175
G0 X1.000 Y2.000
1176
G0 Z8.000
1177
G90
1178
G99
1179
G83 X1.000 Y2.000 Z0.000 R5.000 Q1.500 F7380.000
1180
G80
1181
G90
1182
""",
1183
            "",
1184
        )
1185
        self.single_compare(
1186
            path,
1187
            """G90
1188
G21
1189
G0 X1.000 Y2.000
1190
G0 Z8.000
1191
G90
1192
G0 X1.000 Y2.000
1193
G1 Z5.000 F7380.000
1194
G1 Z3.500 F7380.000
1195
G0 Z5.000
1196
G0 Z3.575
1197
G1 Z2.000 F7380.000
1198
G0 Z5.000
1199
G0 Z2.075
1200
G1 Z0.500 F7380.000
1201
G0 Z5.000
1202
G0 Z0.575
1203
G1 Z0.000 F7380.000
1204
G0 Z5.000
1205
G90
1206
""",
1207
            "--translate_drill",
1208
        )
1209
        self.single_compare(
1210
            path,
1211
            """(Begin preamble)
1212
G90
1213
G21
1214
(Begin operation)
1215
G0 X1.000 Y2.000
1216
G0 Z8.000
1217
G90
1218
( G99 )
1219
( G83 X1.000 Y2.000 Z0.000 R5.000 Q1.500 F7380.000 )
1220
G0 X1.000 Y2.000
1221
G1 Z5.000 F7380.000
1222
G1 Z3.500 F7380.000
1223
G0 Z5.000
1224
G0 Z3.575
1225
G1 Z2.000 F7380.000
1226
G0 Z5.000
1227
G0 Z2.075
1228
G1 Z0.500 F7380.000
1229
G0 Z5.000
1230
G0 Z0.575
1231
G1 Z0.000 F7380.000
1232
G0 Z5.000
1233
( G80 )
1234
G90
1235
(Finish operation: testpath)
1236
(Begin postamble)
1237
""",
1238
            "--comments --translate_drill",
1239
        )
1240
        #
1241
        # Re-initialize all of the values before doing more tests.
1242
        #
1243
        postprocessor.UNITS = "G21"
1244
        postprocessor.init_values(postprocessor.global_values)
1245
        #
1246
        # Test translate_drill with G83 and G91.
1247
        path = [
1248
            Path.Command("G0 X1 Y2"),
1249
            Path.Command("G0 Z8"),
1250
            Path.Command("G91"),
1251
            Path.Command("G99"),
1252
            Path.Command("G83 X1 Y2 Z0 F123 Q1.5 R5"),
1253
            Path.Command("G80"),
1254
            Path.Command("G90"),
1255
        ]
1256
        self.single_compare(
1257
            path,
1258
            """G90
1259
G21
1260
G0 X1.000 Y2.000
1261
G0 Z8.000
1262
G91
1263
G99
1264
G83 X1.000 Y2.000 Z0.000 R5.000 Q1.500 F7380.000
1265
G80
1266
G90
1267
""",
1268
            "--no-comments --no-translate_drill",
1269
        )
1270
        self.single_compare(
1271
            path,
1272
            """G90
1273
G21
1274
G0 X1.000 Y2.000
1275
G0 Z8.000
1276
G91
1277
G90
1278
G0 Z13.000
1279
G0 X2.000 Y4.000
1280
G1 Z11.500 F7380.000
1281
G0 Z13.000
1282
G0 Z11.575
1283
G1 Z10.000 F7380.000
1284
G0 Z13.000
1285
G0 Z10.075
1286
G1 Z8.500 F7380.000
1287
G0 Z13.000
1288
G0 Z8.575
1289
G1 Z8.000 F7380.000
1290
G0 Z13.000
1291
G91
1292
G90
1293
""",
1294
            "--translate_drill",
1295
        )
1296
        self.single_compare(
1297
            path,
1298
            """(Begin preamble)
1299
G90
1300
G21
1301
(Begin operation)
1302
G0 X1.000 Y2.000
1303
G0 Z8.000
1304
G91
1305
( G99 )
1306
( G83 X1.000 Y2.000 Z0.000 R5.000 Q1.500 F7380.000 )
1307
G90
1308
G0 Z13.000
1309
G0 X2.000 Y4.000
1310
G1 Z11.500 F7380.000
1311
G0 Z13.000
1312
G0 Z11.575
1313
G1 Z10.000 F7380.000
1314
G0 Z13.000
1315
G0 Z10.075
1316
G1 Z8.500 F7380.000
1317
G0 Z13.000
1318
G0 Z8.575
1319
G1 Z8.000 F7380.000
1320
G0 Z13.000
1321
G91
1322
( G80 )
1323
G90
1324
(Finish operation: testpath)
1325
(Begin postamble)
1326
""",
1327
            "--comments --translate_drill",
1328
        )
1329

1330
    #############################################################################
1331

1332
    def test10900(self):
1333
        """Test G90 command Generation."""
1334
        self.compare_third_line("G90", "G90", "")
1335

1336
    #############################################################################
1337

1338
    def test10901(self):
1339
        """Test G90.1 command Generation."""
1340
        self.compare_third_line("G90.1", "G90.1", "")
1341

1342
    #############################################################################
1343

1344
    def test10910(self):
1345
        """Test G91 command Generation."""
1346
        self.compare_third_line("G91", "G91", "")
1347

1348
    #############################################################################
1349

1350
    def test10911(self):
1351
        """Test G91.1 command Generation."""
1352
        self.compare_third_line("G91.1", "G91.1", "")
1353

1354
    #############################################################################
1355

1356
    def test10920(self):
1357
        """Test G92 command Generation."""
1358
        self.compare_third_line(
1359
            "G92 X10 Y20 Z30 A40 B50 C60 U70 V80 W90",
1360
            ("G92 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 " "U70.000 V80.000 W90.000"),
1361
            "",
1362
        )
1363

1364
    #############################################################################
1365

1366
    def test10921(self):
1367
        """Test G92.1 command Generation."""
1368
        self.compare_third_line("G92.1", "G92.1", "")
1369

1370
    #############################################################################
1371

1372
    def test10922(self):
1373
        """Test G92.2 command Generation."""
1374
        self.compare_third_line("G92.2", "G92.2", "")
1375

1376
    #############################################################################
1377

1378
    def test10923(self):
1379
        """Test G92.3 command Generation."""
1380
        self.compare_third_line("G92.3", "G92.3", "")
1381

1382
    #############################################################################
1383

1384
    def test10930(self):
1385
        """Test G93 command Generation."""
1386
        self.compare_third_line("G93", "G93", "")
1387

1388
    #############################################################################
1389

1390
    def test10940(self):
1391
        """Test G94 command Generation."""
1392
        self.compare_third_line("G94", "G94", "")
1393

1394
    #############################################################################
1395

1396
    def test10950(self):
1397
        """Test G95 command Generation."""
1398
        self.compare_third_line("G95", "G95", "")
1399

1400
    #############################################################################
1401

1402
    def test10980(self):
1403
        """Test G98 command Generation."""
1404
        self.compare_third_line("G98", "G98", "")
1405

1406
    #############################################################################
1407

1408
    def test10990(self):
1409
        """Test G99 command Generation."""
1410
        self.compare_third_line("G99", "G99", "")
1411

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

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

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

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