From 006c98e5650b530e5220f279c1e803fefe69d40d Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期二, 25 十一月 2025 15:47:33 +0800
Subject: [PATCH] 优化一些东西;

---
 Plugin.CurrentSensorControl/ControlPage.xaml.cs |   43 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/Plugin.CurrentSensorControl/ControlPage.xaml.cs b/Plugin.CurrentSensorControl/ControlPage.xaml.cs
index fb11a44..85d9f42 100644
--- a/Plugin.CurrentSensorControl/ControlPage.xaml.cs
+++ b/Plugin.CurrentSensorControl/ControlPage.xaml.cs
@@ -5,6 +5,7 @@
 using HMI.Core.Util;
 using HMI.UI.Util;
 using HMI.Util;
+using HslCommunication.Profinet.Siemens;
 using log4net;
 using Microsoft.Win32;
 using Plugin.CurrentSensorControl.Entity;
@@ -13,6 +14,7 @@
 using System.Timers;
 using System.Windows;
 using System.Windows.Controls;
+using System.Xml.Linq;
 
 namespace Plugin.CurrentSensorControl
 {
@@ -28,10 +30,33 @@
 
         private System.Timers.Timer timer;
         private System.Timers.Timer opcTimer;
-        private SCADAApi api;
         public static ILog Logger { get; private set; }
 
         private volatile bool needRead = false;
+
+        private SiemensS7Net api;
+
+        private bool plcMute = false;
+        public bool PlcMute
+        {
+            get => plcMute;
+            set
+            {
+                try
+                {
+                    string name = $"PLC_Mute";
+                    if (S7Context.WriteData(api, name, value))
+                    {
+                        plcMute = value;
+                        OnPropertyChanged(nameof(PlcMute));
+                    }
+                }
+                catch (Exception ex)
+                {
+
+                }
+            }
+        }
 
         public ControlPage()
         {
@@ -46,6 +71,7 @@
             opcTimer.Interval = 1000;
 
             S7Context.Init(SystemSetting.Instance.PlcIp, SystemSetting.Instance.PlcPort);
+            api = S7Context.Get($"1");
 
             DataContext = this;
             InitializeComponent();
@@ -73,6 +99,19 @@
         private void Timer_Elapsed(object sender, ElapsedEventArgs e)
         {
             timer.Enabled = false;
+            try
+            {
+                if (S7Context.GetData(api, "PLC_Mute", out object val))
+                {
+                    plcMute = (bool)val;
+                    OnPropertyChanged("PlcMute");
+                }
+            }
+            catch (Exception ex)
+            {
+
+            }
+
             try
             {
                 foreach (var ctl in controls)
@@ -299,7 +338,7 @@
 
         private void DoDelete(SensorData data)
         {
-            if (MsgBoxHelper2.WarnChoose("鍒犻櫎?") == MessageBoxResult.OK)
+            if (MsgBoxHelper2.WarnChoose("纭畾瑕佸垹闄ゅ悧?") == MessageBoxResult.OK)
             {
                 var index = Datasource.IndexOf(data);
                 if (index >= 0)

--
Gitblit v1.9.1