Commit 854d1a38 authored by 潘栩锋's avatar 潘栩锋 🚴

添加 WarningSystem2 报警模块 添加不能复位的报警内容, 它只能服务器主动调用 Remove 删除报警。 客户端按 Reset()…

添加 WarningSystem2 报警模块 添加不能复位的报警内容, 它只能服务器主动调用 Remove 删除报警。  客户端按 Reset() 不会令它消失。 解决了PLC报警内容被复位,只能通过轮询报警寄存器不断触发。
parent 1352f2db
......@@ -34,6 +34,13 @@ namespace FLY.OBJComponents.Common
/// 附加信息, json格式
/// </summary>
public string Accessory { get; set; }
/// <summary>
/// 可以被复位
/// </summary>
public bool CanReset { get; set; } = true;
public FlyData_WarningHistory Clone()
{
return new FlyData_WarningHistory()
......
......@@ -107,7 +107,7 @@ namespace FLY.OBJComponents.Server
}
//--------------------------------------------------------------------------------
//连接断开事件, 3秒查一次,不能有复位的机会
//连接断开事件, 3秒后再查一次,不能有复位的机会
FObjBase.PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD,
() =>
{
......@@ -131,11 +131,11 @@ namespace FLY.OBJComponents.Server
//FObjBase.PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD,
// () =>
// {
// foreach(var objError in obj_error)
// foreach (var objError in obj_error)
// {
// object sender = objError.Key;
// ErrorAction errorAction = objError.Value;
// foreach (var ei in errorAction.error_property)
// foreach (var ei in errorAction.error_property)
// {
// //获取描述
// var type = sender.GetType();
......@@ -153,7 +153,7 @@ namespace FLY.OBJComponents.Server
// mWarning.Add(errcode, description, state);
// }
// }
// }, TimeSpan.FromSeconds(1));
// }, TimeSpan.FromSeconds(3));
}
string GetPlcName(int index)
{
......@@ -168,7 +168,7 @@ namespace FLY.OBJComponents.Server
//没有定义全部名字
return $"{plcNames[0]} No.{index + 1}";
}
return plcNames[index];
}
public void ResetError(INotifyPropertyChanged sender)
......@@ -199,16 +199,19 @@ namespace FLY.OBJComponents.Server
var type = sender.GetType();
var property = type.GetProperty(ei.property);
bool b = (bool)property.GetValue(sender, null);
string desp = ei.msg;
ERR_STATE state = b ? ERR_STATE.ON : ERR_STATE.OFF;
string description = ei.msg;
byte errcode = ei.code;//每个报警必须不一样!!
string description = desp;
errorAction.action?.Invoke(ref description, errorAction.state);
mWarning.Add(errcode, description, state);
if (b)
{
//修改报警文字内容
errorAction.action?.Invoke(ref description, errorAction.state);
//报警, 不能被复位的!!!
mWarning.Add(errcode, description, canReset: false);
}
else {
mWarning.Remove(errcode);
}
}
}
#endregion
......
......@@ -62,8 +62,9 @@ namespace FLY.OBJComponents.Server
public void Reset()
{
errors.Clear();
updateReasonList();
if (errors.RemoveAll(e => e.CanReset == true) > 0) {
updateReasonList();
}
}
public void Silence()
......@@ -72,29 +73,15 @@ namespace FLY.OBJComponents.Server
}
#region IWarningServiceSimple
public void Add(int errcode, string description)
{
Add(errcode, description, ERR_STATE.ON);
}
public void Add(int errcode, string description, string accessory)
{
Add(errcode, description, ERR_STATE.ON, accessory, false);
}
public void Add(int errcode, string description, ERR_STATE state)
{
Add(errcode, description, state, "", false );
}
public void Update(int errcode, string description)
{
Update(errcode, description, "");
}
public void Update(int errcode, string description, string accessory)
public void Update(int errcode, string description, string accessory="", bool canReset=true)
{
Add(errcode, description, ERR_STATE.ON, accessory, true);
Add(errcode, description,
accessory:accessory,
isUpdate:true,
canReset:canReset);
}
......@@ -106,7 +93,8 @@ namespace FLY.OBJComponents.Server
/// <param name="state">状态,ON or OFF</param>
/// <param name="accessory">附加信息</param>
/// <param name="isUpdate">就算已经存在,也有刷新</param>
public void Add(int errcode, string description, ERR_STATE state, string accessory, bool isUpdate)
/// <param name="canReset">可以被Reset()清除</param>
public void Add(int errcode, string description, ERR_STATE state = ERR_STATE.ON, string accessory = "", bool isUpdate=false, bool canReset=true)
{
if (!Enable)
return;
......@@ -144,7 +132,8 @@ namespace FLY.OBJComponents.Server
ErrCode = errcode,
Description = description,
State = state,
Accessory = accessory
Accessory = accessory,
CanReset = canReset
};
errors.Add(error);
updateReasonList();
......
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