private void loadGCodeWorker_DoWork(object sender, DoWorkEventArgs e)
		{
			totalGCodeStream?.Dispose();

			string gcodeFilename = e.Argument as string;
			loadedGCode = GCodeFile.Load(gcodeFilename);

			gCodeFileStream0 = new GCodeFileStream(loadedGCode);
			pauseHandlingStream1 = new PauseHandlingStream(gCodeFileStream0);
			queuedCommandStream2 = new QueuedCommandsStream(pauseHandlingStream1);
			relativeToAbsoluteStream3 = new RelativeToAbsoluteStream(queuedCommandStream2);
			printLevelingStream4 = new PrintLevelingStream(relativeToAbsoluteStream3);
			waitForTempStream5 = new WaitForTempStream(printLevelingStream4);
			babyStepsStream6 = new BabyStepsStream(waitForTempStream5);
			extrusionMultiplyerStream7 = new ExtrusionMultiplyerStream(babyStepsStream6);
			feedrateMultiplyerStream8 = new FeedRateMultiplyerStream(extrusionMultiplyerStream7);
			requestTemperaturesStream9 = new RequestTemperaturesStream(feedrateMultiplyerStream8);
			totalGCodeStream = requestTemperaturesStream9;
		}
Пример #2
0
		public void PauseHandlingStreamTests()
		{
			string[] inputLines = new string[]
			{
				"; the printer is moving normally",
				"G1 X10 Y10 Z10 E0",
				"G1 X10 Y10 Z10 E10",
				"G1 X10 Y10 Z10 E30",

				"; the printer pauses",
				"G91",
				"G1 Z10 E - 10 F12000",
				"G90",

				"; the user moves the printer",

				"; the printer un-pauses",
				"G91",
				"G1 Z-10 E10.8 F12000",
				"G90",
				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[]
			{
				"; the printer is moving normally",
				"G1 X10 Y10 Z10 E0",
				"G1 X10 Y10 Z10 E10",
				"G1 X10 Y10 Z10 E30",

				"; the printer pauses",
				"", // G91 is removed
				"G1 X10 Y10 Z20 E20 F12000", // altered to be absolute
				"G90",

				"; the user moves the printer",

				"; the printer un-pauses",
				"", // G91 is removed
				"G1 X10 Y10 Z10 E30.8",
				"G90",
				null,
			};

			PauseHandlingStream pauseHandlingStream = new PauseHandlingStream(new TestGCodeStream(inputLines));

			int expectedIndex = 0;
			string correctedLine = pauseHandlingStream.ReadLine();
			string expectedLine = expected[expectedIndex++];
            Assert.IsTrue(correctedLine == expectedLine);
			while (correctedLine != null)
			{
				expectedLine = expected[expectedIndex++];
				correctedLine = pauseHandlingStream.ReadLine();
				Assert.IsTrue(correctedLine == expectedLine);
			}
		}
		void CreateStreamProcessors(string gcodeFilename, bool recoveryEnabled)
		{
			totalGCodeStream?.Dispose();

			GCodeStream firstStream = null;
			if (gcodeFilename != null)
			{
				loadedGCode = GCodeFile.Load(gcodeFilename);
				gCodeFileStream0 = new GCodeFileStream(loadedGCode);

				if (ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.recover_is_enabled)
					&& activePrintTask != null) // We are resuming a failed print (do lots of interesting stuff).
				{
					pauseHandlingStream1 = new PauseHandlingStream(new PrintRecoveryStream(gCodeFileStream0, activePrintTask.PercentDone));
				}
				else
				{
					pauseHandlingStream1 = new PauseHandlingStream(gCodeFileStream0);
				}

				firstStream = pauseHandlingStream1;
			}
			else
			{
				firstStream = new NotPrintingStream();
			}

			queuedCommandStream2 = new QueuedCommandsStream(firstStream);
			relativeToAbsoluteStream3 = new RelativeToAbsoluteStream(queuedCommandStream2);
			printLevelingStream4 = new PrintLevelingStream(relativeToAbsoluteStream3, true);
			waitForTempStream5 = new WaitForTempStream(printLevelingStream4);
			babyStepsStream6 = new BabyStepsStream(waitForTempStream5);
			if (activePrintTask != null)
			{
				// make sure we are in the position we were when we stopped printing
				babyStepsStream6.Offset = new Vector3(activePrintTask.PrintingOffsetX, activePrintTask.PrintingOffsetY, activePrintTask.PrintingOffsetZ);
			}
			extrusionMultiplyerStream7 = new ExtrusionMultiplyerStream(babyStepsStream6);
			feedrateMultiplyerStream8 = new FeedRateMultiplyerStream(extrusionMultiplyerStream7);
			requestTemperaturesStream9 = new RequestTemperaturesStream(feedrateMultiplyerStream8);
			totalGCodeStream = requestTemperaturesStream9;
		}
		private void LoadGCodeToPrint(string gcodeFilename)
		{
			totalGCodeStream?.Dispose();

			loadedGCode = GCodeFile.Load(gcodeFilename);

			gCodeFileStream0 = new GCodeFileStream(loadedGCode);
			if(activePrintTask != null) // We are resuming a failed print (do lots of interesting stuff).
			{
				pauseHandlingStream1 = new PauseHandlingStream(new ResumePrintingStream(gCodeFileStream0, activePrintTask.PercentDone));
			}
			else
			{
				pauseHandlingStream1 = new PauseHandlingStream(gCodeFileStream0);
			}
			queuedCommandStream2 = new QueuedCommandsStream(pauseHandlingStream1);
			relativeToAbsoluteStream3 = new RelativeToAbsoluteStream(queuedCommandStream2);
			printLevelingStream4 = new PrintLevelingStream(relativeToAbsoluteStream3);
			waitForTempStream5 = new WaitForTempStream(printLevelingStream4);
			babyStepsStream6 = new BabyStepsStream(waitForTempStream5);
			if(activePrintTask != null)
			{
				// make sure we are in the position we were when we stopped printing
				babyStepsStream6.Offset = new Vector3(activePrintTask.PrintingOffsetX, activePrintTask.PrintingOffsetY, activePrintTask.PrintingOffsetZ);
			}
			extrusionMultiplyerStream7 = new ExtrusionMultiplyerStream(babyStepsStream6);
			feedrateMultiplyerStream8 = new FeedRateMultiplyerStream(extrusionMultiplyerStream7);
			requestTemperaturesStream9 = new RequestTemperaturesStream(feedrateMultiplyerStream8);
			totalGCodeStream = requestTemperaturesStream9;
		}