public BabyStepsStream(GCodeStream internalStream) : base(null) { maxLengthStream = new MaxLengthStream(internalStream, 1); offsetStream = new OffsetStream(maxLengthStream, new Vector3(0, 0, 0)); base.internalStream = offsetStream; }
public BabyStepsStream(GCodeStream internalStream) : base(null) { ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) => { if ((e as StringEventArgs)?.Data == SettingsKey.baby_step_z_offset) { OffsetChanged(); } }, ref unregisterEvents); maxLengthStream = new MaxLengthStream(internalStream, 1); offsetStream = new OffsetStream(maxLengthStream, new Vector3(0, 0, ActiveSliceSettings.Instance.GetValue <double>(SettingsKey.baby_step_z_offset))); base.internalStream = offsetStream; }
public BabyStepsStream(PrinterSettings printerSettings, GCodeStream internalStream, double startingMaxLength = 1) : base(null) { this.printerSettings = printerSettings; ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) => { if ((e as StringEventArgs)?.Data == SettingsKey.baby_step_z_offset) { OffsetChanged(); } }, ref unregisterEvents); maxLengthStream = new MaxLengthStream(internalStream, startingMaxLength); offsetStream = new OffsetStream(maxLengthStream, new Vector3(0, 0, printerSettings.GetValue <double>(SettingsKey.baby_step_z_offset))); base.internalStream = offsetStream; }
public void MaxLengthStreamTests() { string[] lines = new string[] { "G1 X0 Y0 Z0 E0 F500", "M105", "G1 X18 Y0 Z0 F2500", "G28", "G1 X0 Y0 Z0 E0 F500", null, }; // We should go back to the above code when possible. It requires making pause part and move while paused part of the stream. // All communication should go through stream to minimize the difference between printing and controlling while not printing (all printing in essence). string[] expected = new string[] { "G1 X0 Y0 Z0 E0 F500", "M105", "G1 X6 F2500", "G1 X12", "G1 X18", "G28", "G1 X12 F500", "G1 X6", "G1 X0", null, }; StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData")); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); MaxLengthStream maxLengthStream = new MaxLengthStream(new TestGCodeStream(lines), 6); int expectedIndex = 0; string actualLine = maxLengthStream.ReadLine(); string expectedLine = expected[expectedIndex++]; Assert.AreEqual(expectedLine, actualLine, "Unexpected response from MaxLengthStream"); while (actualLine != null) { actualLine = maxLengthStream.ReadLine(); expectedLine = expected[expectedIndex++]; Assert.AreEqual(expectedLine, actualLine, "Unexpected response from MaxLengthStream"); } }
public BabyStepsStream(PrinterConfig printer, GCodeStream internalStream, double startingMaxLength = 1) : base(printer, internalStream) { void Printer_SettingChanged(object s, EventArgs e) { if ((e as StringEventArgs)?.Data == SettingsKey.baby_step_z_offset) { OffsetChanged(); } } printer.Settings.SettingChanged += Printer_SettingChanged; printer.Disposed += (s, e) => printer.Settings.SettingChanged -= Printer_SettingChanged; maxLengthStream = new MaxLengthStream(printer, internalStream, startingMaxLength); offsetStream = new OffsetStream(maxLengthStream, printer, new Vector3(0, 0, printer.Settings.GetValue <double>(SettingsKey.baby_step_z_offset))); base.internalStream = offsetStream; }
public void MaxLengthStreamTests() { string[] lines = new string[] { "G1 X0 Y0 Z0 E0 F500", "M105", "G1 X18 Y0 Z0 F2500", "G28", "G1 X0 Y0 Z0 E0 F500", null, }; // We should go back to the above code when possible. It requires making pause part and move while paused part of the stream. // All communication should go through stream to minimize the difference between printing and controlling while not printing (all printing in essence). string[] expected = new string[] { "G1 X0 Y0 Z0 E0 F500", "M105", "G1 X6 Y0 Z0 F2500", "G1 X12 Y0 Z0", "G1 X18 Y0 Z0", "G28", "G1 X12 Y0 Z0 F500", "G1 X6 Y0 Z0", "G1 X0 Y0 Z0", null, }; MaxLengthStream maxLengthStream = new MaxLengthStream(new TestGCodeStream(lines), 6); int expectedIndex = 0; string correctedLine = maxLengthStream.ReadLine(); Assert.IsTrue(correctedLine == expected[expectedIndex++]); while (correctedLine != null) { correctedLine = maxLengthStream.ReadLine(); Assert.IsTrue(correctedLine == expected[expectedIndex++]); } }