public override string ReadLine() { string lineToSend = internalStream.ReadLine(); if (lineToSend != null && lineToSend.EndsWith("; NO_PROCESSING")) { return(lineToSend); } if (lineToSend != null && LineIsMovement(lineToSend)) { PrinterMove currentMove = GetPosition(lineToSend, this.lastDestination); PrinterMove moveToSend = currentMove; moveToSend.feedRate *= FeedRateRatio; if (moveToSend.HaveAnyPosition) { lineToSend = CreateMovementLine(moveToSend, this.lastDestination); } this.lastDestination = currentMove; return(lineToSend); } return(lineToSend); }
public override void SetPrinterPosition(PrinterMove position) { }
public override void SetPrinterPosition(PrinterMove position) { internalStream.SetPrinterPosition(position); }
public string ProcessLine(string lineToProcess) { if (lineToProcess != null && lineToProcess.StartsWith("G9")) { if (lineToProcess.StartsWith("G91")) { xyzAbsoluteMode = false; eAbsoluteMode = false; return(""); } else if (lineToProcess.StartsWith("G90")) { xyzAbsoluteMode = true; eAbsoluteMode = true; if (haveSentG90) { // If we have already set the printer to absolute mode, do not send it again. // This will guarantee we send it once and then we don't send it again (as this ensures we never send a G91). return(""); } haveSentG90 = true; } if (lineToProcess.StartsWith("M83")) { // extruder to relative mode eAbsoluteMode = false; } else if (lineToProcess.StartsWith("82")) { // extruder to absolute mode eAbsoluteMode = true; } } if (lineToProcess != null && LineIsMovement(lineToProcess)) { PrinterMove currentDestination; if (xyzAbsoluteMode && eAbsoluteMode) { currentDestination = GetPosition(lineToProcess, lastDestination); } else { PrinterMove xyzDestination = GetPosition(lineToProcess, lastDestination); double feedRate = xyzDestination.feedRate; if (!xyzAbsoluteMode) { xyzDestination = GetPosition(lineToProcess, PrinterMove.Zero); xyzDestination += lastDestination; } PrinterMove eDestination = GetPosition(lineToProcess, lastDestination); if (!eAbsoluteMode) { eDestination = GetPosition(lineToProcess, PrinterMove.Zero); eDestination += lastDestination; } currentDestination.extrusion = eDestination.extrusion; currentDestination.feedRate = feedRate; currentDestination.position = xyzDestination.position; lineToProcess = CreateMovementLine(currentDestination, lastDestination); } // send the first one lastDestination = currentDestination; } return(lineToProcess); }
public override void SetPrinterPosition(PrinterMove position) { this.lastDestination.CopyKnowSettings(position); internalStream.SetPrinterPosition(lastDestination); }
public string ProcessLine(string lineToProcess) { if (lineToProcess.StartsWith("G9")) { if (lineToProcess.StartsWith("G91")) { xyzAbsoluteMode = false; eAbsoluteMode = false; // do not actually send this to the printer return(""); } else if (lineToProcess.StartsWith("G90")) { xyzAbsoluteMode = true; eAbsoluteMode = true; if (haveSentG90) { // If we have already set the printer to absolute mode, do not send it again. // This will guarantee we send it once and then we don't send it again (as this ensures we never send a G91). return(""); } haveSentG90 = true; } } else if (lineToProcess.StartsWith("M83")) { // extruder to relative mode eAbsoluteMode = false; // do not actually send this to the printer return(""); } else if (lineToProcess.StartsWith("M82")) { // extruder to absolute mode eAbsoluteMode = true; if (haveSentM82) { return(""); } haveSentM82 = true; } if (LineIsMovement(lineToProcess)) { PrinterMove currentDestination; currentDestination = GetPosition(lineToProcess, lastDestination); if (!xyzAbsoluteMode || !eAbsoluteMode) { PrinterMove xyzDestination = GetPosition(lineToProcess, lastDestination); if (xyzDestination.HaveAnyPosition) { double feedRate = xyzDestination.feedRate; if (!xyzAbsoluteMode) { xyzDestination = GetPosition(lineToProcess, PrinterMove.Zero); if (lastDestination.position.X != double.PositiveInfinity) { xyzDestination.position.X += lastDestination.position.X; } if (lastDestination.position.Y != double.PositiveInfinity) { xyzDestination.position.Y += lastDestination.position.Y; } if (lastDestination.position.Z != double.PositiveInfinity) { xyzDestination.position.Z += lastDestination.position.Z; } } PrinterMove eDestination = GetPosition(lineToProcess, lastDestination); if (!eAbsoluteMode) { eDestination = GetPosition(lineToProcess, PrinterMove.Zero); if (lastDestination.extrusion != double.PositiveInfinity) { eDestination += lastDestination; } } currentDestination.extrusion = eDestination.extrusion; currentDestination.feedRate = feedRate; currentDestination.position = xyzDestination.position; } if (!lineToProcess.StartsWith("G28") && !lineToProcess.StartsWith("G29") && !lineToProcess.StartsWith("G30")) { lineToProcess = CreateMovementLine(currentDestination, lastDestination); } } // send the first one lastDestination = currentDestination; } return(lineToProcess); }