소스 검색

数据接入

yhluo 4 주 전
부모
커밋
cdf98c06dc
2개의 변경된 파일27개의 추가작업 그리고 38개의 파일을 삭제
  1. 5 0
      UAS_MES_BG/FunctionCode/Make/Make_ParseLog.cs
  2. 22 38
      UAS_MES_HYSX/FunctionCode/Make/Make_WirelessThroughput.cs

+ 5 - 0
UAS_MES_BG/FunctionCode/Make/Make_ParseLog.cs

@@ -853,6 +853,11 @@ namespace UAS_MES_NEW.Make
 
                         if(string.IsNullOrEmpty(wo) && string.IsNullOrEmpty(line))
                         {
+                            if (currItem.Length < 3)
+                            {
+                                LogMessage($"NG,文件{PathName} 序列号{currItem[0]}无系统记录,日志无IP信息");
+                                continue;
+                            }
                             sql.Clear();
                             sql.Append($"SELECT a.li_code,b.dl_macode,c.sc_name FROM line_ipaoi a,deviceline b,source c WHERE a.ipaddress = '{currItem[2]}' AND a.li_code = b.dl_linecode AND a.li_code = c.sc_linecode AND c.sc_wccode = 'SMT' AND instr(c.sc_name, 'AOI') > 0 AND b.dl_type = 'SMT'");
                             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");

+ 22 - 38
UAS_MES_HYSX/FunctionCode/Make/Make_WirelessThroughput.cs

@@ -62,20 +62,24 @@ namespace UAS_MES_NEW.Make
             if (IsCheckSet()) return;
 
             string sn = SN.Text.Trim();
+
+            if (IPList.Text.IndexOf(':') > 0) IPList.Text = IPList.Text.Replace(":", ":");
+            else IPList.Text = IPList.Text.Trim();
+
             if (SN.Text.IndexOf(';') > 0) SN.Text = sn.Replace(";", ";");
             else SN.Text = sn;
-            UpdateSN("L", SN.Text.Trim());
-
-            int iSPort = 5001;
 
+            UpdateSN("L", SN.Text.Trim());
+            
             ShowMsg(1, $"开始测试");
+            int iSPort = Convert.ToInt32(IPList.Text.Trim().Split(':')[1]);
             var tester = new CameraIperfTester(
                 timeOut: TestTime.Text.Trim(),
                 cameraIp: ProductList.Text.Trim(),
                 cameraPort: 23,
                 username: Account.Text.Trim(),
                 password: ProductList.Text.Trim(),
-                iperfServerIp: IPList.Text.Trim(),
+                iperfServerIp: IPList.Text.Trim().Split(':')[0],
                 iperfServerPort: iSPort
             );
 
@@ -282,8 +286,8 @@ namespace UAS_MES_NEW.Make
                     RunIperfClient($"-c {cameraIp} -p {iperfServerPort} -t 10 -w 1M -i 1 -P 8 -R", iperfPath, upLog);
                     RunIperfClient($"-c {cameraIp} -p {iperfServerPort} -t 10 -w 1M -i 1 -P 8", iperfPath, downLog);
 
-                    double upRate = ParseIperfBitrate(upLog);
-                    double downRate = ParseIperfBitrate(downLog);
+                    string upRate = ParseIperfBitrate(upLog);
+                    string downRate = ParseIperfBitrate(downLog);
 
                     return $"OK,{upRate}|{downRate}";
                 }
@@ -359,50 +363,30 @@ namespace UAS_MES_NEW.Make
                     File.WriteAllText(logPath, output + Environment.NewLine + error);
                 }
             }
-            private double ParseIperfBitrate(string logPath)
+            private string ParseIperfBitrate(string logPath)
             {
-                if (!File.Exists(logPath)) return 0.0;
+                if (!File.Exists(logPath)) return "0.0";
+
                 var lines = File.ReadAllLines(logPath);
+                List<string> logItem = new List<string> { };
                 foreach (var line in lines)
                 {
                     if (line.Trim().StartsWith("[SUM]"))
                     {
-                        var regex = new Regex(@"\d+\.?\d*\s+Mbits/sec");
-                        var match = regex.Match(line);
-                        if (match.Success)
-                        {
-                            var mbitsPart = match.Value.Replace("Mbits/sec", "").Trim();
-                            if (double.TryParse(mbitsPart, out double rate))
-                            {
-                                return rate;
-                            }
-                        }
+                        logItem.Add(line);
                     }
                 }
-
-                var summaryLine = lines.LastOrDefault(l => l.Contains("sender") || l.Contains("receiver"));
-                if (summaryLine != null)
+                if(logItem.Count > 0 && logItem[logItem.Count].Contains("receiver"))
                 {
-                    var parts = summaryLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
-                    for (int i = parts.Length - 1; i >= 0; i--)
+                    var matches = Regex.Matches(logItem[logItem.Count], @"(\d+\.?\d*)\s+(?:MBytes|Mbits/sec)");
+                    if (matches.Count >= 2)
                     {
-                        if (parts[i].Contains("Mbits/sec") && i > 0)
-                        {
-                            if (double.TryParse(parts[i - 1], out double rate))
-                            {
-                                return rate;
-                            }
-                        }
-                        else if (parts[i].Contains("Gbits/sec") && i > 0)
-                        {
-                            if (double.TryParse(parts[i - 1], out double rate))
-                            {
-                                return rate * 1000; // 转为 Mbps
-                            }
-                        }
+                        double value1 = double.Parse(matches[0].Groups[1].Value);
+                        double value2 = double.Parse(matches[1].Groups[1].Value);
+                        return value2.ToString();
                     }
                 }
-                return 0.0;
+                return "0.0";
             }
 
             private void WriteStream(NetworkStream stream, string text)