diff --git a/StaticData/PrinterSettings/BCN/BCN Sigma/config.ini b/StaticData/PrinterSettings/BCN/BCN Sigma/config.ini
index 6a3fd8148..858f33f5d 100644
--- a/StaticData/PrinterSettings/BCN/BCN Sigma/config.ini
+++ b/StaticData/PrinterSettings/BCN/BCN Sigma/config.ini
@@ -143,7 +143,7 @@ support_material_enforce_layers = 0
support_material_extruder = 1
support_material_extrusion_width = 0
support_material_infill_angle = 45
-support_material_interface_extruder = 2
+support_material_interface_extruder = 1
support_material_interface_layers = 4
support_material_interface_spacing = 0
support_material_pattern = honeycomb
diff --git a/StaticData/PrinterSettings/Lulzbot/TAZ 6/config.ini b/StaticData/PrinterSettings/Lulzbot/TAZ 6/config.ini
index c55901153..6824424d8 100644
--- a/StaticData/PrinterSettings/Lulzbot/TAZ 6/config.ini
+++ b/StaticData/PrinterSettings/Lulzbot/TAZ 6/config.ini
@@ -115,7 +115,7 @@ manual_probe_paper_width = .1
# Extruder
extruder_offset = 0x0
-start_gcode = ;This profile is designed specifically for LulzBot TAZ 6 3D Printer\n;Basic slice data:\n;Sliced at: {day} {date} {time}\n;Layer height: {layer_height}\n;Walls: {wall_thickness}\n;Fill: {fill_density}\n;Estimated Print time: {print_time}\n;Filament used: {filament_amount}m {filament_weight}g\n;Filament cost: {filament_cost}\nG26 ; clear potential 'probe fail' condition\nG21 ; set units to Millimetres\nM107 ; disable fans\nG90 ; absolute positioning\nM82 ; set extruder to absolute mode\nG92 E0 ; set extruder position to 0\nM140 S[bed_temperature] ; get bed heating up\nG28 XY ; home X and Y\nG1 X-19 Y258 F1000 ; move to safe homing position\nM109 S160 ; soften filament for z homing\nG28 Z ; home Z\nM104 S[extruder_wipe_temperature]; wipe temp\nG1 E-30 F100 ; suck up XXmm of filament\nG1 X-15 Y100 F3000 ; move above wiper pad\nG1 Z1 ; push nozzle into wiper\nG1 X-17 Y95 F1000 ; slow wipe\nG1 X-17 Y90 F1000 ; slow wipe\nG1 X-17 Y85 F1000 ; slow wipe\nG1 X-15 Y90 F1000 ; slow wipe\nG1 X-17 Y80 F1000 ; slow wipe\nG1 X-15 Y95 F1000 ; slow wipe\nG1 X-17 Y75 F2000 ; fast wipe\nG1 X-15 Y65 F2000 ; fast wipe\nG1 X-17 Y70 F2000 ; fast wipe\nG1 X-15 Y60 F2000 ; fast wipe\nG1 X-17 Y55 F2000 ; fast wipe\nG1 X-15 Y50 F2000 ; fast wipe\nG1 X-17 Y40 F2000 ; fast wipe\nG1 X-15 Y45 F2000 ; fast wipe\nG1 X-17 Y35 F2000 ; fast wipe\nG1 X-15 Y40 F2000 ; fast wipe\nG1 X-17 Y70 F2000 ; fast wipe\nG1 X-15 Y30 Z2 F2000 ; fast wipe\nG1 X-17 Y35 F2000 ; fast wipe\nG1 X-15 Y25 F2000 ; fast wipe\nG1 X-17 Y30 F2000 ; fast wipe\nG1 X-15 Y25 Z1.5 F1000 ; slow wipe\nG1 X-17 Y23 F1000 ; slow wipe\nG1 Z10 ; raise extruder\nM109 S150 ; heat to probe temp\nG1 X-9 Y-9 ; move above probe\nM204 S100 ; set accel for probing\nG29 ; probe sequence (for auto-leveling)\nM204 S500 ; set accel back to normal\nG1 X0 Y0 Z15 F5000 ; get out the way\nM400 ; clear buffer\nG4 S1 ; pause\nM117 Heating... ; LCD status message\nM140 S[bed_temperature] ; get bed heating up\nM109 S[temperature] ; set extruder temp and wait\nM190 S[bed_temperature] ; get bed temping up during first layer\nG1 Z2 E0 F75 ; extrude filament back into nozzle\nM117 TAZ Printing... ; LCD status message\n
-end_gcode = ;\nM400 ; wait for moves to finish\nM104 S0 ; hotend off\nM107 ; fans off\nG91 ; relative positioning\nG1 E-1 F300 ; retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+20 E-5 X-20 Y-20 F3000 ; move Z up a bit and retract filament even more\nM117 Cooling please wait ; progress indicator message\nG90 ; absolute positioning\nG1 Y0 F3000 ; move to cooling position\nM190 R[bed_remove_part_temperature] ; set bed to cool off\nG1 Y280 F3000 ; present finished print\nM84 ; steppers off\nG90 ; absolute positioning\nM117 Print complete ; progress indicator message\n;{profile_string}
+start_gcode = ;This profile is designed specifically for LulzBot TAZ 6 3D Printer\n;Basic slice data:\n;Sliced at: [day] [date] [time]\n;Layer height: [layer_height]\n;Walls: [wall_thickness]\n;Fill: [fill_density]\n;Estimated Print time: [print_time]\n;Filament used: [filament_amount]m [filament_weight]g\n;Filament cost: [filament_cost]\nG26 ; clear potential 'probe fail' condition\nG21 ; set units to Millimetres\nM107 ; disable fans\nG90 ; absolute positioning\nM82 ; set extruder to absolute mode\nG92 E0 ; set extruder position to 0\nM140 S[bed_temperature] ; get bed heating up\nG28 XY ; home X and Y\nG1 X-19 Y258 F1000 ; move to safe homing position\nM109 S160 ; soften filament for z homing\nG28 Z ; home Z\nM104 S[extruder_wipe_temperature]; wipe temp\nG1 E-30 F100 ; suck up XXmm of filament\nG1 X-15 Y100 F3000 ; move above wiper pad\nG1 Z1 ; push nozzle into wiper\nG1 X-17 Y95 F1000 ; slow wipe\nG1 X-17 Y90 F1000 ; slow wipe\nG1 X-17 Y85 F1000 ; slow wipe\nG1 X-15 Y90 F1000 ; slow wipe\nG1 X-17 Y80 F1000 ; slow wipe\nG1 X-15 Y95 F1000 ; slow wipe\nG1 X-17 Y75 F2000 ; fast wipe\nG1 X-15 Y65 F2000 ; fast wipe\nG1 X-17 Y70 F2000 ; fast wipe\nG1 X-15 Y60 F2000 ; fast wipe\nG1 X-17 Y55 F2000 ; fast wipe\nG1 X-15 Y50 F2000 ; fast wipe\nG1 X-17 Y40 F2000 ; fast wipe\nG1 X-15 Y45 F2000 ; fast wipe\nG1 X-17 Y35 F2000 ; fast wipe\nG1 X-15 Y40 F2000 ; fast wipe\nG1 X-17 Y70 F2000 ; fast wipe\nG1 X-15 Y30 Z2 F2000 ; fast wipe\nG1 X-17 Y35 F2000 ; fast wipe\nG1 X-15 Y25 F2000 ; fast wipe\nG1 X-17 Y30 F2000 ; fast wipe\nG1 X-15 Y25 Z1.5 F1000 ; slow wipe\nG1 X-17 Y23 F1000 ; slow wipe\nG1 Z10 ; raise extruder\nM109 S150 ; heat to probe temp\nG1 X-9 Y-9 ; move above probe\nM204 S100 ; set accel for probing\nG29 ; probe sequence (for auto-leveling)\nM204 S500 ; set accel back to normal\nG1 X0 Y0 Z15 F5000 ; get out the way\nM400 ; clear buffer\nG4 S1 ; pause\nM117 Heating... ; LCD status message\nM140 S[bed_temperature] ; get bed heating up\nM109 S[temperature] ; set extruder temp and wait\nM190 S[bed_temperature] ; get bed temping up during first layer\nG1 Z2 E0 F75 ; extrude filament back into nozzle\nM117 TAZ Printing... ; LCD status message\n
+end_gcode = ;\nM400 ; wait for moves to finish\nM104 S0 ; hotend off\nM107 ; fans off\nG91 ; relative positioning\nG1 E-1 F300 ; retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+20 E-5 X-20 Y-20 F3000 ; move Z up a bit and retract filament even more\nM117 Cooling please wait ; progress indicator message\nG90 ; absolute positioning\nG1 Y0 F3000 ; move to cooling position\nM190 R[bed_remove_part_temperature] ; set bed to cool off\nG1 Y280 F3000 ; present finished print\nM84 ; steppers off\nG90 ; absolute positioning\nM117 Print complete ; progress indicator message\n;[profile_string]
before_toolchange_gcode =
toolchange_gcode =
diff --git a/StaticData/PrinterSettings/Me3D/Me2/config.ini b/StaticData/PrinterSettings/Me3D/Me2/config.ini
index 3b668cbf8..8d04776f7 100644
--- a/StaticData/PrinterSettings/Me3D/Me2/config.ini
+++ b/StaticData/PrinterSettings/Me3D/Me2/config.ini
@@ -126,7 +126,7 @@ solid_infill_speed = 60
solid_shell = 0
spiral_vase = 0
standby_temperature_delta = -5
-start_gcode = ;Me3D - MC1.5 startup sequence - Me2 (G5,G6,G7) Build 02/16\n;Remove the ";" to activate any line\n;MAKE SURE YOU KNOW WHAT EACH LINE DOES BEFORE YOU CHANGE IT!!! The Me2 is 100% hackable and so has limited physical protection from errors in the g-code\nM104 S[first_layer_temperature] ; Start heater and continue g-code\nG21 ; set units to millimeters\nM201 X5000 Y5000; max accel print\nM202 X5000 Y5000; max accel travel\nM205 X15; max xyjerk mm/s\nG92; Zero current head position\nG91; Relative position\nG1 Z10; clear bed \nG90 ; ABS position\nG28; home axes\nG29; perform auto levelling at three corners\nM82 ; use absolute distances for extrusion\nG1 Z15 F4000; Raise Z axis clear\nG1 X-5 F4000; Move to X axis zero\nG1 Y5 F4000;\nG92 E0; zero the extruded length\nM109 S[first_layer_temperature]; Set print temperature and wait\nG1 F100 E19; extrude feed stock to prime hotend barrel and purge\n; Create purge line\nG1 Z[z_offset] F1000; z_offset variable only available in MC1.2.3 and above\nG91; Relative motion \nG1 Z0.3;\nG1 X10 Y1 F1000; Change this value to move the position of the line on the bed\nG1 X120 E20;\nG1 Y1;\nG1 X-100 E16.5;\nG1 X-20 E2;\nG1 X10 Y-3 F500;\nG1 Y5 F4000;\nG92 E0;\nG90;\nG92 E0; zero the extruded length again\nM117 OK...let's print;
+start_gcode = ;Me3D - MC1.5 startup sequence - Me2 (G5,G6,G7) Build 02/16\n;Remove the ";" to activate any line\n;MAKE SURE YOU KNOW WHAT EACH LINE DOES BEFORE YOU CHANGE IT!!! The Me2 is 100% hackable and so has limited physical protection from errors in the g-code\nM104 S[temperature] ; Start heater and continue g-code\nG21 ; set units to millimeters\nM201 X5000 Y5000; max accel print\nM202 X5000 Y5000; max accel travel\nM205 X15; max xyjerk mm/s\nG92; Zero current head position\nG91; Relative position\nG1 Z10; clear bed \nG90 ; ABS position\nG28; home axes\nG29; perform auto levelling at three corners\nM82 ; use absolute distances for extrusion\nG1 Z15 F4000; Raise Z axis clear\nG1 X-5 F4000; Move to X axis zero\nG1 Y5 F4000;\nG92 E0; zero the extruded length\nM109 S[temperature]; Set print temperature and wait\nG1 F100 E19; extrude feed stock to prime hotend barrel and purge\n; Create purge line\nG1 Z[z_offset] F1000; z_offset variable only available in MC1.2.3 and above\nG91; Relative motion \nG1 Z0.3;\nG1 X10 Y1 F1000; Change this value to move the position of the line on the bed\nG1 X120 E20;\nG1 Y1;\nG1 X-100 E16.5;\nG1 X-20 E2;\nG1 X10 Y-3 F500;\nG1 Y5 F4000;\nG92 E0;\nG90;\nG92 E0; zero the extruded length again\nM117 OK...let's print;
start_perimeters_at_concave_points = 0
start_perimeters_at_non_overhang = 0
support_air_gap = .3
diff --git a/Tests/MatterControl.Tests/MatterControl.Tests.csproj b/Tests/MatterControl.Tests/MatterControl.Tests.csproj
index de3d35f42..b5d874efd 100644
--- a/Tests/MatterControl.Tests/MatterControl.Tests.csproj
+++ b/Tests/MatterControl.Tests/MatterControl.Tests.csproj
@@ -70,7 +70,7 @@
-
+
diff --git a/Tests/MatterControl.Tests/MatterControl/ConfigIniTests.cs b/Tests/MatterControl.Tests/MatterControl/ConfigIniTests.cs
new file mode 100644
index 000000000..b63d43c02
--- /dev/null
+++ b/Tests/MatterControl.Tests/MatterControl/ConfigIniTests.cs
@@ -0,0 +1,403 @@
+using MatterHackers.MatterControl;
+using NUnit.Framework;
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Globalization;
+using MatterHackers.MatterControl.SlicerConfiguration;
+
+namespace MatterControl.Tests.MatterControl
+{
+ [TestFixture, Category("ConfigIni")]
+ public class ConfigIniTests
+ {
+ private static List allPrinters;
+ private static string matterControlDirectory = Path.GetFullPath(Path.Combine("..", "..", "..", ".."));
+ private static string printerSettingsDirectory = Path.GetFullPath(Path.Combine(matterControlDirectory, "StaticData", "PrinterSettings"));
+
+ static ConfigIniTests()
+ {
+ allPrinters = (from configIni in new DirectoryInfo(printerSettingsDirectory).GetFiles("config.ini", System.IO.SearchOption.AllDirectories)
+ select new PrinterConfig
+ {
+ PrinterName = configIni.Directory.Name,
+ Oem = configIni.Directory.Parent.Name,
+ ConfigPath = configIni.FullName,
+ RelativeConfigPath = configIni.FullName.Substring(printerSettingsDirectory.Length + 1),
+ SettingsLayer = SettingsLayer.LoadFromIni(configIni.FullName)
+ }).ToList();
+ }
+
+ [Test]
+ public void CsvBedSizeExistsAndHasTwoValues()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ string bedSize = printer.SettingsLayer.ValueOrDefault("bed_size");
+
+ // Must exist in all configs
+ Assert.IsNotNullOrEmpty(bedSize, "[bed_size] must exist: " + printer.RelativeConfigPath);
+
+ string[] segments = bedSize.Trim().Split(',');
+
+ // Must be a CSV and have two values
+ Assert.AreEqual(2, segments.Length, "[bed_size] should have two values separated by a comma: " + printer.RelativeConfigPath);
+ });
+ }
+
+ [Test]
+ public void CsvPrintCenterExistsAndHasTwoValues()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ string printCenter = printer.SettingsLayer.ValueOrDefault("print_center");
+
+ // Must exist in all configs
+ Assert.IsNotNullOrEmpty(printCenter, "[print_center] must exist: " + printer.RelativeConfigPath);
+
+ string[] segments = printCenter.Trim().Split(',');
+
+ // Must be a CSV and have only two values
+ Assert.AreEqual(2, segments.Length, "[print_center] should have two values separated by a comma: " + printer.RelativeConfigPath);
+ });
+ }
+
+ [Test]
+ public void RetractLengthIsLessThanTwenty()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ string retractLengthString = printer.SettingsLayer.ValueOrDefault("retract_length");
+ if (!string.IsNullOrEmpty(retractLengthString))
+ {
+ float retractLength;
+ if (!float.TryParse(retractLengthString, out retractLength))
+ {
+ Assert.Fail("Invalid [retract_length] value (float parse failed): " + printer.RelativeConfigPath);
+ }
+
+ Assert.Less(retractLength, 20, "[retract_length]: " + printer.RelativeConfigPath);
+ }
+ });
+ }
+
+ [Test]
+ public void ExtruderCountIsGreaterThanZero()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ string extruderCountString = printer.SettingsLayer.ValueOrDefault("extruder_count");
+
+ // TODO: Should extruder count be required as originally expected?
+ if (string.IsNullOrEmpty(extruderCountString))
+ {
+ Console.WriteLine("extruder_count missing: " + printer.RelativeConfigPath);
+ return;
+ }
+
+ // Must exist in all configs
+ Assert.IsNotNullOrEmpty(extruderCountString, "[extruder_count] must exist: " + printer.RelativeConfigPath);
+
+ int extruderCount;
+ if (!int.TryParse(extruderCountString, out extruderCount))
+ {
+ Assert.Fail("Invalid [extruder_count] value (int parse failed): " + printer.RelativeConfigPath);
+ }
+
+ // Must be greater than zero
+ Assert.Greater(extruderCount, 0, "[extruder_count]: " + printer.RelativeConfigPath);
+ });
+ }
+
+ [Test]
+ public void MinFanSpeedOneHundredOrLess()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ string fanSpeedString = printer.SettingsLayer.ValueOrDefault("min_fan_speed");
+ if (!string.IsNullOrEmpty(fanSpeedString))
+ {
+ // Must be valid int data
+ int minFanSpeed;
+ if (!int.TryParse(fanSpeedString, out minFanSpeed))
+ {
+ Assert.Fail("Invalid [min_fan_speed] value (int parse failed): " + printer.RelativeConfigPath);
+ }
+
+ // Must be less than or equal to 100
+ Assert.LessOrEqual(minFanSpeed, 100, "[min_fan_speed]: " + printer.RelativeConfigPath);
+ }
+ });
+ }
+
+ [Test]
+ public void MaxFanSpeedOneHundredOrLess()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ string fanSpeedString = printer.SettingsLayer.ValueOrDefault("max_fan_speed");
+ if (!string.IsNullOrEmpty(fanSpeedString))
+ {
+ // Must be valid int data
+ int maxFanSpeed;
+ if (!int.TryParse(fanSpeedString, out maxFanSpeed))
+ {
+ Assert.Fail("Invalid [max_fan_speed] value (int parse failed): " + printer.RelativeConfigPath);
+ }
+
+ // Must be less than or equal to 100
+ Assert.LessOrEqual(maxFanSpeed, 100, "[max_fan_speed]: " + printer.RelativeConfigPath);
+ }
+ });
+ }
+
+ [Test]
+ public void NoCurlyBracketsInGcode()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ // TODO: Why aren't we testing all gcode sections?
+ string[] keysToTest = { "start_gcode", "end_gcode" };
+ foreach (string gcodeKey in keysToTest)
+ {
+ string gcode = printer.SettingsLayer.ValueOrDefault(gcodeKey);
+ if (gcode.Contains("{") || gcode.Contains("}") )
+ {
+ Assert.Fail(string.Format("[{0}] Curly brackets not allowed: {1}", gcodeKey, printer.RelativeConfigPath));
+ }
+ }
+ });
+ }
+
+ [Test]
+ public void BottomSolidLayersEqualsOneMM()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ string bottomSolidLayers = printer.SettingsLayer.ValueOrDefault("bottom_solid_layers");
+ if (!string.IsNullOrEmpty(bottomSolidLayers))
+ {
+ if (bottomSolidLayers != "1mm")
+ {
+ printer.RuleViolated = true;
+ return;
+ }
+
+ Assert.AreEqual("1mm", bottomSolidLayers, "[bottom_solid_layers] must be 1mm: " + printer.RelativeConfigPath);
+ }
+ });
+ }
+
+ [Test]
+ public void NoFirstLayerTempInStartGcode()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ string startGcode = printer.SettingsLayer.ValueOrDefault("start_gcode");
+ Assert.False(startGcode.Contains("first_layer_temperature"), "[start_gcode] should not contain [first_layer_temperature]" + printer.RelativeConfigPath);
+ });
+ }
+
+ [Test]
+ public void NoFirstLayerBedTempInStartGcode()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ string startGcode = printer.SettingsLayer.ValueOrDefault("start_gcode");
+ Assert.False(startGcode.Contains("first_layer_bed_temperature"), "[start_gcode] should not contain [first_layer_bed_temperature]" + printer.RelativeConfigPath);
+ });
+ }
+
+ [Test]
+ public void FirstLayerHeightLessThanNozzleDiameter()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ float nozzleDiameter = float.Parse(printer.SettingsLayer.ValueOrDefault("nozzle_diameter"));
+ float layerHeight = float.Parse(printer.SettingsLayer.ValueOrDefault("layer_height"));
+
+ string firstLayerHeightString = printer.SettingsLayer.ValueOrDefault("first_layer_height");
+ if (!string.IsNullOrEmpty(firstLayerHeightString))
+ {
+ float firstLayerHeight = ValueOrPercentageOf(firstLayerHeightString, layerHeight);
+
+ // TODO: Remove once validated and resolved
+ if (firstLayerHeight >= nozzleDiameter)
+ {
+ printer.RuleViolated = true;
+ return;
+ }
+
+ Assert.Less(firstLayerHeight, nozzleDiameter, "[first_layer_height] must be less than [nozzle_diameter]: " + printer.RelativeConfigPath);
+ }
+ });
+ }
+
+ [Test]
+ public void LayerHeightLessThanNozzleDiameter()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ float nozzleDiameter = float.Parse(printer.SettingsLayer.ValueOrDefault("nozzle_diameter"));
+ float layerHeight = float.Parse(printer.SettingsLayer.ValueOrDefault("layer_height"));
+
+ // TODO: Remove once validated and resolved
+ if (layerHeight >= nozzleDiameter)
+ {
+ printer.RuleViolated = true;
+ return;
+ }
+
+ Assert.Less(layerHeight, nozzleDiameter, "[layer_height] must be less than [nozzle_diameter]: " + printer.RelativeConfigPath);
+ });
+ }
+
+ // TODO: Requires review
+ [Test]
+ public void LayerHeightAcceptable()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ float nozzleDiameter = float.Parse(printer.SettingsLayer.ValueOrDefault("nozzle_diameter"));
+
+ string firstLayerExtrusionWidthString = printer.SettingsLayer.ValueOrDefault("first_layer_extrusion_width");
+ if (!string.IsNullOrEmpty(firstLayerExtrusionWidthString))
+ {
+ float firstLayerExtrusionWidth = ValueOrPercentageOf(firstLayerExtrusionWidthString, nozzleDiameter);
+
+ // TODO: Why are we finding the product of the extrusion width and nozzleDiameter?
+ float firstLayerExtrusionWidthToTest = firstLayerExtrusionWidth * nozzleDiameter;
+ float firstLayerExtrusionWidthThreshold = nozzleDiameter * 4;
+
+ if (firstLayerExtrusionWidthToTest >= firstLayerExtrusionWidthThreshold ||
+ firstLayerExtrusionWidthToTest <= 0 )
+ {
+ if (firstLayerExtrusionWidthToTest >= firstLayerExtrusionWidthThreshold)
+ {
+ Console.WriteLine("Extrusion width greater than threshold: " + printer.RelativeConfigPath);
+ }
+ else if (firstLayerExtrusionWidthToTest <= 0)
+ {
+ Console.WriteLine("Extrusion width <= 0: " + printer.RelativeConfigPath);
+ }
+
+ printer.RuleViolated = true;
+ return;
+ }
+
+ Assert.Less(firstLayerExtrusionWidthToTest, firstLayerExtrusionWidthThreshold, "[first_layer_extrusion_width] greater than acceptable value: " + printer.RelativeConfigPath);
+
+ // TODO: We're not validating first_layer_extrusion_width as we have the product of nozzleDiameter and firstLayerExtrusionWidth. Seems confusing
+ Assert.Greater(firstLayerExtrusionWidthToTest, 0, "First layer extrusion width cannot be zero: " + printer.RelativeConfigPath);
+ }
+ });
+ }
+
+ [Test]
+ public void FirstLayerExtrusionWidthGreaterThanZero()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ float nozzleDiameter = float.Parse(printer.SettingsLayer.ValueOrDefault("nozzle_diameter"));
+
+ string firstLayerExtrusionWidthString = printer.SettingsLayer.ValueOrDefault("first_layer_extrusion_width");
+ if (!string.IsNullOrEmpty(firstLayerExtrusionWidthString))
+ {
+ float firstLayerExtrusionWidth = ValueOrPercentageOf(firstLayerExtrusionWidthString, nozzleDiameter);
+
+ // TODO: Remove once validated and resolved
+ if (firstLayerExtrusionWidth <= 0)
+ {
+ printer.RuleViolated = true;
+ return;
+ }
+
+ Assert.Greater(firstLayerExtrusionWidth, 0, "[first_layer_extrusion_width] must be greater than zero: " + printer.RelativeConfigPath);
+ }
+ });
+ }
+
+ [Test]
+ public void SupportMaterialAssignedToExtruderOne()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ string supportMaterialExtruder = printer.SettingsLayer.ValueOrDefault("support_material_extruder");
+ if (!string.IsNullOrEmpty(supportMaterialExtruder) && printer.Oem != "Esagono")
+ {
+ Assert.AreEqual("1", supportMaterialExtruder, "[support_material_extruder] must be assigned to extruder 1: " + printer.RelativeConfigPath);
+ }
+ });
+ }
+
+ [Test]
+ public void SupportInterfaceMaterialAssignedToExtruderOne()
+ {
+ ValidateOnAllPrinters(printer =>
+ {
+ string supportMaterialInterfaceExtruder = printer.SettingsLayer.ValueOrDefault("support_material_interface_extruder");
+ if (!string.IsNullOrEmpty(supportMaterialInterfaceExtruder) && printer.Oem != "Esagono")
+ {
+ Assert.AreEqual("1", supportMaterialInterfaceExtruder, "[support_material_interface_extruder] must be assigned to extruder 1");
+ }
+ });
+ }
+
+ private static float ValueOrPercentageOf(string valueOrPercent, float baseValue)
+ {
+ if (valueOrPercent.Contains("%"))
+ {
+ float percentage = float.Parse(valueOrPercent.Replace("%", "")) / 100;
+ return baseValue * percentage;
+ }
+ else
+ {
+ return float.Parse(valueOrPercent);
+ }
+ }
+
+ ///
+ /// Calls the given delegate for each known printer, passing in a PrinterConfig object that has
+ /// config.ini loaded into a SettingsLayer as well as state about the printer
+ ///
+ /// The action to invoke for each printer
+ private void ValidateOnAllPrinters(Action action)
+ {
+ var ruleViolations = new List();
+
+ foreach (var printer in allPrinters)
+ {
+ printer.RuleViolated = false;
+ action(printer);
+
+ if (printer.RuleViolated)
+ {
+ ruleViolations.Add(printer.RelativeConfigPath);
+ }
+ }
+
+ Assert.IsTrue(
+ ruleViolations.Count == 0, /* Use == instead of Assert.AreEqual to better convey failure details */
+ string.Format("One or more printers violate this rule: \r\n\r\n{0}\r\n", string.Join("\r\n", ruleViolations.ToArray())));
+ }
+
+ private class PrinterConfig
+ {
+ public string PrinterName { get; set; }
+ public string Oem { get; set; }
+ public string ConfigPath { get; set; }
+ public string RelativeConfigPath { get; set; }
+ public SettingsLayer SettingsLayer { get; set; }
+
+ // HACK: short term hack to support a general purpose test rollup function for cases where multiple config files
+ // violate a rule and in the short term we want to report and resolve the issues in batch rather than having a
+ // single test failure. Long term the single test failure better communicates the issue and assist with troubleshooting
+ // by using .AreEqual .LessOrEqual, etc. to communicate intent
+ public bool RuleViolated { get; set; } = false;
+ }
+ }
+}
diff --git a/Tests/MatterControl.Tests/MatterControl/PrinterCallBackTests.cs b/Tests/MatterControl.Tests/MatterControl/PrinterCallBackTests.cs
deleted file mode 100644
index 23be38ed4..000000000
--- a/Tests/MatterControl.Tests/MatterControl/PrinterCallBackTests.cs
+++ /dev/null
@@ -1,292 +0,0 @@
-using MatterHackers.MatterControl;
-using NUnit.Framework;
-using System;
-using System.IO;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Globalization;
-using MatterHackers.MatterControl.SlicerConfiguration;
-
-namespace MatterControl.Tests.MatterControl
-{
-
- [TestFixture]
- public class PrinterCallbackTests
- {
-
- Dictionary settingsComparison;
-
-
- /*[Test]
- public void Blah()
- {
- Assert.True("B" == "B");
- }*/
-
- [Test, Category("PrinterConfigurationFiles"), Ignore("Not Finished")]
- public void PrinterConfigTests()
- {
-
- //Do the work to setup the expected failure case
- //ActiveSliceSettings.Instance.FirstLayerExtrusionWidth = 0.2;
-
- //Assert.True(ActiveSliceSettings.Instance.IsValid());
- //Assert.True("A" == "A");
-
- //Do the work to setup the expected failure case
- //Assert.False(ActiveSliceSettings.Instance.IsValid());
-
- DirectoryInfo currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
- var allConfigFile = currentDirectory.Parent.Parent.Parent.Parent.FullName;
- string pathToPrinterSettings = @"StaticData\PrinterSettings";
- var fullPathToPrinterSettings = Path.Combine(allConfigFile, pathToPrinterSettings);
-
- DirectoryInfo test = new DirectoryInfo(fullPathToPrinterSettings);
-
- IEnumerable fileList = test.GetFiles(".", System.IO.SearchOption.AllDirectories);
-
- var allPrinterConfigs = fileList.Where(file => file.Name == "config.ini");
-
- foreach (FileInfo files in allPrinterConfigs)
- {
- Console.WriteLine(files.FullName);
-
- settingsComparison = new Dictionary();
- foreach(string line in File.ReadLines(files.FullName))
- {
-
- string[] settingNameAndValue = line.Split(new []{'='}, StringSplitOptions.RemoveEmptyEntries);
- string settingName = settingNameAndValue[0].Trim();
- string settingValue = string.Empty;
-
- if (settingNameAndValue.Length == 2)
- {
- settingValue = settingNameAndValue[1].Trim();
- }
-
- createComparisonDictionary(settingName, settingValue);
- bedSizeXYSeparatedByComma(settingName, settingValue);
- printCenterFormatSeparatedByComma(settingName, settingValue);
- testRetractLengthLessThanTwenty(settingName, settingValue);
- testExtruderCountGreaterThanZero(settingName, settingValue);
- maxFanSpeedNotGreaterThanOneHundred(settingName, settingValue);
- minimumFanSpeedLessThanOneHundred(settingName, settingValue);
- noCurlyBracketsInStartGcode(settingName, settingValue);
- noCurlyBracketsInEndGcode(settingName, settingValue);
- testBottomSolidLayersOneMM(settingName, settingValue);
- testFirstLayerTempNotInStartGcode(settingName, settingValue);
- testFirstLayerBedTemperatureNotInStartGcode(settingName, settingValue);
-
- }
-
- compareDictionarySettings();
- }
- }
-
- public void createComparisonDictionary (string settingName, string settingValue)
- {
-
- if (settingName == "nozzle_diameter")
- {
- settingsComparison[settingName] = float.Parse(settingValue);
-
- }
- else if(settingName == "layer_height")
- {
- settingsComparison[settingName] = float.Parse(settingValue);
-
- }
- else if (settingName =="first_layer_height")
- {
- if (settingValue.Contains("%"))
- {
- string newVal = settingValue.Replace("%", " ");
- settingsComparison[settingName] = float.Parse(newVal) / 100;
- }
- else
- {
- settingsComparison[settingName] = float.Parse(settingValue);
- }
-
- }
- else if (settingName == "first_layer_extrusion_width")
- {
-
- if (settingValue.Contains("%"))
- {
- string newVal = settingValue.Replace("%", " ");
- settingsComparison[settingName] = float.Parse(newVal) / 100;
- }
- else
- {
- settingsComparison[settingName] = float.Parse(settingValue);
- }
- }
-
- }
-
- public void compareDictionarySettings()
- {
-
- float firstLayerHeight = settingsComparison["first_layer_height"];
- float nozzleDiameter = settingsComparison["nozzle_diameter"];
- float layerHeight = settingsComparison["layer_height"];
- float firstLayerExtrusionWidth = settingsComparison["first_layer_extrusion_width"];
- float firstLayerExtrusionWidthToTest = firstLayerExtrusionWidth * nozzleDiameter;
- float firstLayerExtrusionWidthThreshold = nozzleDiameter * 4;
-
- if (firstLayerHeight > nozzleDiameter)
- {
- Console.WriteLine("first layer height greater than nozzle diameter");
- }
-
- if (layerHeight > nozzleDiameter)
- {
- Console.WriteLine("layer height greater than nozzle diameter");
- }
-
- if(firstLayerExtrusionWidthToTest > firstLayerExtrusionWidthThreshold)
- {
- Console.WriteLine("First Layer extrusion width greater than acceptable value");
- }
-
- if(firstLayerExtrusionWidthToTest <= 0)
- {
- Console.WriteLine("First layer extrusion width cannot be zero");
- }
-
- }
-
-
- public void bedSizeXYSeparatedByComma(string settingName, string settingValue)
- {
-
- string[] settingValueToTest = settingValue.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
-
- if (settingName == "bed_size" && settingValueToTest.Length != 2)
- {
- string test = String.Format("Name: {0} :: Value: {1} ", settingValue, settingValue.Length.ToString());
- Console.WriteLine(test);
- }
- }
-
- public void printCenterFormatSeparatedByComma(string settingName, string settingValue)
- {
- string[] settingValueToTest = settingValue.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- if (settingName == "print_center" && settingValueToTest.Length != 2)
- {
- string test = String.Format("Name: {0} :: Value: {1} ", settingValue, settingValue.Length.ToString());
- Console.WriteLine(test);
- }
- }
-
- public void testRetractLengthLessThanTwenty(string settingName, string settingValue)
- {
-
- if(settingName == "retract_length")
- {
- float convertedSettingValue = float.Parse(settingValue, CultureInfo.InvariantCulture.NumberFormat);
- if (convertedSettingValue > 20)
- {
- string test = String.Format("{0} :: {1}", settingName, convertedSettingValue.ToString());
- Console.WriteLine(test);
- }
- }
- }
-
- public void testExtruderCountGreaterThanZero(string settingName, string settingValue)
- {
- if (settingName =="extruder_count")
- {
- int convertedExtruderCount = Int32.Parse(settingValue);
- if(convertedExtruderCount < 1)
- {
- string test = String.Format("{0} :: {1}", settingName, convertedExtruderCount.ToString());
- Console.WriteLine(test);
- }
- }
- }
-
- public void minimumFanSpeedLessThanOneHundred(string settingName, string settingValue)
- {
- if (settingName == "min_fan_speed")
- {
- int convertedFanSpeed = Int32.Parse(settingValue);
-
- if(convertedFanSpeed > 100)
- {
- string test = String.Format("{0} :: {1}", settingName, convertedFanSpeed.ToString());
- Console.WriteLine(test);
- }
- }
- }
-
- public void maxFanSpeedNotGreaterThanOneHundred(string settingName, string settingValue)
- {
-
- if (settingName == "max_fan_speed")
- {
- int convertedFanSpeed = Int32.Parse(settingValue);
-
- if (convertedFanSpeed > 100)
- {
- string test = String.Format("{0} :: {1}", settingName, convertedFanSpeed.ToString());
- Console.WriteLine(test);
- }
- }
- }
-
- public void noCurlyBracketsInStartGcode(string settingName, string settingValue)
- {
-
- if (settingName == "start_gcode" && settingValue.Contains("}"))
- {
- Console.WriteLine("CURLY BRACKETS IN THERE");
- }
-
- }
-
- public void noCurlyBracketsInEndGcode(string settingName, string settingValue)
- {
- if (settingName == "end_gcode" && settingValue.Contains("}"))
- {
- Console.WriteLine("Curly brakcet in end gcode");
- }
-
- }
-
-
- public void testBottomSolidLayersOneMM(string settingName, string settingValue)
- {
-
- if (settingName == "bottom_solid_layers" && settingValue != "1mm")
- {
- Console.WriteLine("Bottom solid layer test fail");
- }
-
- }
-
- public void testFirstLayerTempNotInStartGcode(string settingName, string settingValue)
- {
-
- if(settingName == "start_gcode" && settingValue.Contains("first_layer_temperature"))
- {
- Console.WriteLine("FIRST Layer temp fail");
- }
-
- }
-
- public void testFirstLayerBedTemperatureNotInStartGcode(string settingName, string settingValue)
- {
-
- if(settingName == "start_gcode" && settingValue.Contains("first_layer_bed_temperature"))
- {
- Console.WriteLine("FIRST LAYER BED TEMP FAIL");
-
- }
- }
- }
-}