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.CurrentStabilization().x_type = "fixed_coordinate" self.Settings.CurrentStabilization().x_fixed_coordinate = 10 self.Settings.CurrentStabilization().y_type = "fixed_coordinate" self.Settings.CurrentStabilization().y_fixed_coordinate = 20 snapshotGcodeGenerator = SnapshotGcodeGenerator( self.Settings, self.CreateOctoprintPrinterProfile()) # get the coordinates and test coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 10 and coords["Y"] == 20) # get the coordinates and test coords = snapshotGcodeGenerator.GetSnapshotPosition(1, 1) self.assertTrue(coords["X"] == 10 and coords["Y"] == 20) # get the coordinates and test coords = snapshotGcodeGenerator.GetSnapshotPosition(100, 100) self.assertTrue(coords["X"] == 10 and coords["Y"] == 20)
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.CurrentStabilization().x_type = "fixed_path" self.Settings.CurrentStabilization().x_fixed_path = "0,1,2,3,4,5" self.Settings.CurrentStabilization().y_type = "fixed_path" self.Settings.CurrentStabilization().y_fixed_path = "5,4,3,2,1,0" # test with no loop self.Settings.CurrentStabilization().x_fixed_path_loop = False self.Settings.CurrentStabilization().x_fixed_path_invert_loop = False self.Settings.CurrentStabilization().y_fixed_path_loop = False self.Settings.CurrentStabilization().y_fixed_path_invert_loop = False snapshotGcodeGenerator = SnapshotGcodeGenerator( self.Settings, self.CreateOctoprintPrinterProfile()) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 0 and coords["Y"] == 5) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 1 and coords["Y"] == 4) coords = snapshotGcodeGenerator.GetSnapshotPosition(1, 0) self.assertTrue(coords["X"] == 2 and coords["Y"] == 3) coords = snapshotGcodeGenerator.GetSnapshotPosition(1, 1) self.assertTrue(coords["X"] == 3 and coords["Y"] == 2) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 1) self.assertTrue(coords["X"] == 4 and coords["Y"] == 1) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 5 and coords["Y"] == 0) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 5 and coords["Y"] == 0) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 5 and coords["Y"] == 0) # test with loop, no invert self.Settings.CurrentStabilization().x_fixed_path_loop = True self.Settings.CurrentStabilization().x_fixed_path_invert_loop = False self.Settings.CurrentStabilization().y_fixed_path_loop = True self.Settings.CurrentStabilization().y_fixed_path_invert_loop = False snapshotGcodeGenerator = SnapshotGcodeGenerator( self.Settings, self.CreateOctoprintPrinterProfile()) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 0 and coords["Y"] == 5) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 1 and coords["Y"] == 4) coords = snapshotGcodeGenerator.GetSnapshotPosition(1, 0) self.assertTrue(coords["X"] == 2 and coords["Y"] == 3) coords = snapshotGcodeGenerator.GetSnapshotPosition(1, 1) self.assertTrue(coords["X"] == 3 and coords["Y"] == 2) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 1) self.assertTrue(coords["X"] == 4 and coords["Y"] == 1) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 5 and coords["Y"] == 0) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 0 and coords["Y"] == 5) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 1 and coords["Y"] == 4) # test with loop and invert self.Settings.CurrentStabilization().x_fixed_path_loop = True self.Settings.CurrentStabilization().x_fixed_path_invert_loop = True self.Settings.CurrentStabilization().y_fixed_path_loop = True self.Settings.CurrentStabilization().y_fixed_path_invert_loop = True snapshotGcodeGenerator = SnapshotGcodeGenerator( self.Settings, self.CreateOctoprintPrinterProfile()) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 0 and coords["Y"] == 5) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 1 and coords["Y"] == 4) coords = snapshotGcodeGenerator.GetSnapshotPosition(1, 0) self.assertTrue(coords["X"] == 2 and coords["Y"] == 3) coords = snapshotGcodeGenerator.GetSnapshotPosition(1, 1) self.assertTrue(coords["X"] == 3 and coords["Y"] == 2) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 1) self.assertTrue(coords["X"] == 4 and coords["Y"] == 1) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 5 and coords["Y"] == 0) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 4 and coords["Y"] == 1) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 3 and coords["Y"] == 2) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 2 and coords["Y"] == 3) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 1 and coords["Y"] == 4) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 0 and coords["Y"] == 5) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 1 and coords["Y"] == 4)
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.CurrentStabilization().x_type = "relative_path" self.Settings.CurrentStabilization().x_relative_path = "0,25,50,75,100" self.Settings.CurrentStabilization().y_type = "relative_path" self.Settings.CurrentStabilization().y_relative_path = "100,75,50,25,0" # test with no loop self.Settings.CurrentStabilization().x_relative_path_loop = False self.Settings.CurrentStabilization( ).x_relative_path_invert_loop = False self.Settings.CurrentStabilization().y_relative_path_loop = False self.Settings.CurrentStabilization( ).y_relative_path_invert_loop = False snapshotGcodeGenerator = SnapshotGcodeGenerator( self.Settings, self.CreateOctoprintPrinterProfile()) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 0 and coords["Y"] == 200) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 62.5 and coords["Y"] == 150) coords = snapshotGcodeGenerator.GetSnapshotPosition(1, 0) self.assertTrue(coords["X"] == 125 and coords["Y"] == 100) coords = snapshotGcodeGenerator.GetSnapshotPosition(1, 1) self.assertTrue(coords["X"] == 187.5 and coords["Y"] == 50) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 1) self.assertTrue(coords["X"] == 250 and coords["Y"] == 0) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 250 and coords["Y"] == 0) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 250 and coords["Y"] == 0) # test with loop, no invert self.Settings.CurrentStabilization().x_relative_path_loop = True self.Settings.CurrentStabilization( ).x_relative_path_invert_loop = False self.Settings.CurrentStabilization().y_relative_path_loop = True self.Settings.CurrentStabilization( ).y_relative_path_invert_loop = False snapshotGcodeGenerator = SnapshotGcodeGenerator( self.Settings, self.CreateOctoprintPrinterProfile()) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 0 and coords["Y"] == 200) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 62.5 and coords["Y"] == 150) coords = snapshotGcodeGenerator.GetSnapshotPosition(1, 0) self.assertTrue(coords["X"] == 125 and coords["Y"] == 100) coords = snapshotGcodeGenerator.GetSnapshotPosition(1, 1) self.assertTrue(coords["X"] == 187.5 and coords["Y"] == 50) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 1) self.assertTrue(coords["X"] == 250 and coords["Y"] == 0) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 0 and coords["Y"] == 200) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 62.5 and coords["Y"] == 150) # test with loop and invert self.Settings.CurrentStabilization().x_relative_path_loop = True self.Settings.CurrentStabilization().x_relative_path_invert_loop = True self.Settings.CurrentStabilization().y_relative_path_loop = True self.Settings.CurrentStabilization().y_relative_path_invert_loop = True snapshotGcodeGenerator = SnapshotGcodeGenerator( self.Settings, self.CreateOctoprintPrinterProfile()) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 0 and coords["Y"] == 200) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 62.5 and coords["Y"] == 150) coords = snapshotGcodeGenerator.GetSnapshotPosition(1, 0) self.assertTrue(coords["X"] == 125 and coords["Y"] == 100) coords = snapshotGcodeGenerator.GetSnapshotPosition(1, 1) self.assertTrue(coords["X"] == 187.5 and coords["Y"] == 50) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 1) self.assertTrue(coords["X"] == 250 and coords["Y"] == 0) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 187.5 and coords["Y"] == 50) coords = snapshotGcodeGenerator.GetSnapshotPosition(0, 0) self.assertTrue(coords["X"] == 125 and coords["Y"] == 100)