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

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

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