FlyData_WarningHistory.cs 2.89 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2
using FLY.Thick.RemoteHistory;
using FObjBase;
3
using SQLite;
潘栩锋's avatar
潘栩锋 committed
4 5 6 7 8 9 10 11 12
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLY.OBJComponents.Common
{

13
    public class FlyData_WarningHistory : IFlyData,IDbBase
潘栩锋's avatar
潘栩锋 committed
14
    {
15
        public Int64 ID { get; set; }
潘栩锋's avatar
潘栩锋 committed
16 17 18 19 20 21 22 23
        /// <summary>
        /// 时间
        /// </summary>
        public DateTime Time { get; set; }

        /// <summary>
        /// 出错码
        /// </summary>
24
        public int ErrCode { get; set; }
潘栩锋's avatar
潘栩锋 committed
25 26 27 28 29 30 31 32
        /// <summary>
        /// 出错状态
        /// </summary>
        public ERR_STATE State { get; set; }
        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; }
33 34 35 36
        /// <summary>
        /// 附加信息, json格式
        /// </summary>
        public string Accessory { get; set; }
潘栩锋's avatar
潘栩锋 committed
37 38 39 40 41 42 43 44 45 46 47 48
        public FlyData_WarningHistory Clone()
        {
            return new FlyData_WarningHistory()
            {
                Time = Time,
                ErrCode = ErrCode,
                State = State,
                Description = Description
            };
        }
        public string GetHeader()
        {
49
            return "时间,出错码,状态,描述";
潘栩锋's avatar
潘栩锋 committed
50 51 52 53 54
        }

        public bool TryParse(string header, string str)
        {
            string[] items = str.Split(new char[] { ',' });
55
            if (items.Length < 4)
潘栩锋's avatar
潘栩锋 committed
56 57 58 59 60 61
                return false;
            DateTime dt;
            if (DateTime.TryParse(items[0], out dt))
                Time = dt;
            else
                return false;
62
            int b;
潘栩锋's avatar
潘栩锋 committed
63

64
            if (int.TryParse(items[1], out b))
潘栩锋's avatar
潘栩锋 committed
65 66 67 68 69 70 71 72 73
                ErrCode = b;
            else
                return false;
            ERR_STATE state;
            if (Enum.TryParse<ERR_STATE>(items[2], out state))
                State = state;
            else
                return false;
            Description = items[3];
74 75 76



潘栩锋's avatar
潘栩锋 committed
77 78 79 80 81 82 83 84 85
            return true;
        }

        public override string ToString()
        {
            string str;
            str = Time.ToString();
            str += "," + ErrCode.ToString();
            str += "," + State.ToString();
86
            str += "," + Description;
潘栩锋's avatar
潘栩锋 committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
            return str;
        }
    }

    /// <summary>
    /// 报警状态
    /// </summary>
    public enum ERR_STATE
    {
        /// <summary>
        /// 报警中
        /// </summary>
        ON,
        /// <summary>
        /// 关闭
        /// </summary>
103
        OFF
潘栩锋's avatar
潘栩锋 committed
104 105 106 107 108 109 110 111 112 113 114
    }

    /// <summary>
    /// 出错类型
    /// </summary>
    public struct ERRNO
    {
        public byte Code;
        public string Descrption;
        public bool OffIsError;
    }
115 116 117 118 119 120

    public static class PlcErrNos
    {
        /// <summary>
        /// PLC连接断开
        /// </summary>
121
        public static ERRNO ERRNO_PLC_DISCONNECTED = new ERRNO() { Code = 255, Descrption = "PLC连接断开" };
122
    }
潘栩锋's avatar
潘栩锋 committed
123
}