Commit 11ba095b authored by 潘栩锋's avatar 潘栩锋 🚴

修改 curve 与 getsample 都把 厚度值需要 *100, 改为直接double 类型了

parent f230d817
...@@ -158,9 +158,6 @@ ...@@ -158,9 +158,6 @@
<Compile Include="PgCurve.xaml.cs"> <Compile Include="PgCurve.xaml.cs">
<DependentUpon>PgCurve.xaml</DependentUpon> <DependentUpon>PgCurve.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="PgCurveModify.xaml.cs">
<DependentUpon>PgCurveModify.xaml</DependentUpon>
</Compile>
<Compile Include="PgError\PgErrorTable2.xaml.cs"> <Compile Include="PgError\PgErrorTable2.xaml.cs">
<DependentUpon>PgErrorTable2.xaml</DependentUpon> <DependentUpon>PgErrorTable2.xaml</DependentUpon>
</Compile> </Compile>
...@@ -314,10 +311,6 @@ ...@@ -314,10 +311,6 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="PgCurveModify.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="PgError\PgErrorTable2.xaml"> <Page Include="PgError\PgErrorTable2.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
......
...@@ -338,6 +338,9 @@ namespace FLY.Thick.Base.UI ...@@ -338,6 +338,9 @@ namespace FLY.Thick.Base.UI
int threshold = BorderSearchService.TempAD - BorderSearchService.TempRange; int threshold = BorderSearchService.TempAD - BorderSearchService.TempRange;
DrawYGridTick(e.ChartGraphics, pen, threshold); DrawYGridTick(e.ChartGraphics, pen, threshold);
threshold = BorderSearchService.TempAD + BorderSearchService.TempRange;
DrawYGridTick(e.ChartGraphics, pen, threshold);
} }
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Chr="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization" xmlns:Chr="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
xmlns:local="clr-namespace:FLY.Thick.Base.UI" xmlns:local="clr-namespace:FLY.Thick.Base.UI"
xmlns:common="clr-namespace:FLY.Thick.Base.Common;assembly=FLY.Thick.Base"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="768" d:DesignWidth="1024" d:DesignHeight="768" d:DesignWidth="1024"
Background="WhiteSmoke" Background="WhiteSmoke"
...@@ -42,47 +43,60 @@ ...@@ -42,47 +43,60 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel> <StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}"> <StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="曲线类型" /> <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="曲线类型" />
<ComboBox Width="191" HorizontalAlignment="Left"> <ComboBox Width="191" HorizontalAlignment="Left">
<ComboBoxItem IsSelected="{Binding Flag, Converter={StaticResource curvetype2boolconv}, ConverterParameter=E}"> <ComboBoxItem IsSelected="{Binding Flag, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:CurveType.E}}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" FontSize="32" Text="自然对数E"/> <TextBlock Style="{StaticResource Styles.Text.FieldContent}" FontSize="32" Text="自然对数E"/>
</ComboBoxItem> </ComboBoxItem>
<ComboBoxItem IsSelected="{Binding Flag, Converter={StaticResource curvetype2boolconv}, ConverterParameter=Line}"> <ComboBoxItem IsSelected="{Binding Flag, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:CurveType.Line}}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" FontSize="32" Text="线性"/> <TextBlock Style="{StaticResource Styles.Text.FieldContent}" FontSize="32" Text="线性"/>
</ComboBoxItem> </ComboBoxItem>
<ComboBoxItem IsSelected="{Binding Flag, Converter={StaticResource curvetype2boolconv}, ConverterParameter=X2}" > <ComboBoxItem IsSelected="{Binding Flag, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:CurveType.X2}}" >
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" FontSize="32" Text="2次曲线"/> <TextBlock Style="{StaticResource Styles.Text.FieldContent}" FontSize="32" Text="2次曲线"/>
</ComboBoxItem> </ComboBoxItem>
</ComboBox> </ComboBox>
</StackPanel> </StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}"> <StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="修正方式" /> <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="修正方式" />
<ComboBox Width="191" HorizontalAlignment="Left"> <ComboBox Width="191" HorizontalAlignment="Left">
<ComboBoxItem IsSelected="{Binding CorrectWay, Converter={StaticResource curvecorrway2boolconv}, ConverterParameter=OnePointIsScale}"> <ComboBoxItem IsSelected="{Binding CorrectWay, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:CurveCorrectWay.OnePointIsScale}}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" FontSize="32" Text="缩放"/> <TextBlock Style="{StaticResource Styles.Text.FieldContent}" FontSize="32" Text="缩放"/>
</ComboBoxItem> </ComboBoxItem>
<ComboBoxItem IsSelected="{Binding CorrectWay, Converter={StaticResource curvecorrway2boolconv}, ConverterParameter=OnePointIsOffset}"> <ComboBoxItem IsSelected="{Binding CorrectWay, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:CurveCorrectWay.OnePointIsOffset}}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" FontSize="32" Text="平移"/> <TextBlock Style="{StaticResource Styles.Text.FieldContent}" FontSize="32" Text="平移"/>
</ComboBoxItem> </ComboBoxItem>
</ComboBox> </ComboBox>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<DataGrid Grid.Row="1" AutoGenerateColumns="False" Width="204" TextBlock.FontSize="18" TextBlock.FontWeight="Normal" ItemsSource="{Binding Curves}"> <DataGrid Grid.Row="1" AutoGenerateColumns="False" Width="200" TextBlock.FontSize="18" TextBlock.FontWeight="Normal" ItemsSource="{Binding Curves}">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="AD" Binding="{Binding AD}" Width="100"/> <DataGridTextColumn Header="AD" Binding="{Binding AD}" Width="100"/>
<DataGridTextColumn Header="Value" Binding="{Binding Value,Converter={StaticResource thickconv}}" Width="100"/> <DataGridTextColumn Header="Value" Binding="{Binding Value}" Width="100"/>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
<StackPanel Grid.Row="2" Margin="0,5"> <WrapPanel Grid.Row="2" Margin="{StaticResource ControlMargin}" Width="200">
<Button Content="缩放" Style="{StaticResource ButtonStyle2}" Command="{Binding ScaleCmd}"/> <Button Content="应用" Style="{StaticResource Styles.Button.Square.Accent2}" Command="{Binding ApplyCmd}" />
<Button Content="应用" Style="{StaticResource ButtonStyle2}" Command="{Binding ApplyCmd}" /> </WrapPanel>
</StackPanel>
</Grid> </Grid>
<WindowsFormsHost Grid.Column="1" Margin="{StaticResource ControlMargin}"> <Grid Grid.Column="1" >
<Chr:Chart x:Name="chart1"/> <Grid.RowDefinitions>
</WindowsFormsHost> <RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}" >
<Button Content="AD缩放" Style="{StaticResource Styles.Button.Square2}" Command="{Binding AdScaleCmd}"/>
<Button Content="VALUE缩放" Style="{StaticResource Styles.Button.Square2}" Command="{Binding ValueScaleCmd}"/>
<Button Content="修正" Style="{StaticResource Styles.Button.Square2}" Command="{Binding SetRevisedCmd}"/>
<Button Content="导出xlsx" Style="{StaticResource Styles.Button.Square2}" Command="{Binding SaveXlsxCmd}"/>
<Button Content="导入xlsx" Style="{StaticResource Styles.Button.Square2}" Command="{Binding LoadXlsxCmd}"/>
</StackPanel>
<WindowsFormsHost Grid.Row="1" Margin="{StaticResource ControlMargin}">
<Chr:Chart x:Name="chart1"/>
</WindowsFormsHost>
</Grid>
</Grid> </Grid>
</Grid> </Grid>
</Page> </Page>
<Page x:Class="FLY.Thick.Base.UI.PgCurveModify"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Chr="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
xmlns:local="clr-namespace:FLY.Thick.Base.UI"
mc:Ignorable="d"
d:DesignHeight="768" d:DesignWidth="1024"
Background="WhiteSmoke"
Title="Page_Curve">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources>
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Background="{StaticResource Background_Title}">
<Button Style="{StaticResource ButtonStyle_back2}" Command="BrowseBack"/>
<TextBlock Style="{StaticResource TextBlockStyle_Title}" Text="修正AD曲线"/>
</StackPanel>
<Grid Grid.Row="1" Margin="0,5,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="784*" />
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="1" Margin="{StaticResource ControlMargin}">
<Button Content="设置修正" Style="{StaticResource ButtonStyle2}" Command="{Binding SetRevisedCmd}" Width="210" />
<Button Content="缩放" Style="{StaticResource ButtonStyle2}" Command="{Binding ScaleCmd}" Width="210" />
<Button Content="应用" Style="{StaticResource ButtonStyle2}" Command="{Binding ApplyCmd}" Width="210" />
</StackPanel>
</Grid>
<WindowsFormsHost Grid.Column="1" Margin="5">
<Chr:Chart x:Name="chart1"/>
</WindowsFormsHost>
</Grid>
</Grid>
</Page>
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<TextBlock Text="|" Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm_interval}" FontSize="24" /> <TextBlock Text="|" Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm_interval}" FontSize="24" />
<TextBlock Text="{Binding OrgAD}" Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" FontSize="12" /> <TextBlock Text="{Binding OrgAD}" Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" FontSize="12" />
</StackPanel> </StackPanel>
<TextBlock Grid.Column="1" Text="{Binding SampleValue,Converter={StaticResource ResourceKey=thickconv}}" FontSize="24" FontFamily="Microsoft Sans Serif" TextAlignment="Center" HorizontalAlignment="Center" Background="{StaticResource Color_theme_activity}" Foreground="White"/> <TextBlock Grid.Column="1" Text="{Binding SampleValue,StringFormat={}{0:F2}}" FontSize="24" FontFamily="Microsoft Sans Serif" TextAlignment="Center" HorizontalAlignment="Center" Background="{StaticResource Color_theme_activity}" Foreground="White"/>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:flyctrllib="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary" xmlns:flyctrllib="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
xmlns:local="clr-namespace:FLY.Thick.Base.UI" xmlns:local="clr-namespace:FLY.Thick.Base.UI"
Title="" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" SizeToContent="WidthAndHeight" > Title="" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" SizeToContent="WidthAndHeight"
Background="WhiteSmoke">
<Window.Resources> <Window.Resources>
<ResourceDictionary> <ResourceDictionary>
<local:BytesConverter x:Key="bytesconv"/> <local:BytesConverter x:Key="bytesconv"/>
...@@ -14,24 +16,25 @@ ...@@ -14,24 +16,25 @@
</Window.Resources> </Window.Resources>
<Grid TextBlock.FontSize="24" TextBlock.FontStyle="Normal" > <Grid TextBlock.FontSize="24" TextBlock.FontStyle="Normal" >
<StackPanel Orientation="Vertical" Margin="5,20"> <StackPanel Margin="{StaticResource ControlMargin}">
<Grid Height="30"/>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical" Margin="5"> <StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeader}" Text="原始AD" /> <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="原始" />
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="{Binding Old}" /> <TextBox Style="{StaticResource Styles.Text.FieldContent.Input}" Text="{Binding Old}" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeader}" Text="->" VerticalAlignment="Center" /> <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="->" VerticalAlignment="Center" />
<StackPanel Orientation="Vertical" Margin="5"> <StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="比例变化后AD" /> <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="变化后" />
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding New}" /> <TextBox Style="{StaticResource Styles.Text.FieldContent.Input}" Text="{Binding New}" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<Button Content="应用" Style="{StaticResource ButtonStyle2}" Margin="5" Width="auto" Click="button_apply_Click" /> <Button Style="{StaticResource Styles.Button.Apply}" Click="button_apply_Click" />
</StackPanel> </StackPanel>
</Grid> </Grid>
......
...@@ -19,8 +19,8 @@ namespace FLY.Thick.Base.UI ...@@ -19,8 +19,8 @@ namespace FLY.Thick.Base.UI
/// </summary> /// </summary>
public partial class WdAdScale : FLY.ControlLibrary.WindowBigClose public partial class WdAdScale : FLY.ControlLibrary.WindowBigClose
{ {
public int Old { get; set; } public double Old { get; set; }
public int New { get; set; } public double New { get; set; }
public WdAdScale() public WdAdScale()
{ {
......
...@@ -42,14 +42,7 @@ namespace FLY.Thick.Base.Client ...@@ -42,14 +42,7 @@ namespace FLY.Thick.Base.Client
[PropertyChanged.DoNotCheckEquality] [PropertyChanged.DoNotCheckEquality]
public CurveCell[] Curves { get; set; } public CurveCell[] Curves { get; set; }
public void SetRevised() public void Apply(CurveCorrectWay correctWay, CurveType flag, CurveCell2[] curves)
{
for (int i = 0; i < Curves.Count(); i++)
{
Curves[i].AD = Curves[i].RevisedAD;
}
}
public void Apply(CurveCorrectWay correctWay, CurveType flag, CurveCell[] curves)
{ {
Call(nameof(Apply), new { correctWay, flag, curves }); Call(nameof(Apply), new { correctWay, flag, curves });
} }
......
...@@ -16,14 +16,14 @@ namespace FLY.Thick.Base.Common ...@@ -16,14 +16,14 @@ namespace FLY.Thick.Base.Common
{ {
return "value=" + Value.ToString() + " ad=" + AD.ToString() + " revisedad=" + RevisedAD.ToString(); return "value=" + Value.ToString() + " ad=" + AD.ToString() + " revisedad=" + RevisedAD.ToString();
} }
/// <summary> /// <summary>
/// 面密度 /// 面密度
/// </summary> /// </summary>
public int Value { get; set; } public double Value { get; set; }
public int AD { get; set; } public int AD { get; set; }
/// <summary> /// <summary>
/// 校正后的AD值 /// 校正后的AD值
/// </summary> /// </summary>
...@@ -34,6 +34,25 @@ namespace FLY.Thick.Base.Common ...@@ -34,6 +34,25 @@ namespace FLY.Thick.Base.Common
#endregion #endregion
} }
public class CurveCell2 : INotifyPropertyChanged
{
public override string ToString()
{
return $"ad={AD},value={Value:F2}";
}
/// <summary>
/// 面密度
/// </summary>
public double Value { get; set; }
public int AD { get; set; }
#region INotifyPropertyChanged 成员
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
public enum AD2ValueFlag public enum AD2ValueFlag
{ {
/// <summary> /// <summary>
......
...@@ -17,28 +17,19 @@ namespace FLY.Thick.Base.Common ...@@ -17,28 +17,19 @@ namespace FLY.Thick.Base.Common
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
public void SetRevised()
{
for (int i = 0; i < Curves.Count(); i++)
{
Curves[i].AD = Curves[i].RevisedAD;
}
}
#region E #region E
int AD2Value_E(int ad, AD2ValueFlag flag) double AD2Value_E(int ad, AD2ValueFlag flag)
{ {
int i; int i;
int thick; double value;
if (Curves.Count < 1) return -1; if (Curves.Count() < 1) return -1;
if (ad < 0) return -1; if (ad < 0) return -1;
if (ad == 0) ad = 1; if (ad == 0) ad = 1;
if (flag == AD2ValueFlag.NoRevised) if (flag == AD2ValueFlag.NoRevised)
{ {
for (i = 0; i < Curves.Count; i++) for (i = 0; i < Curves.Count(); i++)
{ {
if (ad < Curves[i].AD) if (ad < Curves[i].AD)
continue; continue;
...@@ -48,7 +39,7 @@ namespace FLY.Thick.Base.Common ...@@ -48,7 +39,7 @@ namespace FLY.Thick.Base.Common
} }
else else
{ {
for (i = 0; i < Curves.Count; i++) for (i = 0; i < Curves.Count(); i++)
{ {
if (ad < Curves[i].RevisedAD) if (ad < Curves[i].RevisedAD)
continue; continue;
...@@ -56,51 +47,40 @@ namespace FLY.Thick.Base.Common ...@@ -56,51 +47,40 @@ namespace FLY.Thick.Base.Common
break; break;
} }
} }
if (i >= Curves.Count) i = Curves.Count - 1;
if (i == 0) i = 1; if (i >= Curves.Count())
i = Curves.Count() - 1;
if (i == 0)
i = 1;
var c0 = Curves[i - 1];
var c1 = Curves[i];
double ad0, ad1, ad2;
if (flag == AD2ValueFlag.NoRevised) if (flag == AD2ValueFlag.NoRevised)
{ {
ad0 = Math.Log(c0.AD, Math.E);
double adi_ad0 = Math.Log(Curves[i].AD) - Math.Log(Curves[i - 1].AD); ad1 = Math.Log(c1.AD, Math.E);
double vi_v0 = Curves[i].Value - Curves[i - 1].Value; ad2 = Math.Log(ad, Math.E);
double a = vi_v0 / adi_ad0;
double b = Curves[i - 1].Value - Math.Log(Curves[i - 1].AD) * a;
thick = (int)(Math.Log(ad) * a + b);
//double u;
//u = Math.Log((double)Curves[i - 1].AD / Curves[i].AD, Math.E) * 100 / (Curves[i].Value - Curves[i - 1].Value);
//thick = (int)(Math.Log((double)Curves[i - 1].AD / ad, Math.E) * 100 / u + Curves[i - 1].Value);
} }
else else
{ {
double adi_ad0 = Math.Log(Curves[i].RevisedAD) - Math.Log(Curves[i - 1].RevisedAD); ad0 = Math.Log(c0.RevisedAD, Math.E);
double vi_v0 = Curves[i].Value - Curves[i - 1].Value; ad1 = Math.Log(c1.RevisedAD, Math.E);
double a = vi_v0 / adi_ad0; ad2 = Math.Log(ad, Math.E);
double b = Curves[i - 1].Value - Math.Log(Curves[i - 1].RevisedAD) * a;
thick = (int)(Math.Log(ad) * a + b);
//double u;
//u = Math.Log((double)Curves[i - 1].RevisedAD / Curves[i].RevisedAD, Math.E) * 100 / (Curves[i].Value - Curves[i - 1].Value);
//thick = (int)(Math.Log((double)Curves[i - 1].RevisedAD / ad, Math.E) * 100 / u + Curves[i - 1].Value);
} }
//if (thick < 0) double u = (c1.Value - c0.Value) / (ad1 - ad0);
// return 0; value = (ad2 - ad0) * u + c0.Value;
return thick; return value;
} }
#endregion #endregion
#region 线性 #region 线性
int AD2Value_Line(int ad, AD2ValueFlag flag) double AD2Value_Line(int ad, AD2ValueFlag flag)
{ {
int i; int i;
int thick; double value;
if (Curves.Count < 2) return -1; if (Curves.Count() < 2) return -1;
if (ad < 0) return -1; if (ad < 0) return -1;
if (ad == 0) ad = 1; if (ad == 0) ad = 1;
bool isDescending = true;//降序排列 bool isDescending = true;//降序排列
...@@ -112,7 +92,7 @@ namespace FLY.Thick.Base.Common ...@@ -112,7 +92,7 @@ namespace FLY.Thick.Base.Common
{ {
if (isDescending)//降序排列 if (isDescending)//降序排列
{ {
for (i = 0; i < Curves.Count; i++) for (i = 0; i < Curves.Count(); i++)
{ {
if (ad < Curves[i].AD) if (ad < Curves[i].AD)
continue; continue;
...@@ -122,7 +102,7 @@ namespace FLY.Thick.Base.Common ...@@ -122,7 +102,7 @@ namespace FLY.Thick.Base.Common
} }
else else
{ {
for (i = 0; i < Curves.Count; i++) for (i = 0; i < Curves.Count(); i++)
{ {
if (ad > Curves[i].AD) if (ad > Curves[i].AD)
continue; continue;
...@@ -130,22 +110,12 @@ namespace FLY.Thick.Base.Common ...@@ -130,22 +110,12 @@ namespace FLY.Thick.Base.Common
break; break;
} }
} }
if (i >= Curves.Count) i = Curves.Count - 1;
if (i == 0) i = 1;
double adi_ad0 = Curves[i].AD - Curves[i - 1].AD;
double vi_v0 = Curves[i].Value - Curves[i - 1].Value;
double a = vi_v0 / adi_ad0;
double b = Curves[i - 1].Value - Curves[i - 1].AD * a;
thick = (int)(ad * a + b);
return thick;
} }
else else
{ {
if (isDescending)//降序排列 if (isDescending)//降序排列
{ {
for (i = 0; i < Curves.Count; i++) for (i = 0; i < Curves.Count(); i++)
{ {
if (ad < Curves[i].RevisedAD) if (ad < Curves[i].RevisedAD)
continue; continue;
...@@ -155,7 +125,7 @@ namespace FLY.Thick.Base.Common ...@@ -155,7 +125,7 @@ namespace FLY.Thick.Base.Common
} }
else else
{ {
for (i = 0; i < Curves.Count; i++) for (i = 0; i < Curves.Count(); i++)
{ {
if (ad > Curves[i].RevisedAD) if (ad > Curves[i].RevisedAD)
continue; continue;
...@@ -163,29 +133,43 @@ namespace FLY.Thick.Base.Common ...@@ -163,29 +133,43 @@ namespace FLY.Thick.Base.Common
break; break;
} }
} }
if (i >= Curves.Count) i = Curves.Count - 1; }
if (i == 0) i = 1;
double adi_ad0 = Curves[i].AD - Curves[i - 1].RevisedAD; if (i >= Curves.Count()) i = Curves.Count() - 1;
double vi_v0 = Curves[i].Value - Curves[i - 1].Value; if (i == 0) i = 1;
double a = vi_v0 / adi_ad0;
double b = Curves[i - 1].Value - Curves[i - 1].RevisedAD * a;
thick = (int)(ad * a + b); var c0 = Curves[i - 1];
return thick; var c1 = Curves[i];
double ad0, ad1, ad2 = ad;
if (flag == AD2ValueFlag.NoRevised)
{
ad0 = c0.AD;
ad1 = c1.AD;
}
else
{
ad0 = c0.RevisedAD;
ad1 = c1.RevisedAD;
} }
double u = (c1.Value - c0.Value) / (ad1 - ad0);
value = (ad2 - ad0) * u + c0.Value;
return value;
} }
#endregion #endregion
public int AD2Value(int ad, AD2ValueFlag flag) public double AD2Value(int ad, AD2ValueFlag flag)
{ {
double value;
switch (Flag) switch (Flag)
{ {
case CurveType.Line: case CurveType.Line:
return AD2Value_Line(ad, flag); value = AD2Value_Line(ad, flag);
break;
default: default:
return AD2Value_E(ad, flag); value = AD2Value_E(ad, flag);
break;
} }
return value;
} }
#endregion #endregion
} }
......
...@@ -24,6 +24,6 @@ namespace FLY.Thick.Base.IService ...@@ -24,6 +24,6 @@ namespace FLY.Thick.Base.IService
CurveCell[] Curves { get; } CurveCell[] Curves { get; }
void Apply(CurveCorrectWay correctWay, CurveType flag, CurveCell[] curves); void Apply(CurveCorrectWay correctWay, CurveType flag, CurveCell2[] curves);
} }
} }
...@@ -144,9 +144,12 @@ namespace FLY.Thick.Base.IService ...@@ -144,9 +144,12 @@ namespace FLY.Thick.Base.IService
/// <summary> /// <summary>
/// 状态:当前测量的AD值 对应的 样品值 /// 状态:当前测量的AD值 对应的 样品值
/// </summary> /// </summary>
public int SampleValue { get; set; } public double SampleValue { get; set; }
/// <summary>
/// 采集失败了
/// </summary>
public bool IsFailure { get; set; }
#region INotifyPropertyChanged 成员 #region INotifyPropertyChanged 成员
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
......
...@@ -40,7 +40,7 @@ namespace FLY.Thick.Base.OBJ_INTERFACE ...@@ -40,7 +40,7 @@ namespace FLY.Thick.Base.OBJ_INTERFACE
public class Pack_State_SampleCell public class Pack_State_SampleCell
{ {
public int ad; public int ad;
public int value; public double value;
} }
public class Pack_State_SampleFeature public class Pack_State_SampleFeature
{ {
......
...@@ -75,21 +75,22 @@ namespace FLY.Thick.Base.Server ...@@ -75,21 +75,22 @@ namespace FLY.Thick.Base.Server
Flag = CurveType.E; Flag = CurveType.E;
Curves = new CurveCell[] { Curves = new CurveCell[] {
new CurveCell() { AD = 57564, Value = 0 }, new CurveCell() { AD = 57564, Value = 0 },
new CurveCell() { AD = 30850, Value = 8800 }, new CurveCell() { AD = 30850, Value = 88 },
new CurveCell() { AD = 19000, Value = 17600 }, new CurveCell() { AD = 19000, Value = 176 },
new CurveCell() { AD = 12528, Value = 26400 }, new CurveCell() { AD = 12528, Value = 264 },
new CurveCell() { AD = 8409, Value = 35200 }, new CurveCell() { AD = 8409, Value = 352 },
new CurveCell() { AD = 5650, Value = 44000 }, new CurveCell() { AD = 5650, Value = 440 },
new CurveCell() { AD = 3779, Value = 52800 }, new CurveCell() { AD = 3779, Value = 528 },
new CurveCell() { AD = 2513, Value = 61600 }, new CurveCell() { AD = 2513, Value = 616 },
new CurveCell() { AD = 1660, Value = 70400 } new CurveCell() { AD = 1660, Value = 704 }
}; };
} }
public void Apply(CurveCorrectWay correctWay, CurveType flag, CurveCell[] curves) public void Apply(CurveCorrectWay correctWay, CurveType flag, CurveCell2[] curves)
{ {
CorrectWay = correctWay; CorrectWay = correctWay;
Flag = flag; Flag = flag;
Curves = curves;
Curves = curves.Select(c2 => new CurveCell() { AD = c2.AD, Value = c2.Value }).ToArray();
ClearExChange(); ClearExChange();
ReviseCurve(); ReviseCurve();
...@@ -202,10 +203,10 @@ namespace FLY.Thick.Base.Server ...@@ -202,10 +203,10 @@ namespace FLY.Thick.Base.Server
#region E #region E
int AD2Value_E(int ad, AD2ValueFlag flag) double AD2Value_E(int ad, AD2ValueFlag flag)
{ {
int i; int i;
int thick; double value;
if (Curves.Count() < 1) return -1; if (Curves.Count() < 1) return -1;
if (ad < 0) return -1; if (ad < 0) return -1;
...@@ -230,35 +231,38 @@ namespace FLY.Thick.Base.Server ...@@ -230,35 +231,38 @@ namespace FLY.Thick.Base.Server
break; break;
} }
} }
if (i >= Curves.Count()) i = Curves.Count() - 1;
if (i >= Curves.Count())
if (i == 0) i = 1; i = Curves.Count() - 1;
if (i == 0)
i = 1;
var c0 = Curves[i - 1];
var c1 = Curves[i];
double ad0, ad1, ad2;
if (flag == AD2ValueFlag.NoRevised) if (flag == AD2ValueFlag.NoRevised)
{ {
double u; ad0 = Math.Log(c0.AD, Math.E);
ad1 = Math.Log(c1.AD, Math.E);
u = Math.Log((double)Curves[i - 1].AD / Curves[i].AD, Math.E) * 100 / (Curves[i].Value - Curves[i - 1].Value); ad2 = Math.Log(ad, Math.E);
thick = (int)(Math.Log((double)Curves[i - 1].AD / ad, Math.E) * 100 / u + Curves[i - 1].Value);
} }
else else
{ {
double u; ad0 = Math.Log(c0.RevisedAD, Math.E);
ad1 = Math.Log(c1.RevisedAD, Math.E);
u = Math.Log((double)Curves[i - 1].RevisedAD / Curves[i].RevisedAD, Math.E) * 100 / (Curves[i].Value - Curves[i - 1].Value); ad2 = Math.Log(ad, Math.E);
thick = (int)(Math.Log((double)Curves[i - 1].RevisedAD / ad, Math.E) * 100 / u + Curves[i - 1].Value);
} }
//if (thick < 0) double u = (c1.Value - c0.Value) / (ad1 - ad0);
// return 0; value = (ad2 - ad0) * u + c0.Value;
return thick; return value;
} }
#endregion #endregion
#region 线性 #region 线性
int AD2Value_Line(int ad, AD2ValueFlag flag) double AD2Value_Line(int ad, AD2ValueFlag flag)
{ {
int i; int i;
int thick; double value;
if (Curves.Count() < 2) return -1; if (Curves.Count() < 2) return -1;
if (ad < 0) return -1; if (ad < 0) return -1;
...@@ -290,19 +294,8 @@ namespace FLY.Thick.Base.Server ...@@ -290,19 +294,8 @@ namespace FLY.Thick.Base.Server
break; break;
} }
} }
if (i >= Curves.Count()) i = Curves.Count() - 1;
if (i == 0) i = 1;
double adi_ad0 = Curves[i].AD - Curves[i - 1].AD;
double vi_v0 = Curves[i].Value - Curves[i - 1].Value;
double a = vi_v0 / adi_ad0;
double b = Curves[i - 1].Value - Curves[i - 1].AD * a;
thick = (int)(ad * a + b);
return thick;
} }
else else {
{
if (isDescending)//降序排列 if (isDescending)//降序排列
{ {
for (i = 0; i < Curves.Count(); i++) for (i = 0; i < Curves.Count(); i++)
...@@ -323,23 +316,33 @@ namespace FLY.Thick.Base.Server ...@@ -323,23 +316,33 @@ namespace FLY.Thick.Base.Server
break; break;
} }
} }
if (i >= Curves.Count()) i = Curves.Count() - 1; }
if (i == 0) i = 1;
if (i >= Curves.Count()) i = Curves.Count() - 1;
double adi_ad0 = Curves[i].RevisedAD - Curves[i - 1].RevisedAD; if (i == 0) i = 1;
double vi_v0 = Curves[i].Value - Curves[i - 1].Value;
double a = vi_v0 / adi_ad0;
double b = Curves[i - 1].Value - Curves[i - 1].RevisedAD * a;
thick = (int)(ad * a + b); var c0 = Curves[i - 1];
return thick; var c1 = Curves[i];
double ad0, ad1, ad2 = ad;
if (flag == AD2ValueFlag.NoRevised)
{
ad0 = c0.AD;
ad1 = c1.AD;
} }
else
{
ad0 = c0.RevisedAD;
ad1 = c1.RevisedAD;
}
double u = (c1.Value - c0.Value) / (ad1 - ad0);
value = (ad2 - ad0) * u + c0.Value;
return value;
} }
#endregion #endregion
public double AD2Value(int ad, AD2ValueFlag flag) public double AD2Value(int ad, AD2ValueFlag flag)
{ {
int value; double value;
switch (Flag) switch (Flag)
{ {
case CurveType.Line: case CurveType.Line:
...@@ -349,7 +352,7 @@ namespace FLY.Thick.Base.Server ...@@ -349,7 +352,7 @@ namespace FLY.Thick.Base.Server
value = AD2Value_E(ad, flag); value = AD2Value_E(ad, flag);
break; break;
} }
return value / 100.0; return value;
} }
...@@ -373,7 +376,15 @@ namespace FLY.Thick.Base.Server ...@@ -373,7 +376,15 @@ namespace FLY.Thick.Base.Server
{ {
static Mapper Mapper { get; } = new AutoMapper.Mapper(new MapperConfiguration(c => static Mapper Mapper { get; } = new AutoMapper.Mapper(new MapperConfiguration(c =>
{ {
c.CreateMap<CurveCollection, CurveCollectionJsonDb>().ReverseMap(); c.CreateMap<CurveCollection, CurveCollectionJsonDb>()
.ForMember(s => s.Curves, opt =>
{
opt.MapFrom(s => s.Curves == null ? null : s.Curves.Select(cu => new CurveCell2() { AD = cu.AD, Value = cu.Value }).ToArray());
}).ReverseMap().ForMember(s => s.Curves, opt =>
{
opt.MapFrom(s => s.Curves == null ? null : s.Curves.Select(cu => new CurveCell() { AD = cu.AD, Value = cu.Value }).ToArray());
});
})); }));
public static bool Load(CurveCollection src, string filePath) public static bool Load(CurveCollection src, string filePath)
{ {
...@@ -418,16 +429,16 @@ namespace FLY.Thick.Base.Server ...@@ -418,16 +429,16 @@ namespace FLY.Thick.Base.Server
public CurveType Flag = CurveType.E; public CurveType Flag = CurveType.E;
public CurveCell[] Curves = new CurveCell[] { public CurveCell2[] Curves = new CurveCell2[] {
new CurveCell() { AD = 57564, Value = 0 }, new CurveCell2() { AD = 57564, Value = 0 },
new CurveCell() { AD = 30850, Value = 8800 }, new CurveCell2() { AD = 30850, Value = 88 },
new CurveCell() { AD = 19000, Value = 17600 }, new CurveCell2() { AD = 19000, Value = 176 },
new CurveCell() { AD = 12528, Value = 26400 }, new CurveCell2() { AD = 12528, Value = 264 },
new CurveCell() { AD = 8409, Value = 35200 }, new CurveCell2() { AD = 8409, Value = 352 },
new CurveCell() { AD = 5650, Value = 44000 }, new CurveCell2() { AD = 5650, Value = 440 },
new CurveCell() { AD = 3779, Value = 52800 }, new CurveCell2() { AD = 3779, Value = 528 },
new CurveCell() { AD = 2513, Value = 61600 }, new CurveCell2() { AD = 2513, Value = 616 },
new CurveCell() { AD = 1660, Value = 70400 } new CurveCell2() { AD = 1660, Value = 704 }
}; };
} }
} }
...@@ -277,7 +277,7 @@ namespace FLY.Thick.Base.Server ...@@ -277,7 +277,7 @@ namespace FLY.Thick.Base.Server
} }
else { else {
//完成一次周期 //完成一次周期
if (gsample.OK()) if (!gsample.IsFailure())
orgStartTime = timer.Elapsed; orgStartTime = timer.Elapsed;
state = CTRLST.INIT; state = CTRLST.INIT;
} }
...@@ -290,7 +290,7 @@ namespace FLY.Thick.Base.Server ...@@ -290,7 +290,7 @@ namespace FLY.Thick.Base.Server
{ {
gsample.Do(Misc.DIRECTION.BACKWARD); gsample.Do(Misc.DIRECTION.BACKWARD);
//完成一次周期 //完成一次周期
if (gsample.OK()) if (!gsample.IsFailure())
orgStartTime = timer.Elapsed; orgStartTime = timer.Elapsed;
state = CTRLST.INIT; state = CTRLST.INIT;
} break; } break;
......
...@@ -359,7 +359,6 @@ namespace FLY.Thick.Base.Server ...@@ -359,7 +359,6 @@ namespace FLY.Thick.Base.Server
} }
bool mIsFailure = false;
/// <summary> /// <summary>
/// 样品取样,推送给thickm, 参数一定合法,不用检测 /// 样品取样,推送给thickm, 参数一定合法,不用检测
/// </summary> /// </summary>
...@@ -495,6 +494,7 @@ namespace FLY.Thick.Base.Server ...@@ -495,6 +494,7 @@ namespace FLY.Thick.Base.Server
{ {
sample.AD = ad; sample.AD = ad;
} }
sample.IsFailure = isFailure;
} }
} }
...@@ -509,7 +509,6 @@ namespace FLY.Thick.Base.Server ...@@ -509,7 +509,6 @@ namespace FLY.Thick.Base.Server
ERRNOs.Instance.SAMPLE_ERRNO_Failure.Descrption, ERRNOs.Instance.SAMPLE_ERRNO_Failure.Descrption,
OBJComponents.Common.ERR_STATE.ON); OBJComponents.Common.ERR_STATE.ON);
} }
mIsFailure = isFailure;
} }
/// <summary> /// <summary>
...@@ -520,21 +519,38 @@ namespace FLY.Thick.Base.Server ...@@ -520,21 +519,38 @@ namespace FLY.Thick.Base.Server
{ {
if (Enable) if (Enable)
{ {
if (mIsFailure) foreach (SampleCell sample in Samples)
return false; {
if (sample.Enable)
//foreach (SampleCell sample in Samples) {
//{ if ((sample.AD < 0))
// if ((sample.Enable) && (sample.AD < 0)) return false;
// { }
// return false; }
// }
//}
} }
return true; return true;
} }
/// <summary>
/// 刚才报警了,采样失败
/// </summary>
/// <returns></returns>
public bool IsFailure()
{
if (Enable)
{
foreach (SampleCell sample in Samples)
{
if (sample.Enable)
{
if ((sample.AD < 0) || (sample.IsFailure))
return true;
}
}
}
return false;
}
/// <summary> /// <summary>
/// 获取N秒的数据, /// 获取N秒的数据,
/// </summary> /// </summary>
......
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