using FLY.OBJComponents.Common;
using FLY.OBJComponents.IService;
using FLY.OBJComponents.Server.Model;
using FObjBase;
using SQLite;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLY.OBJComponents.Server
{
    public class BufferError : BufferSQLite<FlyData_WarningHistory, DB_Error> 
    {
        public void Init(DBTable<DB_Error> dbTable)
        {
            base.Init(dbTable, mapLc2Db, mapDb2Lc);
        }
        static DB_Error mapLc2Db(FlyData_WarningHistory lc) 
        {
            return new DB_Error()
            {
                ID = lc.ID,
                Time = lc.Time,
                ErrCode = lc.ErrCode,
                Descrption = lc.Description,
                IsOn = lc.State == ERR_STATE.ON
            };
        }
        static FlyData_WarningHistory mapDb2Lc(DB_Error db)
        {
            return new FlyData_WarningHistory()
            {
                ID = db.ID,
                Time = db.Time,
                ErrCode = db.ErrCode,
                Description = db.Descrption,
                State = db.IsOn? ERR_STATE.ON: ERR_STATE.OFF
            };
        }
    }
}
