Commit 21c5a6f2 authored by 潘栩锋's avatar 潘栩锋 🚴

添加 ErrorConf 报警时显示的 PLC名称 可以自定义。

parent 9fa1a097
......@@ -16,7 +16,8 @@ namespace FLY.OBJComponents.Server
#region 延时推送 MARKNO
const int MARKNO_DELAY_ISCONNECTED = 4;
#endregion
string plcName;
List<string> plcNames;
/// <summary>
/// 需要设置
/// </summary>
......@@ -30,9 +31,17 @@ namespace FLY.OBJComponents.Server
{
this.PLCos = PLCos;
this.mWarning = mWarning;
this.plcName = plcName;
plcNames = new List<string>();
plcNames.Add(plcName);
}
public ErrorConf(PLCProxySystem PLCos, WarningSystem2 mWarning, string[] plcNames)
{
this.PLCos = PLCos;
this.mWarning = mWarning;
this.plcNames = new List<string>();
if (plcNames.All(s => !string.IsNullOrEmpty(s)))
this.plcNames.AddRange(plcNames);
}
#region 报警
public class ErrorAction
{
......@@ -109,11 +118,7 @@ namespace FLY.OBJComponents.Server
ERRNO errno = PlcErrNos.Instance.ERRNO_PLC_DISCONNECTED;
UInt16 errcode = (UInt16)(errno.Code - i);
string description;
if (PLCos.PLCs.Count() > 1)
description = $"{plcName} No.{i+1} " + errno.Descrption;
else
description = $"{plcName} " + errno.Descrption;
string description = $"{GetPlcName(i)} " + errno.Descrption;
mWarning.Add(errcode, description, state);
}
......@@ -150,7 +155,22 @@ namespace FLY.OBJComponents.Server
// }
// }, TimeSpan.FromSeconds(1));
}
string GetPlcName(int index)
{
if (PLCos.PLCs.Count() == 1)
{
return plcNames[0];
}
//多个PLC
if (PLCos.PLCs.Count() != plcNames.Count())
{
//没有定义全部名字
return $"{plcNames[0]} No.{index + 1}";
}
return plcNames[index];
}
public void ResetError(INotifyPropertyChanged sender)
{
var type = sender.GetType();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment