From 4787609e9eafd73398dfc699cc0434f8617d68c9 Mon Sep 17 00:00:00 2001
From: C3204 <zhengyabo@lanpucloud.cn>
Date: 星期三, 07 一月 2026 16:50:44 +0800
Subject: [PATCH] 修复主界面菜单栏字体显示bug。
---
LB_SmartVision/VisionForm.cs | 243 ++++++++++++++++++++++++++++++++++--------------
1 files changed, 170 insertions(+), 73 deletions(-)
diff --git a/LB_SmartVision/VisionForm.cs b/LB_SmartVision/VisionForm.cs
index 343d396..98bf6a7 100644
--- a/LB_SmartVision/VisionForm.cs
+++ b/LB_SmartVision/VisionForm.cs
@@ -3,6 +3,7 @@
using LB_SmartVision.Forms.Pages;
using LB_SmartVision.Forms.Pages.CameraPage;
using LB_SmartVision.Forms.Pages.CommunicatorPage;
+using LB_SmartVision.Forms.Pages.HistoricalData;
using LB_SmartVision.Forms.Pages.MESPage;
using LB_SmartVision.Forms.Pages.MotionControlPage;
using LB_SmartVision.Forms.Pages.ProcessPage;
@@ -16,6 +17,7 @@
using LB_VisionProcesses.Cameras;
using LB_VisionProcesses.Cameras.HRCameras;
using LB_VisionProcesses.Communicators;
+using LB_VisionProcesses.Communicators.SiemensS7;
using LB_VisionProcesses.Communicators.TCom;
using LB_VisionProcesses.Forms;
using log4net.Config;
@@ -42,6 +44,7 @@
{
AllProcessesPage AllProcessesPages = new AllProcessesPage();
CamerasEditPage CamerasEditPage = new CamerasEditPage();
+ HistoricalDataEditPage HistoricalDataEditPage = new HistoricalDataEditPage();
CommunicatorsEditPage CommunicatorsEditPage = new CommunicatorsEditPage();
SettingEditPage SettingEditPage = new SettingEditPage();
MESEditPage MESEditPage = new MESEditPage();
@@ -69,6 +72,8 @@
AllProcessesPages.controlsPanel.Dock = DockStyle.Fill;
materialTabControl.Controls.Add(AllProcessesPages);
+ HistoricalDataEditPage.LogInfo += LogInfo;
+ materialTabControl.Controls.Add(new MyPage(HistoricalDataEditPage));
CamerasEditPage.LogInfo += LogInfo;
materialTabControl.Controls.Add(new MyPage(CamerasEditPage));
@@ -242,7 +247,7 @@
{
return;
}
- string strInfo = DateTime.Now.ToString("[yyyy:MM:HH:mm:ss:fff] ");
+ string strInfo = DateTime.Now.ToString("[yyyy:MM:dd:HH:mm:ss:fff] ");
strInfo += strLog;
if (infoType != LogInfoType.NOSHOW)
{
@@ -258,19 +263,30 @@
switch (infoType)
{
case LogInfoType.INFO:
- this.rich_Info.SelectionColor = Color.Wheat;
- break;
+ {
+ this.rich_Info.SelectionColor = Color.Wheat;
+ AsyncLogHelper.Info(strLog);
+ break;
+ }
case LogInfoType.WARN:
- this.rich_Info.SelectionColor = Color.LightGoldenrodYellow;
- break;
+ {
+ this.rich_Info.SelectionColor = Color.Yellow;
+ AsyncLogHelper.Warn(strLog);
+ break;
+ }
case LogInfoType.PASS:
- this.rich_Info.SelectionColor = Color.Green;
- break;
+ {
+ this.rich_Info.SelectionColor = Color.Green;
+ AsyncLogHelper.Info(strLog);
+ break;
+ }
case LogInfoType.ERROR:
- this.rich_Info.SelectionColor = Color.Red;
- break;
+ {
+ this.rich_Info.SelectionColor = Color.Red;
+ AsyncLogHelper.Error(strLog);
+ break;
+ }
}
-
// 鏇存柊 UI 鎺т欢锛屾瘮濡傛樉绀烘帴鏀跺埌鐨勬秷鎭�
this.rich_Info.AppendText(strInfo);
this.rich_Info.AppendText("\r\n");
@@ -282,32 +298,43 @@
{
if (this.rich_Info.Lines.Length > 1000)
+ {
this.rich_Info.Clear();
-
+ }
// 濡傛灉宸茬粡鍦� UI 绾跨▼涓婏紝鐩存帴鏇存柊 UI
switch (infoType)
{
case LogInfoType.INFO:
- this.rich_Info.SelectionColor = Color.Wheat;
- break;
+ {
+ this.rich_Info.SelectionColor = Color.Wheat;
+ AsyncLogHelper.Info(strLog);
+ break;
+ }
case LogInfoType.WARN:
- this.rich_Info.SelectionColor = Color.Yellow;
- break;
+ {
+ this.rich_Info.SelectionColor = Color.Yellow;
+ AsyncLogHelper.Warn(strLog);
+ break;
+ }
case LogInfoType.PASS:
- this.rich_Info.SelectionColor = Color.Green;
- break;
+ {
+ this.rich_Info.SelectionColor = Color.Green;
+ AsyncLogHelper.Info(strLog);
+ break;
+ }
case LogInfoType.ERROR:
- this.rich_Info.SelectionColor = Color.Red;
- break;
+ {
+ this.rich_Info.SelectionColor = Color.Red;
+ AsyncLogHelper.Error(strLog);
+ break;
+ }
}
-
this.rich_Info.AppendText(strInfo);
this.rich_Info.AppendText("\r\n");
this.rich_Info.SelectionStart = this.rich_Info.Text.Length;
this.rich_Info.ScrollToCaret();
}
}
- AsyncLogHelper.Info(strLog);
}
public static bool SaveAllLayout()
@@ -502,9 +529,9 @@
{
XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));
string[] paths = {
- @"鐢熶骇鏃ュ織\Run_Log",
- @"鐢熶骇鏃ュ織\Debug_Log",
- @"鐢熶骇鏃ュ織\Error_Log",
+ @"鐢熶骇鏃ュ織\Run",
+ @"鐢熶骇鏃ュ織\Debug",
+ @"鐢熶骇鏃ュ織\Error",
@"鐢熶骇鏃ュ織\Fatal",
@"鐢熶骇鏃ュ織\Warn",
};
@@ -764,65 +791,122 @@
{
string CommunicatorName = CommunicatorConnectionString.Key;
string CommunicatorAddress = CommunicatorConnectionString.Value;
-
- // 瀹氫箟姝e垯琛ㄨ揪寮忎互鎻愬彇鍗忚銆両P 鍦板潃鍜岀鍙�
- //1. \((.*?)\)锛歕(鍜� \) 鏄敤浜庡尮閰嶆嫭鍙风殑杞箟瀛楃銆�
- // (.*?) 鏄竴涓潪璐┆鐨勫尮閰嶏紝鐢ㄦ潵鍖归厤绫诲悕锛圡yProcesses.Communicators.TCPServer 鎴� MyProcesses.Communicators.UARTPort锛夈��
- //2. ([^:] +)锛氬尮閰嶅啋鍙蜂箣鍓嶇殑閮ㄥ垎锛屽嵆鍦板潃锛�127.0.0.1 鎴� COM5锛夈�傝繖閲屼娇鐢ㄤ簡[^:] 鏉ュ尮閰嶉櫎浜嗗啋鍙蜂箣澶栫殑浠绘剰瀛楃銆�
- //3. (\d +) 锛氬尮閰嶇鍙e彿锛岀‘淇濆畠鍖归厤涓�涓垨澶氫釜鏁板瓧銆�
-
- string pattern = @"^\((?<ClassName>[^)]+)\)\[(?<IP>[^]]+)\]\[(?<PORT>[^]]+)\]$";
- Match match = Regex.Match(CommunicatorAddress, pattern);
-
- if (match.Success)
+ if (!string.IsNullOrEmpty(CommunicatorAddress) && CommunicatorAddress.Contains("SiemensLBS7"))
{
- string ClassName = match.Groups["ClassName"].Value; // "TCP"
- string IP = match.Groups["IP"].Value; // "127.0.0.1"
- string PORT = match.Groups["PORT"].Value; // "1111"
+ // 瀹氫箟姝e垯琛ㄨ揪寮忎互鎻愬彇鍗忚銆両P 鍦板潃鍜岀鍙�
+ //1. \((.*?)\)锛歕(鍜� \) 鏄敤浜庡尮閰嶆嫭鍙风殑杞箟瀛楃銆�
+ // (.*?) 鏄竴涓潪璐┆鐨勫尮閰嶏紝鐢ㄦ潵鍖归厤绫诲悕锛圡yProcesses.Communicators.TCPServer 鎴� MyProcesses.Communicators.UARTPort锛夈��
+ //2. ([^:] +)锛氬尮閰嶅啋鍙蜂箣鍓嶇殑閮ㄥ垎锛屽嵆鍦板潃锛�127.0.0.1 鎴� COM5锛夈�傝繖閲屼娇鐢ㄤ簡[^:] 鏉ュ尮閰嶉櫎浜嗗啋鍙蜂箣澶栫殑浠绘剰瀛楃銆�
+ //3. (\d +) 锛氬尮閰嶇鍙e彿锛岀‘淇濆畠鍖归厤涓�涓垨澶氫釜鏁板瓧銆�
- if (string.IsNullOrEmpty(ClassName) || string.IsNullOrEmpty(IP) || string.IsNullOrEmpty(PORT))
- break;
+ string pattern = @"^\((?<ClassName>[^)]+)\)\[(?<IP>[^]]+)\]\[(?<Slot>[^]]+)\]\[(?<CpuType>[^]]+)\]\[(?<PlcAddress>[^]]+)\]$";
+ Match match = Regex.Match(CommunicatorAddress, pattern);
- //鍒╃敤鍙嶅皠鍒涘缓瀹炰緥
- Type type = IProcess.GetExecutingAssembly().GetType(ClassName);
- if (type == null)
+ if (match.Success)
{
- Debug.WriteLine("Class not found.");
- return false;
- }
- var Communicator = Activator.CreateInstance(type, CommunicatorName) as BaseCommunicator;
+ string ClassName = match.Groups["ClassName"].Value; // "TCP"
+ string IP = match.Groups["IP"].Value; // "127.0.0.1"
+ string Slot = match.Groups["Slot"].Value; // "1111"
+ string CpuType= match.Groups["CpuType"].Value;
+ string PlcAddress = match.Groups["PlcAddress"].Value;
+ if (string.IsNullOrEmpty(ClassName) || string.IsNullOrEmpty(IP) || string.IsNullOrEmpty(Slot) || string.IsNullOrEmpty(CpuType) || string.IsNullOrEmpty(PlcAddress))
+ break;
- if (Communicator == null)
- {
- Debug.WriteLine("BaseCommunicator not found.");
- return false;
- }
+ //鍒╃敤鍙嶅皠鍒涘缓瀹炰緥
+ Type type = IProcess.GetExecutingAssembly().GetType(ClassName);
+ if (type == null)
+ {
+ Debug.WriteLine("Class not found.");
+ return false;
+ }
+ var Communicator = Activator.CreateInstance(type, CommunicatorName) as BaseCommunicator;
- //TCP瀹㈡埛绔渶鍚庡啀杩炴帴
- if (Communicator is TCPClient)
- {
- clientsCommunicatorsConnectionString.TryAdd(CommunicatorConnectionString.Key, CommunicatorConnectionString.Value);
- continue;
- }
+ if (Communicator == null)
+ {
+ Debug.WriteLine("BaseCommunicator not found.");
+ return false;
+ }
- Communicator.CommunicatorConnections.Add("鍦板潃", IP);
- Communicator.CommunicatorConnections.Add("绔彛", PORT);
- Communicator.CommunicatorName = CommunicatorName;
- if (!Communicator.Connect())
- {
- LogInfo($"鍒濆鍖栭�氳鍙{CommunicatorName}]澶辫触,鍘熷洜鏄瘂Communicator.Msg}", LogInfoType.ERROR);
+ Communicator.CommunicatorConnections.Add("鍦板潃", IP);
+ Communicator.CommunicatorConnections.Add("绔彛", Slot);
+ Communicator.CommunicatorConnections.Add("鍨嬪彿", CpuType);
+ Communicator.CommunicatorConnections.Add("鍙橀噺鍦板潃", PlcAddress);
+ Communicator.CommunicatorName = CommunicatorName;
+ if (!Communicator.Connect())
+ {
+ LogInfo($"鍒濆鍖栭�氳鍙{CommunicatorName}]澶辫触,鍘熷洜鏄瘂Communicator.Msg}", LogInfoType.ERROR);
+ }
+ else
+ {
+ LogInfo($"鍒濆鍖栭�氳鍙{CommunicatorName}]鎴愬姛", LogInfoType.PASS);
+ }
+ GlobalVar.dicCommunicators.TryAdd(CommunicatorName, Communicator);
}
else
{
- LogInfo($"鍒濆鍖栭�氳鍙{CommunicatorName}]鎴愬姛", LogInfoType.PASS);
+ Debug.WriteLine("No match found.");
}
- GlobalVar.dicCommunicators.TryAdd(CommunicatorName, Communicator);
}
else
{
- Debug.WriteLine("No match found.");
- }
+ // 瀹氫箟姝e垯琛ㄨ揪寮忎互鎻愬彇鍗忚銆両P 鍦板潃鍜岀鍙�
+ //1. \((.*?)\)锛歕(鍜� \) 鏄敤浜庡尮閰嶆嫭鍙风殑杞箟瀛楃銆�
+ // (.*?) 鏄竴涓潪璐┆鐨勫尮閰嶏紝鐢ㄦ潵鍖归厤绫诲悕锛圡yProcesses.Communicators.TCPServer 鎴� MyProcesses.Communicators.UARTPort锛夈��
+ //2. ([^:] +)锛氬尮閰嶅啋鍙蜂箣鍓嶇殑閮ㄥ垎锛屽嵆鍦板潃锛�127.0.0.1 鎴� COM5锛夈�傝繖閲屼娇鐢ㄤ簡[^:] 鏉ュ尮閰嶉櫎浜嗗啋鍙蜂箣澶栫殑浠绘剰瀛楃銆�
+ //3. (\d +) 锛氬尮閰嶇鍙e彿锛岀‘淇濆畠鍖归厤涓�涓垨澶氫釜鏁板瓧銆�
+ string pattern = @"^\((?<ClassName>[^)]+)\)\[(?<IP>[^]]+)\]\[(?<PORT>[^]]+)\]$";
+ Match match = Regex.Match(CommunicatorAddress, pattern);
+
+ if (match.Success)
+ {
+ string ClassName = match.Groups["ClassName"].Value; // "TCP"
+ string IP = match.Groups["IP"].Value; // "127.0.0.1"
+ string PORT = match.Groups["PORT"].Value; // "1111"
+
+ if (string.IsNullOrEmpty(ClassName) || string.IsNullOrEmpty(IP) || string.IsNullOrEmpty(PORT))
+ break;
+
+ //鍒╃敤鍙嶅皠鍒涘缓瀹炰緥
+ Type type = IProcess.GetExecutingAssembly().GetType(ClassName);
+ if (type == null)
+ {
+ Debug.WriteLine("Class not found.");
+ return false;
+ }
+ var Communicator = Activator.CreateInstance(type, CommunicatorName) as BaseCommunicator;
+
+ if (Communicator == null)
+ {
+ Debug.WriteLine("BaseCommunicator not found.");
+ return false;
+ }
+
+ //TCP瀹㈡埛绔渶鍚庡啀杩炴帴
+ if (Communicator is TCPClient)
+ {
+ clientsCommunicatorsConnectionString.TryAdd(CommunicatorConnectionString.Key, CommunicatorConnectionString.Value);
+ continue;
+ }
+
+ Communicator.CommunicatorConnections.Add("鍦板潃", IP);
+ Communicator.CommunicatorConnections.Add("绔彛", PORT);
+ Communicator.CommunicatorName = CommunicatorName;
+ if (!Communicator.Connect())
+ {
+ LogInfo($"鍒濆鍖栭�氳鍙{CommunicatorName}]澶辫触,鍘熷洜鏄瘂Communicator.Msg}", LogInfoType.ERROR);
+ }
+ else
+ {
+ LogInfo($"鍒濆鍖栭�氳鍙{CommunicatorName}]鎴愬姛", LogInfoType.PASS);
+ }
+ GlobalVar.dicCommunicators.TryAdd(CommunicatorName, Communicator);
+ }
+ else
+ {
+ Debug.WriteLine("No match found.");
+ }
+ }
}
//TCP瀹㈡埛绔渶鍚庤繛鎺�
@@ -903,13 +987,26 @@
string ClassName = item.Value.GetType().FullName;// "TCP"
string IP = item.Value.CommunicatorConnections["鍦板潃"].ToString();//"127.0.0.1"
string PORT = item.Value.CommunicatorConnections["绔彛"].ToString();//"1111"
-
- if (string.IsNullOrEmpty(ClassName) || string.IsNullOrEmpty(IP) || string.IsNullOrEmpty(PORT))
+ if (!string.IsNullOrEmpty(ClassName) && ClassName.Contains("SiemensLBS7"))
{
- break;
+ string CpuType = item.Value.CommunicatorConnections["鍨嬪彿"].ToString();
+ string PlcAddress = item.Value.CommunicatorConnections["鍙橀噺鍦板潃"].ToString();
+ if (string.IsNullOrEmpty(ClassName) || string.IsNullOrEmpty(IP) || string.IsNullOrEmpty(PORT) || string.IsNullOrEmpty(CpuType) || string.IsNullOrEmpty(PlcAddress))
+ {
+ break;
+ }
+ string CommunicatorConnectionString = $"({ClassName})[{IP}][{PORT}][{CpuType}][{PlcAddress}]";
+ GlobalVar.allCommunicatorsConnectionString.TryAdd(item.Key, CommunicatorConnectionString);
}
- string CommunicatorConnectionString = $"({ClassName})[{IP}][{PORT}]";
- GlobalVar.allCommunicatorsConnectionString.TryAdd(item.Key, CommunicatorConnectionString);
+ else
+ {
+ if (string.IsNullOrEmpty(ClassName) || string.IsNullOrEmpty(IP) || string.IsNullOrEmpty(PORT))
+ {
+ break;
+ }
+ string CommunicatorConnectionString = $"({ClassName})[{IP}][{PORT}]";
+ GlobalVar.allCommunicatorsConnectionString.TryAdd(item.Key, CommunicatorConnectionString);
+ }
}
var settings = new JsonSerializerSettings
{
--
Gitblit v1.9.3