public GCodeCompressed(GCode c) { int p = c.orig.IndexOf(';'); string tmp = (p >= 0 ? c.orig.Substring(0, p) : c.orig).Trim(); data = enc.GetBytes(tmp); }
public void PushData(string code) { code = code.Replace('\r', '\n'); string[] lines = code.Split('\n'); foreach (string line in lines) { if (line.Length == 0) { continue; } GCode gcode = new GCode(); gcode.Parse(line); if (!gcode.comment) { jobList.AddLast(new GCodeCompressed(gcode)); totalLines++; } } }
public void PushGCodeShortArray(List <GCodeShort> codes) { foreach (GCodeShort line in codes) { if (line.Length == 0) { continue; } ana.analyzeShort(line); GCode gcode = new GCode(); gcode.Parse(line.text); if (!gcode.comment) { jobList.AddLast(new GCodeCompressed(gcode)); totalLines++; } if (line.hasLayer) { maxLayer = line.layer; } } computedPrintingTime = ana.printingTime; }
public void executeHostCommand(GCode code) { string com = code.getHostCommand(); string param = code.getHostParameter(); if (com.Equals("@info")) { conn.log(param, false, 3); } else if (com.Equals("@pause")) { SoundConfig.PlayPrintPaused(false); conn.pause(param); } else if (com.Equals("@sound")) { SoundConfig.PlaySoundCommand(false); } }
public void Analyze(GCode code) { if (code.hostCommand) { string cmd = code.getHostCommand(); if (cmd.Equals("@hide")) drawing = false; else if (cmd.Equals("@show")) drawing = true; else if (cmd.Equals("@isathome")) { hasXHome = hasYHome = hasZHome = true; x = Main.printerSettings.XHomePos; y = Main.printerSettings.YHomePos; z = Main.printerSettings.ZHomePos; xOffset = yOffset = zOffset = 0; } return; } //if (code.forceAscii) return; // Don't analyse host commands and unknown commands if (code.hasN) lastline = code.N; if (uploading && !code.hasM && code.M != 29) return; // ignore upload commands if (code.hasG) { switch (code.G) { case 0: case 1: eChanged = false; if (code.hasF) f = code.F; if (relative) { if (code.hasX) x += code.X; if (code.hasY) y += code.Y; if (code.hasZ) z += code.Z; if (code.hasE) { eChanged = code.E != 0; e += code.E; } } else { if (code.hasX) x = xOffset + code.X; if (code.hasY) y = yOffset + code.Y; if (code.hasZ) { z = zOffset + code.Z; } if (code.hasE) { if (eRelative) { eChanged = code.E != 0; e += code.E; } else { eChanged = e != (eOffset + code.E); e = eOffset + code.E; } } } if (x < Main.printerSettings.XMin) { x = Main.printerSettings.XMin; hasXHome = false; } if (y < Main.printerSettings.YMin) { y = Main.printerSettings.YMin; hasYHome = false; } if (z < 0) { z = 0; hasZHome = false; } if (x > Main.printerSettings.XMax) { hasXHome = false; } if (y > Main.printerSettings.YMax) { hasYHome = false; } if (z > printerHeight) { hasZHome = false; } if (e > emax) { emax = e; if (z != lastZPrint) { layer++; lastZPrint = z; if (!privateAnalyzer && Main.conn.job.hasData() && Main.conn.job.maxLayer >= 0) { //PrinterConnection.logInfo("Printing layer " + layer.ToString() + " of " + Main.conn.job.maxLayer.ToString()); PrinterConnection.logInfo(Trans.T2("L_PRINTING_LAYER_X_OF_Y",layer.ToString(), Main.conn.job.maxLayer.ToString())); } } } if (eventPosChanged != null) if (privateAnalyzer) eventPosChanged(code, x, y, z); else Main.main.Invoke(eventPosChanged, code, x, y, z); float dx = Math.Abs(x - lastX); float dy = Math.Abs(y - lastY); float dz = Math.Abs(z - lastZ); float de = Math.Abs(e - lastE); if (dx + dy + dz > 0.001) { printingTime += Math.Sqrt(dx * dx + dy * dy + dz * dz) * 60.0f / f; } else printingTime += de * 60.0f / f; lastX = x; lastY = y; lastZ = z; lastE = e; break; case 28: case 161: { bool homeAll = !(code.hasX || code.hasY || code.hasZ); if (code.hasX || homeAll) { xOffset = 0; x = Main.printerSettings.XHomePos; hasXHome = true; } if (code.hasY || homeAll) { yOffset = 0; y = Main.printerSettings.YHomePos; hasYHome = true; } if (code.hasZ || homeAll) { zOffset = 0; z = Main.printerSettings.ZHomePos; hasZHome = true; } if (code.hasE) { eOffset = 0; e = 0; emax = 0; } if (eventPosChanged != null) if (privateAnalyzer) eventPosChanged(code, x, y, z); else Main.main.Invoke(eventPosChanged, code, x, y, z); } break; case 162: { bool homeAll = !(code.hasX || code.hasY || code.hasZ); if (code.hasX || homeAll) { xOffset = 0; x = Main.printerSettings.XMax; hasXHome = true; } if (code.hasY || homeAll) { yOffset = 0; y = Main.printerSettings.YMax; hasYHome = true; } if (code.hasZ || homeAll) { zOffset = 0; z = Main.printerSettings.PrintAreaHeight; hasZHome = true; } if (eventPosChanged != null) if (privateAnalyzer) eventPosChanged(code, x, y, z); else Main.main.Invoke(eventPosChanged, code, x, y, z); } break; case 90: relative = false; break; case 91: relative = true; break; case 92: if (code.hasX) { xOffset = x - code.X; x = xOffset; } if (code.hasY) { yOffset = y - code.Y; y = yOffset; } if (code.hasZ) { zOffset = z - code.Z; z = zOffset; } if (code.hasE) { eOffset = e - code.E; lastE = e = eOffset; } if (eventPosChanged != null) if (privateAnalyzer) eventPosChanged(code, x, y, z); else Main.main.Invoke(eventPosChanged, code, x, y, z); break; } } else if (code.hasM) { switch (code.M) { case 28: uploading = true; break; case 29: uploading = false; break; case 80: powerOn = true; fireChanged(); break; case 81: powerOn = false; fireChanged(); break; case 82: eRelative = false; break; case 83: eRelative = true; break; case 104: case 109: { int idx = activeExtruder; if (code.hasT) idx = code.T; if (code.hasS) setTemperature(idx,code.S); } fireChanged(); break; case 106: fanOn = true; if (code.hasS) fanVoltage = code.S; fireChanged(); break; case 107: fanOn = false; fireChanged(); break; case 110: lastline = code.N; break; case 111: if (code.hasS) { debugLevel = code.S; } break; case 140: case 190: if (code.hasS) bedTemp = code.S; fireChanged(); break; case 203: // Temp monitor if(code.hasS) tempMonitor = code.S; break; case 220: if(code.hasS) speedMultiply = code.S; break; } } else if (code.hasT) { activeExtruder = code.T; fireChanged(); } }
public void PushGCodeShortArray(List<GCodeShort> codes) { foreach (GCodeShort line in codes) { if (line.Length == 0) continue; ana.analyzeShort(line); GCode gcode = new GCode(); gcode.Parse(line.text); if (!gcode.comment) { jobList.AddLast(new GCodeCompressed(gcode)); totalLines++; } if (line.hasLayer) maxLayer = line.layer; } computedPrintingTime = ana.printingTime; }
public void PushData(string code) { code = code.Replace('\r', '\n'); string[] lines = code.Split('\n'); foreach (string line in lines) { if (line.Length == 0) continue; GCode gcode = new GCode(); gcode.Parse(line); if (!gcode.comment) { jobList.AddLast(new GCodeCompressed(gcode)); totalLines++; } } }
private void writeString(BinaryWriter file, string code, bool binary) { GCode gc = new GCode(); gc.Parse(code); if (gc.hostCommand) return; if (binary) { if (gc.hasCode) { byte[] data = gc.getBinary(1); file.Write(data); } } else { System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); string cmd = gc.getAscii(false, false); if (cmd.Length > 0) file.Write(enc.GetBytes(cmd + "\n")); } }
public GCode PopData() { GCode gc = null; bool finished = false; lock (jobList) { if (jobList.Count == 0) { return(null); } try { gc = new GCode(jobList.First.Value); jobList.RemoveFirst(); linesSend++; /*PrintTime pt = new PrintTime(); * pt.line = linesSend; * pt.time = DateTime.Now.Ticks; * lock (times) * { * times.AddLast(pt); * if (times.Count > 1500) * times.RemoveFirst(); * }*/ } catch { }; finished = jobList.Count == 0 && mode != 3; } if (finished) { dataComplete = false; mode = 2; jobFinished = DateTime.Now; long ticks = (jobFinished.Ticks - jobStarted.Ticks) / 10000; long hours = ticks / 3600000; ticks -= 3600000 * hours; long min = ticks / 60000; ticks -= 60000 * min; long sec = ticks / 1000; //Main.conn.log("Printjob finished at " + jobFinished.ToShortDateString()+" "+jobFinished.ToShortTimeString(),false,3); Main.conn.log(Trans.T1("L_PRINTJOB_FINISHED_AT", jobFinished.ToShortDateString() + " " + jobFinished.ToShortTimeString()), false, 3); StringBuilder s = new StringBuilder(); if (hours > 0) { s.Append(Trans.T1("L_TIME_H:", hours.ToString())); //"h:"); } if (min > 0) { s.Append(Trans.T1("L_TIME_M:", min.ToString())); } s.Append(Trans.T1("L_TIME_S", sec.ToString())); //Main.conn.log("Printing time:"+s.ToString(),false,3); //Main.conn.log("Lines send:" + linesSend.ToString(), false, 3); //Main.conn.firePrinterAction("Finished in "+s.ToString()); Main.conn.log(Trans.T1("L_PRINTING_TIME:", s.ToString()), false, 3); Main.conn.log(Trans.T1("L_LINES_SEND:X", linesSend.ToString()), false, 3); Main.conn.firePrinterAction(Trans.T1("L_FINISHED_IN", s.ToString())); DoEndKillActions(); Main.main.Invoke(Main.main.UpdateJobButtons); Main.main.printPanel.Invoke(Main.main.printPanel.SetStatusJobFinished); PiMakerHost.view.SoundConfig.PlayPrintFinished(false); } return(gc); }
/// <summary> /// Add a GCode line to be visualized. /// </summary> /// <param name="g"></param> public void AddGCode(GCode g) { act = g; ana.Analyze(g); laste = ana.emax; }
void OnPosChange(GCode act, float x, float y, float z) { if (!ana.drawing) { lastx = x; lasty = y; lastz = z; laste = ana.emax; return; } float locDist = (float)Math.Sqrt((x - lastx) * (x - lastx) + (y - lasty) * (y - lasty) + (z - lastz) * (z - lastz)); bool isLastPos = locDist < 0.00001; if (!act.hasG || (act.G > 1 && act.G != 28)) return; int segpos = ana.activeExtruder; if (ana.eChanged == false) { GCodeTravel travel = new GCodeTravel(); travel.fline = GCodePoint.toFileLine(fileid, actLine); travel.p1.X = lastx; travel.p1.Y = lasty; travel.p1.Z = lastz; travel.p2.X = x; travel.p2.Y = y; travel.p2.Z = z; travelMoves.Add(travel); } if (segpos < 0 || segpos >= MaxExtruder) segpos = 0; LinkedList<GCodePath> seg = segments[segpos]; if (seg.Count == 0 || laste >= ana.e) // start new segment { if (!isLastPos) // no move, no action { GCodePath p = new GCodePath(); p.Add(new Vector3(x, y, z), ana.emax, totalDist, GCodePoint.toFileLine(fileid, actLine)); if (seg.Count > 0 && seg.Last.Value.pointsLists.Last.Value.Count == 1) { seg.RemoveLast(); } seg.AddLast(p); changed = true; } } else { if (!isLastPos) { totalDist += locDist; seg.Last.Value.Add(new Vector3(x, y, z), ana.emax, totalDist, GCodePoint.toFileLine(fileid, actLine)); changed = true; } } lastx = x; lasty = y; lastz = z; laste = ana.emax; }
public void Reduce() { for (int i = 0; i < MaxExtruder; i++) { LinkedList<GCodePath> seg = segments[i]; if (seg.Count < 2) continue; if (!liveView) { GCodePath first = seg.First.Value; while (seg.Count > 1) { first.Join(seg.First.Next.Value); seg.First.Next.Value.Free(); seg.Remove(seg.First.Next.Value); } } else { LinkedListNode<GCodePath> act = seg.First, next; while (act.Next != null) { next = act.Next; if (next.Next == null) { break; // Don't touch last segment we are writing to } GCodePath nextval = next.Value; if (nextval.pointsCount < 2) { act = next; if (act.Next != null) act = act.Next; } else if (nextval.lastDist > minHotDist) { if (act.Value.pointsCount < 500) { act.Value.Join(nextval); seg.Remove(nextval); nextval.Free(); } else { act = next; } } else if (act.Value.pointsCount < 5000 || (nextval.pointsCount >= 5000 && act.Value.pointsCount < 27000)) { act.Value.Join(nextval); seg.Remove(nextval); nextval.Free(); } else { act = next; } } } } }
public void ParseText(string text, bool clear) { GCode gc = new GCode(); if (clear) Clear(); foreach (string s in text.Split('\n')) { gc.Parse(s); AddGCode(gc); } }
public void receiveLine(GCode code) { bytesin += code.orig.Length; ana.Analyze(code); lock (output) { if (code.hasM) switch (code.M) { case 115: // Firmware output.AddLast("FIRMWARE_NAME:PiMakerVirtualPrinter FIRMWARE_URL:https://github.com/PiMaker/PiMaker-Firmware/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1 PiMaker_PROTOCOL:1"); //output.AddLast("FIRMWARE_NAME:Marlin FIRMWARE_URL:https://github.com/PiMaker/PiMaker-Firmware/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1 PiMaker_PROTOCOL:1"); break; case 105: // Print Temperatures output.AddLast("T:" + extruderTemp[activeExtruder].ToString("0") + " B:" + bedTemp.ToString("0.00")+" @:"+extruderOut[activeExtruder].ToString("0")+ " T0:"+extruderTemp[0].ToString("0.00")+" @0:"+extruderOut[0].ToString("0")+ " T1:"+extruderTemp[1].ToString("0.00")+" @1:"+extruderOut[1].ToString("0")+ " T2:"+extruderTemp[2].ToString("0.00")+" @2:"+extruderOut[2].ToString("0")); break; case 205: // EEPROM Settings output.AddLast("EPR:2 75 76800 Baudrate"); output.AddLast("EPR:2 79 0 Max. inactive time [ms,0=off]"); output.AddLast("EPR:2 83 60000 Stop stepper afer inactivity [ms,0=off]"); output.AddLast("EPR:3 3 40.00 X-axis steps per mm"); output.AddLast("EPR:3 7 40.00 Y-axis steps per mm"); output.AddLast("EPR:3 11 3333.59 Z-axis steps per mm"); output.AddLast("EPR:3 15 20000.00 X-axis max. feedrate [mm/min]"); output.AddLast("EPR:3 19 20000.00 Y-axis max. feedrate [mm/min]"); output.AddLast("EPR:3 23 2.00 Z-axis max. feedrate [mm/min]"); output.AddLast("EPR:3 27 1500.00 X-axis homing feedrate [mm/min]"); output.AddLast("EPR:3 31 1500.00 Y-axis homing feedrate [mm/min]"); output.AddLast("EPR:3 35 100.00 Z-axis homing feedrate [mm/min]"); output.AddLast("EPR:3 39 20.00 X-axis start speed [mm/s]"); output.AddLast("EPR:3 43 20.00 Y-axis start speed [mm/s]"); output.AddLast("EPR:3 47 1.00 Z-axis start speed [mm/s]"); output.AddLast("EPR:3 51 750.00 X-axis acceleration [mm/s^2]"); output.AddLast("EPR:3 55 750.00 Y-axis acceleration [mm/s^2]"); output.AddLast("EPR:3 59 50.00 Z-axis acceleration [mm/s^2]"); output.AddLast("EPR:3 63 750.00 X-axis travel acceleration [mm/s^2]"); output.AddLast("EPR:3 67 750.00 Y-axis travel acceleration [mm/s^2]"); output.AddLast("EPR:3 71 50.00 Z-axis travel acceleration [mm/s^2]"); output.AddLast("EPR:3 150 373.00 Extr. steps per mm"); output.AddLast("EPR:3 154 1200.00 Extr. max. feedrate [mm/min]"); output.AddLast("EPR:3 158 10.00 Extr. start feedrate [mm/s]"); output.AddLast("EPR:3 162 10000.00 Extr. acceleration [mm/s^2]"); output.AddLast("EPR:0 166 1 Heat manager [0-1]"); output.AddLast("EPR:0 167 130 PID drive max"); output.AddLast("EPR:2 168 300 PID P-gain [*0.01]"); output.AddLast("EPR:2 172 2 PID I-gain [*0.01]"); output.AddLast("EPR:2 176 2000 PID D-gain [*0.01]"); output.AddLast("EPR:0 180 200 PID max value [0-255]"); output.AddLast("EPR:2 181 0 X-offset [steps]"); output.AddLast("EPR:2 185 0 Y-offset [steps]"); output.AddLast("EPR:2 189 40 Temp. stabilize time [s]"); break; } else if (code.hasT) { if (code.T >= 0 && code.T < numExtruder) activeExtruder = code.T; } output.AddLast("ok"); } }
public void Analyze(GCode code) { if (code.hostCommand) { string cmd = code.getHostCommand(); if (cmd.Equals("@hide")) { drawing = false; } else if (cmd.Equals("@show")) { drawing = true; } else if (cmd.Equals("@isathome")) { hasXHome = hasYHome = hasZHome = true; x = Main.printerSettings.XHomePos; y = Main.printerSettings.YHomePos; z = Main.printerSettings.ZHomePos; xOffset = yOffset = zOffset = 0; } return; } //if (code.forceAscii) return; // Don't analyse host commands and unknown commands if (code.hasN) { lastline = code.N; } if (uploading && !code.hasM && code.M != 29) { return; // ignore upload commands } if (code.hasG) { switch (code.G) { case 0: case 1: eChanged = false; if (code.hasF) { f = code.F; } if (relative) { if (code.hasX) { x += code.X; } if (code.hasY) { y += code.Y; } if (code.hasZ) { z += code.Z; } if (code.hasE) { eChanged = code.E != 0; e += code.E; } } else { if (code.hasX) { x = xOffset + code.X; } if (code.hasY) { y = yOffset + code.Y; } if (code.hasZ) { z = zOffset + code.Z; } if (code.hasE) { if (eRelative) { eChanged = code.E != 0; e += code.E; } else { eChanged = e != (eOffset + code.E); e = eOffset + code.E; } } } if (x < Main.printerSettings.XMin) { x = Main.printerSettings.XMin; hasXHome = false; } if (y < Main.printerSettings.YMin) { y = Main.printerSettings.YMin; hasYHome = false; } if (z < 0) { z = 0; hasZHome = false; } if (x > Main.printerSettings.XMax) { hasXHome = false; } if (y > Main.printerSettings.YMax) { hasYHome = false; } if (z > printerHeight) { hasZHome = false; } if (e > emax) { emax = e; if (z != lastZPrint) { layer++; lastZPrint = z; if (!privateAnalyzer && Main.conn.job.hasData() && Main.conn.job.maxLayer >= 0) { //PrinterConnection.logInfo("Printing layer " + layer.ToString() + " of " + Main.conn.job.maxLayer.ToString()); PrinterConnection.logInfo(Trans.T2("L_PRINTING_LAYER_X_OF_Y", layer.ToString(), Main.conn.job.maxLayer.ToString())); } } } if (eventPosChanged != null) { if (privateAnalyzer) { eventPosChanged(code, x, y, z); } else { Main.main.Invoke(eventPosChanged, code, x, y, z); } } float dx = Math.Abs(x - lastX); float dy = Math.Abs(y - lastY); float dz = Math.Abs(z - lastZ); float de = Math.Abs(e - lastE); if (dx + dy + dz > 0.001) { printingTime += Math.Sqrt(dx * dx + dy * dy + dz * dz) * 60.0f / f; } else { printingTime += de * 60.0f / f; } lastX = x; lastY = y; lastZ = z; lastE = e; break; case 28: case 161: { bool homeAll = !(code.hasX || code.hasY || code.hasZ); if (code.hasX || homeAll) { xOffset = 0; x = Main.printerSettings.XHomePos; hasXHome = true; } if (code.hasY || homeAll) { yOffset = 0; y = Main.printerSettings.YHomePos; hasYHome = true; } if (code.hasZ || homeAll) { zOffset = 0; z = Main.printerSettings.ZHomePos; hasZHome = true; } if (code.hasE) { eOffset = 0; e = 0; emax = 0; } if (eventPosChanged != null) { if (privateAnalyzer) { eventPosChanged(code, x, y, z); } else { Main.main.Invoke(eventPosChanged, code, x, y, z); } } } break; case 162: { bool homeAll = !(code.hasX || code.hasY || code.hasZ); if (code.hasX || homeAll) { xOffset = 0; x = Main.printerSettings.XMax; hasXHome = true; } if (code.hasY || homeAll) { yOffset = 0; y = Main.printerSettings.YMax; hasYHome = true; } if (code.hasZ || homeAll) { zOffset = 0; z = Main.printerSettings.PrintAreaHeight; hasZHome = true; } if (eventPosChanged != null) { if (privateAnalyzer) { eventPosChanged(code, x, y, z); } else { Main.main.Invoke(eventPosChanged, code, x, y, z); } } } break; case 90: relative = false; break; case 91: relative = true; break; case 92: if (code.hasX) { xOffset = x - code.X; x = xOffset; } if (code.hasY) { yOffset = y - code.Y; y = yOffset; } if (code.hasZ) { zOffset = z - code.Z; z = zOffset; } if (code.hasE) { eOffset = e - code.E; lastE = e = eOffset; } if (eventPosChanged != null) { if (privateAnalyzer) { eventPosChanged(code, x, y, z); } else { Main.main.Invoke(eventPosChanged, code, x, y, z); } } break; } } else if (code.hasM) { switch (code.M) { case 28: uploading = true; break; case 29: uploading = false; break; case 80: powerOn = true; fireChanged(); break; case 81: powerOn = false; fireChanged(); break; case 82: eRelative = false; break; case 83: eRelative = true; break; case 104: case 109: { int idx = activeExtruder; if (code.hasT) { idx = code.T; } if (code.hasS) { setTemperature(idx, code.S); } } fireChanged(); break; case 106: fanOn = true; if (code.hasS) { fanVoltage = code.S; } fireChanged(); break; case 107: fanOn = false; fireChanged(); break; case 110: lastline = code.N; break; case 111: if (code.hasS) { debugLevel = code.S; } break; case 140: case 190: if (code.hasS) { bedTemp = code.S; } fireChanged(); break; case 203: // Temp monitor if (code.hasS) { tempMonitor = code.S; } break; case 220: if (code.hasS) { speedMultiply = code.S; } break; } } else if (code.hasT) { activeExtruder = code.T; fireChanged(); } }
public GCode PopData() { GCode gc = null; bool finished = false; lock (jobList) { if (jobList.Count == 0) return null; try { gc = new GCode(jobList.First.Value); jobList.RemoveFirst(); linesSend++; /*PrintTime pt = new PrintTime(); pt.line = linesSend; pt.time = DateTime.Now.Ticks; lock (times) { times.AddLast(pt); if (times.Count > 1500) times.RemoveFirst(); }*/ } catch { }; finished = jobList.Count == 0 && mode != 3; } if (finished) { dataComplete = false; mode = 2; jobFinished = DateTime.Now; long ticks = (jobFinished.Ticks - jobStarted.Ticks) / 10000; long hours = ticks / 3600000; ticks -= 3600000 * hours; long min = ticks / 60000; ticks -= 60000 * min; long sec = ticks / 1000; //Main.conn.log("Printjob finished at " + jobFinished.ToShortDateString()+" "+jobFinished.ToShortTimeString(),false,3); Main.conn.log(Trans.T1("L_PRINTJOB_FINISHED_AT",jobFinished.ToShortDateString() + " " + jobFinished.ToShortTimeString()), false, 3); StringBuilder s = new StringBuilder(); if (hours > 0) s.Append(Trans.T1("L_TIME_H:",hours.ToString())); //"h:"); if (min > 0) s.Append(Trans.T1("L_TIME_M:",min.ToString())); s.Append(Trans.T1("L_TIME_S",sec.ToString())); //Main.conn.log("Printing time:"+s.ToString(),false,3); //Main.conn.log("Lines send:" + linesSend.ToString(), false, 3); //Main.conn.firePrinterAction("Finished in "+s.ToString()); Main.conn.log(Trans.T1("L_PRINTING_TIME:",s.ToString()), false, 3); Main.conn.log(Trans.T1("L_LINES_SEND:X",linesSend.ToString()), false, 3); Main.conn.firePrinterAction(Trans.T1("L_FINISHED_IN",s.ToString())); DoEndKillActions(); Main.main.Invoke(Main.main.UpdateJobButtons); Main.main.printPanel.Invoke(Main.main.printPanel.SetStatusJobFinished); PiMakerHost.view.SoundConfig.PlayPrintFinished(false); } return gc; }
public void receiveLine(GCode code) { bytesin += code.orig.Length; ana.Analyze(code); lock (output) { if (code.hasM) { switch (code.M) { case 115: // Firmware output.AddLast("FIRMWARE_NAME:PiMakerVirtualPrinter FIRMWARE_URL:https://github.com/PiMaker/PiMaker-Firmware/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1 PiMaker_PROTOCOL:1"); //output.AddLast("FIRMWARE_NAME:Marlin FIRMWARE_URL:https://github.com/PiMaker/PiMaker-Firmware/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1 PiMaker_PROTOCOL:1"); break; case 105: // Print Temperatures output.AddLast("T:" + extruderTemp[activeExtruder].ToString("0") + " B:" + bedTemp.ToString("0.00") + " @:" + extruderOut[activeExtruder].ToString("0") + " T0:" + extruderTemp[0].ToString("0.00") + " @0:" + extruderOut[0].ToString("0") + " T1:" + extruderTemp[1].ToString("0.00") + " @1:" + extruderOut[1].ToString("0") + " T2:" + extruderTemp[2].ToString("0.00") + " @2:" + extruderOut[2].ToString("0")); break; case 205: // EEPROM Settings output.AddLast("EPR:2 75 76800 Baudrate"); output.AddLast("EPR:2 79 0 Max. inactive time [ms,0=off]"); output.AddLast("EPR:2 83 60000 Stop stepper afer inactivity [ms,0=off]"); output.AddLast("EPR:3 3 40.00 X-axis steps per mm"); output.AddLast("EPR:3 7 40.00 Y-axis steps per mm"); output.AddLast("EPR:3 11 3333.59 Z-axis steps per mm"); output.AddLast("EPR:3 15 20000.00 X-axis max. feedrate [mm/min]"); output.AddLast("EPR:3 19 20000.00 Y-axis max. feedrate [mm/min]"); output.AddLast("EPR:3 23 2.00 Z-axis max. feedrate [mm/min]"); output.AddLast("EPR:3 27 1500.00 X-axis homing feedrate [mm/min]"); output.AddLast("EPR:3 31 1500.00 Y-axis homing feedrate [mm/min]"); output.AddLast("EPR:3 35 100.00 Z-axis homing feedrate [mm/min]"); output.AddLast("EPR:3 39 20.00 X-axis start speed [mm/s]"); output.AddLast("EPR:3 43 20.00 Y-axis start speed [mm/s]"); output.AddLast("EPR:3 47 1.00 Z-axis start speed [mm/s]"); output.AddLast("EPR:3 51 750.00 X-axis acceleration [mm/s^2]"); output.AddLast("EPR:3 55 750.00 Y-axis acceleration [mm/s^2]"); output.AddLast("EPR:3 59 50.00 Z-axis acceleration [mm/s^2]"); output.AddLast("EPR:3 63 750.00 X-axis travel acceleration [mm/s^2]"); output.AddLast("EPR:3 67 750.00 Y-axis travel acceleration [mm/s^2]"); output.AddLast("EPR:3 71 50.00 Z-axis travel acceleration [mm/s^2]"); output.AddLast("EPR:3 150 373.00 Extr. steps per mm"); output.AddLast("EPR:3 154 1200.00 Extr. max. feedrate [mm/min]"); output.AddLast("EPR:3 158 10.00 Extr. start feedrate [mm/s]"); output.AddLast("EPR:3 162 10000.00 Extr. acceleration [mm/s^2]"); output.AddLast("EPR:0 166 1 Heat manager [0-1]"); output.AddLast("EPR:0 167 130 PID drive max"); output.AddLast("EPR:2 168 300 PID P-gain [*0.01]"); output.AddLast("EPR:2 172 2 PID I-gain [*0.01]"); output.AddLast("EPR:2 176 2000 PID D-gain [*0.01]"); output.AddLast("EPR:0 180 200 PID max value [0-255]"); output.AddLast("EPR:2 181 0 X-offset [steps]"); output.AddLast("EPR:2 185 0 Y-offset [steps]"); output.AddLast("EPR:2 189 40 Temp. stabilize time [s]"); break; } } else if (code.hasT) { if (code.T >= 0 && code.T < numExtruder) { activeExtruder = code.T; } } output.AddLast("ok"); } }
private void writeArray(BinaryWriter file, List<GCodeShort> list, bool binary) { foreach (GCodeShort code in list) { GCode gc = new GCode(); gc.Parse(code.text); if (gc.hostCommand) continue; if (binary) { if (gc.hasCode) { byte[] data = gc.getBinary(1); file.Write(data); } } else { System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); string cmd = gc.getAscii(false, false); if (cmd.Length > 0) file.Write(enc.GetBytes(cmd + "\n")); } } }