添加电池故障报警处理

master
CZ 4 months ago
parent 83fcbdc630
commit 4ad5cc8d27

@ -10,4 +10,16 @@ public class EquipAlarmDefineRepository : BaseRepository<EquipAlarmDefine>
public EquipAlarmDefineRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) public EquipAlarmDefineRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{ {
} }
/// <summary>
///
/// </summary>
/// <param name="equipTypeCode">0-充电机;1-电表2-水冷3-plc</param>
/// <param name="equipCode"></param>
/// <param name="errorCode"></param>
/// <returns></returns>
public EquipAlarmDefine? SelectByEquipCodeAndErrorCode(int equipTypeCode, string equipCode)
{
return this.QueryByClause(it => it.EquipTypeCode == equipTypeCode &&
it.EquipCode == equipCode);
}
} }

@ -22,7 +22,239 @@ namespace Service.Charger.Handler
if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client)) if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client))
{ {
Log.Info($"receive {msg} from {sn}"); Log.Info($"receive {msg} from {sn}");
#region 故障处理
string bms = "bms";
List<string> lstAlarm = new List<string>();
if (msg.SingleBattery == 1)
{
lstAlarm.Add(bms + sn + "100");
}
else if (msg.SingleBattery == 2)
{
lstAlarm.Add(bms + sn + "101");
}
if (msg.VoltageOvershoot == 2)
{
lstAlarm.Add(bms + sn + "102");
}
if (msg.TemperatureExceedance == 1)
{
lstAlarm.Add(bms + sn + "103");
}
else if (msg.TemperatureExceedance == 2)
{
lstAlarm.Add(bms + sn + "104");
}
if (msg.TemperatureDifference == 2)
{
lstAlarm.Add(bms + sn + "105");
}
if (msg.LowSOC == 1)
{
lstAlarm.Add(bms + sn + "106");
}
if (msg.DischargeCurrent == 2)
{
lstAlarm.Add(bms + sn + "107");
}
if (msg.ChargingCurrentLimit == 1)
{
lstAlarm.Add(bms + sn + "108");
}
else if (msg.ChargingCurrentLimit == 2)
{
lstAlarm.Add(bms + sn + "109");
}
if (msg.TotalTemp == 2)
{
lstAlarm.Add(bms + sn + "110");
}
if (msg.HighVoltageLow == 2)
{
lstAlarm.Add(bms + sn + "111");
}
if (msg.MonomerLimit == 1)
{
lstAlarm.Add(bms + sn + "112");
}
else if (msg.MonomerLimit == 1)
{
lstAlarm.Add(bms + sn + "113");
}
if (msg.VoltageDifference == 2)
{
lstAlarm.Add(bms + sn + "114");
}
if (msg.TemperatureOvershoot == 1)
{
lstAlarm.Add(bms + sn + "115");
}
else if (msg.TemperatureOvershoot == 2)
{
lstAlarm.Add(bms + sn + "116");
}
if (msg.TempDifference == 2)
{
lstAlarm.Add(bms + sn + "117");
}
if (msg.VeryLowSoc == 1)
{
lstAlarm.Add(bms + sn + "118");
}
if (msg.DischargeCurrentLimit == 2)
{
lstAlarm.Add(bms + sn + "119");
}
if (msg.ChargingCurrent == 2)
{
lstAlarm.Add(bms + sn + "120");
}
if (msg.TotalTempLimit == 2)
{
lstAlarm.Add(bms + sn + "121");
}
if (msg.HighVoltageInsulation == 1)
{
lstAlarm.Add(bms + sn + "122");
}
if (msg.HardwareFailure == 1)
{
lstAlarm.Add(bms + sn + "123");
}
if (msg.BatteryFaultCode != 0)
{
lstAlarm.Add(bms + sn + msg.BatteryFaultCode.ToString());
}
SaveAlarmInfo(lstAlarm);
#endregion
}
}
#region 故障处理方法
private void SaveAlarmInfo(List<string> lstAlarm)
{
string bms = "bms";
if (lstAlarm.Count > 0)
{
#region 有报警比较两边差异,新出现的报警就添加,消失的报警就处理并记录
var lstEquipAlarmRecord = EquipAlarmRecordRepository.QueryListByClause(i => i.EquipTypeCode == (int)EquipmentType.BMS);
var sqllstAlarm = lstEquipAlarmRecord.Select(obj => obj.ErrorCode).ToList();
// 找出实时报警中存在但数据库中不存在的元素
List<string> uniqueToList1 = lstAlarm.Except(sqllstAlarm).ToList();
// 找出数据库中存在但实时报警中不存在的元素
List<string> uniqueToList2 = sqllstAlarm.Except(lstAlarm).ToList();
if (uniqueToList1.Count > 0)
{
//这里要添加新的报警数据
foreach (var errorCode in uniqueToList1)
{
EquipAlarmDefine? alarmDefine =
EquipAlarmDefineRepository.SelectByEquipCodeAndErrorCode((int)EquipmentType.BMS, bms);
if (alarmDefine != null)
{
EquipAlarmRecord record = new EquipAlarmRecord()
{
EquipTypeCode = alarmDefine.EquipTypeCode,
EquipCode = alarmDefine.EquipCode,
ErrorCode = alarmDefine.ErrorCode,
ErrorLevel = alarmDefine.ErrorLevel,
ErrorMsg = alarmDefine.ErrorMsg,
ProcessMethod = alarmDefine.ProcessMethod,
StartTime = DateTime.Now
};
EquipAlarmRecordRepository.Insert(record);
}
}
}
if (uniqueToList2.Count > 0)
{
//这些是要清除实时报警,并且处理记录的。
// 使用LINQ找出ErrorCode在uniqueToList2中的EquipAlarmRecord对象
List<EquipAlarmRecord> filteredObjectList = lstEquipAlarmRecord
.Where(obj => uniqueToList2.Contains(obj.ErrorCode))
.ToList();
foreach (var VARIABLE in filteredObjectList)
{
EquipAlarmProcessRecord EquipAlarmProcessRecord = new EquipAlarmProcessRecord();
EquipAlarmProcessRecord.EquipTypeCode = VARIABLE.EquipTypeCode;
EquipAlarmProcessRecord.EquipCode = VARIABLE.EquipCode;
EquipAlarmProcessRecord.ErrorCode = VARIABLE.ErrorCode;
EquipAlarmProcessRecord.ErrorLevel = VARIABLE.ErrorLevel;
EquipAlarmProcessRecord.ErrorMsg = VARIABLE.ErrorMsg;
EquipAlarmProcessRecord.ProcessMethod = VARIABLE.ProcessMethod;
EquipAlarmProcessRecord.StartTime = VARIABLE.StartTime;
EquipAlarmProcessRecord.ProcessTime = DateTime.Now;
EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord);
}
EquipAlarmRecordRepository.Delete(filteredObjectList);
}
#endregion
}
else
{
#region 没报警把已处理记录更新并删除实时报警
var lstEquipAlarmRecord = EquipAlarmRecordRepository.QueryListByClause(i => i.EquipTypeCode == (int)EquipmentType.BMS);
if (lstEquipAlarmRecord.Count > 0)
{
foreach (var VARIABLE in lstEquipAlarmRecord)
{
EquipAlarmProcessRecord EquipAlarmProcessRecord = new EquipAlarmProcessRecord();
EquipAlarmProcessRecord.EquipTypeCode = VARIABLE.EquipTypeCode;
EquipAlarmProcessRecord.EquipCode = VARIABLE.EquipCode;
EquipAlarmProcessRecord.ErrorCode = VARIABLE.ErrorCode;
EquipAlarmProcessRecord.ErrorLevel = VARIABLE.ErrorLevel;
EquipAlarmProcessRecord.ErrorMsg = VARIABLE.ErrorMsg;
EquipAlarmProcessRecord.ProcessMethod = VARIABLE.ProcessMethod;
EquipAlarmProcessRecord.StartTime = VARIABLE.StartTime;
EquipAlarmProcessRecord.ProcessTime = DateTime.Now;
EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord);
}
}
EquipAlarmRecordRepository.Delete(lstEquipAlarmRecord);
#endregion
} }
} }
#endregion
} }
} }

@ -171,29 +171,6 @@ namespace Service.Charger.Handler
EquipAlarmRecordRepository.Delete(filteredObjectList); EquipAlarmRecordRepository.Delete(filteredObjectList);
} }
} }
//else
//{
/*var lstNowEquipAlarmRecord = EquipAlarmRecordRepository.QueryListByClause(i => i.EquipCode == sn);
if (lstNowEquipAlarmRecord.Count > 0)
{
foreach (var VARIABLE in lstNowEquipAlarmRecord)
{
EquipAlarmProcessRecord EquipAlarmProcessRecord = new EquipAlarmProcessRecord();
EquipAlarmProcessRecord.EquipTypeCode = VARIABLE.EquipTypeCode;
EquipAlarmProcessRecord.EquipCode = VARIABLE.EquipCode;
EquipAlarmProcessRecord.ErrorCode = VARIABLE.ErrorCode;
EquipAlarmProcessRecord.ErrorLevel = VARIABLE.ErrorLevel;
EquipAlarmProcessRecord.ErrorMsg = VARIABLE.ErrorMsg;
EquipAlarmProcessRecord.ProcessMethod = VARIABLE.ProcessMethod;
EquipAlarmProcessRecord.StartTime = VARIABLE.StartTime;
EquipAlarmProcessRecord.ProcessTime=DateTime.Now;
EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord);
}
}
EquipAlarmRecordRepository.Delete(i=>i.Id>0);*/
//}
#endregion #endregion
} }
} }

@ -29,107 +29,181 @@ namespace Service.Charger.Msg.Charger.Resp
/// <summary> /// <summary>
/// 单体蓄电池或蓄电池模块电压越限 /// 单体蓄电池或蓄电池模块电压越限
/// </summary> /// </summary>
[Property(32, 16)] [Property(32, 2)]
public short SingleBattery { get; set; } public byte SingleBattery { get; set; }
/// <summary> /// <summary>
/// 电压偏差越限 /// 电压偏差越限
/// </summary> /// </summary>
[Property(48, 16)] [Property(34, 2)]
public short VoltageOvershoot { get; set; } public byte VoltageOvershoot { get; set; }
/// <summary> /// <summary>
/// 温度越限 /// 温度越限
/// </summary> /// </summary>
[Property(64, 16)] [Property(36, 2)]
public short TemperatureExceedance { get; set; } public byte TemperatureExceedance { get; set; }
/// <summary> /// <summary>
/// 温度偏差越限 /// 温度偏差越限
/// </summary> /// </summary>
[Property(80, 16)] [Property(38, 2)]
public short TemperatureDifference { get; set; } public byte TemperatureDifference { get; set; }
/// <summary> /// <summary>
/// SOC 低 /// SOC 低
/// </summary> /// </summary>
[Property(96, 16)] [Property(40, 2)]
public short LowSOC { get; set; } public byte LowSOC { get; set; }
/// <summary> /// <summary>
/// 放电电流越限 /// 放电电流越限
/// </summary> /// </summary>
[Property(112, 16)] [Property(42, 2)]
public short DischargeCurrent { get; set; } public byte DischargeCurrent { get; set; }
/// <summary> /// <summary>
/// 充电电流限 /// 充电电流限
/// </summary> /// </summary>
[Property(128, 16)] [Property(44, 2)]
public short ChargingCurrentLimit { get; set; } public byte ChargingCurrentLimit { get; set; }
/// <summary> /// <summary>
/// 总正负极柱温度越限 /// 总正负极柱温度越限
/// </summary> /// </summary>
[Property(144, 16)] [Property(46, 2)]
public short TotalTemp { get; set; } public byte TotalTemp { get; set; }
/// <summary> /// <summary>
/// 电池系统故障码 /// 电池系统故障码
///
/// 0x1011 单体温度过高一级
/// 0x1012 单体温度过高二级
/// 0x1013 单体温度过高三级
/// 0x1021 单体温度过低一级
/// 0x1022 单体温度过低二级
/// 0x1023 单体温度过低三级
/// 0x1031 单体过压一级
/// 0x1032 单体过压二级
/// 0x1033 单体过压三级
/// 0x1041 单体欠压一级
/// 0x1042 单体欠压二级
/// 0x1043 单体欠压三级
/// 0x10A1 电池包总压过高一级
/// 0x10A2 电池包总压过高二级
/// 0x10A3 电池包总压过高三级
/// 0x10B1 电池包总压过低一级
/// 0x10B2 电池包总压过低二级
/// 0x10B3 电池包总压过低三级
/// 0x1061 放电过流一级
/// 0x1062 放电过流二级
/// 0x1063 放电过流三级
/// 0x1091 充电过流一级
/// 0x1092 充电过流二级
/// 0x1093 充电过流三级
/// 0x10E1 单体压差过大一级
/// 0x10E2 单体压差过大二级
/// 0x10E3 单体压差过大三级
/// 0x10D1 单体温差过大一级
/// 0x10D2 单体温差过大二级
/// 0x10D3 单体温差过大三级
/// 0x10C1 绝缘过低一级
/// 0x10C2 绝缘过低二级
/// 0x10C3 绝缘过低三级
/// 0x10F1 SOC 过低一级
/// 0x10F2 SOC 过低二级
/// 0x10F3 SOC 过低三级
/// 0x1111 供电电压过低一级
/// 0x1112 供电电压过低二级
/// 0x1113 供电电压过低三级
/// 0x1121 供电电压过高一级
/// 0x1122 供电电压过高二级
/// 0x1123 供电电压过高三级
/// 0x1141 电池温升过快一级
/// 0x1142 电池温升过快二级
/// 0x1143 电池温升过快三级
/// 0x1103 Pack 回路断开
/// 0x2013 从板通讯丢失
/// 0x2033 充电机丢失
/// 0x2043 绝缘仪通讯丢失
/// 0x2053 电流传感器通讯丢失
/// 0x2073 热管理机组通讯丢失
/// 0x20E3 电流传感器采样异常
/// 0x20D3 绝缘采样异常
/// 0x4013 主正继电器开路故障
/// 0x4023 主负继电器开路故障
/// 0x40F2 主正继电器粘连故障
/// 0x4102 主负继电器粘连故障
/// 0x5013 外部短路故障
/// 0x5032 高压互锁故障
/// 0x5053 CC2 电压异常
/// 0x5153 充电枪连接故障
/// 0x6033 充电系统不匹配故障
/// 0x6023 充电电流异常
/// 0x7022 均衡故障
/// 0x8023 火灾报警
/// 0x8013 自保护故障
/// 0x8033 电池过放
/// 0x8043 电池过充
/// 0x5123 预充故障
/// 0x90B3 电池电压采样线开路
/// 0x90C3 电池温度采样线开路
/// 0x90E3 电池电压采样异常
/// 0x90F3 电池温度采样异常
/// </summary> /// </summary>
[Property(160, 16)] [Property(48, 16)]
public short BatteryFaultCode { get; set; } public short BatteryFaultCode { get; set; }
/// <summary> /// <summary>
/// 高压绝缘低 /// 高压绝缘低
/// </summary> /// </summary>
[Property(176, 16)] [Property(64, 2)]
public short HighVoltageLow { get; set; } public byte HighVoltageLow { get; set; }
/// <summary> /// <summary>
/// 单体蓄电池或蓄电池模块电压越极限 /// 单体蓄电池或蓄电池模块电压越极限
/// </summary> /// </summary>
[Property(192, 16)] [Property(66, 2)]
public short MonomerLimit { get; set; } public byte MonomerLimit { get; set; }
/// <summary> /// <summary>
/// 电压偏差越极限a /// 电压偏差越极限
/// </summary> /// </summary>
[Property(200, 16)] [Property(68, 2)]
public short VoltageDifference { get; set; } public byte VoltageDifference { get; set; }
/// <summary> /// <summary>
/// 温度越极限 /// 温度越极限
/// </summary> /// </summary>
[Property(216, 16)] [Property(70, 2)]
public short TemperatureOvershoot { get; set; } public byte TemperatureOvershoot { get; set; }
/// <summary> /// <summary>
/// 温度偏差越极限 /// 温度偏差越极限
/// </summary> /// </summary>
[Property(232, 16)] [Property(72, 2)]
public short TempDifference { get; set; } public byte TempDifference { get; set; }
/// <summary> /// <summary>
/// SOC 极低 /// SOC 极低
/// </summary> /// </summary>
[Property(248, 16)] [Property(74, 2)]
public short VeryLowSOC { get; set; } public byte VeryLowSoc { get; set; }
/// <summary> /// <summary>
/// 放电电流越极限 /// 放电电流越极限
/// </summary> /// </summary>
[Property(264, 16)] [Property(76, 2)]
public short DischargeCurrentLimit { get; set; } public byte DischargeCurrentLimit { get; set; }
/// <summary> /// <summary>
/// 充电电流越极限 /// 充电电流越极限
/// </summary> /// </summary>
[Property(280, 16)] [Property(78, 2)]
public short ChargingCurrent { get; set; } public byte ChargingCurrent { get; set; }
/// <summary> /// <summary>
/// 总正负极柱温度越极限 /// 总正负极柱温度越极限
/// </summary> /// </summary>
[Property(296, 16)] [Property(80, 2)]
public short TotalTempLimit { get; set; } public byte TotalTempLimit { get; set; }
/// <summary> /// <summary>
/// 高压绝缘极低 /// 高压绝缘极低
/// </summary> /// </summary>
[Property(312, 16)] [Property(82, 2)]
public short highVoltageInsulation { get; set; } public byte HighVoltageInsulation { get; set; }
/// <summary> /// <summary>
/// 硬件故障 /// 硬件故障
/// </summary> /// </summary>
[Property(328, 16)] [Property(84, 2)]
public short HardwareFailure { get; set; } public byte HardwareFailure { get; set; }
/// <summary> /// <summary>
/// 保留 /// 保留
/// </summary> /// </summary>
[Property(344, 16)] [Property(86, 2)]
public short Reserve { get; set; } public byte Reserve { get; set; }
} }
} }

Loading…
Cancel
Save