|
@@ -264,22 +264,26 @@ namespace UAS_MES_NEW.Make
|
|
|
foreach (string file in txtFiles)
|
|
foreach (string file in txtFiles)
|
|
|
{
|
|
{
|
|
|
LogMessage(file);
|
|
LogMessage(file);
|
|
|
- if (Device.SelectedIndex == 0) // SPI
|
|
|
|
|
|
|
+ if (Device.SelectedIndex == 0) // SPI 已测试对接
|
|
|
{
|
|
{
|
|
|
ParseLogInsert(file);
|
|
ParseLogInsert(file);
|
|
|
Console.WriteLine();
|
|
Console.WriteLine();
|
|
|
}
|
|
}
|
|
|
- else if (Device.SelectedIndex == 1) // AOI
|
|
|
|
|
|
|
+ else if (Device.SelectedIndex == 1) // AOI 已测试对接
|
|
|
{
|
|
{
|
|
|
ParseLogInsert(file);
|
|
ParseLogInsert(file);
|
|
|
Console.WriteLine();
|
|
Console.WriteLine();
|
|
|
}
|
|
}
|
|
|
- else if (Device.SelectedIndex == 2) // 印刷机
|
|
|
|
|
|
|
+ else if (Device.SelectedIndex == 2) // 印刷机 待测试对接
|
|
|
{
|
|
{
|
|
|
- PrinterData xmlData = ReadWithXmlReader(file);
|
|
|
|
|
- Console.WriteLine();
|
|
|
|
|
|
|
+ // 印刷机xml文件解析
|
|
|
|
|
+ //PrinterData xmlData = ReadWithXmlReader(file);
|
|
|
|
|
+ //Console.WriteLine();
|
|
|
|
|
+
|
|
|
|
|
+ // 印刷机csv文件解析
|
|
|
|
|
+ //var csvData = ParseCsvFile(file);
|
|
|
}
|
|
}
|
|
|
- else if (Device.SelectedIndex == 3) // 贴片机
|
|
|
|
|
|
|
+ else if (Device.SelectedIndex == 3) // 贴片机 导站位表已测试对接
|
|
|
{
|
|
{
|
|
|
if (!File.Exists(file))
|
|
if (!File.Exists(file))
|
|
|
{
|
|
{
|
|
@@ -651,6 +655,91 @@ namespace UAS_MES_NEW.Make
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public List<MesData> ParseCsvFile(string filePath)
|
|
|
|
|
+ {
|
|
|
|
|
+ var mesDataList = new List<MesData>();
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ string fileName = Path.GetFileName(filePath);
|
|
|
|
|
+
|
|
|
|
|
+ var lines = File.ReadAllLines(filePath);
|
|
|
|
|
+
|
|
|
|
|
+ if (lines.Length == 0)
|
|
|
|
|
+ return mesDataList;
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < lines.Length; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ var values = ParseCsvLine(lines[i]);
|
|
|
|
|
+ var mesData = new MesData
|
|
|
|
|
+ {
|
|
|
|
|
+ FileName = fileName,
|
|
|
|
|
+ ModelName = GetValue(values, 0),
|
|
|
|
|
+ LineNumber = GetValue(values, 1),
|
|
|
|
|
+ BoardStatus = GetValue(values, 2),
|
|
|
|
|
+ BoardBarcode = GetValue(values, 3),
|
|
|
|
|
+ ArrayID = GetValue(values, 4),
|
|
|
|
|
+ ArrayStatus = GetValue(values, 5),
|
|
|
|
|
+ ArrayBarcode = GetValue(values, 6),
|
|
|
|
|
+ DateTime = GetValue(values, 7),
|
|
|
|
|
+ PadID = GetValue(values, 8),
|
|
|
|
|
+ ComponentID = GetValue(values, 9),
|
|
|
|
|
+ Type = GetValue(values, 10),
|
|
|
|
|
+ AreaPercent = GetValue(values, 11),
|
|
|
|
|
+ Height = GetValue(values, 12),
|
|
|
|
|
+ VolumePercent = GetValue(values, 13),
|
|
|
|
|
+ XOffset = GetValue(values, 14),
|
|
|
|
|
+ YOffset = GetValue(values, 15),
|
|
|
|
|
+ PadSizeX = GetValue(values, 16),
|
|
|
|
|
+ PadSizeY = GetValue(values, 17),
|
|
|
|
|
+ Area = GetValue(values, 18),
|
|
|
|
|
+ HeightPercent = GetValue(values, 19),
|
|
|
|
|
+ Volume = GetValue(values, 20),
|
|
|
|
|
+ Result = GetValue(values, 21),
|
|
|
|
|
+ Errcode = GetValue(values, 22),
|
|
|
|
|
+ PinNum = GetValue(values, 23),
|
|
|
|
|
+ Barcode = GetValue(values, 24),
|
|
|
|
|
+ Date = GetValue(values, 25),
|
|
|
|
|
+ Time = GetValue(values, 26),
|
|
|
|
|
+ ArrayID2 = GetValue(values, 27)
|
|
|
|
|
+ };
|
|
|
|
|
+ mesDataList.Add(mesData);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ LogMessage($"解析csv文件报错,{ex.Message}");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return mesDataList;
|
|
|
|
|
+ }
|
|
|
|
|
+ private string[] ParseCsvLine(string line)
|
|
|
|
|
+ {
|
|
|
|
|
+ List<string> values = new List<string>();
|
|
|
|
|
+ bool inQuotes = false;
|
|
|
|
|
+ int startIndex = 0;
|
|
|
|
|
+ for (int i = 0; i < line.Length; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (line[i] == '"')
|
|
|
|
|
+ {
|
|
|
|
|
+ inQuotes = !inQuotes;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (line[i] == ',' && !inQuotes)
|
|
|
|
|
+ {
|
|
|
|
|
+ string value = line.Substring(startIndex, i - startIndex).Trim('"');
|
|
|
|
|
+ values.Add(value);
|
|
|
|
|
+ startIndex = i + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ string lastValue = line.Substring(startIndex).Trim('"');
|
|
|
|
|
+ values.Add(lastValue);
|
|
|
|
|
+
|
|
|
|
|
+ return values.ToArray();
|
|
|
|
|
+ }
|
|
|
|
|
+ private string GetValue(string[] values, int index)
|
|
|
|
|
+ {
|
|
|
|
|
+ return index < values.Length ? values[index] : string.Empty;
|
|
|
|
|
+ }
|
|
|
private class Log
|
|
private class Log
|
|
|
{
|
|
{
|
|
|
public string SN { set; get; }
|
|
public string SN { set; get; }
|
|
@@ -702,6 +791,39 @@ namespace UAS_MES_NEW.Make
|
|
|
public string StencilNum { get; set; }
|
|
public string StencilNum { get; set; }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public class MesData
|
|
|
|
|
+ {
|
|
|
|
|
+ public string FileName { get; set; }
|
|
|
|
|
+ public string ModelName { get; set; }
|
|
|
|
|
+ public string LineNumber { get; set; }
|
|
|
|
|
+ public string BoardStatus { get; set; }
|
|
|
|
|
+ public string BoardBarcode { get; set; }
|
|
|
|
|
+ public string ArrayID { get; set; }
|
|
|
|
|
+ public string ArrayStatus { get; set; }
|
|
|
|
|
+ public string ArrayBarcode { get; set; }
|
|
|
|
|
+ public string DateTime { get; set; }
|
|
|
|
|
+ public string PadID { get; set; }
|
|
|
|
|
+ public string ComponentID { get; set; }
|
|
|
|
|
+ public string Type { get; set; }
|
|
|
|
|
+ public string AreaPercent { get; set; }
|
|
|
|
|
+ public string Height { get; set; }
|
|
|
|
|
+ public string VolumePercent { get; set; }
|
|
|
|
|
+ public string XOffset { get; set; }
|
|
|
|
|
+ public string YOffset { get; set; }
|
|
|
|
|
+ public string PadSizeX { get; set; }
|
|
|
|
|
+ public string PadSizeY { get; set; }
|
|
|
|
|
+ public string Area { get; set; }
|
|
|
|
|
+ public string HeightPercent { get; set; }
|
|
|
|
|
+ public string Volume { get; set; }
|
|
|
|
|
+ public string Result { get; set; }
|
|
|
|
|
+ public string Errcode { get; set; }
|
|
|
|
|
+ public string PinNum { get; set; }
|
|
|
|
|
+ public string Barcode { get; set; }
|
|
|
|
|
+ public string Date { get; set; }
|
|
|
|
|
+ public string Time { get; set; }
|
|
|
|
|
+ public string ArrayID2 { get; set; }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void claerBtn_Click(object sender, EventArgs e)
|
|
private void claerBtn_Click(object sender, EventArgs e)
|
|
|
{
|
|
{
|
|
|
lstFiles.Items.Clear();
|
|
lstFiles.Items.Clear();
|