增加报警
This commit is contained in:
235
CapMachine.Wpf/Services/AlarmService.cs
Normal file
235
CapMachine.Wpf/Services/AlarmService.cs
Normal file
@@ -0,0 +1,235 @@
|
||||
using CapMachine.Model.Alarm;
|
||||
using CapMachine.Wpf.Alarm;
|
||||
using CapMachine.Wpf.Dtos;
|
||||
using Prism.Events;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警服务
|
||||
/// </summary>
|
||||
public class AlarmService : BindableBase
|
||||
{
|
||||
public AlarmService(ConfigService configService, IEventAggregator eventAggregator,IFreeSql freeSql
|
||||
)
|
||||
{
|
||||
ConfigService = configService;
|
||||
//事件服务
|
||||
_EventAggregator = eventAggregator;
|
||||
FreeSql = freeSql;
|
||||
//DataRecordService = dataRecordService;
|
||||
//SysRunServer = sysRunService;
|
||||
|
||||
ListAlarmRunCell = new ObservableCollection<AlarmRunCell>()
|
||||
{
|
||||
new AlarmRunCell(FreeSql){Index=0,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="急停报警",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V0.0",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="急停报警",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=1,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="高压压控",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V0.1",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="高压压控",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=2,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="低压压控",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V0.2",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="低压压控",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=3,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="水压低",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V0.3",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="水压低",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=4,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="水泵过载",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V0.4",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="水泵过载",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=5,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="冷水机组故障",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V0.5",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="冷水机组故障",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=6,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="排气压力",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V0.6",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="排气压力",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=7,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="吸气压力",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V0.7",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="吸气压力",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=8,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="吸气温度",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V1.0",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="吸气温度",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=9,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="吸气混合器温度",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V1.1",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="吸气混合器温度",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=10,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="水加热温度",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V1.2",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="水加热温度",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=11,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="排气温度",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V1.3",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="排气温度",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=12,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="水箱进水温度",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V1.4",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="水箱进水温度",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=13,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="压缩机表面温度",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V1.5",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="压缩机表面温度",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
new AlarmRunCell(FreeSql){Index=14,CurAlarmConfig=new AlarmConfig()
|
||||
{
|
||||
Name="试验箱",
|
||||
ActiveType=ActiveType.Bool,
|
||||
Address="V1.6",
|
||||
AlarmLevel=AlarmLevel.Level1,
|
||||
Category="一般报警",
|
||||
Message="试验箱",
|
||||
ThresholdDown=1,
|
||||
ThresholdUp=1,
|
||||
BoolActiveValue=true
|
||||
}},
|
||||
};
|
||||
}
|
||||
public ConfigService ConfigService { get; }
|
||||
|
||||
private IEventAggregator _EventAggregator { get; set; }
|
||||
public IFreeSql FreeSql { get; }
|
||||
public DataRecordService DataRecordService { get; }
|
||||
public SysRunService SysRunServer { get; }
|
||||
public MachineRtDataService MachineRtDataService { get; }
|
||||
|
||||
|
||||
private ObservableCollection<AlarmRunCell> _ListAlarmRunCell;
|
||||
/// <summary>
|
||||
/// 报警实时数据集合
|
||||
/// </summary>
|
||||
public ObservableCollection<AlarmRunCell> ListAlarmRunCell
|
||||
{
|
||||
get { return _ListAlarmRunCell; }
|
||||
set { _ListAlarmRunCell = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user