From 771a0e7b6b1276087515bbe94de28358cb92963b Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期四, 04 六月 2026 10:32:27 +0800
Subject: [PATCH] 优化老化;
---
Plugin.DOControl/DOControl.xaml.cs | 75 ++++++++++++++++++++-----------------
1 files changed, 41 insertions(+), 34 deletions(-)
diff --git a/Plugin.DOControl/DOControl.xaml.cs b/Plugin.DOControl/DOControl.xaml.cs
index b5e1924..405c4ff 100644
--- a/Plugin.DOControl/DOControl.xaml.cs
+++ b/Plugin.DOControl/DOControl.xaml.cs
@@ -5,6 +5,7 @@
using HMI.UI;
using HMI.UI.Util;
using log4net;
+using OPCConnection;
using Panuon.WPF.UI;
using Plugin.DOControl.Entity;
using System;
@@ -26,8 +27,8 @@
/// <summary>
/// 瀹炰緥鍖栨湇鍔″櫒鎺ュ彛鍑芥暟
/// </summary>
- //private OpcInterface.OpcInterface lTSCADAApi = new OpcInterface.OpcInterface();
- private PipeClient pipeClient = new PipeClient("DAService");
+ private SCADAApi lTSCADAApi = new OPCClient();
+ //private PipeClient pipeClient = new PipeClient("DAService");
private ObservableCollection<string> groups;
public ObservableCollection<string> Groups
@@ -99,8 +100,14 @@
public override void DoClose(object sender, EventArgs e)
{
- motorMonitorTimer.Enabled = false;
- base.DoClose(sender, e);
+ try
+ {
+
+ motorMonitorTimer.Enabled = false;
+ base.DoClose(sender, e);
+ }
+ catch {
+ }
}
public static string FilePath { get; private set; }
@@ -376,24 +383,24 @@
/// <param name="value">鍊�</param>
private void SetPlcValue(string key, string value)
{
- //if (!lTSCADAApi.DoFctWriteSingle(key, value, out string errMsg))
- //{
- // ToastHelper.Error(this, errMsg);
- //}
+ if (!lTSCADAApi.DoFctWriteSingle(key, value, out string errMsg))
+ {
+ ToastHelper.Error(this, errMsg);
+ }
- pipeClient.SendMessage("asdsadasda", out _);
+ //lTSCADAApi.SendMessage("asdsadasda", out _);
}
private string GetPlcValue(string key)
{
- //if (lTSCADAApi.DoFctReadSingle(key, out string Val, out string errMsg))
- //{
- // return Val;
- //}
- //else
- //{
- // return null;
- //}
+ if (lTSCADAApi.DoFctReadSingle(key, out string Val, out string errMsg))
+ {
+ return Val;
+ }
+ else
+ {
+ return null;
+ }
return null;
}
@@ -450,25 +457,25 @@
LoadData();
if (SystemSetting.Instance.PlcEnabled)
{
- //if (lTSCADAApi.Connect2("127.0.0.1", 6543, 18888, out string errMsg))
- //{
- // motorMonitorTimer.Enabled = true;
- // RefreshControl();
- //}
- //else
- //{
- // MsgBoxHelper2.Error(errMsg);
- //}
- try
+ if (lTSCADAApi.Connect2("127.0.0.1", 6543, 28888, out string errMsg))
{
- pipeClient.OnConnected += PipeClient_OnConnected;
+ motorMonitorTimer.Enabled = true;
+ RefreshControl();
+ }
+ else
+ {
+ MsgBoxHelper2.Error(errMsg);
+ }
+ //try
+ //{
+ // pipeClient.OnConnected += PipeClient_OnConnected;
- pipeClient.Connect();
- }
- catch (Exception ex)
- {
- MsgBoxHelper.Error(this, ex.Message);
- }
+ // pipeClient.Connect();
+ //}
+ //catch (Exception ex)
+ //{
+ // MsgBoxHelper.Error(this, ex.Message);
+ //}
}
Loaded -= UserControl_Loaded;
}
--
Gitblit v1.9.1