Example #1
0
 def test_drill_optimisation(self):
     commands = list(parse_file("testdata/drill_cycle.ngc"))
     optimised = gcode_optimise.optimise(commands, 100)
     self.assertEqual(len(commands), len(optimised), "Should be same number of commands before/after")
     self.assertNotEqual(commands, optimised, "Optimised drill pass should use different order")
     for c in commands:
         self.assertTrue(c in optimised, "All commands in commands should be in optimised set, including %s" % c)
Example #2
0
 def test_drill_optimisation(self):
     commands = list(parse_file("testdata/drill_cycle.ngc"))
     optimised = gcode_optimise.optimise(commands, 100)
     self.assertEqual(len(commands), len(optimised), "Should be same number of commands before/after")
     self.assertNotEqual(commands, optimised, "Optimised drill pass should use different order")
     for c in commands:
         self.assertTrue(c in optimised, "All commands in commands should be in optimised set, including %s" % c)
Example #3
0
    def _deviation_commands(self, threshold):
        # test data is 10mm line w/1mm deviation
        commands = parse_file("testdata/deviate_1mm.ngc")
        old_moves = [c for c in commands if c["name"]=="G1"]
        not_moves = [c for c in commands if c["name"]!="G1"]
        optimised = gcode_optimise.optimise(commands, threshold)
        new_moves = [c for c in optimised if c["name"]=="G1"]
        new_not_moves = [c for c in optimised if c["name"]!="G1"]
        test_equal_commands(self, not_moves, new_not_moves) # everything but G1 should commands should be 100% the same
        for new in optimised:
            self.assertTrue(new in commands, "Every optimised command should already exist in old set, including %s" % new)
            self.assertTrue(optimised.index(new) <= commands.index(new), "Optimisation strips commands, so any new command should have index at or before it's position in the old command list (testing %s)" % new)


        return old_moves, new_moves
Example #4
0
    def _deviation_commands(self, threshold):
        # test data is 10mm line w/1mm deviation
        commands = parse_file("testdata/deviate_1mm.ngc")
        old_moves = [c for c in commands if c["name"] == "G1"]
        not_moves = [c for c in commands if c["name"] != "G1"]
        optimised = gcode_optimise.optimise(commands, threshold)
        new_moves = [c for c in optimised if c["name"] == "G1"]
        new_not_moves = [c for c in optimised if c["name"] != "G1"]
        test_equal_commands(self, not_moves, new_not_moves)  # everything but G1 should commands should be 100% the same
        for new in optimised:
            self.assertTrue(
                new in commands, "Every optimised command should already exist in old set, including %s" % new
            )
            self.assertTrue(
                optimised.index(new) <= commands.index(new),
                "Optimisation strips commands, so any new command should have index at or before it's position in the old command list (testing %s)"
                % new,
            )

        return old_moves, new_moves