Commit 9671ddff authored by 潘栩锋's avatar 潘栩锋 🚴

还在修改 样品采集,添加很多报警

parent 7e126e15
...@@ -64,16 +64,10 @@ namespace FLY.Thick.Base.UI ...@@ -64,16 +64,10 @@ namespace FLY.Thick.Base.UI
/// </summary> /// </summary>
public bool Enable { get; set; } public bool Enable { get; set; }
/// <summary>
/// 参数:速度
/// </summary>
public UInt32 Velocity { get; set; }
/// <summary> /// <summary>
/// 参数:样品点范围 /// 参数:样品点范围
/// </summary> /// </summary>
public int Range { get; set; } public int SampleRange { get; set; }
/// <summary> /// <summary>
/// 参数:移动滤波 ,窗口值 /// 参数:移动滤波 ,窗口值
...@@ -92,6 +86,18 @@ namespace FLY.Thick.Base.UI ...@@ -92,6 +86,18 @@ namespace FLY.Thick.Base.UI
/// 异常值 /// 异常值
/// </summary> /// </summary>
public int ErrValue { get; set; } public int ErrValue { get; set; }
/// <summary>
/// 当前 样品X_AD/样品0_AD 与 上一次比较 差异比例 单位不是%
/// </summary>
public double CrossErrPercent { get; set; }
/// <summary>
/// 异常比较 时间间隔范围;
/// 两次时间点比较, 时间点的间隔最大时长。 大于它无效,不能比较
/// </summary>
public int ErrIntervalMin { get; set; }
/// <summary> /// <summary>
/// 参数:样品点参数 /// 参数:样品点参数
/// </summary> /// </summary>
...@@ -99,7 +105,7 @@ namespace FLY.Thick.Base.UI ...@@ -99,7 +105,7 @@ namespace FLY.Thick.Base.UI
/// <summary> /// <summary>
/// 参数:特征查找范围 /// 参数:特征查找范围
/// </summary> /// </summary>
public int Search { get; set; } public int SearchRange { get; set; }
/// <summary> /// <summary>
/// 参数:特征参数 /// 参数:特征参数
/// </summary> /// </summary>
...@@ -133,13 +139,12 @@ namespace FLY.Thick.Base.UI ...@@ -133,13 +139,12 @@ namespace FLY.Thick.Base.UI
this.getSampleService = getSampleService; this.getSampleService = getSampleService;
this.gageInfoService = gageInfoService; this.gageInfoService = gageInfoService;
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Enable), this, nameof(Enable)); Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Enable), this, nameof(Enable));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Velocity), this, nameof(Velocity)); Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.SampleRange), this, nameof(SampleRange));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Range), this, nameof(Range));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Window), this, nameof(Window)); Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Window), this, nameof(Window));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.IsCheckByPercent), this, nameof(IsCheckByPercent)); Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.IsCheckByPercent), this, nameof(IsCheckByPercent));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.ErrPercent), this, nameof(ErrPercent)); Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.ErrPercent), this, nameof(ErrPercent));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.ErrValue), this, nameof(ErrValue)); Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.ErrValue), this, nameof(ErrValue));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Search), this, nameof(Search)); Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.SearchRange), this, nameof(SearchRange));
Samples = new SampleCell[this.getSampleService.Samples.Count()]; Samples = new SampleCell[this.getSampleService.Samples.Count()];
Features = new SampleFeature[this.getSampleService.Features.Count()]; Features = new SampleFeature[this.getSampleService.Features.Count()];
...@@ -173,7 +178,7 @@ namespace FLY.Thick.Base.UI ...@@ -173,7 +178,7 @@ namespace FLY.Thick.Base.UI
this.getSampleService.Enable = this.Enable; this.getSampleService.Enable = this.Enable;
this.getSampleService.Range = this.Range; this.getSampleService.SampleRange = this.SampleRange;
this.getSampleService.Velocity = this.Velocity; this.getSampleService.Velocity = this.Velocity;
this.getSampleService.Window = this.Window; this.getSampleService.Window = this.Window;
this.getSampleService.IsCheckByPercent = this.IsCheckByPercent; this.getSampleService.IsCheckByPercent = this.IsCheckByPercent;
...@@ -190,7 +195,7 @@ namespace FLY.Thick.Base.UI ...@@ -190,7 +195,7 @@ namespace FLY.Thick.Base.UI
sample_desp.OrgAD = sample_src.OrgAD; sample_desp.OrgAD = sample_src.OrgAD;
sample_desp.Position = sample_src.Position; sample_desp.Position = sample_src.Position;
} }
this.getSampleService.Search = this.Search; this.getSampleService.SearchRange = this.SearchRange;
for (int i = 0; i < Features.Count(); i++) for (int i = 0; i < Features.Count(); i++)
{ {
var feature_src = this.Features[i]; var feature_src = this.Features[i];
......
...@@ -15,14 +15,14 @@ namespace FLY.Thick.Base.Client ...@@ -15,14 +15,14 @@ namespace FLY.Thick.Base.Client
/// 边界查找服务 构造 /// 边界查找服务 构造
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
public GetSampleServiceClient(UInt32 id) : base(id) { init(); } public GetSampleServiceClient(UInt32 id) : base(id) { }
/// <summary> /// <summary>
/// 边界查找服务 构造 /// 边界查找服务 构造
/// </summary> /// </summary>
/// <param name="serviceId">服务id</param> /// <param name="serviceId">服务id</param>
/// <param name="connName">连接器</param> /// <param name="connName">连接器</param>
public GetSampleServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { init(); } public GetSampleServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { }
...@@ -41,7 +41,7 @@ namespace FLY.Thick.Base.Client ...@@ -41,7 +41,7 @@ namespace FLY.Thick.Base.Client
/// <summary> /// <summary>
/// 参数:样品点范围 /// 参数:样品点范围
/// </summary> /// </summary>
public int Range { get; set; } public int SampleRange { get; set; }
/// <summary> /// <summary>
...@@ -65,19 +65,23 @@ namespace FLY.Thick.Base.Client ...@@ -65,19 +65,23 @@ namespace FLY.Thick.Base.Client
/// <summary> /// <summary>
/// 样品 /// 样品
/// </summary> /// </summary>
public SampleCell[] Samples { get; set; } = new SampleCell[3]; public SampleCell[] Samples { get; set; } = new SampleCell[] {
new SampleCell(),new SampleCell(),new SampleCell()
};
/// <summary> /// <summary>
/// 查找公差 /// 查找公差
/// </summary> /// </summary>
public int Search { get; set; } public int SearchRange { get; set; }
/// <summary> /// <summary>
/// 特征 相识度 0 正, 1 反 /// 特征 相识度 0 正, 1 反
/// </summary> /// </summary>
public SampleFeature[] Features { get; set; } = new SampleFeature[2]; public SampleFeature[] Features { get; set; } = new SampleFeature[] {
new SampleFeature(),new SampleFeature()
};
public double CrossErrPercent { get; set; }
public int ErrIntervalMin { get; set; }
/// <summary> /// <summary>
/// ///
...@@ -88,16 +92,6 @@ namespace FLY.Thick.Base.Client ...@@ -88,16 +92,6 @@ namespace FLY.Thick.Base.Client
} }
#endregion #endregion
void init()
{
for (int i = 0; i < Samples.Count(); i++)
Samples[i] = new SampleCell();
for (int i = 0; i < Features.Count(); i++)
Features[i] = new SampleFeature();
}
} }
} }
...@@ -24,43 +24,64 @@ namespace FLY.Thick.Base.IService ...@@ -24,43 +24,64 @@ namespace FLY.Thick.Base.IService
/// <summary> /// <summary>
/// 参数:速度 /// 参数:速度
/// </summary> /// </summary>
UInt32 Velocity { get; set; } UInt32 Velocity { get; }
/// <summary> /// <summary>
/// 参数:样品点范围 /// 参数:样品点范围 单位:脉冲
/// 样品点直径为 Range*2
/// </summary> /// </summary>
int Range { get; set; } int SampleRange { get; set; }
/// <summary> /// <summary>
/// 参数:移动滤波 ,窗口值 /// 参数:移动滤波 ,窗口值 单位:min
/// </summary> /// </summary>
int Window { get; set; } int Window { get; set; }
/// <summary> /// <summary>
/// 使用%方式检查异常 /// 使用%方式检查异常
/// 1.滤波前AD 与 滤波后AD比较
/// 2.当前样品AD 与 上一次样品AD比较
/// 3.当前 样品X_AD/样品0_AD 与 上一次比较
/// </summary> /// </summary>
bool IsCheckByPercent { get; set; } bool IsCheckByPercent { get; set; }
/// <summary> /// <summary>
/// 异常% /// 异常比例 单位不是%
/// </summary> /// </summary>
double ErrPercent { get; set; } double ErrPercent { get; set; }
/// <summary> /// <summary>
/// 异常值 /// 异常值
/// </summary> /// </summary>
int ErrValue { get; set; } int ErrValue { get; set; }
/// <summary>
/// 当前 样品X_AD/样品0_AD 与 上一次比较 差异比例 单位不是%
/// </summary>
double CrossErrPercent { get; set; }
/// <summary>
/// 异常比较 时间间隔范围;
/// 两次时间点比较, 时间点的间隔最大时长。 大于它无效,不能比较
/// </summary>
int ErrIntervalMin { get; set; }
/// <summary> /// <summary>
/// 参数:样品点参数 /// 参数:样品点参数
/// </summary> /// </summary>
[PropertyPush] [PropertyPush]
SampleCell[] Samples { get; } SampleCell[] Samples { get; }
/// <summary> /// <summary>
/// 参数:特征查找范围 /// 参数:特征查找范围 单位:脉冲
/// 取样范围 会扩大为 -SearchRange ~ +SearchRange
/// </summary> /// </summary>
int Search { get; set; } int SearchRange { get; set; }
/// <summary> /// <summary>
/// 参数:特征参数 /// 参数:特征参数 0:正方向, 1:反方向
/// </summary> /// </summary>
[PropertyPush] [PropertyPush]
SampleFeature[] Features { get; } SampleFeature[] Features { get; }
......
...@@ -239,8 +239,10 @@ namespace FLY.Thick.Base.Server ...@@ -239,8 +239,10 @@ namespace FLY.Thick.Base.Server
public class TempFilter2 public class TempFilter2
{ {
List<TempFilterData> Datas = new List<TempFilterData>(); List<TempFilterData> Datas = new List<TempFilterData>();
const int KeepTimeMin = 6;
const int KeepCount = 9;
TimeSpan keepTime = TimeSpan.FromMinutes(KeepTimeMin);
TimeSpan keepTime = TimeSpan.FromMinutes(6);
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
...@@ -261,35 +263,41 @@ namespace FLY.Thick.Base.Server ...@@ -261,35 +263,41 @@ namespace FLY.Thick.Base.Server
{ {
filterTime = TimeSpan.Zero; filterTime = TimeSpan.Zero;
} }
keepTime = TimeSpan.FromMinutes(Math.Max(6, filterTime.TotalMinutes * 3));
var now = DateTime.Now; var now = DateTime.Now;
Datas.RemoveAll(d => d.Time < now - keepTime); keepTime = TimeSpan.FromMinutes(Math.Max(KeepTimeMin, filterTime.TotalMinutes * 3));
KeepSize();
Datas.Add(new TempFilterData() Datas.Add(new TempFilterData()
{ {
Ad = ad, Ad = ad,
FilterAd = ad, FilterAd = ad,
Time = now Time = now
}); });
double sum = 0; double sum = ad;
int cnt = 0; int cnt = 1;
for (int i = 0; i < Datas.Count(); i++) for (int i = 1; i < Datas.Count(); i++)
{
var d = Datas[Datas.Count()-1-i];
if (d.Time >= (now - filterTime) && d.IsReset == false)
{ {
sum += d.Ad; int index = Datas.Count() - 1 - i;
cnt++; var d = Datas[index];
} if (d.IsReset) {
else { //这个是reset 信号,退出
break; break;
} }
} if (d.Time < (now - filterTime))
if (cnt > 0)
{ {
Datas.Last().FilterAd = (int)Math.Round(sum / cnt); //太久了,退出
break;
} }
return Datas.Last().FilterAd;
sum += d.Ad;
cnt++;
}
ad = (int)Math.Round(sum / cnt);
Datas.Last().FilterAd = ad;
return ad;
} }
/// <summary> /// <summary>
...@@ -297,14 +305,49 @@ namespace FLY.Thick.Base.Server ...@@ -297,14 +305,49 @@ namespace FLY.Thick.Base.Server
/// </summary> /// </summary>
public void Reset() public void Reset()
{ {
var now = DateTime.Now; KeepSize();
Datas.RemoveAll(d => d.Time < now - keepTime); if (Datas.Count > 0 && !Datas.Last().IsReset)
{
//上一次是复位信号,就不需要再添加一个复位信号了
Datas.Add(new TempFilterData() { IsReset = true, Time = DateTime.Now }); Datas.Add(new TempFilterData() { IsReset = true, Time = DateTime.Now });
} }
}
void KeepSize()
{
var now = DateTime.Now;
int index = Datas.FindIndex(d => d.Time >= now - keepTime);
if (index <= 0)
return;
//小于index, 都是要删除的
//但必须保证删除后 Datas.Length >=10
int len = Datas.Count() - index;
if (len < KeepCount)
index = Datas.Count() - KeepCount;
if (index <= 0)
return;
Datas.RemoveRange(0, index);
}
public List<TempFilterData> GetDatas() public List<TempFilterData> GetDatas()
{ {
return Datas; return Datas;
} }
public int GetLastAd(DateTime time)
{
for (int i = 1; i < Datas.Count; i++)
{
int index = Datas.Count() - 1 - i;
var d = Datas[index];
if (d.Time < time)
return -1;//时间太早了,没有数据
if (Datas[index].IsReset)
continue;
return d.Ad;
}
return -1;//没有数据
}
} }
} }
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