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

1. 优化 边界查找拐点方式算法改进,温修范围%设置

2. 修复 AD盒设置,ip设置界面每次都重新connect,导致先读,再写入,画面看到好像没有改一样。
parent fb7cdf6d
......@@ -10,6 +10,7 @@
<sys:String x:Key="strSetTemperature">SetTemp</sys:String>
<sys:String x:Key="strTemperatureAD">TempAD</sys:String>
<sys:String x:Key="strTemperatureRange">TempRange</sys:String>
<sys:String x:Key="strTempRangePercent">TempRange%</sys:String>
<sys:String x:Key="strFilter">Filter</sys:String>
<sys:String x:Key="strSensorWidth">SensorWidth</sys:String>
<sys:String x:Key="strBorderLessen">B.Lessen</sys:String>
......
......@@ -13,6 +13,7 @@
<sys:String x:Key="strInflectionPoint">拐点查找</sys:String>
<sys:String x:Key="strSetTemperature">设置温修</sys:String>
<sys:String x:Key="strTemperatureAD">温修AD</sys:String>
<sys:String x:Key="strTempRangePercent">温修范围%</sys:String>
<sys:String x:Key="strTemperatureRange">温修范围</sys:String>
<sys:String x:Key="strFilter">滤波器</sys:String>
<sys:String x:Key="strSensorWidth">探头直径</sys:String>
......
......@@ -86,18 +86,31 @@
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strSetTemperature}" />
<ToggleButton Style="{StaticResource ToggleButtonStyle1}" IsChecked="{Binding TempADBySet}" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="5" Visibility="{Binding TempADBySet, Converter={StaticResource ResourceKey=visbilityconv},ConverterParameter=CollapsedWhenTrue}">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeader}" Text="{DynamicResource strTemperatureAD}" />
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}" Text="{Binding TempAD}" />
</StackPanel>
<StackPanel Orientation="Vertical" Margin="5" Visibility="{Binding TempADBySet, Converter={StaticResource ResourceKey=visbilityconv},ConverterParameter=Collapsed}">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strTemperatureAD}" />
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding TempAD}" />
</StackPanel>
<Grid>
<StackPanel Orientation="Vertical" Margin="5" Visibility="{Binding TempADBySet, Converter={StaticResource visbilityconv},ConverterParameter=CollapsedWhenTrue}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeader}" Text="{DynamicResource strTemperatureAD}" />
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="{Binding TempAD}" />
</StackPanel>
<StackPanel Orientation="Vertical" Margin="5" Visibility="{Binding TempADBySet, Converter={StaticResource visbilityconv},ConverterParameter=Collapsed}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strTemperatureAD}" />
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding TempAD}" />
</StackPanel>
</Grid>
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strTemperatureRange}" />
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding TempRange}" />
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strTempRangePercent}" />
<ToggleButton Style="{StaticResource ToggleButtonStyle1}" IsChecked="{Binding IsTempRangeByPercent}" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Margin="5" >
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strTemperatureRange}" />
<Grid>
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding TempRange}" Visibility="{Binding IsTempRangeByPercent, Converter={StaticResource visbilityconv},ConverterParameter=CollapsedWhenTrue}"/>
<StackPanel Orientation="Horizontal" Visibility="{Binding IsTempRangeByPercent, Converter={StaticResource visbilityconv},ConverterParameter=Collapsed}">
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding TempRangePercent,Converter={StaticResource percentconv}}"/>
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="%"/>
</StackPanel>
</Grid>
</StackPanel>
</StackPanel>
<WrapPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical" Margin="5">
......
......@@ -24,8 +24,6 @@ namespace ThickTcpUiInWindow
public partial class Page_FlyAD : Page
{
FlyADServiceClient mFlyADService;
IPEndPoint ServerIPEP;
TDGageServiceClient mTDGageService;
......
......@@ -23,233 +23,72 @@ namespace FLY.Thick.Base.Client
}
#region IBorderSearchService 成员
private bool enable;
public bool Enable
{
get
{
return enable;
}
set
{
if (enable != value)
{
enable = value;
NotifyPropertyChanged("Enable");
}
}
}
bool isbreakdetect = true;
public bool Enable { get; set; }
/// <summary>
/// 边界拐点检测,找到的边界更加精确
/// </summary>
public bool IsBreakDetect
{
get
{
return isbreakdetect;
}
set
{
if (isbreakdetect != value)
{
isbreakdetect = value;
NotifyPropertyChanged("IsBreakDetect");
}
}
}
private Range valid = new Range();
public Range Valid
{
get
{
return valid;
}
}
private Range border_backw = new Range();
public Range Border_Backw
{
get
{
return border_backw;
}
}
private Range border_forw = new Range();
public Range Border_Forw
{
get
{
return border_forw;
}
}
private int width;
public bool IsBreakDetect { get; set; } = true;
public Range Valid { get; } = new Range();
public Range Border_Backw { get; } = new Range();
public Range Border_Forw { get; } = new Range();
/// <summary>
/// 当前膜宽,测量出来的,单位是 脉冲
/// </summary>
public int Width
{
get { return width; }
protected set
{
if (width != value)
{
width = value;
NotifyPropertyChanged("Width");
}
}
}
private int mid;
public int Width { get; protected set; }
/// <summary>
/// 膜中间位置 单位 脉冲
/// </summary>
public int Mid
{
get { return mid; }
protected set
{
if (mid != value)
{
mid = value;
NotifyPropertyChanged("Mid");
}
}
}
public int Mid { get; protected set; }
bool tempADBySet = false;
/// <summary>
/// 手动设置温修AD值
/// </summary>
public bool TempADBySet
{
get
{
return tempADBySet;
}
set
{
if (tempADBySet != value)
{
tempADBySet = value;
NotifyPropertyChanged("TempADBySet");
}
public bool TempADBySet { get; set; }
}
}
public int TempAD { get; set; }
private int tempad;
public int TempAD
{
get
{
return tempad;
}
set
{
if (tempad != value)
{
tempad = value;
NotifyPropertyChanged("TempAD");
}
}
}
private int temprange;
public int TempRange
{
get
{
return temprange;
}
set
{
if (temprange != value)
{
temprange = value;
NotifyPropertyChanged("TempRange");
}
}
}
private int n;
public int N
{
get
{
return n;
}
set
{
if (n != value)
{
n = value;
NotifyPropertyChanged("N");
}
}
}
public int TempRange { get; set; }
/// <summary>
/// 温修范围是温修的百分比
/// </summary>
public bool IsTempRangeByPercent { get; set; } = true;
/// <summary>
/// 温修范围百分比
/// </summary>
public double TempRangePercent { get; set; } = 0.02;
public int N { get; set; }
private int sensorwidth;
/// <summary>
/// 探头直径,单位脉冲, 膜宽 = 边界范围 - 探头直径
/// </summary>
public int SensorWidth
{
get
{
return sensorwidth;
}
set
{
if (sensorwidth != value)
{
sensorwidth = value;
NotifyPropertyChanged("SensorWidth");
}
}
}
private int n2;
public int N2
{
get
{
return n2;
}
set
{
if (n2 != value)
{
n2 = value;
NotifyPropertyChanged("N2");
}
}
}
private int n3;
public int N3
{
get
{
return n3;
}
set
{
if (n3 != value)
{
n3 = value;
NotifyPropertyChanged("N3");
}
}
}
public int SensorWidth { get; set; }
public int N2 { get; set; }
public int N3 { get; set; }
private int[] datas = null;
/// <summary>
/// 用于调试, 进入到边界查找的数据
/// </summary>
public int[] Datas
{
get { return datas; }
protected set
{
datas = value;
NotifyPropertyChanged("Datas");
}
}
[PropertyChanged.DoNotCheckEquality]
public int[] Datas { get; protected set; } = null;
#endregion
#region INotifyPropertyChanged 成员
......@@ -278,12 +117,15 @@ namespace FLY.Thick.Base.Client
p.valid = Valid;
p.sensorwidth = SensorWidth;
p.isBreakDetect = IsBreakDetect;
p.isTempRangeByPercent = IsTempRangeByPercent;
p.tempRangePercent = TempRangePercent;
string json = Newtonsoft.Json.JsonConvert.SerializeObject(p);
//获取所有数据,设置推送
CurrObjSys.SetValueEx(
mConn, mServerID, ID,
BORDERSEARCH_OBJ_INTERFACE.SET_PARAMS,
p.ToBytes());
Misc.Converter.StringToBytes(json));
}
public override void Dispose()
{
......@@ -315,10 +157,10 @@ namespace FLY.Thick.Base.Client
{
case BORDERSEARCH_OBJ_INTERFACE.GET_PARAMS:
{
BORDERSEARCH_OBJ_INTERFACE.Pack_Params p = new BORDERSEARCH_OBJ_INTERFACE.Pack_Params();
if (!p.TryParse(infodata))
return;
string json = Misc.Converter.BytesToString(infodata);
var p = Newtonsoft.Json.JsonConvert.DeserializeObject<BORDERSEARCH_OBJ_INTERFACE.Pack_Params>(json);
Enable = p.enable;
Valid.Begin = p.valid.Begin;
Valid.End = p.valid.End;
......@@ -330,12 +172,17 @@ namespace FLY.Thick.Base.Client
N2=p.n2;
N3=p.n3;
IsBreakDetect = p.isBreakDetect;
IsTempRangeByPercent = p.isTempRangeByPercent;
TempRangePercent = p.tempRangePercent;
} break;
case BORDERSEARCH_OBJ_INTERFACE.GET_RESULT:
{
BORDERSEARCH_OBJ_INTERFACE.Pack_Result p = new BORDERSEARCH_OBJ_INTERFACE.Pack_Result();
if (!p.TryParse(infodata))
return;
string json = Misc.Converter.BytesToString(infodata);
var p = Newtonsoft.Json.JsonConvert.DeserializeObject<BORDERSEARCH_OBJ_INTERFACE.Pack_Result>(json);
Border_Forw.Begin = p.borderForw.Begin;
Border_Forw.End = p.borderForw.End;
Border_Backw.Begin = p.borderBackw.Begin;
......@@ -345,9 +192,11 @@ namespace FLY.Thick.Base.Client
} break;
case BORDERSEARCH_OBJ_INTERFACE.GET_DATAS:
{
BORDERSEARCH_OBJ_INTERFACE.Pack_Data p = new BORDERSEARCH_OBJ_INTERFACE.Pack_Data();
if (!p.TryParse(infodata))
return;
string json = Misc.Converter.BytesToString(infodata);
var p = Newtonsoft.Json.JsonConvert.DeserializeObject<BORDERSEARCH_OBJ_INTERFACE.Pack_Data>(json);
Datas = p.data;
}
break;
......
......@@ -54,7 +54,15 @@ namespace FLY.Thick.Base.IService
/// AD超过了范围, 就认为开始找到边界
/// </summary>
int TempRange{get;set;}
/// <summary>
/// 温修范围是温修的百分比
/// </summary>
bool IsTempRangeByPercent { get; set; }
/// <summary>
/// 温修范围百分比
/// </summary>
double TempRangePercent { get; set; }
/// <summary>
/// 有滤波器,只有非空的连续N个pos以上,才开始算边界开始
/// </summary>
......
......@@ -11,7 +11,7 @@ namespace FLY.Thick.Base.OBJ_INTERFACE
public class BORDERSEARCH_OBJ_INTERFACE
{
#region Pack
public class Pack_Params : IPack
public class Pack_Params
{
public bool enable;
public Range valid;
......@@ -23,142 +23,21 @@ namespace FLY.Thick.Base.OBJ_INTERFACE
public int n2;
public int n3;
public bool isBreakDetect;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(enable));
buf.AddRange(valid.ToBytes());
buf.AddRange(BitConverter.GetBytes(tempADBySet));
buf.AddRange(BitConverter.GetBytes(tempad));
buf.AddRange(BitConverter.GetBytes(temprange));
buf.AddRange(BitConverter.GetBytes(n));
buf.AddRange(BitConverter.GetBytes(sensorwidth));
buf.AddRange(BitConverter.GetBytes(n2));
buf.AddRange(BitConverter.GetBytes(n3));
buf.AddRange(BitConverter.GetBytes(isBreakDetect));
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
if (value.Length < (1+8+1+4*6+1))
return false;
int idx = 0;
enable = BitConverter.ToBoolean(value, idx);
idx += 1;
valid = new Range();
valid.TryParse(value, idx);
idx += 8;
tempADBySet = BitConverter.ToBoolean(value, idx);
idx += 1;
tempad = BitConverter.ToInt32(value, idx);
idx += 4;
temprange = BitConverter.ToInt32(value, idx);
idx += 4;
n = BitConverter.ToInt32(value, idx);
idx += 4;
sensorwidth = BitConverter.ToInt32(value, idx);
idx += 4;
n2 = BitConverter.ToInt32(value, idx);
idx += 4;
n3 = BitConverter.ToInt32(value, idx);
idx += 4;
isBreakDetect = BitConverter.ToBoolean(value, idx);
idx += 1;
return true;
}
#endregion
public bool isTempRangeByPercent;
public double tempRangePercent;
}
public class Pack_Result : IPack
public class Pack_Result
{
public Range borderForw;
public Range borderBackw;
public int width;
public int mid;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(borderForw.ToBytes());
buf.AddRange(borderBackw.ToBytes());
buf.AddRange(BitConverter.GetBytes(width));
buf.AddRange(BitConverter.GetBytes(mid));
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
if (value.Length < 8+8+4+4)
return false;
int idx = 0;
borderForw = new Range();
borderForw.TryParse(value, 0);
idx += 8;
borderBackw = new Range();
borderBackw.TryParse(value, idx);
idx += 8;
width = BitConverter.ToInt32(value, idx);
idx += 4;
mid = BitConverter.ToInt32(value, idx);
idx += 4;
return true;
}
#endregion
}
public class Pack_Data : IPack
public class Pack_Data
{
public int[] data;
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
if (data == null)
{
buf.AddRange(BitConverter.GetBytes(0));
}
else
{
buf.AddRange(BitConverter.GetBytes(data.Length));
for (int i = 0; i < data.Length; i++)
{
buf.AddRange(BitConverter.GetBytes(data[i]));
}
}
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
int cnt = 4;
int index = 0;
if (value.Length < (index + cnt))
return false;
int idx = index;
int len = BitConverter.ToInt32(value, idx);
idx += 4;
cnt += len * 4;
if (value.Length < (index + cnt))
return false;
if (len <= 0)
data = null;
else
{
data = new int[len];
for (int i = 0; i < len; i++)
{
data[i] = BitConverter.ToInt32(value, idx);
idx += 4;
}
}
return true;
}
}
#endregion
#region GetValue
......
......@@ -32,6 +32,8 @@ namespace FLY.Thick.Base.Server.OBJProxy
(e.PropertyName == "TempADBySet") ||
(e.PropertyName == "TempAD") ||
(e.PropertyName == "TempRange") ||
(e.PropertyName == "TempRangePercent") ||
(e.PropertyName == "IsTempRangeByPercent") ||
(e.PropertyName == "SensorWidth") ||
(e.PropertyName == "N") ||
(e.PropertyName == "N2") ||
......@@ -98,9 +100,12 @@ namespace FLY.Thick.Base.Server.OBJProxy
sensorwidth = mBorderSearch.SensorWidth,
n2 = mBorderSearch.N2,
n3 = mBorderSearch.N3,
isBreakDetect = mBorderSearch.IsBreakDetect
isBreakDetect = mBorderSearch.IsBreakDetect,
isTempRangeByPercent = mBorderSearch.IsTempRangeByPercent,
tempRangePercent = mBorderSearch.TempRangePercent
};
infodata = p.ToBytes();
string json = Newtonsoft.Json.JsonConvert.SerializeObject(p);
infodata = Misc.Converter.StringToBytes(json);
} break;
case BORDERSEARCH_OBJ_INTERFACE.GET_RESULT:
{
......@@ -111,7 +116,8 @@ namespace FLY.Thick.Base.Server.OBJProxy
width = mBorderSearch.Width,
mid = mBorderSearch.Mid
};
infodata = p.ToBytes();
string json = Newtonsoft.Json.JsonConvert.SerializeObject(p);
infodata = Misc.Converter.StringToBytes(json);
} break;
case BORDERSEARCH_OBJ_INTERFACE.GET_DATAS:
{
......@@ -119,7 +125,8 @@ namespace FLY.Thick.Base.Server.OBJProxy
{
data = mBorderSearch.Datas
};
infodata = p.ToBytes();
string json = Newtonsoft.Json.JsonConvert.SerializeObject(p);
infodata = Misc.Converter.StringToBytes(json);
}
break;
default:
......@@ -133,25 +140,26 @@ namespace FLY.Thick.Base.Server.OBJProxy
{
case BORDERSEARCH_OBJ_INTERFACE.SET_PARAMS:
{
BORDERSEARCH_OBJ_INTERFACE.Pack_Params p = new BORDERSEARCH_OBJ_INTERFACE.Pack_Params();
if (p.TryParse(infodata))
{
mBorderSearch.Enable = p.enable;
mBorderSearch.Valid.Begin = p.valid.Begin;
mBorderSearch.Valid.End = p.valid.End;
mBorderSearch.TempRange = p.temprange;
mBorderSearch.TempADBySet = p.tempADBySet;
mBorderSearch.TempAD = p.tempad;
mBorderSearch.N = p.n;
mBorderSearch.SensorWidth = p.sensorwidth;
mBorderSearch.N2 = p.n2;
mBorderSearch.N3 = p.n3;
string json = Misc.Converter.BytesToString(infodata);
var p = Newtonsoft.Json.JsonConvert.DeserializeObject<BORDERSEARCH_OBJ_INTERFACE.Pack_Params>(json);
mBorderSearch.Enable = p.enable;
mBorderSearch.Valid.Begin = p.valid.Begin;
mBorderSearch.Valid.End = p.valid.End;
mBorderSearch.TempRange = p.temprange;
mBorderSearch.TempADBySet = p.tempADBySet;
mBorderSearch.IsBreakDetect = p.isBreakDetect;
mBorderSearch.TempAD = p.tempad;
mBorderSearch.N = p.n;
mBorderSearch.SensorWidth = p.sensorwidth;
mBorderSearch.N2 = p.n2;
mBorderSearch.N3 = p.n3;
mBorderSearch.Apply();
}
mBorderSearch.IsBreakDetect = p.isBreakDetect;
mBorderSearch.IsTempRangeByPercent = p.isTempRangeByPercent;
mBorderSearch.TempRangePercent = p.tempRangePercent;
mBorderSearch.Apply();
} break;
}
}
......
......@@ -99,7 +99,8 @@ namespace FLY.Thick.Base.Server.OBJProxy
mFlyAD.HasCRC = p.hasCRC;
mFlyAD.GridSmooth = p.gridsmooth;
var ep = Misc.StringConverter.ToIPEndPoint(p.ep);
mFlyAD.Connect(ep);
if(!mFlyAD.LocalEP.Equals(ep))
mFlyAD.Connect(ep);
mFlyAD.PosOffset = p.posoffset;
mFlyAD.JogVelocity = p.jogvelocity;
mFlyAD.PosOfGrid = p.posofgrid;
......
......@@ -85,7 +85,17 @@ namespace FLY.Thick.Base.Server
/// <summary>
/// AD超过了范围, 就认为开始找到边界
/// </summary>
public int TempRange { get; set; }
public int TempRange { get; set; } = 1000;
/// <summary>
/// 温修范围是温修的百分比
/// </summary>
public bool IsTempRangeByPercent { get; set; } = true;
/// <summary>
/// 温修范围百分比
/// </summary>
public double TempRangePercent { get; set; } = 0.02;
/// <summary>
......@@ -160,7 +170,8 @@ namespace FLY.Thick.Base.Server
Border.Reset();
Mid = Valid.Mid;
TempRange = 500;
TempRangePercent = 500.0 / 50000;
IsTempRangeByPercent = true;
}
void Border_Backw_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
......@@ -179,19 +190,26 @@ namespace FLY.Thick.Base.Server
void BorderSearch_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "CurrTempAD")
if (e.PropertyName == "CurrTempAD")
{
if (!TempADBySet)
TempAD = CurrTempAD;
}
//if (GetSavePropertyNames().Contains(e.PropertyName))
//{
// FObjBase.PollModule.Current.Poll_JustOnce(
// new FObjBase.PollModule.PollHandler(delegate()
// {
// Save();
// }), this, MARKNO_SAVE);
//}
else if (e.PropertyName == "TempAD")
{
if (IsTempRangeByPercent)
{
TempRange = (int)(TempAD * TempRangePercent);
}
}
else if ((e.PropertyName == "TempRangePercent") || (e.PropertyName == "IsTempRangeByPercent"))
{
if (IsTempRangeByPercent)
{
TempRange = (int)(TempAD * TempRangePercent);
}
}
}
public void Init()
......@@ -446,8 +464,7 @@ namespace FLY.Thick.Base.Server
int[] filterdats = new int[dat.Length];//数据滤波
for (int i = 0; i <= borderbegin_grid; i++)
for (int i = 0; i < dat.Length; i++)
{
int b = i - num;
int e = i + num;
......@@ -463,59 +480,62 @@ namespace FLY.Thick.Base.Server
}
filterdats[i] = Misc.MyMath.Avg(dat, b, e);
}
int bg = borderbegin_grid;
int eg = borderend_grid;
for (int i = borderend_grid; i < dat.Length; i++)
int[] breakdats = new int[dat.Length];
num = 1;
for (int i = 0; i < dat.Length; i++)
{
int b = i - num;
int e = i + num;
if (b < 0)
{
b = 0;
e = b + num * 2;
}
else if (e >= (dat.Length - 1))
if ((i - num) < 0)
breakdats[i] = Misc.MyBase.NULL_VALUE;
else if ((i + num) >= dat.Length)
breakdats[i] = Misc.MyBase.NULL_VALUE;
else if (!Misc.MyBase.ISVALIDATA(filterdats[i - num]))
breakdats[i] = Misc.MyBase.NULL_VALUE;
else if (!Misc.MyBase.ISVALIDATA(filterdats[i + num]))
breakdats[i] = Misc.MyBase.NULL_VALUE;
else if (!Misc.MyBase.ISVALIDATA(filterdats[i]))
breakdats[i] = Misc.MyBase.NULL_VALUE;
else
{
e = dat.Length - 1;
b = e - num * 2;
breakdats[i] = Math.Abs((filterdats[i] - filterdats[i - num]) * (filterdats[i + num] - filterdats[i]));
}
filterdats[i] = Misc.MyMath.Avg(dat, b, e);
}
int bg = borderbegin_grid;
int eg = borderend_grid;
int last_breakdat = int.MaxValue;
bool isdown = false;
//从第1次找到的边界开始,往外找,找折点的最小值
for (int i = borderbegin_grid; i >= (borderbegin_grid - sensor_grid); i--)
{
bg = i;
if ((i - num) < 0)
break;
if ((i + num) >= dat.Length)
break;
if (!Misc.MyBase.ISVALIDATA(filterdats[i - num]))
if (!Misc.MyBase.ISVALIDATA(breakdats[i - num]))
break;
if (!Misc.MyBase.ISVALIDATA(filterdats[i + num]))
break;
if (!Misc.MyBase.ISVALIDATA(filterdats[i]))
if (!Misc.MyBase.ISVALIDATA(breakdats[i + num]))
break;
int breakdat = (filterdats[i] - filterdats[i - num]) * (filterdats[i + num] - filterdats[i]);
if(last_breakdat == int.MaxValue)
last_breakdat = breakdat;
else if (breakdat < last_breakdat)
last_breakdat = breakdat;
else
{
//找到边界了
if (!Misc.MyBase.ISVALIDATA(breakdats[i]))
break;
if (breakdats[i] < breakdats[i + num])
{
//在减少
bg = i;
isdown = true;
}
if (isdown)
{
if (breakdats[i] < breakdats[i - num])
{
//之前那个就是最小值
break;
}
}
}
last_breakdat = int.MaxValue;
isdown = false;
for (int i = borderend_grid; i <= (borderend_grid + sensor_grid); i++)
{
eg = i;
if ((i - num) < 0)
break;
if ((i + num) >= dat.Length)
......@@ -527,15 +547,19 @@ namespace FLY.Thick.Base.Server
if (!Misc.MyBase.ISVALIDATA(filterdats[i]))
break;
int breakdat = (filterdats[i] - filterdats[i - num]) * (filterdats[i + num] - filterdats[i]);
if (last_breakdat == int.MaxValue)
last_breakdat = breakdat;
else if (breakdat < last_breakdat)
last_breakdat = breakdat;
else
if (breakdats[i] < breakdats[i - num])
{
//找到边界了
break;
//在减少
eg = i;
isdown = true;
}
if (isdown)
{
if (breakdats[i] < breakdats[i + num])
{
//之前那个就是最小值
break;
}
}
}
borderbegin_grid = bg;
......@@ -764,6 +788,8 @@ namespace FLY.Thick.Base.Server
"TempADBySet",
"TempAD",
"TempRange",
"TempRangePercent",
"IsTempRangeByPercent",
"N",
"SensorWidth",
"N2",
......
......@@ -51,8 +51,8 @@ namespace FLY.Thick.Base.Server
void flyad_TimeGridEvent(object sender, FlyADBase.TimeGridEventArgs e)
{
if (IsIgnoreDataWhenIdle && !IsRunning)
return;
//if (IsIgnoreDataWhenIdle && !IsRunning)
// return;
DateTime dt = e.Time;
TimeSpan ts = e.Ts;
......
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