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

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

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