From 5fbf6281d7fd152b59a30e91c044d840fe9fd602 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Mon, 3 Dec 2018 16:33:25 -0800 Subject: [PATCH] put in the ability to specify "; NO_PROCESSING" on a gcode line issue: MatterHackers/MCCentral#4663 set position Z Tower and no Level --- .../Io/BabyStepsStream.cs | 15 ++++++++---- .../Io/ExtrusionMultiplyerStream.cs | 9 ++++++- .../Io/FeedRateMultiplyerStream.cs | 6 +++++ .../Io/MaxLengthStream.cs | 16 +++++++++---- .../PrinterCommunication/Io/OffsetStream.cs | 8 ++++++- .../Io/PauseHandlingStream.cs | 4 ++++ .../Io/PrintLevelingStream.cs | 24 ++++++++++++------- .../Io/ProcessWriteRegExStream.cs | 5 ++++ .../Io/RelativeToAbsoluteStream.cs | 5 ++++ .../Io/WaitForTempStream.cs | 6 +++++ .../UIFields/ExtruderOffsetField.cs | 2 -- StaticData/SliceSettings/Properties.json | 8 +++---- Submodules/MatterSlice | 2 +- 13 files changed, 83 insertions(+), 27 deletions(-) diff --git a/MatterControlLib/PrinterCommunication/Io/BabyStepsStream.cs b/MatterControlLib/PrinterCommunication/Io/BabyStepsStream.cs index 04e74a01e..f43678cbd 100644 --- a/MatterControlLib/PrinterCommunication/Io/BabyStepsStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/BabyStepsStream.cs @@ -74,10 +74,17 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io public override string ReadLine() { - string processedLine = offsetStream.ReadLine(); - if (processedLine != null + string lineToSend = offsetStream.ReadLine(); + + if (lineToSend != null + && lineToSend.EndsWith("; NO_PROCESSING")) + { + return lineToSend; + } + + if (lineToSend != null && layerCount < 1 - && GCodeFile.IsLayerChange(processedLine)) + && GCodeFile.IsLayerChange(lineToSend)) { layerCount++; if (layerCount == 1) @@ -85,7 +92,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io maxLengthStream.MaxSegmentLength = 5; } } - return processedLine; + return lineToSend; } private void OffsetChanged() diff --git a/MatterControlLib/PrinterCommunication/Io/ExtrusionMultiplyerStream.cs b/MatterControlLib/PrinterCommunication/Io/ExtrusionMultiplyerStream.cs index d00ae000b..dbedbb559 100644 --- a/MatterControlLib/PrinterCommunication/Io/ExtrusionMultiplyerStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/ExtrusionMultiplyerStream.cs @@ -45,7 +45,14 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io public override string ReadLine() { - return ApplyExtrusionMultiplier(internalStream.ReadLine()); + var lineToSend = internalStream.ReadLine(); + if (lineToSend != null + && lineToSend.EndsWith("; NO_PROCESSING")) + { + return lineToSend; + } + + return ApplyExtrusionMultiplier(lineToSend); } private string ApplyExtrusionMultiplier(string lineBeingSent) diff --git a/MatterControlLib/PrinterCommunication/Io/FeedRateMultiplyerStream.cs b/MatterControlLib/PrinterCommunication/Io/FeedRateMultiplyerStream.cs index 9fba634f6..ae154c1ba 100644 --- a/MatterControlLib/PrinterCommunication/Io/FeedRateMultiplyerStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/FeedRateMultiplyerStream.cs @@ -54,6 +54,12 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io { string lineToSend = internalStream.ReadLine(); + if (lineToSend != null + && lineToSend.EndsWith("; NO_PROCESSING")) + { + return lineToSend; + } + if (lineToSend != null && LineIsMovement(lineToSend)) { diff --git a/MatterControlLib/PrinterCommunication/Io/MaxLengthStream.cs b/MatterControlLib/PrinterCommunication/Io/MaxLengthStream.cs index 3b4ea5571..c2b5ccfd2 100644 --- a/MatterControlLib/PrinterCommunication/Io/MaxLengthStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/MaxLengthStream.cs @@ -60,12 +60,18 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io { if (movesToSend.Count == 0) { - string lineFromChild = base.ReadLine(); + string lineToSend = base.ReadLine(); - if (lineFromChild != null - && LineIsMovement(lineFromChild)) + if (lineToSend != null + && lineToSend.EndsWith("; NO_PROCESSING")) { - PrinterMove currentDestination = GetPosition(lineFromChild, lastDestination); + return lineToSend; + } + + if (lineToSend != null + && LineIsMovement(lineToSend)) + { + PrinterMove currentDestination = GetPosition(lineToSend, lastDestination); PrinterMove deltaToDestination = currentDestination - lastDestination; deltaToDestination.feedRate = 0; // remove the changing of the federate (we'll set it initially) double lengthSquared = Math.Max(deltaToDestination.LengthSquared, deltaToDestination.extrusion * deltaToDestination.extrusion); @@ -109,7 +115,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io lastDestination = currentDestination; } - return lineFromChild; + return lineToSend; } else { diff --git a/MatterControlLib/PrinterCommunication/Io/OffsetStream.cs b/MatterControlLib/PrinterCommunication/Io/OffsetStream.cs index 08053800a..2da7e3100 100644 --- a/MatterControlLib/PrinterCommunication/Io/OffsetStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/OffsetStream.cs @@ -62,7 +62,13 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io { string lineToSend = base.ReadLine(); - if(lineToSend != null + if (lineToSend != null + && lineToSend.EndsWith("; NO_PROCESSING")) + { + return lineToSend; + } + + if (lineToSend != null && lineToSend.StartsWith("T")) { int extruder = 0; diff --git a/MatterControlLib/PrinterCommunication/Io/PauseHandlingStream.cs b/MatterControlLib/PrinterCommunication/Io/PauseHandlingStream.cs index 89c25d735..8039d0a86 100644 --- a/MatterControlLib/PrinterCommunication/Io/PauseHandlingStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/PauseHandlingStream.cs @@ -156,6 +156,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io { return lineToSend; } + if (lineToSend.EndsWith("; NO_PROCESSING")) + { + return lineToSend; + } // We got a line from the gcode we are sending check if we should queue a request for filament runout if (printer.Settings.GetValue(SettingsKey.filament_runout_sensor)) diff --git a/MatterControlLib/PrinterCommunication/Io/PrintLevelingStream.cs b/MatterControlLib/PrinterCommunication/Io/PrintLevelingStream.cs index 1e90b2234..d198b0586 100644 --- a/MatterControlLib/PrinterCommunication/Io/PrintLevelingStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/PrintLevelingStream.cs @@ -71,33 +71,39 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io return "; Software Leveling Applied"; } - string lineFromChild = base.ReadLine(); + string lineToSend = base.ReadLine(); - if(lineFromChild == "; Software Leveling Applied") + if (lineToSend != null + && lineToSend.EndsWith("; NO_PROCESSING")) + { + return lineToSend; + } + + if (lineToSend == "; Software Leveling Applied") { gcodeAlreadyLeveled = true; } - if (lineFromChild != null + if (lineToSend != null && LevelingActive && !gcodeAlreadyLeveled) { - if (LineIsMovement(lineFromChild)) + if (LineIsMovement(lineToSend)) { - PrinterMove currentDestination = GetPosition(lineFromChild, lastDestination); - var leveledLine = GetLeveledPosition(lineFromChild, currentDestination); + PrinterMove currentDestination = GetPosition(lineToSend, lastDestination); + var leveledLine = GetLeveledPosition(lineToSend, currentDestination); lastDestination = currentDestination; return leveledLine; } - else if (lineFromChild.StartsWith("G29")) + else if (lineToSend.StartsWith("G29")) { // remove G29 (machine prob bed) if we are running our own leveling. - lineFromChild = base.ReadLine(); // get the next line instead + lineToSend = base.ReadLine(); // get the next line instead } } - return lineFromChild; + return lineToSend; } public override void SetPrinterPosition(PrinterMove position) diff --git a/MatterControlLib/PrinterCommunication/Io/ProcessWriteRegExStream.cs b/MatterControlLib/PrinterCommunication/Io/ProcessWriteRegExStream.cs index 064a1ce73..4690a198c 100644 --- a/MatterControlLib/PrinterCommunication/Io/ProcessWriteRegExStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/ProcessWriteRegExStream.cs @@ -63,6 +63,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io return null; } + if (baseLine.EndsWith("; NO_PROCESSING")) + { + return baseLine; + } + // if the line has no content don't process it if (baseLine.Length == 0 || baseLine.Trim().Length == 0) diff --git a/MatterControlLib/PrinterCommunication/Io/RelativeToAbsoluteStream.cs b/MatterControlLib/PrinterCommunication/Io/RelativeToAbsoluteStream.cs index b3d026d3d..788fa0258 100644 --- a/MatterControlLib/PrinterCommunication/Io/RelativeToAbsoluteStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/RelativeToAbsoluteStream.cs @@ -128,6 +128,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io // G91 Relative // G90 Absolute string lineToSend = base.ReadLine(); + if (lineToSend != null + && lineToSend.EndsWith("; NO_PROCESSING")) + { + return lineToSend; + } return ProcessLine(lineToSend); } diff --git a/MatterControlLib/PrinterCommunication/Io/WaitForTempStream.cs b/MatterControlLib/PrinterCommunication/Io/WaitForTempStream.cs index 11ab5f4b4..f91575b8d 100644 --- a/MatterControlLib/PrinterCommunication/Io/WaitForTempStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/WaitForTempStream.cs @@ -77,6 +77,12 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io { string lineToSend = base.ReadLine(); + if (lineToSend != null + && lineToSend.EndsWith("; NO_PROCESSING")) + { + return lineToSend; + } + if (lineToSend != null && lineToSend.StartsWith("M")) { diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ExtruderOffsetField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ExtruderOffsetField.cs index d77aa214b..0e2d01583 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ExtruderOffsetField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ExtruderOffsetField.cs @@ -51,8 +51,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.settingsContext = settingsContext; this.textColor = textColor; this.theme = theme; - - //SaveCommaSeparatedIndexSetting(extruderOffset.ExtruderIndex, settingsContext, slicerConfigName, extruderOffset.Value.Replace(",", "x")); } public override void Initialize(int tabIndex) diff --git a/StaticData/SliceSettings/Properties.json b/StaticData/SliceSettings/Properties.json index 2c40cdc97..fc8043c14 100644 --- a/StaticData/SliceSettings/Properties.json +++ b/StaticData/SliceSettings/Properties.json @@ -1670,7 +1670,7 @@ { "SlicerConfigName": "before_toolchange_gcode", "PresentationName": "Before Tool Change G-Code", - "HelpText": "G-Code to be run before every tool change. You can use [wipe_tower_x] & [wipe_tower_y] to set the extruder position if needed.", + "HelpText": "G-Code to be run before every tool change. You can use [wipe_tower_x] [wipe_tower_y] & [wipe_tower_z] to set the extruder position if needed.", "DataEditType": "MULTI_LINE_TEXT", "ShowIfSet": "!sla_printer&extruder_count>1", "DefaultValue": "" @@ -1678,7 +1678,7 @@ { "SlicerConfigName": "toolchange_gcode", "PresentationName": "After Tool Change G-Code", - "HelpText": "G-Code to be run after every tool change. You can use [wipe_tower_x] & [wipe_tower_y] to set the extruder position if needed.", + "HelpText": "G-Code to be run after every tool change. You can use [wipe_tower_x] [wipe_tower_y] & [wipe_tower_z] to set the extruder position if needed.", "ShowIfSet": "!sla_printer&extruder_count>1", "DataEditType": "MULTI_LINE_TEXT", "DefaultValue": "" @@ -1686,7 +1686,7 @@ { "SlicerConfigName": "before_toolchange_gcode_1", "PresentationName": "Before Tool Change G-Code 2", - "HelpText": "G-Code to be run before switching to extruder 2. Will use standard before G-Code if not set. You can use [wipe_tower_x] & [wipe_tower_y] to set the extruder position if needed.", + "HelpText": "G-Code to be run before switching to extruder 2. Will use standard before G-Code if not set. You can use [wipe_tower_x] [wipe_tower_y] & [wipe_tower_z] to set the extruder position if needed.", "DataEditType": "MULTI_LINE_TEXT", "ShowIfSet": "!sla_printer&extruder_count>1", "DefaultValue": "" @@ -1694,7 +1694,7 @@ { "SlicerConfigName": "toolchange_gcode_1", "PresentationName": "After Tool Change G-Code 2", - "HelpText": "G-Code to be run after switching to extruder 2. Will use standard after G-Code if not set. You can use [wipe_tower_x] & [wipe_tower_y] to set the extruder position if needed.", + "HelpText": "G-Code to be run after switching to extruder 2. Will use standard after G-Code if not set. You can use [wipe_tower_x] [wipe_tower_y] & [wipe_tower_z] to set the extruder position if needed.", "ShowIfSet": "!sla_printer&extruder_count>1", "DataEditType": "MULTI_LINE_TEXT", "DefaultValue": "" diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 4ae7af9be..d622147cc 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 4ae7af9be45d448e56f7363398aef4ade38674b1 +Subproject commit d622147cca7e624c572d80750ea59809c95e1496