UPS故障落库

master
CZ 4 months ago
parent 01416c1f22
commit cafa281716

@ -7,5 +7,6 @@ public enum EquipmentType
WaterCool,
Plc,
Bms,
Fire
Fire,
Ups=6,
}

@ -1,8 +1,11 @@
using Common.Const;
using Entity.DbModel.Station;
using HslCommunication;
using HslCommunication.ModBus;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Const;
using HybirdFrameworkDriver.ModbusTcpMaster;
using Repository.Station;
using Service.Ups.Msg;
namespace Service.Ups;
@ -11,7 +14,10 @@ namespace Service.Ups;
[Scope]
public class UpsClient: ModbusTcpMaster
{
public EquipAlarmDefineRepository _equipAlarmDefineRepository;
public EquipAlarmRecordRepository _equipAlarmRecordRepository;
public EquipAlarmProcessRecordRepository _equipAlarmProcessRecordRepository;
public UpsClient()
{
ReadAction = BatchRead;
@ -49,8 +55,171 @@ public class UpsClient: ModbusTcpMaster
ModbusDecoder.Decode<UpsTelemetering>(bytes01, UpsMgr.UpsTelemetering, EndingConst.ByteSeq.AB,
EndingConst.WordSeq.DC);
Dictionary<int, bool> faultDic = new();
faultDic.Add(1, UpsMgr.UpsTelemetering.InputFail.Value == 1 ? true : false);
faultDic.Add(2, UpsMgr.UpsTelemetering.BypassSequenceFail.Value == 1 ? true : false);
faultDic.Add(3, UpsMgr.UpsTelemetering.BypassVoltFail.Value == 1 ? true : false);
faultDic.Add(4, UpsMgr.UpsTelemetering.BYpassFail.Value == 1 ? true : false);
faultDic.Add(5, UpsMgr.UpsTelemetering.BypassOverLoad.Value == 1 ? true : false);
faultDic.Add(6, UpsMgr.UpsTelemetering.BypassOverLoadTimeout.Value == 1 ? true : false);
faultDic.Add(7, UpsMgr.UpsTelemetering.BypassUntrack.Value == 1 ? true : false);
faultDic.Add(8, UpsMgr.UpsTelemetering.OutputShorted.Value == 1 ? true : false);
faultDic.Add(9, UpsMgr.UpsTelemetering.BatteryEod.Value == 1 ? true : false);
faultDic.Add(10, UpsMgr.UpsTelemetering.BypassFanFail.Value == 1 ? true : false);
faultDic.Add(11, UpsMgr.UpsTelemetering.CtWeldReserve.Value == 1 ? true : false);
faultDic.Add(12, UpsMgr.UpsTelemetering.Elector.Value == 1 ? true : false);
faultDic.Add(13, UpsMgr.UpsTelemetering.Unit1RecFail.Value == 1 ? true : false);
faultDic.Add(14, UpsMgr.UpsTelemetering.Unit1InvFail.Value == 1 ? true : false);
faultDic.Add(15, UpsMgr.UpsTelemetering.Unit1RecOverTemp.Value == 1 ? true : false);
faultDic.Add(16, UpsMgr.UpsTelemetering.Unit1FanFail.Value == 1 ? true : false);
faultDic.Add(17, UpsMgr.UpsTelemetering.Unit1IvnOverLoad.Value == 1 ? true : false);
faultDic.Add(18, UpsMgr.UpsTelemetering.Unit1IvnOverLoadTimeOut.Value == 1 ? true : false);
faultDic.Add(19, UpsMgr.UpsTelemetering.Unit1IvnOverTemp.Value == 1 ? true : false);
faultDic.Add(20, UpsMgr.UpsTelemetering.Unit1IvnProtect.Value == 1 ? true : false);
faultDic.Add(21, UpsMgr.UpsTelemetering.Unit2RecFail.Value == 1 ? true : false);
faultDic.Add(22, UpsMgr.UpsTelemetering.Unit2InvFail.Value == 1 ? true : false);
faultDic.Add(23, UpsMgr.UpsTelemetering.Unit2RecOverTemp.Value == 1 ? true : false);
faultDic.Add(24, UpsMgr.UpsTelemetering.Unit2FanFail.Value == 1 ? true : false);
faultDic.Add(25, UpsMgr.UpsTelemetering.Unit2IvnOverLoad.Value == 1 ? true : false);
faultDic.Add(26, UpsMgr.UpsTelemetering.Unit2IvnOverLoadTimeOut.Value == 1 ? true : false);
faultDic.Add(27, UpsMgr.UpsTelemetering.Unit2IvnOverTemp.Value == 1 ? true : false);
faultDic.Add(28, UpsMgr.UpsTelemetering.Unit2IvnProtect.Value == 1 ? true : false);
faultDic.Add(29, UpsMgr.UpsTelemetering.Unit3RecFail.Value == 1 ? true : false);
faultDic.Add(30, UpsMgr.UpsTelemetering.Unit3InvFail.Value == 1 ? true : false);
faultDic.Add(31, UpsMgr.UpsTelemetering.Unit3RecOverTemp.Value == 1 ? true : false);
faultDic.Add(32, UpsMgr.UpsTelemetering.Unit3FanFail.Value == 1 ? true : false);
faultDic.Add(33, UpsMgr.UpsTelemetering.Unit3IvnOverLoad.Value == 1 ? true : false);
faultDic.Add(34, UpsMgr.UpsTelemetering.Unit3IvnOverLoadTimeOut.Value == 1 ? true : false);
faultDic.Add(35, UpsMgr.UpsTelemetering.Unit3IvnOverTemp.Value == 1 ? true : false);
faultDic.Add(36, UpsMgr.UpsTelemetering.Unit3IvnProtect.Value == 1 ? true : false);
faultDic.Add(37, UpsMgr.UpsTelemetering.Unit4RecFail.Value == 1 ? true : false);
faultDic.Add(38, UpsMgr.UpsTelemetering.Unit4InvFail.Value == 1 ? true : false);
faultDic.Add(39, UpsMgr.UpsTelemetering.Unit4RecOverTemp.Value == 1 ? true : false);
faultDic.Add(40, UpsMgr.UpsTelemetering.Unit4FanFail.Value == 1 ? true : false);
faultDic.Add(41, UpsMgr.UpsTelemetering.Unit4IvnOverLoad.Value == 1 ? true : false);
faultDic.Add(42, UpsMgr.UpsTelemetering.Unit4IvnOverLoadTimeOut.Value == 1 ? true : false);
faultDic.Add(43, UpsMgr.UpsTelemetering.Unit4IvnOverTemp.Value == 1 ? true : false);
faultDic.Add(44, UpsMgr.UpsTelemetering.Unit4IvnProtect.Value == 1 ? true : false);
faultDic.Add(45, UpsMgr.UpsTelemetering.Unit5RecFail.Value == 1 ? true : false);
faultDic.Add(46, UpsMgr.UpsTelemetering.Unit5InvFail.Value == 1 ? true : false);
faultDic.Add(47, UpsMgr.UpsTelemetering.Unit5RecOverTemp.Value == 1 ? true : false);
faultDic.Add(48, UpsMgr.UpsTelemetering.Unit5FanFail.Value == 1 ? true : false);
faultDic.Add(49, UpsMgr.UpsTelemetering.Unit5IvnOverLoad.Value == 1 ? true : false);
faultDic.Add(50, UpsMgr.UpsTelemetering.Unit5IvnOverLoadTimeOut.Value == 1 ? true : false);
faultDic.Add(51, UpsMgr.UpsTelemetering.Unit5IvnOverTemp.Value == 1 ? true : false);
faultDic.Add(52, UpsMgr.UpsTelemetering.Unit5IvnProtect.Value == 1 ? true : false);
faultDic.Add(53, UpsMgr.UpsTelemetering.Unit6RecFail.Value == 1 ? true : false);
faultDic.Add(54, UpsMgr.UpsTelemetering.Unit6InvFail.Value == 1 ? true : false);
faultDic.Add(55, UpsMgr.UpsTelemetering.Unit6RecOverTemp.Value == 1 ? true : false);
faultDic.Add(56, UpsMgr.UpsTelemetering.Unit6FanFail.Value == 1 ? true : false);
faultDic.Add(57, UpsMgr.UpsTelemetering.Unit6IvnOverLoad.Value == 1 ? true : false);
faultDic.Add(58, UpsMgr.UpsTelemetering.Unit6IvnOverLoadTimeOut.Value == 1 ? true : false);
faultDic.Add(59, UpsMgr.UpsTelemetering.Unit6IvnOverTemp.Value == 1 ? true : false);
faultDic.Add(60, UpsMgr.UpsTelemetering.Unit6IvnProtect.Value == 1 ? true : false);
faultDic.Add(61, UpsMgr.UpsTelemetering.Unit7RecFail.Value == 1 ? true : false);
faultDic.Add(62, UpsMgr.UpsTelemetering.Unit7InvFail.Value == 1 ? true : false);
faultDic.Add(63, UpsMgr.UpsTelemetering.Unit7RecOverTemp.Value == 1 ? true : false);
faultDic.Add(64, UpsMgr.UpsTelemetering.Unit7FanFail.Value == 1 ? true : false);
faultDic.Add(65, UpsMgr.UpsTelemetering.Unit7IvnOverLoad.Value == 1 ? true : false);
faultDic.Add(66, UpsMgr.UpsTelemetering.Unit7IvnOverLoadTimeOut.Value == 1 ? true : false);
faultDic.Add(67, UpsMgr.UpsTelemetering.Unit7IvnOverTemp.Value == 1 ? true : false);
faultDic.Add(68, UpsMgr.UpsTelemetering.Unit7IvnProtect.Value == 1 ? true : false);
faultDic.Add(69, UpsMgr.UpsTelemetering.Unit8RecFail.Value == 1 ? true : false);
faultDic.Add(70, UpsMgr.UpsTelemetering.Unit8InvFail.Value == 1 ? true : false);
faultDic.Add(71, UpsMgr.UpsTelemetering.Unit8RecOverTemp.Value == 1 ? true : false);
faultDic.Add(72, UpsMgr.UpsTelemetering.Unit8FanFail.Value == 1 ? true : false);
faultDic.Add(73, UpsMgr.UpsTelemetering.Unit8IvnOverLoad.Value == 1 ? true : false);
faultDic.Add(74, UpsMgr.UpsTelemetering.Unit8IvnOverLoadTimeOut.Value == 1 ? true : false);
faultDic.Add(75, UpsMgr.UpsTelemetering.Unit8IvnOverTemp.Value == 1 ? true : false);
faultDic.Add(76, UpsMgr.UpsTelemetering.Unit8IvnProtect.Value == 1 ? true : false);
faultDic.Add(77, UpsMgr.UpsTelemetering.Unit9RecFail.Value == 1 ? true : false);
faultDic.Add(78, UpsMgr.UpsTelemetering.Unit9InvFail.Value == 1 ? true : false);
faultDic.Add(79, UpsMgr.UpsTelemetering.Unit9RecOverTemp.Value == 1 ? true : false);
faultDic.Add(80, UpsMgr.UpsTelemetering.Unit9FanFail.Value == 1 ? true : false);
faultDic.Add(81, UpsMgr.UpsTelemetering.Unit9IvnOverLoad.Value == 1 ? true : false);
faultDic.Add(82, UpsMgr.UpsTelemetering.Unit9IvnOverLoadTimeOut.Value == 1 ? true : false);
faultDic.Add(83, UpsMgr.UpsTelemetering.Unit9IvnOverTemp.Value == 1 ? true : false);
faultDic.Add(84, UpsMgr.UpsTelemetering.Unit9IvnProtect.Value == 1 ? true : false);
faultDic.Add(85, UpsMgr.UpsTelemetering.Unit10RecFail.Value == 1 ? true : false);
faultDic.Add(86, UpsMgr.UpsTelemetering.Unit10InvFail.Value == 1 ? true : false);
faultDic.Add(87, UpsMgr.UpsTelemetering.Unit10RecOverTemp.Value == 1 ? true : false);
faultDic.Add(88, UpsMgr.UpsTelemetering.Unit10FanFail.Value == 1 ? true : false);
faultDic.Add(89, UpsMgr.UpsTelemetering.Unit10IvnOverLoad.Value == 1 ? true : false);
faultDic.Add(90, UpsMgr.UpsTelemetering.Unit10IvnOverLoadTimeOut.Value == 1 ? true : false);
faultDic.Add(91, UpsMgr.UpsTelemetering.Unit10IvnOverTemp.Value == 1 ? true : false);
faultDic.Add(92, UpsMgr.UpsTelemetering.Unit10IvnProtect.Value == 1 ? true : false);
FaultHandling(faultDic);
}
}
/// <summary>
/// 故障处理
/// </summary>
/// <param name="faultDic"></param>
public void FaultHandling(Dictionary<int, bool> faultDic)
{
var EquipAlarmDefineLst =
_equipAlarmDefineRepository.QueryByClauseToList(i => i.EquipTypeCode == (int)EquipmentType.Bms);
foreach (var VARIABLE in faultDic)
{
string errorCode = VARIABLE.Key.ToString();
EquipAlarmRecord equipAlarmRecordSql =
_equipAlarmRecordRepository.QueryByClause(i => i.ErrorCode == errorCode&&i.EquipTypeCode == (int)EquipmentType.Bms);
if (VARIABLE.Value) //有报警
{
if (equipAlarmRecordSql == null)//数据库中没有此报警,这里查询信息添加到数据库
{
EquipAlarmDefine equipAlarmDefine =
EquipAlarmDefineLst.SingleOrDefault(i => i.ErrorCode == VARIABLE.Key.ToString());
if (equipAlarmDefine != null)
{
EquipAlarmRecord equipAlarmRecord = new()
{
EquipTypeCode = equipAlarmDefine.EquipTypeCode,
EquipCode = equipAlarmDefine.EquipCode,
ErrorCode = errorCode,
ErrorLevel = equipAlarmDefine.ErrorLevel,
ErrorMsg = equipAlarmDefine.ErrorMsg,
ProcessMethod = equipAlarmDefine.ProcessMethod,
StartTime = DateTime.Now,
};
_equipAlarmRecordRepository.Insert(equipAlarmRecord);
}
}
}
else
{
if (equipAlarmRecordSql != null) //数据库中没有此报警,这里查询信息添加到数据库
{
EquipAlarmProcessRecord equipAlarmProcessRecord = new()
{
EquipTypeCode = equipAlarmRecordSql.EquipTypeCode,
EquipCode = equipAlarmRecordSql.EquipCode,
ErrorCode = errorCode,
ErrorLevel = equipAlarmRecordSql.ErrorLevel,
ErrorMsg = equipAlarmRecordSql.ErrorMsg,
ProcessMethod = equipAlarmRecordSql.ProcessMethod,
StartTime = equipAlarmRecordSql.StartTime,
ProcessTime = DateTime.Now,
};
_equipAlarmProcessRecordRepository.Insert(equipAlarmProcessRecord);
_equipAlarmRecordRepository.Delete(equipAlarmRecordSql);
}
}
}
}
}

@ -14,19 +14,54 @@ public class UpsTelemetering
public ModbusProperty<ushort> Epo { get; set; } = new(40085);
public ModbusProperty<ushort> InvertorReadyCapscity { get; set; } = new(40086);
public ModbusProperty<ushort> GeneratorInput { get; set; } = new(40087);
/// <summary>
/// 交流输入故障
/// </summary>
public ModbusProperty<ushort> InputFail { get; set; } = new(40088);
/// <summary>
/// 旁路相序故障
/// </summary>
public ModbusProperty<ushort> BypassSequenceFail { get; set; } = new(40089);
public ModbusProperty<ushort> BypassVoltFail { get; set; } = new(40090);
public ModbusProperty<ushort> BYpassFail { get; set; } = new(40091);
public ModbusProperty<ushort> BypassOverLoad { get; set; } = new(40092);
public ModbusProperty<ushort> BypassOverLoadTimeout { get; set; } = new(40093);
public ModbusProperty<ushort> BypassUntrack { get; set; } = new(40094);
public ModbusProperty<ushort> TxTimeLimit { get; set; } = new(40095);
public ModbusProperty<ushort> OutputShorted { get; set; } = new(40096);
public ModbusProperty<ushort> BatteryEod { get; set; } = new(40097);
public ModbusProperty<ushort> BatteryTestBegin { get; set; } = new(40098);
public ModbusProperty<ushort> BatteryTestResult { get; set; } = new(40099);
/// <summary>
/// 旁路电压故障
/// </summary>
public ModbusProperty<ushort> BypassVoltFail { get; set; } = new(40090);
/// <summary>
/// 旁路故障
/// </summary>
public ModbusProperty<ushort> BYpassFail { get; set; } = new(40091);
/// <summary>
/// 旁路过载
/// </summary>
public ModbusProperty<ushort> BypassOverLoad { get; set; } = new(40092);
/// <summary>
/// 旁路过载超时
/// </summary>
public ModbusProperty<ushort> BypassOverLoadTimeout { get; set; } = new(40093);
/// <summary>
/// 旁路超跟踪
/// </summary>
public ModbusProperty<ushort> BypassUntrack { get; set; } = new(40094);
/// <summary>
///
/// </summary>
public ModbusProperty<ushort> TxTimeLimit { get; set; } = new(40095);
/// <summary>
/// 输出短路
/// </summary>
public ModbusProperty<ushort> OutputShorted { get; set; } = new(40096);
/// <summary>
/// 电池EOD
/// </summary>
public ModbusProperty<ushort> BatteryEod { get; set; } = new(40097);
/// <summary>
///
/// </summary>
public ModbusProperty<ushort> BatteryTestBegin { get; set; } = new(40098);
/// <summary>
///
/// </summary>
public ModbusProperty<ushort> BatteryTestResult { get; set; } = new(40099);
public ModbusProperty<ushort> BatteryManualTest { get; set; } = new(40100);
public ModbusProperty<ushort> BatteryMaintainResult { get; set; } = new(40101);
@ -40,10 +75,19 @@ public class UpsTelemetering
public ModbusProperty<ushort> RecStatus { get; set; } = new(40109);
public ModbusProperty<ushort> InputNeutralLost { get; set; } = new(40110);
/// <summary>
/// 风扇故障
/// </summary>
public ModbusProperty<ushort> BypassFanFail { get; set; } = new(40111);
public ModbusProperty<ushort> LostNxRedundant { get; set; } = new(40112);
public ModbusProperty<ushort> EodSystemInhibited { get; set; } = new(40113);
/// <summary>
/// CT焊反
/// </summary>
public ModbusProperty<ushort> CtWeldReserve { get; set; } = new(40114);
/// <summary>
/// 电解液漏液
/// </summary>
public ModbusProperty<ushort> Elector { get; set; } = new(40115);
public ModbusProperty<ushort> Reserve116 { get; set; } = new(40116);
public ModbusProperty<ushort> Reserve117 { get; set; } = new(40117);
@ -52,14 +96,38 @@ public class UpsTelemetering
public ModbusProperty<ushort> SecondModuleOnlineFlagBit { get; set; } = new(40120);
public ModbusProperty<ushort> Unit1Pull { get; set; } = new(40121);
public ModbusProperty<ushort> Unit1RecFail { get; set; } = new(40122);
public ModbusProperty<ushort> Unit1Pull { get; set; } = new(40121);
/// <summary>
/// 模块1整流故障
/// </summary>
public ModbusProperty<ushort> Unit1RecFail { get; set; } = new(40122);
/// <summary>
/// 模块1逆变故障
/// </summary>
public ModbusProperty<ushort> Unit1InvFail { get; set; } = new(40123);
/// <summary>
/// 模块1整流过温
/// </summary>
public ModbusProperty<ushort> Unit1RecOverTemp { get; set; } = new(40124);
/// <summary>
/// 模块1风扇故障
/// </summary>
public ModbusProperty<ushort> Unit1FanFail { get; set; } = new(40125);
public ModbusProperty<ushort> Unit1IvnOverLoad { get; set; } = new(40126);
public ModbusProperty<ushort> Unit1IvnOverLoadTimeOut { get; set; } = new(40127);
/// <summary>
/// 模块1逆变过载
/// </summary>
public ModbusProperty<ushort> Unit1IvnOverLoad { get; set; } = new(40126);
/// <summary>
/// 模块1逆变过载超时
/// </summary>
public ModbusProperty<ushort> Unit1IvnOverLoadTimeOut { get; set; } = new(40127);
/// <summary>
/// 模块1逆变过温
/// </summary>
public ModbusProperty<ushort> Unit1IvnOverTemp { get; set; } = new(40128);
/// <summary>
/// 模块1逆变保护
/// </summary>
public ModbusProperty<ushort> Unit1IvnProtect { get; set; } = new(40129);
public ModbusProperty<ushort> Unit1ManualShutdown { get; set; } = new(40130);
public ModbusProperty<ushort> Reserve131 { get; set; } = new(40131);

Loading…
Cancel
Save