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

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

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