Extract StreamProcessor tool for interactive debugging

This commit is contained in:
jlewin 2019-04-09 11:04:41 -07:00
parent 9f0b1c658c
commit b2a54fd297
3 changed files with 25 additions and 13 deletions

View file

@ -509,16 +509,7 @@ namespace MatterHackers.MatterControl
private void button1_Click(object sender, EventArgs e)
{
var context = ApplicationController.Instance.ActivePrinters.First().Connection.TotalGCodeStream;
var sb = new StringBuilder();
while (context is GCodeStream gCodeStream)
{
sb.AppendFormat("{0} {1}\r\n", gCodeStream.GetType().Name, gCodeStream.DebugInfo);
context = gCodeStream.InternalStream;
}
textBox1.Text = sb.ToString();
textBox1.Text = context.GetDebugState();
}
}
}

View file

@ -28,11 +28,13 @@ either expressed or implied, of the FreeBSD Project.
*/
using System.Linq;
using System.Text;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.UI;
using MatterHackers.DataConverters3D;
using MatterHackers.ImageProcessing;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.PrinterCommunication.Io;
namespace MatterHackers.MatterControl
{
@ -61,5 +63,26 @@ namespace MatterHackers.MatterControl
{
return sourceImage.AnyAlphaToColor(ApplicationController.Instance.Theme.PrimaryAccentColor);
}
public static string GetDebugState(this GCodeStream sourceStream)
{
return GetDebugState(sourceStream, ApplicationController.Instance.ActivePrinters.First());
}
public static string GetDebugState(this GCodeStream sourceStream, PrinterConfig printer)
{
var context = printer.Connection.TotalGCodeStream;
var sb = new StringBuilder();
while (context is GCodeStream gCodeStream)
{
sb.AppendFormat("{0} {1}\r\n", gCodeStream.GetType().Name, gCodeStream.DebugInfo);
context = gCodeStream.InternalStream;
}
return sb.ToString();
}
}
}

View file

@ -101,15 +101,13 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
public static List<string> ProcessWriteRegEx(string lineToWrite, PrinterConfig printer)
{
var WriteLineReplacements = printer.Settings.Helpers.WriteLineReplacements;
var linesToWrite = new List<string>();
linesToWrite.Add(lineToWrite);
var addedLines = new List<string>();
for (int i = 0; i < linesToWrite.Count; i++)
{
foreach (var item in WriteLineReplacements)
foreach (var item in printer.Settings.Helpers.WriteLineReplacements)
{
var splitReplacement = item.Replacement.Split(',');
if (splitReplacement.Length > 0)