diff --git a/Project.FLY.IBC/FLY.IBC/Server/IBCSystem.cs b/Project.FLY.IBC/FLY.IBC/Server/IBCSystem.cs
index 5b0c132072ae2c47e4f994d0202e949bb4aa1d07..ec12e3e763649f6ce982c64db1b8680fa9c1591d 100644
--- a/Project.FLY.IBC/FLY.IBC/Server/IBCSystem.cs
+++ b/Project.FLY.IBC/FLY.IBC/Server/IBCSystem.cs
@@ -165,8 +165,12 @@ namespace FLY.IBC.Server
                 {
                     historyDb.AddWidthRange(dbWidths_1min);
                     dbWidths_1min.Clear();
+                    stopwatch_1min.Restart();
+                }
+                else 
+                {
+                    stopwatch_1min.Reset();
                 }
-                stopwatch_1min.Reset();
             }
 
             if (!stopwatch_interval.IsRunning)
diff --git a/Project.FLY.Weight/FLY.Weight/Server/WeightSystem.cs b/Project.FLY.Weight/FLY.Weight/Server/WeightSystem.cs
index 208e400f9183ca10c2184659da04cf77171b8cdd..f2414144b637d2bf7210f098d612131629d01e47 100644
--- a/Project.FLY.Weight/FLY.Weight/Server/WeightSystem.cs
+++ b/Project.FLY.Weight/FLY.Weight/Server/WeightSystem.cs
@@ -401,8 +401,12 @@ namespace FLY.Weight.Server
                 {
                     mHistoryDb.AddFlowRange(lcFlows_1min);
                     lcFlows_1min.Clear();
+                    stopwatch_1min.Restart();
+                }
+                else 
+                {
+                    stopwatch_1min.Reset();
                 }
-                stopwatch_1min.Reset();
             }
             
             if (!stopwatch_flowInterval.IsRunning)
@@ -673,7 +677,6 @@ namespace FLY.Weight.Server
         public string[] GetSavePropertyNames()
         {
             return new string[]{
-                "FlowListSize",
                 "FlowInterval"
             };
         }
@@ -686,7 +689,6 @@ namespace FLY.Weight.Server
         {
             return new string[]{
                 "FlowInterval",
-                "FlowListSize",
                 "ItemsCnt",
                 "BinCnts"
                 };
diff --git a/Project.FLY.Winder_20190413/FLY.Winder.UI.Client/Common.cs b/Project.FLY.Winder_20190413/FLY.Winder.UI.Client/Common.cs
new file mode 100644
index 0000000000000000000000000000000000000000..6d0f5e12c146151aca2ee701b0c72f0dc390a82b
--- /dev/null
+++ b/Project.FLY.Winder_20190413/FLY.Winder.UI.Client/Common.cs
@@ -0,0 +1,29 @@
+using FLY.OBJComponents.Client;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace FLY.Winder.UI.Client
+{
+    public static class Common
+    {
+        public static void BindingWindowSize<T>(Func<int, BufferWindow<T>> createWindow)
+        {
+            int windowSize = 30;
+            if (Application.Current.Properties["WindowSize"] is int)
+                windowSize = (int)Application.Current.Properties["WindowSize"];
+            var window = createWindow(windowSize);
+            window.PropertyChanged += (s, e) =>
+            {
+                if (e.PropertyName == "Size")
+                {
+                    var w = s as BufferWindow<T>;
+                    Application.Current.Properties["WindowSize"] = w.Size;
+                }
+            };
+        }
+    }
+}
diff --git a/Project.FLY.Winder_20190413/FLY.Winder.UI.Client/FLY.Winder.UI.Client.csproj b/Project.FLY.Winder_20190413/FLY.Winder.UI.Client/FLY.Winder.UI.Client.csproj
index df6028d788f68523d1e1ebb73eb6148b8e1d6e61..5f6ea834b893fdbb2fde6ba45ddb5f3057f4df5b 100644
--- a/Project.FLY.Winder_20190413/FLY.Winder.UI.Client/FLY.Winder.UI.Client.csproj
+++ b/Project.FLY.Winder_20190413/FLY.Winder.UI.Client/FLY.Winder.UI.Client.csproj
@@ -58,6 +58,7 @@
     <Reference Include="PresentationFramework" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Common.cs" />
     <Compile Include="Converter\IsGTMultiValueConverter.cs" />
     <Compile Include="Converter\RatioConverter.cs" />
     <Compile Include="Page_ErrorNewestTable.xaml.cs">
diff --git a/Project.FLY.Winder_20190413/FLY.Winder.UI.Client/Page_ErrorNewestTable.xaml.cs b/Project.FLY.Winder_20190413/FLY.Winder.UI.Client/Page_ErrorNewestTable.xaml.cs
index 24a683107e39586397bb56c21b0063a904fa90db..0bfec61aa5f09f60b8cc1ff156dfb16fed90ea4d 100644
--- a/Project.FLY.Winder_20190413/FLY.Winder.UI.Client/Page_ErrorNewestTable.xaml.cs
+++ b/Project.FLY.Winder_20190413/FLY.Winder.UI.Client/Page_ErrorNewestTable.xaml.cs
@@ -1,4 +1,6 @@
 
+using FLY.OBJComponents.Client;
+using FLY.OBJComponents.Common;
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
@@ -23,8 +25,8 @@ namespace FLY.Winder.UI.Client
     public partial class Page_ErrorNewestTable : Page
     {
 
-        FLY.OBJComponents.Client.WarningServiceClient mWarningService;
-        FLY.OBJComponents.Client.BufferWindow<FLY.OBJComponents.Common.FlyData_WarningHistory> mWindow;
+        WarningServiceClient mWarningService;
+        BufferWindow<FlyData_WarningHistory> mWindow;
 
         public Page_ErrorNewestTable()
         {
@@ -36,7 +38,13 @@ namespace FLY.Winder.UI.Client
         void Init()
         {
             mWarningService = TDGage.Current.mWarningService;
-            mWindow = new OBJComponents.Client.BufferWindow<OBJComponents.Common.FlyData_WarningHistory>(mWarningService.NewestList);
+
+            Common.BindingWindowSize((windowSize) =>
+            {
+                mWindow = new BufferWindow<FlyData_WarningHistory>(mWarningService.NewestList, windowSize);
+                return mWindow;
+            });
+
             grid_window.DataContext = mWindow;
         }
 
diff --git a/Project.FLY.Winder_20190413/FLY.Winder.UI.Server/MainWindow.xaml.cs b/Project.FLY.Winder_20190413/FLY.Winder.UI.Server/MainWindow.xaml.cs
index 26e34be152ada453824fcb9cfcb384457098c7d4..398d5a6e48691a040cd079d5bd5c25243319a17a 100644
--- a/Project.FLY.Winder_20190413/FLY.Winder.UI.Server/MainWindow.xaml.cs
+++ b/Project.FLY.Winder_20190413/FLY.Winder.UI.Server/MainWindow.xaml.cs
@@ -20,7 +20,8 @@ namespace FLY.Winder.UI.Server
     public partial class MainWindow : Window
     {
         FLY.AppHelper.WindowNotifyIconHelper notifyiconhelper;
-        FLY.Winder.Server.TDGage mTDGage;
+        FLY.Winder.Server.TDGage gage;
+        FLY.Winder.Server.OBJProxy.OBJProxy oBJProxy;
         public MainWindow()
         {
             InitializeComponent();
@@ -32,10 +33,11 @@ namespace FLY.Winder.UI.Server
             this.Hide();
 
             FObjBase.PollModule.Current.Start();
-            mTDGage = new FLY.Winder.Server.TDGage("Gage1");
+            gage = new FLY.Winder.Server.TDGage("Gage1");
+            oBJProxy = new Winder.Server.OBJProxy.OBJProxy(0, gage);
 
             FLY.OBJComponents.Server.PLCProxySystem plsos =
-                mTDGage.mData.PLCos as FLY.OBJComponents.Server.PLCProxySystem;
+                gage.mData.PLCos as FLY.OBJComponents.Server.PLCProxySystem;
             grid_plcos.DataContext = plsos;
             grid_plc.DataContext = plsos.PLCs[0];
             
diff --git a/Project.FLY.Winder_20190413/FLY.Winder/FLY.Winder.csproj b/Project.FLY.Winder_20190413/FLY.Winder/FLY.Winder.csproj
index a64a863a48eaa61a37df6cb466a5db945db2760b..bd2b3904a0e052701cfeeb49507eac475bbd3d4f 100644
--- a/Project.FLY.Winder_20190413/FLY.Winder/FLY.Winder.csproj
+++ b/Project.FLY.Winder_20190413/FLY.Winder/FLY.Winder.csproj
@@ -55,7 +55,12 @@
     <Compile Include="OBJ_INTERFACE\WINDER_OBJ_INTERFACE.cs" />
     <Compile Include="OBJ_INTERFACE\OBJ_INTERFACE.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Server.OBJProxy\OBJProxy.cs" />
     <Compile Include="Server.OBJProxy\WinderSystem_OBJProxy.cs" />
+    <Compile Include="Server\Model\DbModel.cs" />
+    <Compile Include="Server\Model\DbTable.cs" />
+    <Compile Include="Server\Model\HistoryDb.cs" />
+    <Compile Include="Server\SysParam.cs" />
     <Compile Include="Server\TDGage.cs" />
     <Compile Include="Server\WinderSystem.cs" />
   </ItemGroup>
@@ -79,6 +84,10 @@
       <Project>{a539505d-9ac0-426b-a9a0-197df50598b0}</Project>
       <Name>OBJComponents</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\thick_public\Project.SQLiteHelper\SQLiteHelper\SQLiteHelper.csproj">
+      <Project>{4CBABFAA-1C62-4510-AC63-A51EE5FD50FF}</Project>
+      <Name>SQLiteHelper</Name>
+    </ProjectReference>
   </ItemGroup>
   <ItemGroup>
     <PackageReference Include="Newtonsoft.Json">
diff --git a/Project.FLY.Winder_20190413/FLY.Winder/OBJ_INTERFACE/OBJ_INTERFACE.cs b/Project.FLY.Winder_20190413/FLY.Winder/OBJ_INTERFACE/OBJ_INTERFACE.cs
index 343784650818c998a5fa53efa32ffda50214e12e..8ac1f8036975e2eb6c3c59c66c575de643b8f025 100644
--- a/Project.FLY.Winder_20190413/FLY.Winder/OBJ_INTERFACE/OBJ_INTERFACE.cs
+++ b/Project.FLY.Winder_20190413/FLY.Winder/OBJ_INTERFACE/OBJ_INTERFACE.cs
@@ -21,5 +21,8 @@ namespace FLY.Winder.OBJ_INTERFACE
         /// 2个
         /// </summary>
         public const UInt32 WINDER_OBJ_PLCOS_ID = 0x001f0210;
+
+
+        public const UInt32 WINDER_OBJ_INFOLIST_ID = 0x001f0220;
     }
 }
diff --git a/Project.FLY.Winder_20190413/FLY.Winder/Server.OBJProxy/OBJProxy.cs b/Project.FLY.Winder_20190413/FLY.Winder/Server.OBJProxy/OBJProxy.cs
new file mode 100644
index 0000000000000000000000000000000000000000..f7374bc7525943a8aa4090a79206220249bdc4e7
--- /dev/null
+++ b/Project.FLY.Winder_20190413/FLY.Winder/Server.OBJProxy/OBJProxy.cs
@@ -0,0 +1,40 @@
+
+using FLY.OBJComponents.Server.OBJProxy;
+using FLY.Winder.Server.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FLY.Winder.Server.OBJProxy
+{
+    public class OBJProxy
+    {
+        WinderSystem_OBJProxy winderSystemOBJProxy;
+
+        Buffer_OBJProxy<Db_WinderInfo> mInfoListOBJProxy;
+
+        WarningSystem_OBJProxy mWarnSystemOBJProxy;
+        public OBJProxy(int objsys_idx, TDGage gage) 
+        {
+            TDGage mGage = gage;
+            winderSystemOBJProxy = new WinderSystem_OBJProxy(objsys_idx, gage.mData);
+
+            mInfoListOBJProxy = new Buffer_OBJProxy<Db_WinderInfo>(
+                objsys_idx,
+                OBJ_INTERFACE.OBJ_INTERFACE.WINDER_OBJ_INFOLIST_ID,
+                gage.mHistoryDb.WinderInfoBuffer);
+
+            mWarnSystemOBJProxy = new WarningSystem_OBJProxy(
+                objsys_idx,
+                OBJ_INTERFACE.OBJ_INTERFACE.WARNING_OBJ_ID,
+                gage.mWarning);
+
+            winderSystemOBJProxy.CurrObjSys.Start_Conn_Server(
+                new IPEndPoint(IPAddress.Any, gage.mSysParam.OBJ_Port), winderSystemOBJProxy.ID);
+
+        }
+    }
+}
diff --git a/Project.FLY.Winder_20190413/FLY.Winder/Server/Model/DbModel.cs b/Project.FLY.Winder_20190413/FLY.Winder/Server/Model/DbModel.cs
new file mode 100644
index 0000000000000000000000000000000000000000..12c89dee7ac28d189790dd7e613252fcce7b2b9f
--- /dev/null
+++ b/Project.FLY.Winder_20190413/FLY.Winder/Server/Model/DbModel.cs
@@ -0,0 +1,42 @@
+using FLY.OBJComponents.Server.Model;
+using SQLite;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FLY.Winder.Server.Model
+{
+    /// <summary>
+    /// 数据库对象
+    /// </summary>
+    public class DbModel:SQLiteDbContext,IErrorDBModel
+    {
+        /// <summary>
+        /// Width表 对象
+        /// </summary>
+        public DBTable<Db_WinderInfo> TbWinderInfo { get; } = new DBTable<Db_WinderInfo>();
+
+        /// <summary>
+        /// Error表 对象
+        /// </summary>
+        public DBTable<DB_Error> TbError { get; } = new DBTable<DB_Error>();
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="dbpath">sqlite数据库路径</param>
+        public DbModel(string dbpath) : base(dbpath)
+        {
+            
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        public DbModel() : this(@"D:\blowingdata\winder.sqlite3")
+        {
+
+        }
+    }
+}
diff --git a/Project.FLY.Winder_20190413/FLY.Winder/Server/Model/DbTable.cs b/Project.FLY.Winder_20190413/FLY.Winder/Server/Model/DbTable.cs
new file mode 100644
index 0000000000000000000000000000000000000000..159ef4dbe92be520239f418a9deedf4ba65b7ea6
--- /dev/null
+++ b/Project.FLY.Winder_20190413/FLY.Winder/Server/Model/DbTable.cs
@@ -0,0 +1,102 @@
+using SQLite;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FLY.Winder.Server.Model
+{
+    /// <summary>
+    /// 收卷表
+    /// </summary>
+    [Table("WinderInfo")]
+    public class Db_WinderInfo : IDbBase
+    {
+        [Key]
+        [PropertyIndex(0)]
+        public Int64 ID { get; set; }
+
+        /// <summary>
+        /// æ—¶é—´
+        /// </summary>
+        [PropertyIndex(1)]
+        public DateTime Time { get; set; }
+
+        /// <summary>
+        /// 线速度 m/min
+        /// </summary>
+        [PropertyIndex(2)]
+        public double Velocity { get; set; }
+
+        /// <summary>
+        /// 上牵引电流   单位 A
+        /// </summary>
+        [PropertyIndex(2)]
+        public double Traction1Current { get; set; }
+
+        /// <summary>
+        /// 二牵引电流   单位 A
+        /// </summary>
+        [PropertyIndex(3)]
+        public double Traction2Current { get; set; }
+
+        /// <summary>
+        /// 内收卷电流   单位 A
+        /// </summary>
+        [PropertyIndex(4)]
+        public double Winder0Current { get; set; }
+
+        /// <summary>
+        /// 外收卷电流   单位 A
+        /// </summary>
+        [PropertyIndex(5)]
+        public double Winder1Current { get; set; }
+
+        /// <summary>
+        /// 二牵引实际张力 单位 Kg
+        /// </summary>
+        [PropertyIndex(6)]
+        public double Traction2TensionKg { get; set; }
+
+        /// <summary>
+        /// 内收卷实际张力 单位 Kg
+        /// </summary>
+        [PropertyIndex(7)]
+        public double Winder0TensionKg { get; set; }
+
+        /// <summary>
+        /// 外收卷实际张力 单位 Kg
+        /// </summary>
+        [PropertyIndex(8)]
+        public double Winder1TensionKg { get; set; }
+
+        /// <summary>
+        /// 旋转塔电流 单位 A
+        /// </summary>
+        [PropertyIndex(9)]
+        public double RotaryCurrent { get; set; }
+
+        /// <summary>
+        /// 旋转塔频率 单位 Hz
+        /// </summary>
+        [PropertyIndex(10)]
+        public double RotaryFreq { get; set; }
+
+        /// <summary>
+        /// 旋转塔正转
+        /// </summary>
+        [PropertyIndex(11)]
+        public bool IsRotaryForw { get; set; }
+
+        /// <summary>
+        /// 旋转塔反转
+        /// </summary>
+        [PropertyIndex(12)]
+        public bool IsRotaryBackw { get; set; }
+
+    }
+
+}
diff --git a/Project.FLY.Winder_20190413/FLY.Winder/Server/Model/HistoryDb.cs b/Project.FLY.Winder_20190413/FLY.Winder/Server/Model/HistoryDb.cs
new file mode 100644
index 0000000000000000000000000000000000000000..72174cf4a257b359fbb8d1efe9b1373c6964ba9a
--- /dev/null
+++ b/Project.FLY.Winder_20190413/FLY.Winder/Server/Model/HistoryDb.cs
@@ -0,0 +1,72 @@
+
+using FLY.OBJComponents.Server;
+using FLY.OBJComponents.Server.Model;
+
+using FObjBase;
+using SQLite;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FLY.Winder.Server.Model
+{
+    /// <summary>
+    /// 数据库 写操作
+    /// </summary>
+    public class HistoryDb
+    {
+        DbModel dbModel;
+        public BufferSQLite<Db_WinderInfo> WinderInfoBuffer;
+        public BufferError ErrorBuffer;
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="dBModel"></param>
+        public void Init(DbModel dBModel)
+        {
+            this.dbModel = dBModel;
+            WinderInfoBuffer = new BufferSQLite<Db_WinderInfo>();
+            WinderInfoBuffer.Init(dBModel.TbWinderInfo);
+
+            ErrorBuffer = new BufferError();
+            ErrorBuffer.Init(dBModel.TbError);
+        }
+
+        /// <summary>
+        /// 按时间删除数据库
+        /// </summary>
+        /// <param name="month"></param>
+        public void KeepDBSize(int month)
+        {
+            if (month <= 3)
+                month = 3;
+
+            DateTime del_time = DateTime.Now - TimeSpan.FromDays(month * 30);
+            string det_time_str = del_time.ToStringOfSQLiteFieldType();
+            List<string> sqls = new List<string>();
+            sqls.Add(
+                $"DELETE FROM {dbModel.TbWinderInfo.TableName}" +
+                $" WHERE EndTime < {det_time_str}");
+
+            sqls.Add(
+                $"DELETE FROM {dbModel.TbError.TableName}" +
+                $" WHERE Time < {det_time_str}");
+
+            dbModel.sqliteHelper.QueryTran(sqls);
+
+        }
+
+        public void AddWinderInfo(
+            Db_WinderInfo winderInfo
+            )
+        {
+            WinderInfoBuffer.Add(winderInfo);
+        }
+        public void AddWinderInfos(IEnumerable<Db_WinderInfo> winderInfos) 
+        {
+            WinderInfoBuffer.AddRange(winderInfos);
+        }
+    }
+}
diff --git a/Project.FLY.Winder_20190413/FLY.Winder/Server/SysParam.cs b/Project.FLY.Winder_20190413/FLY.Winder/Server/SysParam.cs
new file mode 100644
index 0000000000000000000000000000000000000000..76f7b11f4640b87dbf5f178f0bcb66bd6ce78ef3
--- /dev/null
+++ b/Project.FLY.Winder_20190413/FLY.Winder/Server/SysParam.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FLY.Winder.Server
+{
+    public class SysParam : Misc.ISaveToXml
+    {
+        /// <summary>
+        /// OBJ服务端口
+        /// </summary>
+        public int OBJ_Port { get; set; } = 20004;
+
+        /// <summary>
+        /// 数据库保持时间 默认6个月
+        /// </summary>
+        public int DBKeepMonth { get; set; } = 6;
+
+        public SysParam()
+        {
+            Load();
+        }
+        public void Save()
+        {
+            Misc.SaveToXmlHepler.Save("system.xml", this);
+        }
+        public void Load()
+        {
+            Misc.SaveToXmlHepler.Load("system.xml", this);
+        }
+
+        public string[] GetSavePropertyNames()
+        {
+            return new string[]{
+                "OBJ_Port",
+                "DBKeepMonth"
+            };
+        }
+    }
+}
diff --git a/Project.FLY.Winder_20190413/FLY.Winder/Server/TDGage.cs b/Project.FLY.Winder_20190413/FLY.Winder/Server/TDGage.cs
index 35667e8919c55c36a0aabe86d9d4854fe70e92f6..8e622a8ff057fd4f6593e66418bef1c347b3a409 100644
--- a/Project.FLY.Winder_20190413/FLY.Winder/Server/TDGage.cs
+++ b/Project.FLY.Winder_20190413/FLY.Winder/Server/TDGage.cs
@@ -7,27 +7,30 @@ using System.Linq;
 using System.Net;
 using System.Text;
 using System.Threading.Tasks;
+using FLY.Winder.Server.Model;
+using FLY.OBJComponents.Server;
 
 namespace FLY.Winder.Server
 {
-    public class TDGage : Misc.ISaveToXml
+    public class TDGage
     {
         #region 初始化------------------------------------------------------------------
         public string mParamDirectory;//参数目录 m_path;//数据文件的 根目录默认是 Gage1
         public string mName;//名字 如:gage0
         #endregion
 
-        #region 服务器数据--------------------------------------------------------------
+        public SysParam mSysParam;
+        public WinderSystem mData;
         /// <summary>
-        /// OBJ服务端口
+        /// 报警系统
         /// </summary>
-        public int OBJ_Port { get; set; }
-        
-        public WinderSystem mData;
-        WinderSystem_OBJProxy mServerOBJProxy;
-        WarningSystem_OBJProxy mWarnSystemOBJProxy;
+        public WarningSystem mWarning;
+
+        public HistoryDb mHistoryDb;
+
+        DbModel mDbModel;
+
 
-        #endregion
 
         public TDGage(string nam)
         {
@@ -49,51 +52,27 @@ namespace FLY.Winder.Server
         /// </summary>
         public void Init1()
         {
-            OBJ_Port = 20004;
-            Load();
-
-            
-            #region 提取保存的数据
-
+            mSysParam = new SysParam();
             mData = new WinderSystem();
-            mServerOBJProxy = new WinderSystem_OBJProxy(0, mData);
-            mWarnSystemOBJProxy = new WarningSystem_OBJProxy(0, OBJ_INTERFACE.OBJ_INTERFACE.WARNING_OBJ_ID, mData.mWarning);
-            #endregion
 
-            Init2();
+            //---------------------------------------------------------------------------------------------------------------
+            //数据库
+            mDbModel = new DbModel();
+            mDbModel.Init();
 
-        }
-        
-        /// <summary>
-        /// 第2步, 连接到服务器,初始化参数 。由界面的 【登陆】 按钮触发
-        /// </summary>
-        private void Init2()
-        {
-            #region 网络初始化
-            FObjSys.Current.Start_Conn_Server(new IPEndPoint(IPAddress.Any, OBJ_Port), mServerOBJProxy.ID);
+            mHistoryDb = new HistoryDb();
+            mHistoryDb.Init(mDbModel);
+            mHistoryDb.KeepDBSize(mSysParam.DBKeepMonth);
 
-            #endregion
-        }
+            mWarning = new WarningSystem(mHistoryDb.ErrorBuffer);
 
-        #endregion
+            mData.Init(mHistoryDb, mWarning);
 
-        public void Save()
-        {
-            Misc.SaveToXmlHepler.Save("system.xml", this);
-        }
-        public void Load()
-        {
-            Misc.SaveToXmlHepler.Load("system.xml", this);
-        }
-        #region ISaveToXml 成员
 
-        public string[] GetSavePropertyNames()
-        {
-            return new string[]{
-                "OBJ_Port"
-            };
         }
 
         #endregion
+
+
     }
 }
diff --git a/Project.FLY.Winder_20190413/FLY.Winder/Server/WinderSystem.cs b/Project.FLY.Winder_20190413/FLY.Winder/Server/WinderSystem.cs
index beb8e6422d715d65ef85554431322608c4d904e4..39f4259443edd3eb71e3c41b6395abd19c31c947 100644
--- a/Project.FLY.Winder_20190413/FLY.Winder/Server/WinderSystem.cs
+++ b/Project.FLY.Winder_20190413/FLY.Winder/Server/WinderSystem.cs
@@ -4,10 +4,12 @@ using FLY.OBJComponents.IService;
 using FLY.OBJComponents.Server;
 using FLY.Winder.Common;
 using FLY.Winder.IService;
+using FLY.Winder.Server.Model;
 using FObjBase;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
+using System.Diagnostics;
 using System.Linq;
 using System.Text;
 
@@ -38,34 +40,34 @@ namespace FLY.Winder.Server
         /// <summary>
         /// 报警系统
         /// </summary>
-        public WarningSystem mWarning;
+        WarningSystem mWarning;
+        HistoryDb mHistoryDb;
+
 
-        static WinderSystem()
-        {
-            //Misc.SaveToXmlHepler.Regist(typeof(WinderSystemParams));
-        }
         public WinderSystem()
         {
-            Items = new List<WinderInsideOutside>();
-            for (int i = 0; i < 2; i++)
-            {
-                Items.Add(new WinderInsideOutside());
-            }
-            Accessory = new WinderAccessory();
+            //加载PLC寄存器 文件
+            AddConfigFile("WS.xml");
 
 
-    
-            mWarning = new WarningSystem();
 
-            AddConfigFile("WS.xml");
 
+        }
+
+        public void Init(HistoryDb historyDb, WarningSystem warning)
+        {
+            mHistoryDb = historyDb;
+            mWarning = warning;
 
             //--------------------------------------------------------------------------------
             //报警配置
             InitError();
 
-            plcos.Init();
+            FObjBase.PollModule.Current.Poll_Config(
+                FObjBase.PollModule.POLL_CONFIG.ADD, OnPoll, TimeSpan.FromSeconds(1));
+
 
+            plcos.Init();
         }
         #region 报警
         class ErrorAction
@@ -224,6 +226,13 @@ namespace FLY.Winder.Server
                 plcos.PLCs.Add(plc);
             }
 
+            Items = new List<WinderInsideOutside>();
+            for (int i = 0; i < 2; i++)
+            {
+                Items.Add(new WinderInsideOutside());
+            }
+            Accessory = new WinderAccessory();
+
             //objname 转 obj
             PLCos.ObjNames.Add("Accessory", Accessory);
             for (int i = 0; i < Items.Count(); i++)
@@ -255,5 +264,77 @@ namespace FLY.Winder.Server
         }
 
 
+        Stopwatch stopwatch_infoInterval = new Stopwatch();
+        Stopwatch stopwatch_1min = new Stopwatch();
+        List<Db_WinderInfo> dbInfo_1min = new List<Db_WinderInfo>();
+        void OnPoll()
+        {
+            if (stopwatch_1min.IsRunning && stopwatch_1min.Elapsed >= TimeSpan.FromSeconds(60))
+            {
+                //启动了1min 且到点了
+                if (dbInfo_1min.Count > 0)
+                {
+                    mHistoryDb.AddWinderInfos(dbInfo_1min);
+                    dbInfo_1min.Clear();
+                    stopwatch_1min.Restart();
+                }
+                else 
+                {
+                    stopwatch_1min.Reset();
+                }
+            }
+
+
+            if (!stopwatch_infoInterval.IsRunning)
+            {
+                stopwatch_infoInterval.Start();
+                return;
+            }
+            else
+            {
+                if (stopwatch_infoInterval.Elapsed < TimeSpan.FromSeconds(10))
+                    return;
+                else
+                    stopwatch_infoInterval.Restart();
+            }
+
+            if (!PLCos.IsConnectedWithPLC)//连接断开
+                return;
+
+            if (Accessory.Velocity < 2)//没有生产
+                return;
+
+            //记录数据
+            Db_WinderInfo db_WinderInfo = new Db_WinderInfo
+            {
+                Time = DateTime.Now,
+                Velocity = Math.Round(Accessory.Velocity, 1),
+                Traction1Current = Math.Round(Accessory.Traction1Current, 1),
+                Traction2Current = Math.Round(Accessory.Traction2Current, 1),
+                Winder0Current = Math.Round(Items[0].Current,1),
+                Winder1Current = Math.Round(Items[1].Current, 1),
+                Traction2TensionKg = Math.Round(Accessory.Traction2TensionKg,1),
+                Winder0TensionKg = Math.Round(Items[0].TensionKg, 1),
+                Winder1TensionKg = Math.Round(Items[1].TensionKg, 1),
+                RotaryCurrent = Math.Round(Accessory.RotaryCurrent,1),
+                RotaryFreq = Math.Round(Accessory.RotaryFreq,1),
+                IsRotaryForw = Accessory.IsRotaryForw,
+                IsRotaryBackw = Accessory.IsRotaryBackw
+            };
+
+            //写入数据库
+            if (!stopwatch_1min.IsRunning)
+            {
+                //第1次立刻写入
+                mHistoryDb.AddWinderInfo(db_WinderInfo);
+                stopwatch_1min.Start();
+            }
+            else
+            {
+                //第2次,1分钟后才能保存
+                dbInfo_1min.Add(db_WinderInfo);
+            }
+
+        }
     }
 }