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
public string property;
public byte code;
public string msg;
public bool offIsError;
}
Dictionary<INotifyPropertyChanged, ErrorAction> obj_error = new Dictionary<INotifyPropertyChanged, ErrorAction>();
......@@ -60,14 +59,12 @@ namespace FLY.OBJComponents.Server
{
//肯定有,没有就让它出错!!!
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()
{
property = propertyInfo.Name,
msg = desp,
//offIsError = offIsError,
code = ErrCode
};
error_property.Add(errorInfo);
......@@ -105,7 +102,7 @@ namespace FLY.OBJComponents.Server
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;
......@@ -119,23 +116,51 @@ namespace FLY.OBJComponents.Server
}, TimeSpan.FromSeconds(3), true, false, this, MARKNO_DELAY_ISCONNECTED, true);
//--------------------------------------------------------------------------------
//把全部报警状态取反,也就是不报警!!!
foreach (var kv in obj_error)
{
object sender = kv.Key;
foreach (var ei in kv.Value.error_property)
//启动定时器,每1秒查报警,防止 以为报警复位了,但其实还在报警
//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)
{
if (ei.offIsError)
var type = sender.GetType();
foreach (var ei in obj_error[sender as INotifyPropertyChanged].error_property)
{
Misc.PropertiesManager.SetValue(sender, ei.property, true);
var property = type.GetProperty(ei.property);
property.SetValue(sender, false);
}
//false 不用写,默认值就是
}
public void ResetError()
{
foreach (var sender in obj_error.Keys) {
ResetError(sender);
}
}
void Obj_PropertyChanged_ForError(object sender, PropertyChangedEventArgs e)
{
ErrorAction errorAction = obj_error[sender as INotifyPropertyChanged];
......@@ -150,13 +175,8 @@ namespace FLY.OBJComponents.Server
var property = type.GetProperty(ei.property);
bool b = (bool)property.GetValue(sender, null);
string desp = ei.msg;
bool offIsError = ei.offIsError;
ERR_STATE state;
if (offIsError)
state = !b ? ERR_STATE.ON : ERR_STATE.OFF;
else
state = b ? ERR_STATE.ON : ERR_STATE.OFF;
ERR_STATE state = b ? ERR_STATE.ON : ERR_STATE.OFF;
byte errcode = ei.code;//每个报警必须不一样!!
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