Commit 2ec2ccea authored by 潘栩锋's avatar 潘栩锋 🚴

1.GetSample 也变成支持 FObject.Reflect 通讯了

2.删除 FLY.Thick.Base/OBJ_INTERFACE
parent 28b5001c
...@@ -297,39 +297,10 @@ ...@@ -297,39 +297,10 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource ButtonStyle3}" MinHeight="100" Margin="0,5,5,5" Width="150" Command="{Binding GetTempDataCmd}" >
<TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}" Text="获取采集&#x0a;过程" />
</Button>
<StackPanel Orientation="Horizontal">
<ItemsControl x:Name="tempdatas" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<DataGrid ItemsSource="{Binding .}" IsReadOnly="True" Margin="{StaticResource ControlMargin}" AutoGenerateColumns="False" Width="400" TextBlock.FontSize="12" TextBlock.FontWeight="Normal"
>
<DataGrid.Columns>
<DataGridTextColumn Header="时间" Binding="{Binding Time,StringFormat={}{0:HH:mm:ss}}" FontSize="10" Width="100"/>
<DataGridTextColumn Header="AD" Binding="{Binding Ad}" Width="100"/>
<DataGridTextColumn Header="滤波AD" Binding="{Binding FilterAd}" Width="100"/>
<DataGridTextColumn Header="异常" Binding="{Binding IsReset}" Width="100"/>
</DataGrid.Columns>
</DataGrid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</StackPanel>
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>
<Button Style="{StaticResource ButtonStyle_apply}" VerticalAlignment="Bottom" Margin="0,0,20,-45" <Button Style="{StaticResource Styles.Button.Apply}" VerticalAlignment="Bottom" Margin="0,0,20,-45"
Command="{Binding ApplyCmd}"/> Command="{Binding ApplyCmd}"/>
</Grid> </Grid>
</Page> </Page>
...@@ -42,7 +42,7 @@ namespace FLY.Thick.Base.UI ...@@ -42,7 +42,7 @@ namespace FLY.Thick.Base.UI
this.container = container; this.container = container;
viewModel = new GetSampleVm(); viewModel = new GetSampleVm();
viewModel.Init(getSampleService, gageInfoService, tempdatas); viewModel.Init(getSampleService, gageInfoService);
this.DataContext = viewModel; this.DataContext = viewModel;
this.grid_initparam.DataContext = this.initParamService; this.grid_initparam.DataContext = this.initParamService;
} }
...@@ -110,7 +110,6 @@ namespace FLY.Thick.Base.UI ...@@ -110,7 +110,6 @@ namespace FLY.Thick.Base.UI
#region Command #region Command
public RelayCommand ApplyCmd { get; } public RelayCommand ApplyCmd { get; }
public RelayCommand GetOrgAdCmd { get; } public RelayCommand GetOrgAdCmd { get; }
public RelayCommand GetTempDataCmd { get; }
#endregion #endregion
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
...@@ -121,7 +120,6 @@ namespace FLY.Thick.Base.UI ...@@ -121,7 +120,6 @@ namespace FLY.Thick.Base.UI
public GetSampleVm() public GetSampleVm()
{ {
ApplyCmd = new RelayCommand(Apply); ApplyCmd = new RelayCommand(Apply);
GetTempDataCmd = new RelayCommand(GetTempData);
} }
...@@ -129,13 +127,11 @@ namespace FLY.Thick.Base.UI ...@@ -129,13 +127,11 @@ namespace FLY.Thick.Base.UI
[InjectionMethod] [InjectionMethod]
public void Init( public void Init(
IGetSampleService getSampleService, IGetSampleService getSampleService,
IGageInfoService gageInfoService, IGageInfoService gageInfoService)
ItemsControl tempdatas)
{ {
this.getSampleService = getSampleService; this.getSampleService = getSampleService;
this.gageInfoService = gageInfoService; this.gageInfoService = gageInfoService;
this.tempdatas = tempdatas;
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.Velocity), this, nameof(Velocity));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Range), this, nameof(Range)); Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Range), this, nameof(Range));
...@@ -212,17 +208,6 @@ namespace FLY.Thick.Base.UI ...@@ -212,17 +208,6 @@ namespace FLY.Thick.Base.UI
TimeSpan.FromSeconds(2)); TimeSpan.FromSeconds(2));
} }
private void GetTempData()
{
getSampleService.GetTempFilterDatas((asyncContext, retData) =>
{
var ll = retData as List<List<TempFilterData>>;
tempdatas.ItemsSource = ll;
FLY.ControlLibrary.Window_Tip.Show("加载完成",
$"共加载{ll.Count()}列数据",
TimeSpan.FromSeconds(2));
}, null);
}
} }
public class GetSampleVmUt : INotifyPropertyChanged public class GetSampleVmUt : INotifyPropertyChanged
{ {
......
using System; using FLY.Thick.Base.IService;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Misc;
using FObjBase; using FObjBase;
using FLY.Thick.Base.IService; using Misc;
using FLY.Thick.Base.OBJ_INTERFACE; using System;
using FLY.Thick.Base.Common;
namespace FLY.Thick.Base.Client namespace FLY.Thick.Base.Client
{ {
/// <summary> /// <summary>
/// 边界查找服务 客户代理 /// 边界查找服务 客户代理
/// </summary> /// </summary>
public class BorderSearchServiceClient: FObjBase.Reflect.Reflect_SeviceClient, IBorderSearchService public class BorderSearchServiceClient : FObjBase.Reflect.Reflect_SeviceClient, IBorderSearchService
{ {
protected override Type InterfaceType => typeof(IBorderSearchService); protected override Type InterfaceType => typeof(IBorderSearchService);
/// <summary> /// <summary>
...@@ -44,7 +38,7 @@ namespace FLY.Thick.Base.Client ...@@ -44,7 +38,7 @@ namespace FLY.Thick.Base.Client
/// </summary> /// </summary>
public bool IsBreakDetect { get; set; } = true; public bool IsBreakDetect { get; set; } = true;
public RangeStruct Valid { get; set; } public RangeStruct Valid { get; set; }
public Range Border_Backw { get; set; } = new Range(); public Range Border_Backw { get; set; } = new Range();
...@@ -113,7 +107,7 @@ namespace FLY.Thick.Base.Client ...@@ -113,7 +107,7 @@ namespace FLY.Thick.Base.Client
{ {
Call(nameof(GetView), null, asyncDelegate, asyncContext); Call(nameof(GetView), null, asyncDelegate, asyncContext);
} }
public void Apply() public void Apply()
{ {
Call(nameof(Apply)); Call(nameof(Apply));
} }
......
using System; using FLY.Thick.Base.Common;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;
using FObjBase;
using FLY.Thick.Base.IService; using FLY.Thick.Base.IService;
using FLY.Thick.Base.Common; using System;
using FLY.Thick.Base.OBJ_INTERFACE;
namespace FLY.Thick.Base.Client namespace FLY.Thick.Base.Client
{ {
......
using System; using FLY.Thick.Base.IService;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Net;
using FObjBase; using FObjBase;
using FLY.Thick.Base.IService;
using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.Common;
using FObjBase.Reflect; using FObjBase.Reflect;
using System;
namespace FLY.Thick.Base.Client namespace FLY.Thick.Base.Client
{ {
......
using System; using FLY.Thick.Base.Common;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using FObjBase;
using FLY.Thick.Base.IService; using FLY.Thick.Base.IService;
using FLY.Thick.Base.OBJ_INTERFACE; using System;
using FLY.Thick.Base.Common;
using Newtonsoft.Json;
using FLY.OBJComponents.Client;
namespace FLY.Thick.Base.Client namespace FLY.Thick.Base.Client
{ {
......
using System; using FLY.Thick.Base.IService;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;
using FObjBase; using FObjBase;
using FLY.Thick.Base.IService;
using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.Common;
using Newtonsoft.Json;
using FObjBase.Reflect; using FObjBase.Reflect;
using System;
namespace FLY.Thick.Base.Client namespace FLY.Thick.Base.Client
{ {
...@@ -20,10 +10,11 @@ namespace FLY.Thick.Base.Client ...@@ -20,10 +10,11 @@ namespace FLY.Thick.Base.Client
protected override Type InterfaceType => typeof(IScanCorrService); protected override Type InterfaceType => typeof(IScanCorrService);
public ScanCorrServiceClient(UInt32 serviceId) : base(serviceId) public ScanCorrServiceClient(UInt32 serviceId) : base(serviceId)
{ {
} }
public ScanCorrServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { public ScanCorrServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName)
{
} }
/// <summary> /// <summary>
...@@ -65,7 +56,8 @@ namespace FLY.Thick.Base.Client ...@@ -65,7 +56,8 @@ namespace FLY.Thick.Base.Client
/// <param name="groupIndex">组序号</param> /// <param name="groupIndex">组序号</param>
/// <param name="scanCnt">扫描次数</param> /// <param name="scanCnt">扫描次数</param>
/// <param name="smoothFactor">平滑</param> /// <param name="smoothFactor">平滑</param>
public void Start(int groupIndex, int scanCnt, int smoothFactor) { public void Start(int groupIndex, int scanCnt, int smoothFactor)
{
Call(nameof(Start), new { groupIndex = groupIndex, scanCnt = scanCnt, smoothFactor = smoothFactor }); Call(nameof(Start), new { groupIndex = groupIndex, scanCnt = scanCnt, smoothFactor = smoothFactor });
} }
...@@ -73,7 +65,8 @@ namespace FLY.Thick.Base.Client ...@@ -73,7 +65,8 @@ namespace FLY.Thick.Base.Client
/// 清空组数据 /// 清空组数据
/// </summary> /// </summary>
/// <param name="groupIndex"></param> /// <param name="groupIndex"></param>
public void Clear(int groupIndex) { public void Clear(int groupIndex)
{
Call(nameof(Clear), new { groupIndex = groupIndex }); Call(nameof(Clear), new { groupIndex = groupIndex });
} }
...@@ -83,13 +76,15 @@ namespace FLY.Thick.Base.Client ...@@ -83,13 +76,15 @@ namespace FLY.Thick.Base.Client
/// <param name="groupIndex">组序号</param> /// <param name="groupIndex">组序号</param>
/// <param name="corrDatas">修正数据</param> /// <param name="corrDatas">修正数据</param>
/// <param name="avg">均值</param> /// <param name="avg">均值</param>
public void SetCorrData(int groupIndex, int[][] corrDatas, int avg) { public void SetCorrData(int groupIndex, int[][] corrDatas, int avg)
Call(nameof(SetCorrData), new { groupIndex = groupIndex,corrDatas = corrDatas, avg = avg }); {
Call(nameof(SetCorrData), new { groupIndex = groupIndex, corrDatas = corrDatas, avg = avg });
} }
[Call(typeof(GetScanCorrGroupResponse))] [Call(typeof(GetScanCorrGroupResponse))]
public void GetScanCorrGroup(int groupIndex, AsyncCBHandler asyncDelegate, object asyncContext) { public void GetScanCorrGroup(int groupIndex, AsyncCBHandler asyncDelegate, object asyncContext)
{
Call(nameof(GetScanCorrGroup), new { groupIndex = groupIndex }, asyncDelegate, asyncContext); Call(nameof(GetScanCorrGroup), new { groupIndex = groupIndex }, asyncDelegate, asyncContext);
} }
......
...@@ -91,12 +91,7 @@ ...@@ -91,12 +91,7 @@
<Compile Include="IService\IRejectService.cs" /> <Compile Include="IService\IRejectService.cs" />
<Compile Include="IService\IScanCorrService.cs" /> <Compile Include="IService\IScanCorrService.cs" />
<Compile Include="IService\ITDGageService.cs" /> <Compile Include="IService\ITDGageService.cs" />
<Compile Include="OBJ_INTERFACE\CURVE_OBJ_INTERFACE.cs" />
<Compile Include="OBJ_INTERFACE\FIX_OBJ_INTERFACEC.cs" />
<Compile Include="OBJ_INTERFACE\GETSAMPLE_OBJ_INTERFACE.cs" />
<Compile Include="OBJ_INTERFACE\SCANCORR_OBJ_INTERFACE.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Server.OBJProxy\GetSample_OBJProxy.cs" />
<Compile Include="Server\BoltMapImg.cs" /> <Compile Include="Server\BoltMapImg.cs" />
<Compile Include="Server\BorderSearch.cs" /> <Compile Include="Server\BorderSearch.cs" />
<Compile Include="Server\CurveCollection.cs" /> <Compile Include="Server\CurveCollection.cs" />
...@@ -168,6 +163,10 @@ ...@@ -168,6 +163,10 @@
<Link>.editorconfig</Link> <Link>.editorconfig</Link>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="OBJ_INTERFACE\" />
<Folder Include="Server.OBJProxy\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
......
...@@ -7,6 +7,7 @@ using System.ComponentModel; ...@@ -7,6 +7,7 @@ using System.ComponentModel;
using Newtonsoft.Json; using Newtonsoft.Json;
using PropertyChanged; using PropertyChanged;
using FObjBase; using FObjBase;
using FObjBase.Reflect;
namespace FLY.Thick.Base.IService namespace FLY.Thick.Base.IService
{ {
...@@ -20,8 +21,6 @@ namespace FLY.Thick.Base.IService ...@@ -20,8 +21,6 @@ namespace FLY.Thick.Base.IService
/// </summary> /// </summary>
bool Enable { get; set; } bool Enable { get; set; }
/// <summary> /// <summary>
/// 参数:速度 /// 参数:速度
/// </summary> /// </summary>
...@@ -49,38 +48,31 @@ namespace FLY.Thick.Base.IService ...@@ -49,38 +48,31 @@ namespace FLY.Thick.Base.IService
/// 异常值 /// 异常值
/// </summary> /// </summary>
int ErrValue { get; set; } int ErrValue { get; set; }
/// <summary> /// <summary>
/// 参数:样品点参数 /// 参数:样品点参数
/// </summary> /// </summary>
[PropertyPush]
SampleCell[] Samples { get; } SampleCell[] Samples { get; }
/// <summary> /// <summary>
/// 参数:特征查找范围 /// 参数:特征查找范围
/// </summary> /// </summary>
int Search { get; set; } int Search { get; set; }
/// <summary> /// <summary>
/// 参数:特征参数 /// 参数:特征参数
/// </summary> /// </summary>
[PropertyPush]
SampleFeature[] Features { get; } SampleFeature[] Features { get; }
/// <summary>
/// 状态:从flyad7 得到的。 用于绘制图
/// </summary>
int PosOfGrid { get; set;}
/// <summary> /// <summary>
/// 应用 /// 应用
/// </summary> /// </summary>
void Apply(); void Apply();
/// <summary>
/// 返回 List(List(TempFilterData))
/// </summary>
/// <param name="asyncCB"></param>
/// <param name="asyncContext"></param>
void GetTempFilterDatas(AsyncCBHandler asyncCB, object asyncContext);
} }
/// <summary> /// <summary>
/// 采样记录 /// 采样记录
/// </summary> /// </summary>
...@@ -103,36 +95,65 @@ namespace FLY.Thick.Base.IService ...@@ -103,36 +95,65 @@ namespace FLY.Thick.Base.IService
/// </summary> /// </summary>
public bool IsReset { get; set; } public bool IsReset { get; set; }
} }
/// <summary>
/// 样品点 参数
/// </summary>
public class SampleCellParam : INotifyPropertyChanged
{
/// <summary>
/// 参数:使能
/// </summary>
public bool Enable { get; set; }
/// <summary>
/// 参数:只检查不标定
/// </summary>
public bool JustForCheck { get; set; }
/// <summary>
/// 参数:原始AD值
/// </summary>
public int OrgAD { get; set; }
/// <summary>
/// 参数:位置
/// </summary>
public int Position { get; set; }
#region INotifyPropertyChanged 成员
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
/// <summary> /// <summary>
/// 样品点 /// 样品点
/// </summary> /// </summary>
[JsonObject(MemberSerialization.OptIn)]
public class SampleCell:INotifyPropertyChanged public class SampleCell:INotifyPropertyChanged
{ {
/// <summary> /// <summary>
/// 参数:使能 /// 参数:使能
/// </summary> /// </summary>
[JsonProperty]
public bool Enable { get; set; } public bool Enable { get; set; }
/// <summary> /// <summary>
/// 参数:只检查不标定 /// 参数:只检查不标定
/// </summary> /// </summary>
[JsonProperty]
public bool JustForCheck { get; set; } public bool JustForCheck { get; set; }
/// <summary> /// <summary>
/// 参数:原始AD值 /// 参数:原始AD值
/// </summary> /// </summary>
[JsonProperty]
public int OrgAD { get; set; } public int OrgAD { get; set; }
/// <summary> /// <summary>
/// 参数:位置 /// 参数:位置
/// </summary> /// </summary>
[JsonProperty]
public int Position { get; set; } public int Position { get; set; }
/// <summary> /// <summary>
...@@ -157,33 +178,57 @@ namespace FLY.Thick.Base.IService ...@@ -157,33 +178,57 @@ namespace FLY.Thick.Base.IService
#endregion #endregion
} }
/// <summary>
/// 样品正向校正特征
/// </summary>
public class SampleFeatureParam : INotifyPropertyChanged
{
/// <summary>
/// 参数:使能
/// </summary>
public bool Enable { get; set; }
/// <summary>
/// 参数:开始位置
/// </summary>
public int StartPos { get; set; }
/// <summary>
/// 参数:结束位置
/// </summary>
public int EndPos { get; set; }
#region INotifyPropertyChanged 成员
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
/// <summary> /// <summary>
/// 样品正向校正特征 /// 样品正向校正特征
/// </summary> /// </summary>
[JsonObject(MemberSerialization.OptIn)]
public class SampleFeature :INotifyPropertyChanged public class SampleFeature :INotifyPropertyChanged
{ {
/// <summary> /// <summary>
/// 参数:使能 /// 参数:使能
/// </summary> /// </summary>
[JsonProperty]
public bool Enable { get; set; } public bool Enable { get; set; }
/// <summary> /// <summary>
/// 参数:开始位置 /// 参数:开始位置
/// </summary> /// </summary>
[JsonProperty]
public int StartPos { get; set; } public int StartPos { get; set; }
/// <summary> /// <summary>
/// 参数:结束位置 /// 参数:结束位置
/// </summary> /// </summary>
[JsonProperty]
public int EndPos { get; set; } public int EndPos { get; set; }
...@@ -197,13 +242,6 @@ namespace FLY.Thick.Base.IService ...@@ -197,13 +242,6 @@ namespace FLY.Thick.Base.IService
/// </summary> /// </summary>
public int MaxOffset { get; set; } public int MaxOffset { get; set; }
/// <summary>
/// 状态:扫描数据,从扫描数据提取的相似的一段
/// 它的单位是 grid, 需要 posOfGrid, 转换为 pos
/// 开始位置是 StartPos - Search
/// </summary>
[DoNotCheckEquality]
public int[] ScanData { get; set; }
#region INotifyPropertyChanged 成员 #region INotifyPropertyChanged 成员
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FObjBase;
using FLY.Thick.Base.Common;
namespace FLY.Thick.Base.OBJ_INTERFACE
{
public class CURVE_OBJ_INTERFACE
{
#region Pack
public class Pack_CurveList
{
public CurveCorrectWay correctway;
public CurveType flag;
public List<CurveCell> list;
}
#endregion
#region GetValue
/// <summary>
/// Pack_CurveList
/// </summary>
public const UInt16 GET_CURVELIST = 0;
#endregion
#region SetValue
/// <summary>
/// Pack_CurveList
/// </summary>
public const UInt16 SET_CURVELIST = 0;
#endregion
#region PushMsg
/// <summary>
/// Pack_CurveList
/// </summary>
public const UInt16 PUSH_CURVELIST = 0;
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FLY.Thick.Base.OBJ_INTERFACE
{
public class FIX_OBJ_INTERFACE
{
#region Pack
#endregion
#region GetValue
#endregion
#region SetValue
#endregion
#region PushMsg
public const UInt16 PUSH_TIMEGRID = 1;
#endregion
#region CallFunction
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FObjBase;
using FLY.Thick.Base.Common;
namespace FLY.Thick.Base.OBJ_INTERFACE
{
public class GETSAMPLE_OBJ_INTERFACE
{
#region Pack
public class Pack_Params_SampleCell
{
public bool enable;
public bool justForCheck;
public int orgad;
public int position;
}
public class Pack_Params_SampleFeature
{
public bool enable;
public int startpos;
public int endpos;
}
public class Pack_Params
{
public bool enable;
public UInt32 velocity;
public int range;
public int window;
public bool IsCheckByPercent;
public double ErrPercent;
public int ErrValue;
public IEnumerable<Pack_Params_SampleCell> samples;
public int search;
public IEnumerable<Pack_Params_SampleFeature> features;
}
public class Pack_State_SampleCell
{
public int ad;
public double value;
}
public class Pack_State_SampleFeature
{
public double maxRelevancy;
public int maxOffset;
public int[] scanData;
}
public class Pack_State
{
public int posOfGrid;
public IEnumerable<Pack_State_SampleCell> samples;
public IEnumerable<Pack_State_SampleFeature> features;
}
#endregion
#region GetValue
/// <summary>
/// Pack_Params
/// </summary>
public const UInt16 GET_PARAMS = 0;
public const UInt16 GET_STATE = 1;
#endregion
#region SetValue
/// <summary>
/// Pack_Params
/// </summary>
public const UInt16 SET_PARAMS = 0;
#endregion
#region PushMsg
/// <summary>
/// Pack_Params
/// </summary>
public const UInt16 PUSH_PARAMS = 0;
public const UInt16 PUSH_STATE = 1;
#endregion
#region CallFunction
/// <summary>
/// request:null
/// reponse:List(List(TempFilterData))
/// </summary>
public const UInt16 CALL_GET_TEMPDATAS = 0;
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FObjBase;
namespace FLY.Thick.Base.OBJ_INTERFACE
{
public class SCANCORR_OBJ_INTERFACE
{
#region Pack
public class Pack_GetState
{
public int progress;
public bool ing;
}
public class Pack_ValidRange
{
public int begin;
public int end;
}
public class Pack_StartParams
{
public int scantimer;
public int smoothfactor;
public int posofgrid;
public int poslen;
}
public class Pack_GroupParams
{
public int avgad0;
public int avgad1;
}
public class Pack_CallStart
{
public int scantimer;
public int smoothfactor;
public int groupindex;
}
public class Pack_ClearRequest
{
public int groupindex;
}
#endregion
#region GetValue
/// <summary>
/// Pack_GetState
/// </summary>
public const UInt16 GET_PROGRESS = 1;
/// <summary>
/// Pack_Enable
/// </summary>
public const UInt16 GET_ENABLE = 2;
/// <summary>
/// Pack_StartParams
/// </summary>
public const UInt16 GET_START_PARAMS = 3;
/// <summary>
/// Pack_GroupParams
/// </summary>
public const UInt16 GET_GROUP_PARAMS = 4;
/// <summary>
/// Pack_Data
/// </summary>
public const UInt16 GET_GROUP0_FORW = 5;
/// <summary>
/// Pack_Data
/// </summary>
public const UInt16 GET_GROUP0_BACKW = 6;
/// <summary>
/// Pack_Data
/// </summary>
public const UInt16 GET_GROUP1_FORW = 7;
/// <summary>
/// Pack_Data
/// </summary>
public const UInt16 GET_GROUP1_BACKW = 8;
/// <summary>
/// Pack_ValidRange
/// </summary>
public const UInt16 GET_VALIDRANGE = 9;
#endregion
#region SetValue
/// <summary>
/// Pack_Enable
/// </summary>
public const UInt16 SET_ENABLE = 2;
/// <summary>
/// Pack_ValidRange
/// </summary>
public const UInt16 SET_VALIDRANGE = 9;
#endregion
#region CallFunction
/// <summary>
/// Pack_CallStart
/// </summary>
public const UInt16 CALL_START = 1;
/// <summary>
/// Pack_int
/// </summary>
public const UInt16 CALL_CLEAR = 2;
/// <summary>
/// Pack_CallStart
/// </summary>
public const UInt16 CALL_SMOOTH = 3;
#endregion
#region PushInfo
/// <summary>
/// Pack_GetState
/// </summary>
public const UInt16 PUSH_PROGRESS = 1;
public const UInt16 PUSH_ENABLE = 2;
public const UInt16 PUSH_START_PARAMS = 3;
/// <summary>
/// Pack_GroupParams
/// </summary>
public const UInt16 PUSH_GROUP_PARAMS = 4;
/// <summary>
/// Pack_Data
/// </summary>
public const UInt16 PUSH_GROUP0_FORW = 5;
/// <summary>
/// Pack_Data
/// </summary>
public const UInt16 PUSH_GROUP0_BACKW = 6;
/// <summary>
/// Pack_Data
/// </summary>
public const UInt16 PUSH_GROUP1_FORW = 7;
/// <summary>
/// Pack_Data
/// </summary>
public const UInt16 PUSH_GROUP1_BACKW = 8;
/// <summary>
/// Pack_ValidRange
/// </summary>
public const UInt16 PUSH_VALIDRANGE = 9;
#endregion
}
}
...@@ -15,10 +15,10 @@ using PropertyChanged; ...@@ -15,10 +15,10 @@ using PropertyChanged;
using Newtonsoft.Json; using Newtonsoft.Json;
using static Misc.ReverserInfo; using static Misc.ReverserInfo;
using FLY.Thick.Base.Common; using FLY.Thick.Base.Common;
using AutoMapper;
namespace FLY.Thick.Base.Server namespace FLY.Thick.Base.Server
{ {
[JsonObject(MemberSerialization.OptIn)]
public class GSample : IGetSampleService public class GSample : IGetSampleService
{ {
/// <summary> /// <summary>
...@@ -30,69 +30,53 @@ namespace FLY.Thick.Base.Server ...@@ -30,69 +30,53 @@ namespace FLY.Thick.Base.Server
/// <summary> /// <summary>
/// 参数:使能 /// 参数:使能
/// </summary> /// </summary>
[JsonProperty]
public bool Enable { get; set; } = true; public bool Enable { get; set; } = true;
/// <summary> /// <summary>
/// 参数:速度 /// 参数:速度
/// </summary> /// </summary>
[JsonProperty]
public UInt32 Velocity { get; set; } = 500; public UInt32 Velocity { get; set; } = 500;
/// <summary> /// <summary>
/// 参数:样品点范围 /// 参数:样品点范围
/// </summary> /// </summary>
[JsonProperty]
public int Range { get; set; } = 100; public int Range { get; set; } = 100;
/// <summary> /// <summary>
/// 滤波窗口,单位 min /// 滤波窗口,单位 min
/// </summary> /// </summary>
[JsonProperty]
public int Window { get; set; } public int Window { get; set; }
/// <summary> /// <summary>
/// 使用%方式检查异常 /// 使用%方式检查异常
/// </summary> /// </summary>
[JsonProperty]
public bool IsCheckByPercent { get; set; } = true; public bool IsCheckByPercent { get; set; } = true;
/// <summary> /// <summary>
/// 异常% 单位% /// 异常% 单位%
/// </summary> /// </summary>
[JsonProperty]
public double ErrPercent { get; set; } = 2; public double ErrPercent { get; set; } = 2;
/// <summary> /// <summary>
/// 异常值 /// 异常值
/// </summary> /// </summary>
[JsonProperty]
public int ErrValue { get; set; } = 200; public int ErrValue { get; set; } = 200;
/// <summary> /// <summary>
/// 样品 /// 样品
/// </summary> /// </summary>
[JsonProperty]
public SampleCell[] Samples { get; set; } public SampleCell[] Samples { get; set; }
/// <summary> /// <summary>
/// 查找公差 /// 查找公差
/// </summary> /// </summary>
[JsonProperty]
public int Search { get; set; } = 100; public int Search { get; set; } = 100;
/// <summary> /// <summary>
/// 特征 相识度 0 正, 1 反 /// 特征 相识度 0 正, 1 反
/// </summary> /// </summary>
[JsonProperty]
public SampleFeature[] Features { get; set; } public SampleFeature[] Features { get; set; }
/// <summary>
/// 状态:从flyad7 得到的。 用于绘制图
/// </summary>
public int PosOfGrid { get; set; } = 10;
#endregion #endregion
TempFilter2[] tempFilters; TempFilter2[] tempFilters;
DIRECTION[] directions; DIRECTION[] directions;
...@@ -113,6 +97,7 @@ namespace FLY.Thick.Base.Server ...@@ -113,6 +97,7 @@ namespace FLY.Thick.Base.Server
this.param_path = param_path; this.param_path = param_path;
Samples = new SampleCell[3]; Samples = new SampleCell[3];
Features = new SampleFeature[2]; Features = new SampleFeature[2];
tempFilters = new TempFilter2[Samples.Count()]; tempFilters = new TempFilter2[Samples.Count()];
directions = new DIRECTION[Samples.Count()]; directions = new DIRECTION[Samples.Count()];
...@@ -169,40 +154,20 @@ namespace FLY.Thick.Base.Server ...@@ -169,40 +154,20 @@ namespace FLY.Thick.Base.Server
this.warningSystem = warningSystem; this.warningSystem = warningSystem;
Misc.BindingOperations.SetBinding(flyad, nameof(flyad.PosOfGrid), this, nameof(PosOfGrid));
} }
public bool Load() public bool Load()
{ {
try return GSampleJsonDb.Load(this, param_path);
{
string json = File.ReadAllText(param_path);
Newtonsoft.Json.JsonConvert.PopulateObject(json, this);
}
catch
{
return false;
}
return true;
} }
/// <summary> /// <summary>
/// 保存 /// 保存
/// </summary> /// </summary>
public void Save() public bool Save()
{ {
try return GSampleJsonDb.Save(this, param_path);
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(this, Formatting.Indented);
File.WriteAllText(param_path, json);
}
catch
{
}
} }
/// <summary> /// <summary>
/// 1.判断样品取样方向 /// 1.判断样品取样方向
...@@ -409,15 +374,16 @@ namespace FLY.Thick.Base.Server ...@@ -409,15 +374,16 @@ namespace FLY.Thick.Base.Server
int grid_b = grid1 - grid_searchtol; int grid_b = grid1 - grid_searchtol;
int grid_e = grid2 + grid_searchtol; int grid_e = grid2 + grid_searchtol;
int grid_len = grid_e - grid_b + 1; int grid_len = grid_e - grid_b + 1;
psr.ScanData = new int[grid_len];//这个方向的需要 特征查找范围内的数据,不用考虑 buf 不够 grid_len int[] scanData = new int[grid_len];//这个方向的需要 特征查找范围内的数据,不用考虑 buf 不够 grid_len
Array.Copy(buf, grid_b - grid_start, psr.ScanData, 0, grid_len);
Array.Copy(buf, grid_b - grid_start, scanData, 0, grid_len);
double max_relvency = 0; double max_relvency = 0;
int max_grid_offset = 0; int max_grid_offset = 0;
for (int i = 0; i < grid_searchtol * 2; i++) for (int i = 0; i < grid_searchtol * 2; i++)
{ {
double r = Misc.MyMath.Correl(gagedata, grid1, psr.ScanData, i, grid2 - grid1 + 1); double r = Misc.MyMath.Correl(gagedata, grid1, scanData, i, grid2 - grid1 + 1);
if (r > max_relvency) if (r > max_relvency)
{ {
max_relvency = r; max_relvency = r;
...@@ -620,4 +586,92 @@ namespace FLY.Thick.Base.Server ...@@ -620,4 +586,92 @@ namespace FLY.Thick.Base.Server
} }
public delegate void SampleChangedEventHandler(GSample gsample); public delegate void SampleChangedEventHandler(GSample gsample);
public class GSampleJsonDb
{
static Mapper Mapper { get; } = new AutoMapper.Mapper(new MapperConfiguration(c =>
{
c.CreateMap<GSample, GSampleJsonDb>()
.ForMember(s => s.Samples, opt =>
{
opt.MapFrom(s => Map_SampleCell2SampleCellParam(s.Samples));
}).ForMember(s => s.Features, opt =>
{
opt.MapFrom(s => Map_SampleFeature2SampleFeatureParam(s.Features));
})
.ReverseMap()
.ForMember(s => s.Samples, opt =>
{
opt.MapFrom(s => Map_SampleCellParam2SampleCell(s.Samples));
})
.ForMember(s => s.Features, opt =>
{
opt.MapFrom(s => Map_SampleFeatureParam2SampleFeature(s.Features));
});
}));
static SampleCell[] Map_SampleCellParam2SampleCell(SampleCellParam[] sampleCellParams) {
string json = Newtonsoft.Json.JsonConvert.SerializeObject(sampleCellParams);
return Newtonsoft.Json.JsonConvert.DeserializeObject<SampleCell[]>(json);
}
static SampleCellParam[] Map_SampleCell2SampleCellParam(SampleCell[] sampleCells)
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(sampleCells);
return Newtonsoft.Json.JsonConvert.DeserializeObject<SampleCellParam[]>(json);
}
static SampleFeature[] Map_SampleFeatureParam2SampleFeature(SampleFeatureParam[] sampleFeatureParams)
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(sampleFeatureParams);
return Newtonsoft.Json.JsonConvert.DeserializeObject<SampleFeature[]>(json);
}
static SampleFeatureParam[] Map_SampleFeature2SampleFeatureParam(SampleFeature[] sampleFeatures)
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(sampleFeatures);
return Newtonsoft.Json.JsonConvert.DeserializeObject<SampleFeatureParam[]>(json);
}
public static bool Load(GSample src, string filePath)
{
try
{
if (File.Exists(filePath))
{
string json = File.ReadAllText(filePath);
var p = JsonConvert.DeserializeObject<GSampleJsonDb>(json);
Mapper.Map(p, src);
return true;
}
}
catch
{
//异常,没有json 解码失败
}
return false;
}
public static bool Save(GSample src, string filePath)
{
var p = Mapper.Map<GSampleJsonDb>(src);
try
{
File.WriteAllText(filePath, JsonConvert.SerializeObject(p, Formatting.Indented));
return true;
}
catch
{
//异常,没有json 编码失败
}
return false;
}
public bool Enable { get; set; } = true;
public int Range { get; set; } = 100;
public int Window { get; set; }
public bool IsCheckByPercent { get; set; } = true;
public double ErrPercent { get; set; } = 2;
public int ErrValue { get; set; } = 200;
public SampleCellParam[] Samples { get; set; }
public int Search { get; set; } = 100;
public SampleFeatureParam[] Features { get; set; }
}
} }
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