public void open(int baudrate) { this.baudrate = baudrate; ana.start(true); output.AddLast("start"); writeThread = new Thread(new ThreadStart(this.WriteThread)); writeThread.Start(); }
public void open() { baudrate = Main.conn.baud; ana.start(); output.AddLast("start"); writeThread = new Thread(new ThreadStart(this.WriteThread)); writeThread.Start(); }
/// <summary> /// Remove all drawn lines. /// </summary> public override void Clear() { foreach (GCodePath p in segments) { p.Free(); } segments.Clear(); lastx = 1e20f; // Don't ignore first point if it was the last! if (startOnClear) { ana.start(); } }
/// <summary> /// Remove all drawn lines. /// </summary> public override void Clear() { foreach (GCodePath p in segments) { p.Free(); } segments.Clear(); lastx = 1e20f; // Don't ignore first point if it was the last! totalDist = 0; if (colbufSize > 0) { GL.DeleteBuffers(1, colbuf); } colbufSize = 0; if (startOnClear) { ana.start(); } }
/// <summary> /// Analyzes a response from the printer. /// Updates data and sends events according to the data. /// </summary> /// <param name="res"></param> public void analyzeResponse(string res) { int level = 0; if (logWriter != null) { DateTime time = DateTime.Now; logWriter.WriteLine("> " + time.Hour.ToString("00") + ":" + time.Minute.ToString("00") + ":" + time.Second.ToString("00") + "." + time.Millisecond.ToString("000") + " : " + res); } string h = extract(res, "FIRMWARE_NAME:"); if (h != null) { level = 3; firmware = h; } h = extract(res, "FIRMWARE_URL:"); if (h != null) { level = 3; firmware_url = h; } h = extract(res, "PROTOCOL_VERSION:"); if (h != null) { level = 3; protocol = h; } h = extract(res, "MACHINE_TYPE:"); if (h != null) { level = 3; machine = h; } h = extract(res, "EXTRUDER_COUNT:"); if (h != null) { level = 3; if (!int.TryParse(h, out numberExtruder)) { numberExtruder = 1; } } h = extract(res, "X:"); if (h != null) { level = 3; float.TryParse(h, out x); } h = extract(res, "Y:"); if (h != null) { level = 3; float.TryParse(h, out y); } h = extract(res, "Z:"); if (h != null) { level = 3; float.TryParse(h, out z); } h = extract(res, "E:"); if (h != null) { level = 3; float.TryParse(h, out e); } bool tempChange = false; h = extract(res, "T:"); if (h != null) { level = -1; // dont log, we see result in status if (h.IndexOf('.') > 0) { h = h.Substring(0, h.IndexOf('.')); } int.TryParse(h, out extruderTemp); tempChange = true; } h = extract(res, "B:"); if (h != null) { level = -1; // don't log, we see result in status if (h.IndexOf('.') > 0) { h = h.Substring(0, h.IndexOf('.')); } int.TryParse(h, out bedTemp); tempChange = true; } if (res.StartsWith("EPR:")) { eeprom.Add(res); } if (res.StartsWith("MTEMP:")) // Temperature monitor { level = -1; // this happens to often to log. Temperture monitor i sthe log string[] sl = res.Substring(6).Split(' '); if (sl.Length == 4) { UInt32 time; int temp, target, output; UInt32.TryParse(sl[0], out time); int.TryParse(sl[1], out temp); int.TryParse(sl[2], out target); int.TryParse(sl[3], out output); if (time > 0 && eventTempMonitor != null) { try { Main.main.Invoke(eventTempMonitor, time, temp, target, output); } catch { } } } } h = extract(res, "REPETIER_PROTOCOL:"); if (h != null) { level = 3; int.TryParse(h, out binaryVersion); if (transferProtocol == 1) { binaryVersion = 0; // force ascii transfer } } if (res.Equals("start")) { lastline = 0; job.KillJob(); // continuing the old job makes no sense, better save the plastic resendNode = null; history.Clear(); analyzer.start(); readyForNextSend = true; nackLines.Clear(); } if (extract(res, "Error:") != null) { level = 2; } if (tempChange && eventTempChange != null) { Main.main.Invoke(eventTempChange, extruderTemp, bedTemp); } h = extract(res, "Resend:"); if (h != null) { level = 1; log(res, true, level); int line; int.TryParse(h, out line); ignoreNextOk = true; ResendLine(line); } else if (res.StartsWith("ok")) { if (Main.main.logView.toolACK.Checked) { log(res, true, level); } if (!ignoreNextOk) // ok in response of resend? { if (pingpong) { readyForNextSend = true; } else { lock (nackLines) { if (nackLines.Count > 0) { nackLines.RemoveFirst(); } } } resendError = 0; TrySendNextLine(); } else { ignoreNextOk = false; } } else if (res.Equals("wait") && DateTime.Now.Ticks - lastCommandSend > 5000) { if (Main.main.logView.toolACK.Checked) { log(res, true, level); } if (pingpong) { readyForNextSend = true; } else { lock (nackLines) { if (nackLines.Count > 0) { nackLines.Clear(); } } } resendError = 0; TrySendNextLine(); } else if (level >= 0) { log(res, true, level); } }