From 7544b28be9df146b31cff633627e1011e7605175 Mon Sep 17 00:00:00 2001 From: ZhaoGang <15196688790@163.com> Date: Mon, 11 Nov 2024 15:24:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.Academy/50L/AddData.cs | 18 +++--- BPASmartClient.Academy/50L/PlcControl.cs | 64 ++++++++++++++++--- BPASmartClient.Academy/App.config | 43 ++++++++----- .../BPASmartClient.Academy.csproj | 6 ++ BPASmartClient.Academy/Model/Simens_PLC.cs | 4 +- 5 files changed, 99 insertions(+), 36 deletions(-) diff --git a/BPASmartClient.Academy/50L/AddData.cs b/BPASmartClient.Academy/50L/AddData.cs index dde82426..449c70ab 100644 --- a/BPASmartClient.Academy/50L/AddData.cs +++ b/BPASmartClient.Academy/50L/AddData.cs @@ -48,15 +48,15 @@ namespace BPASmartClient.Academy._50L Data.TryAdd(fbd, 0); } }); - AlarmHelper.GetInstance.AddNotify = (s) => - { - App.Current.Dispatcher.Invoke(() => - { - MessageNotify.GetInstance.ShowAlarmLog(s.Info); - }); - }; - AlarmHelper.GetInstance.Register("50L反应釜"); - AlarmHelper.GetInstance.Start(); + //AlarmHelper.GetInstance.AddNotify = (s) => + //{ + // App.Current.Dispatcher.Invoke(() => + // { + // MessageNotify.GetInstance.ShowAlarmLog(s.Info); + // }); + //}; + //AlarmHelper.GetInstance.Register("50L反应釜"); + //AlarmHelper.GetInstance.Start(); } } } diff --git a/BPASmartClient.Academy/50L/PlcControl.cs b/BPASmartClient.Academy/50L/PlcControl.cs index bd78cf90..a079fb00 100644 --- a/BPASmartClient.Academy/50L/PlcControl.cs +++ b/BPASmartClient.Academy/50L/PlcControl.cs @@ -8,6 +8,9 @@ using System.Threading.Tasks; using System.Collections.Concurrent; using System.Diagnostics; using BPA.Helper; +using System.Collections.Specialized; +using System.Configuration; +using BPASmartClient.CustomResource.UserControls.MessageShow; namespace BPASmartClient.Academy._50L { @@ -18,10 +21,12 @@ namespace BPASmartClient.Academy._50L private PlcControl() { } public bool IsConnect => comm != null && comm.IsConnected(); public DeviceStatus DeviceStatus { get; set; } = new DeviceStatus(); + public ConcurrentDictionary AlarmInfo { get; private set; } = new ConcurrentDictionary(); private ICommSiemens comm = CommHelper.Siemens; public string id { get; set; } = ""; public void Init() { + AlarmInfoGet(); Task.Factory.StartNew(() => { CommHelper.CreateSiemens(CpuType.S7200Smart, Json.Data.IpAddress).OnSuccess(s => @@ -36,6 +41,44 @@ namespace BPASmartClient.Academy._50L private volatile bool _isReadSuccess; + + public void AlarmInfoGet() + { + var x = (NameValueCollection)ConfigurationManager.GetSection("Reactor_50L_Alarm/Alarm"); + if (x != null) + { + x.AllKeys.ToList().ForEach(o => + { + if (!AlarmInfo.ContainsKey(o)) + { + AlarmInfo.TryAdd(o, x.Get(o)); + } + }); + } + } + public void AlarmRead() + { + if (this.IsConnect) + { + AlarmInfo.Keys.ToList().ForEach(o => + { + comm.Read(o).OnSuccess(p => + { + if (RTrig.GetInstance($"{o}").Start(p.Content)) + { + App.Current.Dispatcher.Invoke(() => + { + NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "报警", this.AlarmInfo[o]); + MessageNotify.GetInstance.ShowAlarmLog(this.AlarmInfo[o]); + }); + + } + }); + }); + + } + Thread.Sleep(2000); + } private void Read() { TaskManage.GetInstance.StartLong(() => @@ -182,16 +225,17 @@ namespace BPASmartClient.Academy._50L }); comm.Read("DB1.DBX1003.7", 1).OnSuccess(s => DeviceStatus.HeartBeat = s.Content ); - comm.Read("DB1.DBX2004.0", 16).OnSuccess(s => - { - AlarmHelper.GetInstance.Get("50L反应釜").EStop = s.Content[0]; - AlarmHelper.GetInstance.Get("50L反应釜").RotatingMachinesError = s.Content[1]; - AlarmHelper.GetInstance.Get("50L反应釜").AbnormalNegativePressureFan = s.Content[2]; - AlarmHelper.GetInstance.Get("50L反应釜").BrinePumpError = s.Content[3]; - AlarmHelper.GetInstance.Get("50L反应釜").CompressorError = s.Content[4]; - AlarmHelper.GetInstance.Get("50L反应釜").ReactorPressureLimit = s.Content[5]; - }); - + //comm.Read("DB1.DBX2004.0", 16).OnSuccess(s => + //{ + // AlarmHelper.GetInstance.Get("50L反应釜").EStop = s.Content[0]; + // AlarmHelper.GetInstance.Get("50L反应釜").RotatingMachinesError = s.Content[1]; + // AlarmHelper.GetInstance.Get("50L反应釜").AbnormalNegativePressureFan = s.Content[2]; + // AlarmHelper.GetInstance.Get("50L反应釜").BrinePumpError = s.Content[3]; + // AlarmHelper.GetInstance.Get("50L反应釜").CompressorError = s.Content[4]; + // AlarmHelper.GetInstance.Get("50L反应釜").ReactorPressureLimit = s.Content[5]; + //}); + AlarmRead(); + Thread.Sleep(100); }, "数据获取", true); } diff --git a/BPASmartClient.Academy/App.config b/BPASmartClient.Academy/App.config index 0375766b..214fbfd9 100644 --- a/BPASmartClient.Academy/App.config +++ b/BPASmartClient.Academy/App.config @@ -1,18 +1,31 @@  - - -
- - - - - - - - - - - - + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/BPASmartClient.Academy/BPASmartClient.Academy.csproj b/BPASmartClient.Academy/BPASmartClient.Academy.csproj index 9718e35a..a8400e6f 100644 --- a/BPASmartClient.Academy/BPASmartClient.Academy.csproj +++ b/BPASmartClient.Academy/BPASmartClient.Academy.csproj @@ -35,4 +35,10 @@ + + + PreserveNewest + + + diff --git a/BPASmartClient.Academy/Model/Simens_PLC.cs b/BPASmartClient.Academy/Model/Simens_PLC.cs index fb472245..380e8ef9 100644 --- a/BPASmartClient.Academy/Model/Simens_PLC.cs +++ b/BPASmartClient.Academy/Model/Simens_PLC.cs @@ -97,11 +97,11 @@ namespace BPASmartClient.Academy.Model //{ // IsConnected = false; //} - if (p.Content) + if (RTrig.GetInstance($"{o}").Start(p.Content)) { App.Current.Dispatcher.Invoke(() => { - NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", Simens_PLC.GetInstance.AlarmInfo[o], 2, 1); + NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", Simens_PLC.GetInstance.AlarmInfo[o], 2, 3); MessageNotify.GetInstance.ShowAlarmLog(Simens_PLC.GetInstance.AlarmInfo[o]); });