增加报警

This commit is contained in:
2025-01-01 17:41:48 +08:00
parent f26bf28181
commit 7b5df5877d
16 changed files with 896 additions and 122 deletions

View File

@@ -32,6 +32,7 @@ namespace CapMachine.Wpf.Services
/// 事件聚合器
/// </summary>
private IEventAggregator _EventAggregator { get; set; }
public AlarmService AlarmService { get; }
/// <summary>
/// PLCScanTask扫描Task
@@ -97,7 +98,7 @@ namespace CapMachine.Wpf.Services
/// 实例化函数
/// </summary>
/// <param name="eventAggregator"></param>
public MachineRtDataService(IEventAggregator eventAggregator)
public MachineRtDataService(IEventAggregator eventAggregator, AlarmService alarmService)//, AlarmService alarmService
{
//ConcurrentDictionary<DateTime, RecordInfo> keyValuePairs = new ConcurrentDictionary<DateTime, RecordInfo>();
@@ -110,6 +111,7 @@ namespace CapMachine.Wpf.Services
//事件服务
_EventAggregator = eventAggregator;
AlarmService = alarmService;
//秒触发一次
CycleTimer = new System.Timers.Timer(500);
@@ -181,7 +183,7 @@ namespace CapMachine.Wpf.Services
SVAddress = "VW200",
MVAddress = "VW250",
IsMeter = true,
AutoHandSwitchAddress= "VW240",
AutoHandSwitchAddress = "VW240",
Precision = 1,
DecimalPoint = 0,
Samp = 1,
@@ -895,6 +897,11 @@ namespace CapMachine.Wpf.Services
private Random Random { get; set; } = new Random();
/// <summary>
/// 报警结果集合
/// </summary>
private OperateResult<bool[]> OperateResultAlarm { get; set; }
/// <summary>
/// PLC扫描线程
/// </summary>
@@ -912,28 +919,8 @@ namespace CapMachine.Wpf.Services
//DiagnosticsTime.Start();
try
{
//var MyProperty = typeof(int);
//foreach (var item in TagManger.DicTags)
//{
// if (item.Value.ValueType == typeof(short))
// {
// var Tag = TagManger.GetTagByName<short>(item.Key);
// Tag.RtValue.Value++;
// }
// else if (item.Value.ValueType == typeof(double))
// {
// var Tag = TagManger.GetTagByName<double>(item.Key);
// Tag.RtValue.Value++;
// }
//}
//TagInfo.RtValue.Value++;
//RT TODO
//SiemensDrive.Read("VW1", 2);
//var data = TagManger.DicTags["转速"].ValueType.Name;
////第一次计时
@@ -1001,6 +988,16 @@ namespace CapMachine.Wpf.Services
//stopwatch.Stop(); //停止Stopwatch
//Console.WriteLine("Add Elapsed output runTime:{0}", stopwatch.Elapsed.TotalSeconds.ToString());
//stopwatch.Reset();
OperateResultAlarm = SiemensDrive.ReadBool("V0.0", 15);
if (OperateResultAlarm.IsSuccess)
{
foreach (var item in AlarmService.ListAlarmRunCell)
{
item.UpdateBoolValue(OperateResultAlarm.Content[item.Index]);
}
}
}
catch (Exception ex)
{