using FLY.Thick.RemoteHistory; using FObjBase; using SQLite; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FLY.OBJComponents.Common { public class FlyData_WarningHistory : IFlyData,IDbBase { public Int64 ID { get; set; } /// /// 时间 /// public DateTime Time { get; set; } /// /// 出错码 /// public int ErrCode { get; set; } /// /// 出错状态 /// public ERR_STATE State { get; set; } /// /// 描述 /// public string Description { get; set; } /// /// 附加信息, json格式 /// public string Accessory { get; set; } public FlyData_WarningHistory Clone() { return new FlyData_WarningHistory() { Time = Time, ErrCode = ErrCode, State = State, Description = Description }; } public string GetHeader() { return "时间,出错码,状态,描述"; } public bool TryParse(string header, string str) { string[] items = str.Split(new char[] { ',' }); if (items.Length < 4) return false; DateTime dt; if (DateTime.TryParse(items[0], out dt)) Time = dt; else return false; int b; if (int.TryParse(items[1], out b)) ErrCode = b; else return false; ERR_STATE state; if (Enum.TryParse(items[2], out state)) State = state; else return false; Description = items[3]; return true; } public override string ToString() { string str; str = Time.ToString(); str += "," + ErrCode.ToString(); str += "," + State.ToString(); str += "," + Description; return str; } } /// /// 报警状态 /// public enum ERR_STATE { /// /// 报警中 /// ON, /// /// 关闭 /// OFF } /// /// 出错类型 /// public struct ERRNO { public UInt16 Code; public string Descrption; } public class PlcErrNos { public static PlcErrNos Instance { get; } = new PlcErrNos(); /// /// PLC连接断开 /// public ERRNO ERRNO_PLC_DISCONNECTED = new ERRNO() { Code = 65535, Descrption = "PLC连接断开" }; } }