| | |
| | | using HMI.Core.Util; |
| | | using HMI.UI.Util; |
| | | using HMI.Util; |
| | | using HslCommunication.Profinet.Siemens; |
| | | using log4net; |
| | | using Microsoft.Win32; |
| | | using Plugin.CurrentSensorControl.Entity; |
| | |
| | | using System.Timers; |
| | | using System.Windows; |
| | | using System.Windows.Controls; |
| | | using System.Xml.Linq; |
| | | |
| | | namespace Plugin.CurrentSensorControl |
| | | { |
| | |
| | | |
| | | 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() |
| | | { |
| | |
| | | opcTimer.Interval = 1000; |
| | | |
| | | S7Context.Init(SystemSetting.Instance.PlcIp, SystemSetting.Instance.PlcPort); |
| | | api = S7Context.Get($"1"); |
| | | |
| | | DataContext = this; |
| | | InitializeComponent(); |
| | |
| | | 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) |
| | |
| | | |
| | | private void DoDelete(SensorData data) |
| | | { |
| | | if (MsgBoxHelper2.WarnChoose("删除?") == MessageBoxResult.OK) |
| | | if (MsgBoxHelper2.WarnChoose("确定要删除吗?") == MessageBoxResult.OK) |
| | | { |
| | | var index = Datasource.IndexOf(data); |
| | | if (index >= 0) |