Commit 3754da26 authored by 潘栩锋's avatar 潘栩锋 🚴

增加 OBJComponents/Server/ErrorConf.cs 添加全部报警属性设为false; 解决当控制PLC复位后,报警可能不会消失。…

增加 OBJComponents/Server/ErrorConf.cs 添加全部报警属性设为false; 解决当控制PLC复位后,报警可能不会消失。 通过强制设置为 false,下次周期读PLC就能触发 PropertyChanged
parent efea37de
...@@ -46,7 +46,6 @@ namespace FLY.OBJComponents.Server ...@@ -46,7 +46,6 @@ namespace FLY.OBJComponents.Server
public string property; public string property;
public byte code; public byte code;
public string msg; public string msg;
public bool offIsError;
} }
Dictionary<INotifyPropertyChanged, ErrorAction> obj_error = new Dictionary<INotifyPropertyChanged, ErrorAction>(); Dictionary<INotifyPropertyChanged, ErrorAction> obj_error = new Dictionary<INotifyPropertyChanged, ErrorAction>();
...@@ -60,14 +59,12 @@ namespace FLY.OBJComponents.Server ...@@ -60,14 +59,12 @@ namespace FLY.OBJComponents.Server
{ {
//肯定有,没有就让它出错!!! //肯定有,没有就让它出错!!!
string desp = (propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), false).First() as DescriptionAttribute).Description; string desp = (propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), false).First() as DescriptionAttribute).Description;
//bool offIsError = (propertyInfo.GetCustomAttributes(typeof(IsErrorAttribute), false).First() as IsErrorAttribute).OffIsError; //报警如果是反向, 会被设置为放大=-1, 所以 最后属性 肯定是 true 时报警, offIsError没有用
ErrorInfo errorInfo = new ErrorInfo() ErrorInfo errorInfo = new ErrorInfo()
{ {
property = propertyInfo.Name, property = propertyInfo.Name,
msg = desp, msg = desp,
//offIsError = offIsError,
code = ErrCode code = ErrCode
}; };
error_property.Add(errorInfo); error_property.Add(errorInfo);
...@@ -105,7 +102,7 @@ namespace FLY.OBJComponents.Server ...@@ -105,7 +102,7 @@ namespace FLY.OBJComponents.Server
FObjBase.PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD, FObjBase.PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD,
() => () =>
{ {
Misc.BindingOperations.SetBinding(PLCos, "IsConnectedWithPLC", () => Misc.BindingOperations.SetBinding(PLCos, nameof(PLCos.IsConnectedWithPLC), () =>
{ {
bool b = !PLCos.IsConnectedWithPLC; bool b = !PLCos.IsConnectedWithPLC;
...@@ -119,23 +116,51 @@ namespace FLY.OBJComponents.Server ...@@ -119,23 +116,51 @@ namespace FLY.OBJComponents.Server
}, TimeSpan.FromSeconds(3), true, false, this, MARKNO_DELAY_ISCONNECTED, true); }, TimeSpan.FromSeconds(3), true, false, this, MARKNO_DELAY_ISCONNECTED, true);
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
//把全部报警状态取反,也就是不报警!!! //启动定时器,每1秒查报警,防止 以为报警复位了,但其实还在报警
foreach (var kv in obj_error)
//FObjBase.PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD,
// () =>
// {
// foreach(var objError in obj_error)
// {
// object sender = objError.Key;
// ErrorAction errorAction = objError.Value;
// foreach (var ei in errorAction.error_property)
// {
// //获取描述
// 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;
// byte errcode = ei.code;//每个报警必须不一样!!
// string description = desp;
// errorAction.action?.Invoke(ref description, errorAction.state);
// mWarning.Add(errcode, description, state);
// }
// }
// }, TimeSpan.FromSeconds(1));
}
public void ResetError(INotifyPropertyChanged sender)
{
var type = sender.GetType();
foreach (var ei in obj_error[sender as INotifyPropertyChanged].error_property)
{ {
object sender = kv.Key; var property = type.GetProperty(ei.property);
foreach (var ei in kv.Value.error_property) property.SetValue(sender, false);
{ }
if (ei.offIsError) }
{ public void ResetError()
Misc.PropertiesManager.SetValue(sender, ei.property, true); {
} foreach (var sender in obj_error.Keys) {
//false 不用写,默认值就是 ResetError(sender);
}
} }
} }
void Obj_PropertyChanged_ForError(object sender, PropertyChangedEventArgs e) void Obj_PropertyChanged_ForError(object sender, PropertyChangedEventArgs e)
{ {
ErrorAction errorAction = obj_error[sender as INotifyPropertyChanged]; ErrorAction errorAction = obj_error[sender as INotifyPropertyChanged];
...@@ -150,13 +175,8 @@ namespace FLY.OBJComponents.Server ...@@ -150,13 +175,8 @@ namespace FLY.OBJComponents.Server
var property = type.GetProperty(ei.property); var property = type.GetProperty(ei.property);
bool b = (bool)property.GetValue(sender, null); bool b = (bool)property.GetValue(sender, null);
string desp = ei.msg; string desp = ei.msg;
bool offIsError = ei.offIsError;
ERR_STATE state; ERR_STATE state = b ? ERR_STATE.ON : ERR_STATE.OFF;
if (offIsError)
state = !b ? ERR_STATE.ON : ERR_STATE.OFF;
else
state = b ? ERR_STATE.ON : ERR_STATE.OFF;
byte errcode = ei.code;//每个报警必须不一样!! byte errcode = ei.code;//每个报警必须不一样!!
string description = desp; string description = desp;
......
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