From fb4b8642cfbd157ae0635b182b4f578bf337dbef Mon Sep 17 00:00:00 2001
From: C3204 <zhengyabo@lanpucloud.cn>
Date: 星期一, 19 一月 2026 08:41:11 +0800
Subject: [PATCH] user
---
LB_SmartVision/VisionForm.cs | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/LB_SmartVision/VisionForm.cs b/LB_SmartVision/VisionForm.cs
index a8fdfcf..7b5d3c5 100644
--- a/LB_SmartVision/VisionForm.cs
+++ b/LB_SmartVision/VisionForm.cs
@@ -10,6 +10,7 @@
using LB_SmartVision.Forms.Pages.SettingPage;
using LB_SmartVision.Forms.Pages.UserManagementPage;
using LB_SmartVision.ProcessRun;
+using LB_SmartVision.SQL;
using LB_SmartVision.Tool;
using LB_SmartVisionCommon;
using LB_SmartVisionLoginUI;
@@ -687,6 +688,7 @@
com_ProductName.Items.Add("鏂板");
com_ProductName.Text = GlobalVar.strProductName;
this.WindowState = FormWindowState.Maximized;
+ DatabaseRecordProductDataHelper.InitializeDatabase();
}
public void SaveAllSetting()
@@ -841,12 +843,8 @@
if (!string.IsNullOrEmpty(CommunicatorAddress) && CommunicatorAddress.Contains("SiemensLBS7"))
{
// 瀹氫箟姝e垯琛ㄨ揪寮忎互鎻愬彇鍗忚銆両P 鍦板潃鍜岀鍙�
- //1. \((.*?)\)锛歕(鍜� \) 鏄敤浜庡尮閰嶆嫭鍙风殑杞箟瀛楃銆�
- // (.*?) 鏄竴涓潪璐┆鐨勫尮閰嶏紝鐢ㄦ潵鍖归厤绫诲悕锛圡yProcesses.Communicators.TCPServer 鎴� MyProcesses.Communicators.UARTPort锛夈��
- //2. ([^:] +)锛氬尮閰嶅啋鍙蜂箣鍓嶇殑閮ㄥ垎锛屽嵆鍦板潃锛�127.0.0.1 鎴� COM5锛夈�傝繖閲屼娇鐢ㄤ簡[^:] 鏉ュ尮閰嶉櫎浜嗗啋鍙蜂箣澶栫殑浠绘剰瀛楃銆�
- //3. (\d +) 锛氬尮閰嶇鍙e彿锛岀‘淇濆畠鍖归厤涓�涓垨澶氫釜鏁板瓧銆�
-
- string pattern = @"^\((?<ClassName>[^)]+)\)\[(?<IP>[^]]+)\]\[(?<Slot>[^]]+)\]\[(?<CpuType>[^]]+)\]\[(?<PlcAddress>[^]]+)\]$";
+ // 鏇存柊姝e垯浠ユ敮鎸佸彲閫夌殑鏁版嵁绫诲瀷瀛楁
+ string pattern = @"^\((?<ClassName>[^)]+)\)\[(?<IP>[^]]+)\]\[(?<Slot>[^]]+)\]\[(?<CpuType>[^]]+)\]\[(?<PlcAddress>[^]]+)\](?:\[(?<DataType>[^]]+)\])?$";
Match match = Regex.Match(CommunicatorAddress, pattern);
if (match.Success)
@@ -854,8 +852,10 @@
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 CpuType = match.Groups["CpuType"].Value;
string PlcAddress = match.Groups["PlcAddress"].Value;
+ string DataType = match.Groups["DataType"].Success ? match.Groups["DataType"].Value : "String";
+
if (string.IsNullOrEmpty(ClassName) || string.IsNullOrEmpty(IP) || string.IsNullOrEmpty(Slot) || string.IsNullOrEmpty(CpuType) || string.IsNullOrEmpty(PlcAddress))
break;
@@ -878,6 +878,7 @@
Communicator.CommunicatorConnections.Add("绔彛", Slot);
Communicator.CommunicatorConnections.Add("鍨嬪彿", CpuType);
Communicator.CommunicatorConnections.Add("鍙橀噺鍦板潃", PlcAddress);
+ Communicator.CommunicatorConnections.Add("鏁版嵁绫诲瀷", DataType);
Communicator.CommunicatorName = CommunicatorName;
if (!Communicator.Connect())
{
@@ -1028,7 +1029,6 @@
{
string strJson = string.Empty;
GlobalVar.allCommunicatorsConnectionString = new ConcurrentDictionary<string, string>();
-
foreach (var item in GlobalVar.dicCommunicators)
{
string ClassName = item.Value.GetType().FullName;// "TCP"
@@ -1038,11 +1038,14 @@
{
string CpuType = item.Value.CommunicatorConnections["鍨嬪彿"].ToString();
string PlcAddress = item.Value.CommunicatorConnections["鍙橀噺鍦板潃"].ToString();
+ string DataType = item.Value.CommunicatorConnections.Contains("鏁版嵁绫诲瀷") ?
+ item.Value.CommunicatorConnections["鏁版嵁绫诲瀷"].ToString() : "String";
+
if (string.IsNullOrEmpty(ClassName) || string.IsNullOrEmpty(IP) || string.IsNullOrEmpty(PORT) || string.IsNullOrEmpty(CpuType) || string.IsNullOrEmpty(PlcAddress))
{
break;
}
- string CommunicatorConnectionString = $"({ClassName})[{IP}][{PORT}][{CpuType}][{PlcAddress}]";
+ string CommunicatorConnectionString = $"({ClassName})[{IP}][{PORT}][{CpuType}][{PlcAddress}][{DataType}]";
GlobalVar.allCommunicatorsConnectionString.TryAdd(item.Key, CommunicatorConnectionString);
}
else
@@ -1054,6 +1057,7 @@
string CommunicatorConnectionString = $"({ClassName})[{IP}][{PORT}]";
GlobalVar.allCommunicatorsConnectionString.TryAdd(item.Key, CommunicatorConnectionString);
}
+ GlobalVar.dicCommunicators[item.Key].ClassName = ClassName;
}
var settings = new JsonSerializerSettings
{
@@ -1078,6 +1082,11 @@
{ }
}
File.WriteAllText(GlobalVar.allCommunicatorsConnectionStringPath, strJson, Encoding.UTF8);
+ foreach (var item in GlobalVar.dicCommunicators)
+ {
+ string ClassName = item.Value.GetType().FullName;// "TCP"
+ }
+ ConfigManager<ObservableConcurrentDictionary<string, BaseCommunicator>>.SaveConfig<ObservableConcurrentDictionary<string, BaseCommunicator>>(GlobalVar.dicCommunicators, GlobalVar.strApplicationPath + "\\鎵�鏈変骇鍝乗\" + GlobalVar.strProductName + "\\dicCommunicators.json");
return true;
}
catch { return false; }
--
Gitblit v1.9.3