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

修复 追边测厚仪 数据重复3次问题

parent 21640179
......@@ -216,7 +216,17 @@ namespace FLY.FeedbackRenZiJia.Server
//记录改变!!!!
mHeatChanged.Add(mHeatCell.Heats);
UndoIdx = mHeatChanged.mItem.Count() - 1;
//记录到数据库
if (lastLcThickHeat != null)
{
HeatChanged.ITEM heat = mHeatChanged.mItem.Last();
lastLcThickHeat.HTime = heat.Time;
lastLcThickHeat.Heats = heat.Heats;
setLcThickHeatIsStable(lastLcThickHeat);
mHistoryDb.AddThickHeat(lastLcThickHeat);
}
};
mHeatCell.AfterClearOffsetsEvent += (c) => {
......@@ -693,6 +703,20 @@ namespace FLY.FeedbackRenZiJia.Server
}
void setLcThickHeatIsStable(Lc_ThickHeat lcThickHeat)
{
DateTime time = lcThickHeat.Time;
DateTime htime = lcThickHeat.HTime;
double filmLength = lcThickHeat.FilmLength;
double filmVelocity = lcThickHeat.FilmVelocity;
lcThickHeat.IsStable = time > (htime + TimeSpan.FromSeconds(Delay) + TimeSpan.FromMinutes(filmLength / filmVelocity));
}
/// <summary>
/// 最后一次保存的记录
/// </summary>
Lc_ThickHeat lastLcThickHeat=null;
void Add(DateTime time, DateTime endtime, bool isBackw, TimeSpan period, int rotateCnt,
int orgboltno, double rAngle, double filmLength, double filmVelocity, double K,
double[] frame, List<Thick.Blowing.IService.BoltMapCell> boltMaps)
......@@ -712,15 +736,9 @@ namespace FLY.FeedbackRenZiJia.Server
if (invalid_cnt > NBolts / 2)//有一半数据都是无效的
return;
bool need_cal = true;
//获取对应方向的加热幅
HeatChanged.ITEM heat = mHeatChanged.Get(time + period - mHeatBuf.Delay);
if (heat != mHeatChanged.mItem.Last())
{
//后面还加了热, 不用自控
need_cal = false;
}
mHistoryDb.AddThickHeat(new Lc_ThickHeat()
HeatChanged.ITEM heat = mHeatChanged.mItem.Last();
var lcThickHeat = new Lc_ThickHeat()
{
Time = time,
EndTime = endtime,
......@@ -729,16 +747,18 @@ namespace FLY.FeedbackRenZiJia.Server
RCnt = rotateCnt,
OrgBoltNo = orgboltno,
RAngle = rAngle,
FilmLength= filmLength,
FilmLength = filmLength,
FilmVelocity = filmVelocity,
K= K,
Thicks=frame,
K = K,
Thicks = frame,
Boltmap = boltMaps,
IsStable = time>(heat.Time+ TimeSpan.FromSeconds(Delay)+ TimeSpan.FromMinutes(filmLength / filmVelocity)),
HTime = heat.Time,
Heats=heat.Heats
});
Heats = heat.Heats
};
setLcThickHeatIsStable(lcThickHeat);
mHistoryDb.AddThickHeat(lcThickHeat);
lastLcThickHeat = lcThickHeat;
mHeatBuf.IsIntoAutoONo = mHeatCell.IsInAutoONo;
......@@ -773,8 +793,8 @@ namespace FLY.FeedbackRenZiJia.Server
mHeatCell.SetThickPercents(d.Thicks);
if (IsAuto && need_cal)//如果自控中!!!
if (IsAuto && lcThickHeat.IsStable)//如果自控中!!!
{
mHeatCell.Auto();
}
......@@ -800,23 +820,12 @@ namespace FLY.FeedbackRenZiJia.Server
}
#region 撤销
private int undoidx = 0;
/// <summary>
/// undo 的序号
/// </summary>
public int UndoIdx
{
get {
return undoidx;
}
protected set {
if (undoidx != value)
{
undoidx = value;
NotifyPropertyChanged("UndoIdx");
}
}
}
public int UndoIdx { get; protected set; }
//读取 UndoIdx 的 加热
public void Undo()
{
......
......@@ -36,7 +36,7 @@ namespace FLY.FeedbackRenZiJia.Server.Model
CreateMap<Lc_ThickHeat, Db_ThickHeat>()
.ForMember(s => s.RPeriod, opt =>
{
opt.MapFrom(s => s.RPeriod.TotalMinutes);
opt.MapFrom(s => Math.Round(s.RPeriod.TotalMinutes,2));
})
.ForMember(s => s.Thicks, opt =>
{
......
......@@ -27,6 +27,8 @@ namespace FLY.Thick.Blowing.Server
/// </summary>
public class GM_BlowingFix : GM_Base, IBlowingFixService, ISaveToXml
{
NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
const int MARKNO_PROFILE_ADD = 87;
const int MARKNO_PROFILE_CHANGED = 88;
......@@ -1182,7 +1184,7 @@ namespace FLY.Thick.Blowing.Server
/// <param name="frameinfo"></param>
/// <param name="index_start"></param>
/// <param name="index_end"></param>
/// <returns></returns>
/// <returns>false 数据不存在</returns>
bool GetFilmInfoADIndex(FRAME_INFO frameinfo, out int index_start, out int index_end)
{
index_start = mADList.No2Index(frameinfo.NoStartAD);
......@@ -1198,23 +1200,28 @@ namespace FLY.Thick.Blowing.Server
return true;
}
void mPDetect_FilmInfoChangedEvent(object sender, BlowingDetect.FilmInfoChangedEventArgs e)
{
int idx;
int ret = ADListFastSearchIndex(e.Time, out idx);
if (ret < 0)//发送在过去
{
if (mADList.Count > 0)
{
mADListToDoNo = mADList.Index2No(0);
mADListToDoNo_ToFilmInfo = mADListToDoNo;
}
}
else if (ret == 0)
var ret = ADListFastSearchIndex(e.Time, out int idx);
switch (ret)
{
mADListToDoNo = mADList.Index2No(idx);
mADListToDoNo_ToFilmInfo = mADListToDoNo;
case ADListFastSearchIndexResult.Before://发送在过去
{
mADListToDoNo = mADList.Index2No(0);
mADListToDoNo_ToFilmInfo = mADListToDoNo;
}
break;
case ADListFastSearchIndexResult.Now://发生在列表时间内
{
mADListToDoNo = mADList.Index2No(idx);
mADListToDoNo_ToFilmInfo = mADListToDoNo;
}
break;
case ADListFastSearchIndexResult.Future:
{
//未来的,不处理
}
break;
}
}
......@@ -1312,6 +1319,8 @@ namespace FLY.Thick.Blowing.Server
MarkDebugInit();
}
#region 记录测试数据
DateTime markdebug_dt = DateTime.MinValue;
void MarkDebugInit()
{
......@@ -1371,7 +1380,8 @@ namespace FLY.Thick.Blowing.Server
},
TimeSpan.FromMinutes(1));
}
#endregion
void UpdateCurrFrame()
{
FObjBase.PollModule.Current.Poll_JustOnce(
......@@ -1506,56 +1516,101 @@ namespace FLY.Thick.Blowing.Server
}
return boltindex;
}
enum ADListFastSearchIndexResult
{
/// <summary>
/// 时间点在列表以前;
/// </summary>
Before = -1,
/// <summary>
/// 时间点在列表中;
/// </summary>
Now = 0,
/// <summary>
/// 时间点在列表的未来;
/// </summary>
Future = 1
}
/// <summary>
/// 返回 -1, 时间点在列表以前;
/// 返回 0, 时间点在列表中;
/// 返回 1, 时间点在列表的未来;
/// 找到在 dt 前最近的 ADList 序号;
/// 当ADList 没有数据,返回 Future;
/// 已知AD列表每个数据之间的时间差,快速推断结果;
/// </summary>
/// <param name="dt"></param>
/// <param name="index"></param>
/// <returns></returns>
int ADListFastSearchIndex(DateTime dt, out int index)
ADListFastSearchIndexResult ADListFastSearchIndex(DateTime dt, out int index)
{
index = 0;
if (mADList.Count <= 0)
return 1;
if (mADList.Count <= 0)//列表没有数据, 只能当它在未来
return ADListFastSearchIndexResult.Future;
int offset = (int)((mADList.Last().Time - dt).TotalSeconds * 10);
index = mADList.Count-offset-1;
if (index >= mADList.Count)
return 1;
else if (index < 0)
return -1;
if (dt > mADList.Last().Time)
return ADListFastSearchIndexResult.Future;
else if (dt < mADList.First().Time)
return ADListFastSearchIndexResult.Before;
else
{
if(mADList[index].Time == dt)
int offset = (int)((mADList.Last().Time - dt).TotalSeconds / datOf1s_interval.TotalSeconds);
index = mADList.Count - offset - 1;//大约在这个位置附近
//安全限制
if (index >= mADList.Count)
index = mADList.Count() - 1;
else if (index < 0)
index = 0;
if (mADList[index].Time == dt)
{
return 0;
//已经找到就是它!!!!
}
else if(mADList[index].Time > dt)
else if (mADList[index].Time > dt)
{
do{
index--;
if(index<0)
return -1;
while (true)
{
index--;
if (index <= 0)
{
index = 0;//最前面一个了
break;
}
if (mADList[index].Time <= dt)
{
//找到了
break;
}
}
while( mADList[index].Time > dt);
return 0;
}
}
else
{
do{
index++;
if(index>=mADList.Count)
return 1;
while(true)
{
index++;//测试一下
if (index >= mADList.Count)
{
//到顶了,不找了
index--;
break;
}
else if (mADList[index].Time == dt)
{
//找到了,就是它
break;
}
else if (mADList[index].Time > dt)
{
//上一个小于,现在大于,上一个就对了
index--;
break;
}
}
while( mADList[index].Time < dt);
return index;
}
return ADListFastSearchIndexResult.Now;
}
}
......@@ -1742,8 +1797,10 @@ namespace FLY.Thick.Blowing.Server
int adlist_index = mADList.No2Index(mADListToDoNo_ToFilmInfo);//当前在处理的 数据点
if (adlist_index >= mADList.Count)
return;//没有数据需要处理
if (adlist_index < 0)//全部都要处理
adlist_index = 0;
//当没有任何一幅数据时, frameinfo_index = mFrameInfoList.Count = 0
int frameinfo_index = Math.Max(mFrameInfoList.Count - 1, 0);
......@@ -1798,8 +1855,12 @@ namespace FLY.Thick.Blowing.Server
else
{
frameinfo = mFrameInfoList[frameinfo_index];
if (i <= mADList.No2Index(frameinfo.NoEndAD)) //清空数据,重新来过, ????????????
if (i <= mADList.No2Index(frameinfo.NoEndAD))
{
//当为新数据, i应该>mADList.No2Index(frameinfo.NoEndAD)
//能进这里,证明是要重新计算
//清空数据,重新来过
frameinfo.StartTime = adcell.Time;
frameinfo.EndTime = adcell.Time;
frameinfo.direction = adcell.Direction;
......@@ -1863,10 +1924,10 @@ namespace FLY.Thick.Blowing.Server
RPeriod = mPDetect.RenZiJiaPeriod,
RCnt = frameinfo.rotationCnt,
OrgBoltNo = OrgBoltNo,
RAngle = mPDetect.RAngle,
FilmLength = mPDetect.FilmLength,
FilmVelocity = mPDetect.FilmVelocity,
K = mProfileParam.K,
RAngle = Math.Round(mPDetect.RAngle,2),
FilmLength = Math.Round(mPDetect.FilmLength,2),
FilmVelocity = Math.Round(mPDetect.FilmVelocity,2),
K = Math.Round(mProfileParam.K,3),
Thicks = realthicks,
Boltmap = map
};
......@@ -2000,7 +2061,8 @@ namespace FLY.Thick.Blowing.Server
}
}
//检测数据更新情况,放入数据库
//检测数据更新情况,放入数据库, 数据不能被修改
foreach (var frameinfo in mFrameInfoList)
{
if (frameinfo.renZiJiaDataEventArgsHasChanged)
......
......@@ -39,7 +39,7 @@ namespace FLY.Thick.Blowing.Server.Model
CreateMap<Lc_ScanData, Db_ScanData>()
.ForMember(s => s.RPeriod, opt =>
{
opt.MapFrom(s => s.RPeriod.TotalMinutes);
opt.MapFrom(s => Math.Round(s.RPeriod.TotalMinutes,2));
})
.ForMember(s => s.Thicks, opt =>
{
......
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