Example #1
0
    def test_GetSnapshotPosition_Absolute(self):
        """Test getting absolute snapshot positions for x and y"""
        # adjust the settings for absolute position and create the snapshot gcode generator
        self.Settings.current_stabilization().x_type = "fixed_coordinate"
        self.Settings.current_stabilization().x_fixed_coordinate = 10
        self.Settings.current_stabilization().y_type = "fixed_coordinate"
        self.Settings.current_stabilization().y_fixed_coordinate = 20
        snapshot_gcode_generator = SnapshotGcodeGenerator(
            self.Settings, self.create_octoprint_printer_profile())

        # get the coordinates and test
        coords = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coords["X"] == 10 and coords["Y"] == 20)
        # get the coordinates and test
        coords = snapshot_gcode_generator.get_snapshot_position(1, 1)
        self.assertTrue(coords["X"] == 10 and coords["Y"] == 20)
        # get the coordinates and test
        coords = snapshot_gcode_generator.get_snapshot_position(100, 100)
        self.assertTrue(coords["X"] == 10 and coords["Y"] == 20)
Example #2
0
    def test_GetSnapshotPosition_AbsolutePath(self):
        """Test getting absolute path snapshot positions for x and y"""
        # adjust the settings for absolute position and create the snapshot gcode generator
        self.Settings.current_stabilization().x_type = "fixed_path"
        self.Settings.current_stabilization().x_fixed_path = "0,1,2,3,4,5"
        self.Settings.current_stabilization().y_type = "fixed_path"
        self.Settings.current_stabilization().y_fixed_path = "5,4,3,2,1,0"

        # test with no loop
        self.Settings.current_stabilization().x_fixed_path_loop = False
        self.Settings.current_stabilization().x_fixed_path_invert_loop = False
        self.Settings.current_stabilization().y_fixed_path_loop = False
        self.Settings.current_stabilization().y_fixed_path_invert_loop = False
        snapshot_gcode_generator = SnapshotGcodeGenerator(
            self.Settings, self.create_octoprint_printer_profile())
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 0 and coordinates["Y"] == 5)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 1 and coordinates["Y"] == 4)
        coordinates = snapshot_gcode_generator.get_snapshot_position(1, 0)
        self.assertTrue(coordinates["X"] == 2 and coordinates["Y"] == 3)
        coordinates = snapshot_gcode_generator.get_snapshot_position(1, 1)
        self.assertTrue(coordinates["X"] == 3 and coordinates["Y"] == 2)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 1)
        self.assertTrue(coordinates["X"] == 4 and coordinates["Y"] == 1)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 5 and coordinates["Y"] == 0)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 5 and coordinates["Y"] == 0)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 5 and coordinates["Y"] == 0)

        # test with loop, no invert
        self.Settings.current_stabilization().x_fixed_path_loop = True
        self.Settings.current_stabilization().x_fixed_path_invert_loop = False
        self.Settings.current_stabilization().y_fixed_path_loop = True
        self.Settings.current_stabilization().y_fixed_path_invert_loop = False
        snapshot_gcode_generator = SnapshotGcodeGenerator(
            self.Settings, self.create_octoprint_printer_profile())
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 0 and coordinates["Y"] == 5)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 1 and coordinates["Y"] == 4)
        coordinates = snapshot_gcode_generator.get_snapshot_position(1, 0)
        self.assertTrue(coordinates["X"] == 2 and coordinates["Y"] == 3)
        coordinates = snapshot_gcode_generator.get_snapshot_position(1, 1)
        self.assertTrue(coordinates["X"] == 3 and coordinates["Y"] == 2)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 1)
        self.assertTrue(coordinates["X"] == 4 and coordinates["Y"] == 1)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 5 and coordinates["Y"] == 0)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 0 and coordinates["Y"] == 5)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 1 and coordinates["Y"] == 4)

        # test with loop and invert
        self.Settings.current_stabilization().x_fixed_path_loop = True
        self.Settings.current_stabilization().x_fixed_path_invert_loop = True
        self.Settings.current_stabilization().y_fixed_path_loop = True
        self.Settings.current_stabilization().y_fixed_path_invert_loop = True
        snapshot_gcode_generator = SnapshotGcodeGenerator(
            self.Settings, self.create_octoprint_printer_profile())
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 0 and coordinates["Y"] == 5)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 1 and coordinates["Y"] == 4)
        coordinates = snapshot_gcode_generator.get_snapshot_position(1, 0)
        self.assertTrue(coordinates["X"] == 2 and coordinates["Y"] == 3)
        coordinates = snapshot_gcode_generator.get_snapshot_position(1, 1)
        self.assertTrue(coordinates["X"] == 3 and coordinates["Y"] == 2)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 1)
        self.assertTrue(coordinates["X"] == 4 and coordinates["Y"] == 1)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 5 and coordinates["Y"] == 0)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 4 and coordinates["Y"] == 1)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 3 and coordinates["Y"] == 2)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 2 and coordinates["Y"] == 3)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 1 and coordinates["Y"] == 4)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 0 and coordinates["Y"] == 5)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 1 and coordinates["Y"] == 4)
Example #3
0
    def test_GetSnapshotPosition_BedRelativePath(self):
        """Test getting bed relative path snapshot positions for x and y"""
        # adjust the settings for absolute position and create the snapshot gcode generator
        self.Settings.current_stabilization().x_type = "relative_path"
        self.Settings.current_stabilization().x_relative_path = "0,25,50,75,100"
        self.Settings.current_stabilization().y_type = "relative_path"
        self.Settings.current_stabilization().y_relative_path = "100,75,50,25,0"

        # test with no loop
        self.Settings.current_stabilization().x_relative_path_loop = False
        self.Settings.current_stabilization().x_relative_path_invert_loop = False
        self.Settings.current_stabilization().y_relative_path_loop = False
        self.Settings.current_stabilization().y_relative_path_invert_loop = False
        snapshot_gcode_generator = SnapshotGcodeGenerator(
            self.Settings, self.create_octoprint_printer_profile())
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 0 and coordinates["Y"] == 200)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 62.5 and coordinates["Y"] == 150)
        coordinates = snapshot_gcode_generator.get_snapshot_position(1, 0)
        self.assertTrue(coordinates["X"] == 125 and coordinates["Y"] == 100)
        coordinates = snapshot_gcode_generator.get_snapshot_position(1, 1)
        self.assertTrue(coordinates["X"] == 187.5 and coordinates["Y"] == 50)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 1)
        self.assertTrue(coordinates["X"] == 250 and coordinates["Y"] == 0)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 250 and coordinates["Y"] == 0)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 250 and coordinates["Y"] == 0)

        # test with loop, no invert
        self.Settings.current_stabilization().x_relative_path_loop = True
        self.Settings.current_stabilization().x_relative_path_invert_loop = False
        self.Settings.current_stabilization().y_relative_path_loop = True
        self.Settings.current_stabilization().y_relative_path_invert_loop = False
        snapshot_gcode_generator = SnapshotGcodeGenerator(
            self.Settings, self.create_octoprint_printer_profile())
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 0 and coordinates["Y"] == 200)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 62.5 and coordinates["Y"] == 150)
        coordinates = snapshot_gcode_generator.get_snapshot_position(1, 0)
        self.assertTrue(coordinates["X"] == 125 and coordinates["Y"] == 100)
        coordinates = snapshot_gcode_generator.get_snapshot_position(1, 1)
        self.assertTrue(coordinates["X"] == 187.5 and coordinates["Y"] == 50)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 1)
        self.assertTrue(coordinates["X"] == 250 and coordinates["Y"] == 0)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 0 and coordinates["Y"] == 200)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 62.5 and coordinates["Y"] == 150)

        # test with loop and invert
        self.Settings.current_stabilization().x_relative_path_loop = True
        self.Settings.current_stabilization().x_relative_path_invert_loop = True
        self.Settings.current_stabilization().y_relative_path_loop = True
        self.Settings.current_stabilization().y_relative_path_invert_loop = True
        snapshot_gcode_generator = SnapshotGcodeGenerator(
            self.Settings, self.create_octoprint_printer_profile())
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 0 and coordinates["Y"] == 200)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 62.5 and coordinates["Y"] == 150)
        coordinates = snapshot_gcode_generator.get_snapshot_position(1, 0)
        self.assertTrue(coordinates["X"] == 125 and coordinates["Y"] == 100)
        coordinates = snapshot_gcode_generator.get_snapshot_position(1, 1)
        self.assertTrue(coordinates["X"] == 187.5 and coordinates["Y"] == 50)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 1)
        self.assertTrue(coordinates["X"] == 250 and coordinates["Y"] == 0)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 187.5 and coordinates["Y"] == 50)
        coordinates = snapshot_gcode_generator.get_snapshot_position(0, 0)
        self.assertTrue(coordinates["X"] == 125 and coordinates["Y"] == 100)