public override void AnalyzeResponse(string res) { string h; int level = 0; while (res.Length > 0 && res[0] < 32) { res = res.Substring(1); } res = res.Trim(); if (res.Equals("start") || (garbageCleared == false && res.IndexOf("start") != -1)) { lastline = 0; job.KillJob(); // continuing the old job makes no sense, better save the plastic con.sdcardMounted = true; history.Clear(); con.analyzer.start(true); readyForNextSend = true; lock (nackLines) { nackLines.Clear(); } garbageCleared = true; } con.analyzeResponse(res, ref level); h = con.extract(res, "REPETIER_PROTOCOL:"); if (h != null) { level = 3; int.TryParse(h, out binaryVersion); if (transferProtocol == 1) { binaryVersion = 0; // force ascii transfer } con.binaryVersion = binaryVersion; } h = con.extract(res, "Resend:"); if (h != null) { level = 1; con.log(res, true, level); int line; int.TryParse(h, out line); ResendLine(line); } else if (res.StartsWith("ok")) { garbageCleared = true; if (Main.main.logView.switchACK.On) { con.log(res, true, level); } if (pingpong) { readyForNextSend = true; } else { lock (nackLines) { if (nackLines.Count > 0) { nackLines.RemoveFirst(); } } } TrySendNextLine(); } else if (res.Equals("wait")) // && DateTime.Now.Ticks - lastCommandSend > 5000) { if (Main.main.logView.switchACK.On) { con.log(res, true, level); } if (pingpong) { readyForNextSend = true; } else { lock (nackLines) { if (nackLines.Count > 0) { nackLines.Clear(); } } } TrySendNextLine(); } else if (level >= 0 && garbageCleared) { con.log(res, true, level); } }
private void buttonSimulateOK_Click(object sender, EventArgs e) { con.analyzeResponse("ok"); }