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

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

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