Files
CapMachine/CapMachine.Wpf/Services/AlarmService.cs
2025-01-01 17:41:48 +08:00

236 lines
8.9 KiB
C#

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(); }
}
}
}