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

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

2.删除 FLY.Thick.Base/OBJ_INTERFACE
parent 28b5001c
......@@ -297,39 +297,10 @@
</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>
</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}"/>
</Grid>
</Page>
......@@ -42,7 +42,7 @@ namespace FLY.Thick.Base.UI
this.container = container;
viewModel = new GetSampleVm();
viewModel.Init(getSampleService, gageInfoService, tempdatas);
viewModel.Init(getSampleService, gageInfoService);
this.DataContext = viewModel;
this.grid_initparam.DataContext = this.initParamService;
}
......@@ -110,7 +110,6 @@ namespace FLY.Thick.Base.UI
#region Command
public RelayCommand ApplyCmd { get; }
public RelayCommand GetOrgAdCmd { get; }
public RelayCommand GetTempDataCmd { get; }
#endregion
public event PropertyChangedEventHandler PropertyChanged;
......@@ -121,7 +120,6 @@ namespace FLY.Thick.Base.UI
public GetSampleVm()
{
ApplyCmd = new RelayCommand(Apply);
GetTempDataCmd = new RelayCommand(GetTempData);
}
......@@ -129,13 +127,11 @@ namespace FLY.Thick.Base.UI
[InjectionMethod]
public void Init(
IGetSampleService getSampleService,
IGageInfoService gageInfoService,
ItemsControl tempdatas)
IGageInfoService gageInfoService)
{
this.getSampleService = getSampleService;
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.Velocity), this, nameof(Velocity));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Range), this, nameof(Range));
......@@ -212,17 +208,6 @@ namespace FLY.Thick.Base.UI
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
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Misc;
using FLY.Thick.Base.IService;
using FObjBase;
using FLY.Thick.Base.IService;
using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.Common;
using Misc;
using System;
namespace FLY.Thick.Base.Client
{
/// <summary>
/// 边界查找服务 客户代理
/// </summary>
public class BorderSearchServiceClient: FObjBase.Reflect.Reflect_SeviceClient, IBorderSearchService
public class BorderSearchServiceClient : FObjBase.Reflect.Reflect_SeviceClient, IBorderSearchService
{
protected override Type InterfaceType => typeof(IBorderSearchService);
/// <summary>
......@@ -44,7 +38,7 @@ namespace FLY.Thick.Base.Client
/// </summary>
public bool IsBreakDetect { get; set; } = true;
public RangeStruct Valid { get; set; }
public Range Border_Backw { get; set; } = new Range();
......@@ -113,7 +107,7 @@ namespace FLY.Thick.Base.Client
{
Call(nameof(GetView), null, asyncDelegate, asyncContext);
}
public void Apply()
public void Apply()
{
Call(nameof(Apply));
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;
using FObjBase;
using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService;
using FLY.Thick.Base.Common;
using FLY.Thick.Base.OBJ_INTERFACE;
using System;
namespace FLY.Thick.Base.Client
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Net;
using FLY.Thick.Base.IService;
using FObjBase;
using FLY.Thick.Base.IService;
using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.Common;
using FObjBase.Reflect;
using System;
namespace FLY.Thick.Base.Client
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using FObjBase;
using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService;
using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.Common;
using Newtonsoft.Json;
using FLY.OBJComponents.Client;
using System;
namespace FLY.Thick.Base.Client
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;
using FLY.Thick.Base.IService;
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 System;
namespace FLY.Thick.Base.Client
{
......@@ -20,10 +10,11 @@ namespace FLY.Thick.Base.Client
protected override Type InterfaceType => typeof(IScanCorrService);
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>
......@@ -65,7 +56,8 @@ namespace FLY.Thick.Base.Client
/// <param name="groupIndex">组序号</param>
/// <param name="scanCnt">扫描次数</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 });
}
......@@ -73,7 +65,8 @@ namespace FLY.Thick.Base.Client
/// 清空组数据
/// </summary>
/// <param name="groupIndex"></param>
public void Clear(int groupIndex) {
public void Clear(int groupIndex)
{
Call(nameof(Clear), new { groupIndex = groupIndex });
}
......@@ -83,13 +76,15 @@ namespace FLY.Thick.Base.Client
/// <param name="groupIndex">组序号</param>
/// <param name="corrDatas">修正数据</param>
/// <param name="avg">均值</param>
public void SetCorrData(int groupIndex, int[][] corrDatas, int avg) {
Call(nameof(SetCorrData), new { groupIndex = groupIndex,corrDatas = corrDatas, avg = avg });
public void SetCorrData(int groupIndex, int[][] corrDatas, int avg)
{
Call(nameof(SetCorrData), new { groupIndex = groupIndex, corrDatas = corrDatas, avg = avg });
}
[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);
}
......
......@@ -91,12 +91,7 @@
<Compile Include="IService\IRejectService.cs" />
<Compile Include="IService\IScanCorrService.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="Server.OBJProxy\GetSample_OBJProxy.cs" />
<Compile Include="Server\BoltMapImg.cs" />
<Compile Include="Server\BorderSearch.cs" />
<Compile Include="Server\CurveCollection.cs" />
......@@ -168,6 +163,10 @@
<Link>.editorconfig</Link>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="OBJ_INTERFACE\" />
<Folder Include="Server.OBJProxy\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.
......
......@@ -7,6 +7,7 @@ using System.ComponentModel;
using Newtonsoft.Json;
using PropertyChanged;
using FObjBase;
using FObjBase.Reflect;
namespace FLY.Thick.Base.IService
{
......@@ -20,8 +21,6 @@ namespace FLY.Thick.Base.IService
/// </summary>
bool Enable { get; set; }
/// <summary>
/// 参数:速度
/// </summary>
......@@ -49,38 +48,31 @@ namespace FLY.Thick.Base.IService
/// 异常值
/// </summary>
int ErrValue { get; set; }
/// <summary>
/// 参数:样品点参数
/// </summary>
[PropertyPush]
SampleCell[] Samples { get; }
/// <summary>
/// 参数:特征查找范围
/// </summary>
int Search { get; set; }
/// <summary>
/// 参数:特征参数
/// </summary>
[PropertyPush]
SampleFeature[] Features { get; }
/// <summary>
/// 状态:从flyad7 得到的。 用于绘制图
/// </summary>
int PosOfGrid { get; set;}
/// <summary>
/// 应用
/// </summary>
void Apply();
/// <summary>
/// 返回 List(List(TempFilterData))
/// </summary>
/// <param name="asyncCB"></param>
/// <param name="asyncContext"></param>
void GetTempFilterDatas(AsyncCBHandler asyncCB, object asyncContext);
}
/// <summary>
/// 采样记录
/// </summary>
......@@ -103,36 +95,65 @@ namespace FLY.Thick.Base.IService
/// </summary>
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>
[JsonObject(MemberSerialization.OptIn)]
public class SampleCell:INotifyPropertyChanged
{
/// <summary>
/// 参数:使能
/// </summary>
[JsonProperty]
public bool Enable { get; set; }
/// <summary>
/// 参数:只检查不标定
/// </summary>
[JsonProperty]
public bool JustForCheck { get; set; }
/// <summary>
/// 参数:原始AD值
/// </summary>
[JsonProperty]
public int OrgAD { get; set; }
/// <summary>
/// 参数:位置
/// </summary>
[JsonProperty]
public int Position { get; set; }
/// <summary>
......@@ -157,33 +178,57 @@ namespace FLY.Thick.Base.IService
#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>
[JsonObject(MemberSerialization.OptIn)]
public class SampleFeature :INotifyPropertyChanged
{
/// <summary>
/// 参数:使能
/// </summary>
[JsonProperty]
public bool Enable { get; set; }
/// <summary>
/// 参数:开始位置
/// </summary>
[JsonProperty]
public int StartPos { get; set; }
/// <summary>
/// 参数:结束位置
/// </summary>
[JsonProperty]
public int EndPos { get; set; }
......@@ -197,13 +242,6 @@ namespace FLY.Thick.Base.IService
/// </summary>
public int MaxOffset { get; set; }
/// <summary>
/// 状态:扫描数据,从扫描数据提取的相似的一段
/// 它的单位是 grid, 需要 posOfGrid, 转换为 pos
/// 开始位置是 StartPos - Search
/// </summary>
[DoNotCheckEquality]
public int[] ScanData { get; set; }
#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;
using Newtonsoft.Json;
using static Misc.ReverserInfo;
using FLY.Thick.Base.Common;
using AutoMapper;
namespace FLY.Thick.Base.Server
{
[JsonObject(MemberSerialization.OptIn)]
public class GSample : IGetSampleService
{
/// <summary>
......@@ -30,69 +30,53 @@ namespace FLY.Thick.Base.Server
/// <summary>
/// 参数:使能
/// </summary>
[JsonProperty]
public bool Enable { get; set; } = true;
/// <summary>
/// 参数:速度
/// </summary>
[JsonProperty]
public UInt32 Velocity { get; set; } = 500;
/// <summary>
/// 参数:样品点范围
/// </summary>
[JsonProperty]
public int Range { get; set; } = 100;
/// <summary>
/// 滤波窗口,单位 min
/// </summary>
[JsonProperty]
public int Window { get; set; }
/// <summary>
/// 使用%方式检查异常
/// </summary>
[JsonProperty]
public bool IsCheckByPercent { get; set; } = true;
/// <summary>
/// 异常% 单位%
/// </summary>
[JsonProperty]
public double ErrPercent { get; set; } = 2;
/// <summary>
/// 异常值
/// </summary>
[JsonProperty]
public int ErrValue { get; set; } = 200;
/// <summary>
/// 样品
/// </summary>
[JsonProperty]
public SampleCell[] Samples { get; set; }
/// <summary>
/// 查找公差
/// </summary>
[JsonProperty]
public int Search { get; set; } = 100;
/// <summary>
/// 特征 相识度 0 正, 1 反
/// </summary>
[JsonProperty]
public SampleFeature[] Features { get; set; }
/// <summary>
/// 状态:从flyad7 得到的。 用于绘制图
/// </summary>
public int PosOfGrid { get; set; } = 10;
#endregion
TempFilter2[] tempFilters;
DIRECTION[] directions;
......@@ -113,6 +97,7 @@ namespace FLY.Thick.Base.Server
this.param_path = param_path;
Samples = new SampleCell[3];
Features = new SampleFeature[2];
tempFilters = new TempFilter2[Samples.Count()];
directions = new DIRECTION[Samples.Count()];
......@@ -169,40 +154,20 @@ namespace FLY.Thick.Base.Server
this.warningSystem = warningSystem;
Misc.BindingOperations.SetBinding(flyad, nameof(flyad.PosOfGrid), this, nameof(PosOfGrid));
}
public bool Load()
{
try
{
string json = File.ReadAllText(param_path);
Newtonsoft.Json.JsonConvert.PopulateObject(json, this);
}
catch
{
return false;
}
return true;
return GSampleJsonDb.Load(this, param_path);
}
/// <summary>
/// 保存
/// </summary>
public void Save()
public bool Save()
{
try
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(this, Formatting.Indented);
File.WriteAllText(param_path, json);
}
catch
{
}
return GSampleJsonDb.Save(this, param_path);
}
/// <summary>
/// 1.判断样品取样方向
......@@ -409,15 +374,16 @@ namespace FLY.Thick.Base.Server
int grid_b = grid1 - grid_searchtol;
int grid_e = grid2 + grid_searchtol;
int grid_len = grid_e - grid_b + 1;
psr.ScanData = new int[grid_len];//这个方向的需要 特征查找范围内的数据,不用考虑 buf 不够 grid_len
Array.Copy(buf, grid_b - grid_start, psr.ScanData, 0, grid_len);
int[] scanData = new int[grid_len];//这个方向的需要 特征查找范围内的数据,不用考虑 buf 不够 grid_len
Array.Copy(buf, grid_b - grid_start, scanData, 0, grid_len);
double max_relvency = 0;
int max_grid_offset = 0;
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)
{
max_relvency = r;
......@@ -620,4 +586,92 @@ namespace FLY.Thick.Base.Server
}
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