Commit f3fbdde5 authored by 潘栩锋's avatar 潘栩锋 🚴

删除 追边测厚仪与扫描测厚仪都不保存 原始数据。 因为发生了,扫描测厚仪服务器启动时, sqlite原始数据库大于20G.

原因还不明。 直接导致测厚仪服务器不能启动。
parent d0b64cd2
...@@ -28,7 +28,7 @@ namespace FLY.Thick.Blowing.Server ...@@ -28,7 +28,7 @@ namespace FLY.Thick.Blowing.Server
const int MARKNO_PROFILE_ADD = 87; const int MARKNO_PROFILE_ADD = 87;
const int MARKNO_PROFILE_CHANGED = 88; const int MARKNO_PROFILE_CHANGED = 88;
OrgHistoryDb orgHistoryDb; //OrgHistoryDb orgHistoryDb;
HistoryDb historyDb; HistoryDb historyDb;
BulkDb bulkDb; BulkDb bulkDb;
...@@ -740,7 +740,6 @@ namespace FLY.Thick.Blowing.Server ...@@ -740,7 +740,6 @@ namespace FLY.Thick.Blowing.Server
AD2ThkHandler ad2thk, DynArea dynarea, AD2ThkHandler ad2thk, DynArea dynarea,
BlowingFixProfileParam profileParam, BlowingFixProfileParam profileParam,
HistoryDb historyDb, HistoryDb historyDb,
OrgHistoryDb orgHistoryDb,
BulkDb bulkDb BulkDb bulkDb
) )
{ {
...@@ -748,7 +747,7 @@ namespace FLY.Thick.Blowing.Server ...@@ -748,7 +747,7 @@ namespace FLY.Thick.Blowing.Server
mDynArea = dynarea; mDynArea = dynarea;
mProfileParam = profileParam; mProfileParam = profileParam;
this.historyDb = historyDb; this.historyDb = historyDb;
this.orgHistoryDb = orgHistoryDb; //this.orgHistoryDb = orgHistoryDb;
this.bulkDb = bulkDb; this.bulkDb = bulkDb;
this.bulkDb.GetTempFrameAction = GetTempFrame; this.bulkDb.GetTempFrameAction = GetTempFrame;
...@@ -827,34 +826,34 @@ namespace FLY.Thick.Blowing.Server ...@@ -827,34 +826,34 @@ namespace FLY.Thick.Blowing.Server
FObjBase.PollModule.POLL_CONFIG.ADD, FObjBase.PollModule.POLL_CONFIG.ADD,
() => () =>
{ {
mPDetect.GetSignList(markdebug_dt, (asyncContext, retData) => //mPDetect.GetSignList(markdebug_dt, (asyncContext, retData) =>
{ //{
var reponse = retData as GetSignListReponse; // var reponse = retData as GetSignListReponse;
var cells = reponse.datas; // var cells = reponse.datas;
if (cells.Count > 0) // if (cells.Count > 0)
{ // {
orgHistoryDb.AddSignData( // orgHistoryDb.AddSignData(
new Lc_Sign() // new Lc_Sign()
{ // {
Time = cells.First().Time, // Time = cells.First().Time,
Signs = cells.ToArray() // Signs = cells.ToArray()
}); // });
} // }
}, null); //}, null);
mPDetect.GetRollList(markdebug_dt, (asyncContext, retData) => //mPDetect.GetRollList(markdebug_dt, (asyncContext, retData) =>
{ //{
var reponse = retData as GetRollListReponse; // var reponse = retData as GetRollListReponse;
var cells = reponse.datas; // var cells = reponse.datas;
if (cells.Count > 0) // if (cells.Count > 0)
{ // {
orgHistoryDb.AddRollData( // orgHistoryDb.AddRollData(
new Lc_Roll() // new Lc_Roll()
{ // {
Time = cells.First().dt, // Time = cells.First().dt,
Signs = cells.ToArray() // Signs = cells.ToArray()
}); // });
} // }
}, null); //}, null);
this.GetADList(markdebug_dt, (asyncContext, retData) => this.GetADList(markdebug_dt, (asyncContext, retData) =>
{ {
var reponse = retData as GetADListReponse; var reponse = retData as GetADListReponse;
......
...@@ -109,15 +109,15 @@ namespace FLY.Thick.Blowing.Server ...@@ -109,15 +109,15 @@ namespace FLY.Thick.Blowing.Server
/// 数据库对象 /// 数据库对象
/// </summary> /// </summary>
DbModel dbModel; DbModel dbModel;
/// <summary> ///// <summary>
/// 原始数据 数据库对象 ///// 原始数据 数据库对象
/// </summary> ///// </summary>
OrgDbModel orgDbModel; //OrgDbModel orgDbModel;
/// <summary> /// <summary>
/// 数据库写操作 /// 数据库写操作
/// </summary> /// </summary>
public HistoryDb historyDb; public HistoryDb historyDb;
OrgHistoryDb orgHistoryDb; //OrgHistoryDb orgHistoryDb;
/// <summary> /// <summary>
/// 本地数据库 /// 本地数据库
/// </summary> /// </summary>
...@@ -154,10 +154,10 @@ namespace FLY.Thick.Blowing.Server ...@@ -154,10 +154,10 @@ namespace FLY.Thick.Blowing.Server
initParam = new InitParam(null); initParam = new InitParam(null);
dbModel = new DbModel(); dbModel = new DbModel();
orgDbModel = new OrgDbModel(); //orgDbModel = new OrgDbModel();
localDb = new LocalDb(); localDb = new LocalDb();
historyDb = new HistoryDb(); historyDb = new HistoryDb();
orgHistoryDb = new OrgHistoryDb(); //orgHistoryDb = new OrgHistoryDb();
bulkDb = new BulkDb(); bulkDb = new BulkDb();
dynArea = new DynArea(); dynArea = new DynArea();
...@@ -181,16 +181,16 @@ namespace FLY.Thick.Blowing.Server ...@@ -181,16 +181,16 @@ namespace FLY.Thick.Blowing.Server
historyDb.Init(dbModel, localDb); historyDb.Init(dbModel, localDb);
historyDb.KeepDbSize(initParam.DBKeepMonth); historyDb.KeepDbSize(initParam.DBKeepMonth);
orgDbModel.Init(); //orgDbModel.Init();
orgHistoryDb.Init(orgDbModel); //orgHistoryDb.Init(orgDbModel);
orgHistoryDb.KeepDbSize(3); //orgHistoryDb.KeepDbSize(3);
PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD, () => //PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD, () =>
{ //{
//避免1个月都不关程序,每天检查一次 // //避免1个月都不关程序,每天检查一次
orgHistoryDb.KeepDbSize(3); // orgHistoryDb.KeepDbSize(3);
}, TimeSpan.FromDays(1)); //}, TimeSpan.FromDays(1));
bulkDb.Init(historyDb, localDb, dbModel); bulkDb.Init(historyDb, localDb, dbModel);
...@@ -279,8 +279,8 @@ namespace FLY.Thick.Blowing.Server ...@@ -279,8 +279,8 @@ namespace FLY.Thick.Blowing.Server
gmRenZiJiaFix.Init(Ad2Thk, dynArea, profile.Param, //gmRenZiJiaFix.Init(Ad2Thk, dynArea, profile.Param, historyDb,orgHistoryDb, bulkDb );
historyDb,orgHistoryDb, bulkDb ); gmRenZiJiaFix.Init(Ad2Thk, dynArea, profile.Param, historyDb, bulkDb);
gmRenZiJiaFix.Start(); gmRenZiJiaFix.Start();
......
...@@ -981,83 +981,83 @@ namespace FLY.Thick.BlowingScan.Server ...@@ -981,83 +981,83 @@ namespace FLY.Thick.BlowingScan.Server
EndEvent += new EndEventHandler(pollScan_EndEvent); EndEvent += new EndEventHandler(pollScan_EndEvent);
//记录调试数据 //记录调试数据
MarkDebugInit(); //MarkDebugInit();
} }
#region 记录原始数据 #region 记录原始数据
DateTime markdebug_dt = DateTime.MinValue; //DateTime markdebug_dt = DateTime.MinValue;
int markdebug_lastBm = -1; //int markdebug_lastBm = -1;
void MarkDebugInit() //void MarkDebugInit()
{ //{
if (markdebug_dt == DateTime.MinValue) // if (markdebug_dt == DateTime.MinValue)
markdebug_dt = DateTime.Now; // markdebug_dt = DateTime.Now;
//启动1分钟定时器 // //启动1分钟定时器
FObjBase.PollModule.Current.Poll_Config( // FObjBase.PollModule.Current.Poll_Config(
FObjBase.PollModule.POLL_CONFIG.ADD, // FObjBase.PollModule.POLL_CONFIG.ADD,
() => // () =>
{ // {
mPDetect.GetSignList(markdebug_dt, (asyncState, retData) => // mPDetect.GetSignList(markdebug_dt, (asyncState, retData) =>
{ // {
var reponse = retData as GetSignListReponse; // var reponse = retData as GetSignListReponse;
var cells = reponse.datas; // var cells = reponse.datas;
if (cells.Count > 0) // if (cells.Count > 0)
{ // {
mHistoryDb.AddSignData( // mHistoryDb.AddSignData(
new Lc_Sign() // new Lc_Sign()
{ // {
Time = cells.First().Time, // Time = cells.First().Time,
Signs = cells.ToArray() // Signs = cells.ToArray()
}); // });
} // }
}, null); // }, null);
mPDetect.GetRollList(markdebug_dt, (asyncState, retData) => // mPDetect.GetRollList(markdebug_dt, (asyncState, retData) =>
{ // {
var reponse = retData as GetRollListReponse; // var reponse = retData as GetRollListReponse;
var cells = reponse.datas; // var cells = reponse.datas;
if (cells.Count > 0) // if (cells.Count > 0)
{ // {
mHistoryDb.AddRollData( // mHistoryDb.AddRollData(
new Lc_Roll() // new Lc_Roll()
{ // {
Time = cells.First().dt, // Time = cells.First().dt,
Signs = cells.ToArray() // Signs = cells.ToArray()
}); // });
} // }
}, null); // }, null);
int index = mBufList.No2Index(markdebug_lastBm); // int index = mBufList.No2Index(markdebug_lastBm);
index++; // index++;
if (index < 0) // if (index < 0)
index = 0; // index = 0;
if (index < mBufList.Count()) // if (index < mBufList.Count())
{ // {
//有新的数据 // //有新的数据
List<Model.Lc_OrgScanData> lc_OrgScanDatas = new List<Model.Lc_OrgScanData>(); // List<Model.Lc_OrgScanData> lc_OrgScanDatas = new List<Model.Lc_OrgScanData>();
for (int i = index; i < mBufList.Count(); i++) // for (int i = index; i < mBufList.Count(); i++)
{ // {
var data = mBufList[i]; // var data = mBufList[i];
var times = data.ThicksDt.Where(dt => dt != DateTime.MinValue); // var times = data.ThicksDt.Where(dt => dt != DateTime.MinValue);
if (times.Count() == 0) // if (times.Count() == 0)
continue; // continue;
Model.Lc_OrgScanData lcOrgScanData = new Model.Lc_OrgScanData(); // Model.Lc_OrgScanData lcOrgScanData = new Model.Lc_OrgScanData();
lcOrgScanData.Time = times.Min(); // lcOrgScanData.Time = times.Min();
lcOrgScanData.FilmBegin = data.FilmRange.Begin; // lcOrgScanData.FilmBegin = data.FilmRange.Begin;
lcOrgScanData.FilmEnd = data.FilmRange.End; // lcOrgScanData.FilmEnd = data.FilmRange.End;
lcOrgScanData.PosOfGrid = data.PosOfGrid; // lcOrgScanData.PosOfGrid = data.PosOfGrid;
lcOrgScanData.K = mProfileParam.K; // lcOrgScanData.K = mProfileParam.K;
lcOrgScanData.Thicks = ToRealThicks(data.Thicks); // lcOrgScanData.Thicks = ToRealThicks(data.Thicks);
lcOrgScanData.ThicksDt = data.ThicksDt; // lcOrgScanData.ThicksDt = data.ThicksDt;
lc_OrgScanDatas.Add(lcOrgScanData); // lc_OrgScanDatas.Add(lcOrgScanData);
} // }
mHistoryDb.AddOrgScanDatas(lc_OrgScanDatas); // mHistoryDb.AddOrgScanDatas(lc_OrgScanDatas);
}; // };
markdebug_dt = DateTime.Now; // markdebug_dt = DateTime.Now;
}, // },
TimeSpan.FromMinutes(1)); // TimeSpan.FromMinutes(1));
} //}
#endregion #endregion
double[] ToRealThicks(IEnumerable<int> frame) double[] ToRealThicks(IEnumerable<int> frame)
......
...@@ -17,7 +17,7 @@ namespace FLY.Thick.BlowingScan.Server.Model ...@@ -17,7 +17,7 @@ namespace FLY.Thick.BlowingScan.Server.Model
public class HistoryDb : IShareDbService public class HistoryDb : IShareDbService
{ {
DbModel dbModel; DbModel dbModel;
OrgDbModel orgDbModel; //OrgDbModel orgDbModel;
public LocalDb localDb; public LocalDb localDb;
public BufferError ErrorBuffer; public BufferError ErrorBuffer;
#region IShareDbService #region IShareDbService
...@@ -34,10 +34,10 @@ namespace FLY.Thick.BlowingScan.Server.Model ...@@ -34,10 +34,10 @@ namespace FLY.Thick.BlowingScan.Server.Model
/// <param name="dbModel">数据库对象</param> /// <param name="dbModel">数据库对象</param>
/// <param name="orgDbModel">原始数据.数据库对象</param> /// <param name="orgDbModel">原始数据.数据库对象</param>
/// <param name="localDb">数据库的本地版</param> /// <param name="localDb">数据库的本地版</param>
public void Init(DbModel dbModel, OrgDbModel orgDbModel, LocalDb localDb) public void Init(DbModel dbModel, LocalDb localDb)
{ {
this.dbModel = dbModel; this.dbModel = dbModel;
this.orgDbModel = orgDbModel; //this.orgDbModel = orgDbModel;
this.localDb = localDb; this.localDb = localDb;
ErrorBuffer = new BufferError(); ErrorBuffer = new BufferError();
ErrorBuffer.Init(dbModel.TbError); ErrorBuffer.Init(dbModel.TbError);
...@@ -80,31 +80,31 @@ namespace FLY.Thick.BlowingScan.Server.Model ...@@ -80,31 +80,31 @@ namespace FLY.Thick.BlowingScan.Server.Model
} }
/// <summary> ///// <summary>
/// 按时间删除数据库 ///// 按时间删除数据库
/// </summary> ///// </summary>
public void KeepOrgDbSize(int day) //public void KeepOrgDbSize(int day)
{ //{
if (day <= 2) // if (day <= 2)
day = 2; // day = 2;
DateTime del_time = DateTime.Now - TimeSpan.FromDays(day); // DateTime del_time = DateTime.Now - TimeSpan.FromDays(day);
string det_time_str = del_time.ToStringOfSQLiteFieldType(); // string det_time_str = del_time.ToStringOfSQLiteFieldType();
List<string> sqls = new List<string>(); // List<string> sqls = new List<string>();
sqls.Add( // sqls.Add(
$"DELETE FROM {orgDbModel.TbSign.TableName}" + // $"DELETE FROM {orgDbModel.TbSign.TableName}" +
$" WHERE Time < {det_time_str}"); // $" WHERE Time < {det_time_str}");
sqls.Add( // sqls.Add(
$"DELETE FROM {orgDbModel.TbRoll.TableName}" + // $"DELETE FROM {orgDbModel.TbRoll.TableName}" +
$" WHERE Time < {det_time_str}"); // $" WHERE Time < {det_time_str}");
sqls.Add( // sqls.Add(
$"DELETE FROM {orgDbModel.TbOrgScanData.TableName}" + // $"DELETE FROM {orgDbModel.TbOrgScanData.TableName}" +
$" WHERE Time < {det_time_str}"); // $" WHERE Time < {det_time_str}");
orgDbModel.sqliteHelper.QueryTran(sqls); // orgDbModel.sqliteHelper.QueryTran(sqls);
} //}
/// <summary> /// <summary>
/// 保存产品参数 /// 保存产品参数
...@@ -316,59 +316,62 @@ namespace FLY.Thick.BlowingScan.Server.Model ...@@ -316,59 +316,62 @@ namespace FLY.Thick.BlowingScan.Server.Model
#region 原始数据 #region 原始数据
/// <summary> ///// <summary>
/// 记录 原始数据.转向信号 ///// 记录 原始数据.转向信号
/// </summary> ///// </summary>
/// <param name="lc_Sign"></param> ///// <param name="lc_Sign"></param>
public void AddSignData( //public void AddSignData(
Lc_Sign lc_Sign // Lc_Sign lc_Sign
) // )
{ //{
lc_Sign.ID = orgDbModel.TbSign.FreeID; // lc_Sign.ID = orgDbModel.TbSign.FreeID;
//SQLs // //SQLs
List<string> sqls = new List<string>(); // List<string> sqls = new List<string>();
var db_Sign = FLY.Thick.Blowing.Server.Model.OrgLc_AutoMapperProfile.Mapper.Map<Db_Sign>(lc_Sign); // var db_Sign = FLY.Thick.Blowing.Server.Model.OrgLc_AutoMapperProfile.Mapper.Map<Db_Sign>(lc_Sign);
sqls.Add(SQLiteHelper.GetInsertCommandText(db_Sign)); // sqls.Add(SQLiteHelper.GetInsertCommandText(db_Sign));
orgDbModel.sqliteHelper.QueryTranAsync(sqls); // orgDbModel.sqliteHelper.QueryTranAsync(sqls);
} //}
/// <summary> ///// <summary>
/// 记录 原始数据.辊信号 ///// 记录 原始数据.辊信号
/// </summary> ///// </summary>
/// <param name="lc_Roll"></param> ///// <param name="lc_Roll"></param>
public void AddRollData( //public void AddRollData(
Lc_Roll lc_Roll // Lc_Roll lc_Roll
) // )
{ //{
lc_Roll.ID = orgDbModel.TbRoll.FreeID; // lc_Roll.ID = orgDbModel.TbRoll.FreeID;
// //SQLs
// List<string> sqls = new List<string>();
// var db_Roll = FLY.Thick.Blowing.Server.Model.OrgLc_AutoMapperProfile.Mapper.Map<Db_Roll>(lc_Roll);
// sqls.Add(SQLiteHelper.GetInsertCommandText(db_Roll));
// orgDbModel.sqliteHelper.QueryTranAsync(sqls);
//}
///// <summary>
///// 记录 原始数据.扫描数据
///// </summary>
///// <param name="lc_OrgScanDatas"></param>
//public void AddOrgScanDatas(
// List<Lc_OrgScanData> lc_OrgScanDatas
// )
//{
// //SQLs
// List<string> sqls = new List<string>();
// foreach (var lc_OrgScanData in lc_OrgScanDatas)
// {
// lc_OrgScanData.ID = orgDbModel.TbOrgScanData.FreeID;
// var db_OrgScanData = OrgLc_AutoMapperProfile.Mapper.Map<Db_OrgScanData>(lc_OrgScanData);
// sqls.Add(SQLiteHelper.GetInsertCommandText(db_OrgScanData));
// }
// orgDbModel.sqliteHelper.QueryTranAsync(sqls);
//}
//SQLs
List<string> sqls = new List<string>();
var db_Roll = FLY.Thick.Blowing.Server.Model.OrgLc_AutoMapperProfile.Mapper.Map<Db_Roll>(lc_Roll);
sqls.Add(SQLiteHelper.GetInsertCommandText(db_Roll));
orgDbModel.sqliteHelper.QueryTranAsync(sqls); #endregion
}
/// <summary>
/// 记录 原始数据.扫描数据
/// </summary>
/// <param name="lc_OrgScanDatas"></param>
public void AddOrgScanDatas(
List<Lc_OrgScanData> lc_OrgScanDatas
)
{
//SQLs
List<string> sqls = new List<string>();
foreach (var lc_OrgScanData in lc_OrgScanDatas)
{
lc_OrgScanData.ID = orgDbModel.TbOrgScanData.FreeID;
var db_OrgScanData = OrgLc_AutoMapperProfile.Mapper.Map<Db_OrgScanData>(lc_OrgScanData);
sqls.Add(SQLiteHelper.GetInsertCommandText(db_OrgScanData));
}
orgDbModel.sqliteHelper.QueryTranAsync(sqls);
}
/// <summary> /// <summary>
/// 记录 原始数据.样品 /// 记录 原始数据.样品
...@@ -387,8 +390,6 @@ namespace FLY.Thick.BlowingScan.Server.Model ...@@ -387,8 +390,6 @@ namespace FLY.Thick.BlowingScan.Server.Model
dbModel.sqliteHelper.QueryTranAsync(sqls); dbModel.sqliteHelper.QueryTranAsync(sqls);
} }
#endregion
#region IDBShareService #region IDBShareService
public void GetProfile(AsyncCBHandler asyncDelegate, object asyncContext) public void GetProfile(AsyncCBHandler asyncDelegate, object asyncContext)
{ {
......
...@@ -157,10 +157,10 @@ namespace FLY.Thick.BlowingScan.Server ...@@ -157,10 +157,10 @@ namespace FLY.Thick.BlowingScan.Server
/// 数据库对象 /// 数据库对象
/// </summary> /// </summary>
DbModel dbModel; DbModel dbModel;
/// <summary> ///// <summary>
/// 原始数据 数据库对象 ///// 原始数据 数据库对象
/// </summary> ///// </summary>
OrgDbModel orgDbModel; //OrgDbModel orgDbModel;
/// <summary> /// <summary>
/// 数据库写操作 /// 数据库写操作
/// </summary> /// </summary>
...@@ -205,7 +205,7 @@ namespace FLY.Thick.BlowingScan.Server ...@@ -205,7 +205,7 @@ namespace FLY.Thick.BlowingScan.Server
dbModel = new DbModel(); dbModel = new DbModel();
orgDbModel = new OrgDbModel(); //orgDbModel = new OrgDbModel();
localDb = new LocalDb(); localDb = new LocalDb();
historyDb = new HistoryDb(); historyDb = new HistoryDb();
bulkDb = new BulkDb(); bulkDb = new BulkDb();
...@@ -240,16 +240,16 @@ namespace FLY.Thick.BlowingScan.Server ...@@ -240,16 +240,16 @@ namespace FLY.Thick.BlowingScan.Server
//--------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------
//数据库 //数据库
dbModel.Init(); dbModel.Init();
orgDbModel.Init(); //orgDbModel.Init();
historyDb.Init(dbModel, orgDbModel, localDb); historyDb.Init(dbModel, localDb);
historyDb.KeepDBSize(initParam.DBKeepMonth); historyDb.KeepDBSize(initParam.DBKeepMonth);
historyDb.KeepOrgDbSize(3); //historyDb.KeepOrgDbSize(3);
PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD, () => //PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD, () =>
{ //{
//避免1个月都不关程序,每天检查一次 // //避免1个月都不关程序,每天检查一次
historyDb.KeepOrgDbSize(3); // historyDb.KeepOrgDbSize(3);
}, TimeSpan.FromDays(1)); //}, TimeSpan.FromDays(1));
bulkDb.Init(historyDb, localDb, dbModel); bulkDb.Init(historyDb, localDb, dbModel);
......
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