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

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

parent 9fa1a097
...@@ -16,7 +16,8 @@ namespace FLY.OBJComponents.Server ...@@ -16,7 +16,8 @@ namespace FLY.OBJComponents.Server
#region 延时推送 MARKNO #region 延时推送 MARKNO
const int MARKNO_DELAY_ISCONNECTED = 4; const int MARKNO_DELAY_ISCONNECTED = 4;
#endregion #endregion
string plcName;
List<string> plcNames;
/// <summary> /// <summary>
/// 需要设置 /// 需要设置
/// </summary> /// </summary>
...@@ -30,9 +31,17 @@ namespace FLY.OBJComponents.Server ...@@ -30,9 +31,17 @@ namespace FLY.OBJComponents.Server
{ {
this.PLCos = PLCos; this.PLCos = PLCos;
this.mWarning = mWarning; 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 报警 #region 报警
public class ErrorAction public class ErrorAction
{ {
...@@ -109,11 +118,7 @@ namespace FLY.OBJComponents.Server ...@@ -109,11 +118,7 @@ namespace FLY.OBJComponents.Server
ERRNO errno = PlcErrNos.Instance.ERRNO_PLC_DISCONNECTED; ERRNO errno = PlcErrNos.Instance.ERRNO_PLC_DISCONNECTED;
UInt16 errcode = (UInt16)(errno.Code - i); UInt16 errcode = (UInt16)(errno.Code - i);
string description; string description = $"{GetPlcName(i)} " + errno.Descrption;
if (PLCos.PLCs.Count() > 1)
description = $"{plcName} No.{i+1} " + errno.Descrption;
else
description = $"{plcName} " + errno.Descrption;
mWarning.Add(errcode, description, state); mWarning.Add(errcode, description, state);
} }
...@@ -150,7 +155,22 @@ namespace FLY.OBJComponents.Server ...@@ -150,7 +155,22 @@ namespace FLY.OBJComponents.Server
// } // }
// }, TimeSpan.FromSeconds(1)); // }, 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) public void ResetError(INotifyPropertyChanged sender)
{ {
var type = sender.GetType(); 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