public static void WriteCSV(AllInfo.SNinfo snInfo)//(string SN,DateTime checkTime) { //KK07 NSTD E-1 L03 INTRS 20180614201355 GH9814320XDJL4K21.csv string fileName = type + factory + building + line + process + DateTime.Now.ToString("yyyyMMddHHmmss") + snInfo.SN; string path = Document.pathList[1] + fileName + ".csv"; using (StreamWriter file = new StreamWriter(path, true)) { string[] csvStr = null; switch (newFormat) { case false: csvStr = new string[] { type, factory, building, line, process, snInfo.SN, "", "", snInfo.checkTime.ToString("yy,MM,dd,HH,mm,ss"), "1", inspect, "0.0", snInfo.checkItem, snInfo.checkTotal, "1", "JIG", type + line.Remove(0, 1) + process.Substring(0, 1) + snInfo.firstTime.ToString("yyMMddHHmmss").Remove(0, 1) }; break; case true: csvStr = new string[] { type, factory, building, line, process, snInfo.SN, "", "", "", snInfo.checkTime.ToString("yy,MM,dd,HH,mm,ss"), "1", inspect, "N/A", "N/A", "0.0", snInfo.checkItem, snInfo.checkTotal, "1", "JIG", type + line.Remove(0, 1) + process.Substring(0, 1) + snInfo.firstTime.ToString("yyMMddHHmmss").Remove(0, 1) }; break; } string str = String.Join(",", csvStr); file.WriteLine(str);// 直接追加文件末尾,换行 } }
public static void judge(string SN) { AllInfo.SNinfo info = new AllInfo.SNinfo(); info.SN = SN = SN.ToUpper(); string line = "L??"; if (Layout.lineSwitch && SN != "ERROR") { info.lineOK = Check.Check.checkLine(SN, ref line); } info.line = line; #region log记录的一盘里的第一个时间 if (AllInfo.SNlist.Count == 0) { info.firstTime = DateTime.Now; } else { info.firstTime = AllInfo.SNlist[0].firstTime; } info.checkTime = DateTime.Now; #endregion #region SN是否重复 foreach (AllInfo.SNinfo var in AllInfo.SNlist) { if (SN == var.SN && SN != "ERROR") { info.result = "MISS"; info.detail = "Duplicate SN"; AllInfo.SNlist.Add(info); return; } } #endregion if (SN == "ERROR") { info.result = "MISS"; info.detail = "ERROR"; } else if (SN.Length < 17) { info.result = "MISS"; info.detail = "SN format false"; } else if (!Config.checkPPP(SN)) { info.result = "MISS"; info.detail = "Miss PPP"; } else if (!Config.checkEEEE(SN)) { info.result = "MISS"; info.detail = "Miss EEEE"; } else { string temp = string.Empty; info.result = API.SN_Judge(SN, ref temp); info.detail = temp; info.checkTotal = info.checkItem = info.result == "PASS" ? "0" : "1"; } AllInfo.SNlist.Add(info); }
public static Panel paint(AllInfo.SNinfo snInfo) { Color panelColor = new Color(); switch (snInfo.result) { case "PASS": //panelColor = Color.Lime; panelColor = ColorTranslator.FromHtml("#008000"); break; case "MISS": panelColor = Color.Yellow; break; case "HOLD": panelColor = ColorTranslator.FromHtml("#0000FF"); break; default: panelColor = Color.Red; break; } Panel panel = new Panel(); panel.Dock = DockStyle.Fill; panel.BackColor = panelColor; Label l1 = new Label(); l1.Text = snInfo.result; Label l2 = new Label(); //绝对位置change动态位置 l2.Location = new Point(0, 50); l2.Text = Regedit.Trajectory[AllInfo.SNlist.Count - 1]; if (snInfo.result == "FAIL") { Label l3 = new Label(); l3.AutoSize = true; l3.Location = new Point(0, 25); //l3.Location = new Point(0, 10); //l3.Dock = DockStyle.Fill; //l3.Multiline = true; //GH945678901TEST00 //detailTxb.Text = "phase2,AE-1:PASS\r\nphase2,AE-16_01CJ:PASS\r\nphase2,AE-16_01CJ2:FAIL\r\nphase3a,AE-1:PASS\r\nphase3a,AE-2:SKIP\r\nphase3a,AE-3:SKIP\r\nphase3a,AE-40:SKIP\r\nphase3b,AE-16_01CJ#JIG_C_COIL:SKIP\r\n"; string[] temp = snInfo.detail.Split(new string[] { "\r\n" }, StringSplitOptions.None); foreach (string str in temp) { if (str.Contains("FAIL") || str.Contains("SKIP")) { //int startInt = str.IndexOf(","); //int endInt = str.Length - 1; //l3.Text = str.Substring(startInt + 1, endInt - startInt); //string str0 = "AE-16_19MA#M_MG_ATTACH: SKIP"; int startInt = str.IndexOf(","); int endInt = str.IndexOf("#"); if (endInt == -1) { endInt = str.IndexOf(":"); } l3.Text = str.Substring(startInt + 1, endInt - (startInt + 1)); //不能用换行显示,单片机模式下长度是非常长的,界面显示能单行显示全部 //l3.Text = test.Insert(9,"\r\n"); //l3.Height = 40; break; } } //加上突出效果,能显示的长度变小 //l3.Font = new Font("微软雅黑", 9, FontStyle.Bold); panel.Controls.Add(l3); l1.ForeColor = l2.ForeColor = l3.ForeColor = Color.White; } else if (snInfo.result == "HOLD") { Label l3 = new Label(); l3.AutoSize = true; l3.Location = new Point(0, 25); string[] temp = snInfo.detail.Split(new string[] { "\r\n" }, StringSplitOptions.None); foreach (string str in temp) { if (str.Contains("phase3a_fail,")) { int startInt = str.IndexOf(":"); int endInt = str.Length; int i = int.Parse(str.Substring(startInt + 1, endInt - (startInt + 1))); if (i >= 3) { startInt = str.IndexOf(","); endInt = str.IndexOf("#"); if (endInt == -1) { endInt = str.IndexOf(":"); } l3.Text = str.Substring(startInt + 1, endInt - (startInt + 1)); break; } } } panel.Controls.Add(l3); l1.ForeColor = l2.ForeColor = l3.ForeColor = Color.White; } if (lineSwitch && !snInfo.lineOK) { Label l4 = new Label(); l4.AutoSize = true; l4.Location = new Point(50, 25); //l4.Location = new Point(20, 25); l4.Text = snInfo.line; l4.Font = new Font("Arial", 24, FontStyle.Bold); panel.Controls.Add(l4); } panel.Controls.Add(l1); panel.Controls.Add(l2); return(panel); }