Commit 3afe9982 authored by 潘栩锋's avatar 潘栩锋 🚴

waringsystem写错了

parent 9606ae0e
...@@ -41,24 +41,31 @@ namespace FLY.OBJComponents.Server ...@@ -41,24 +41,31 @@ namespace FLY.OBJComponents.Server
ReasonList = new Buffer<FlyData_WarningHistory>(); ReasonList = new Buffer<FlyData_WarningHistory>();
NewestList = new BufferStorage<FlyData_WarningHistory>("warning_newest.csv"); NewestList = new BufferStorage<FlyData_WarningHistory>("warning_newest.csv");
} }
/// <summary>
/// 报警复位!!!!
/// </summary>
public Action ResetEvent; public Action ResetEvent;
public void Reset() public void Reset()
{ {
ReasonList.Reset();
ResetEvent?.Invoke(); ResetEvent?.Invoke();
} }
/// <summary>
/// 正在报警!!!
/// </summary>
public Action RingEvent;
#region IWarningServiceSimple #region IWarningServiceSimple
public void Add(byte errcode, string description, ERR_STATE state) public void Add(byte errcode, string description, ERR_STATE state)
{ {
FlyData_WarningHistory reason = new FlyData_WarningHistory FlyData_WarningHistory reason = new FlyData_WarningHistory();
{ reason.Time = DateTime.Now;
Time = DateTime.Now,
ErrCode = errcode, reason.ErrCode = errcode;
Description = description, reason.Description = description;
State = state reason.State = state;
};
FlyData_WarningHistory error = null; FlyData_WarningHistory error = null;
Buffer<FlyData_WarningHistory> reasonList = ReasonList as Buffer<FlyData_WarningHistory>; Buffer<FlyData_WarningHistory> reasonList = ReasonList as Buffer<FlyData_WarningHistory>;
...@@ -78,7 +85,7 @@ namespace FLY.OBJComponents.Server ...@@ -78,7 +85,7 @@ namespace FLY.OBJComponents.Server
case ERR_STATE.ON: case ERR_STATE.ON:
if (error == null) if (error == null)
{ {
reasonList.Add(reason.Clone()); ((Buffer<FlyData_WarningHistory>)ReasonList).Add(reason.Clone());
} }
else else
...@@ -96,12 +103,20 @@ namespace FLY.OBJComponents.Server ...@@ -96,12 +103,20 @@ namespace FLY.OBJComponents.Server
else else
{ {
error.State = state; error.State = state;
reasonList.Remove(error_id); ((Buffer<FlyData_WarningHistory>)ReasonList).Remove(error_id);
} }
break; break;
} }
((Buffer<FlyData_WarningHistory>)NewestList).Add(reason); ((Buffer<FlyData_WarningHistory>)NewestList).Add(reason);
if (reasonList.Count > 0)
{
RingEvent?.Invoke();
}
else
{
Reset();
}
} }
#endregion #endregion
......
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