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

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

parent f230d817
......@@ -158,9 +158,6 @@
<Compile Include="PgCurve.xaml.cs">
<DependentUpon>PgCurve.xaml</DependentUpon>
</Compile>
<Compile Include="PgCurveModify.xaml.cs">
<DependentUpon>PgCurveModify.xaml</DependentUpon>
</Compile>
<Compile Include="PgError\PgErrorTable2.xaml.cs">
<DependentUpon>PgErrorTable2.xaml</DependentUpon>
</Compile>
......@@ -314,10 +311,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="PgCurveModify.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="PgError\PgErrorTable2.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......
......@@ -338,6 +338,9 @@ namespace FLY.Thick.Base.UI
int threshold = BorderSearchService.TempAD - BorderSearchService.TempRange;
DrawYGridTick(e.ChartGraphics, pen, threshold);
threshold = BorderSearchService.TempAD + BorderSearchService.TempRange;
DrawYGridTick(e.ChartGraphics, pen, threshold);
}
}
......
......@@ -5,6 +5,7 @@
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"
xmlns:common="clr-namespace:FLY.Thick.Base.Common;assembly=FLY.Thick.Base"
mc:Ignorable="d"
d:DesignHeight="768" d:DesignWidth="1024"
Background="WhiteSmoke"
......@@ -42,47 +43,60 @@
</Grid.RowDefinitions>
<StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="曲线类型" />
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="曲线类型" />
<ComboBox Width="191" HorizontalAlignment="Left">
<ComboBoxItem IsSelected="{Binding Flag, Converter={StaticResource curvetype2boolconv}, ConverterParameter=E}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" FontSize="32" Text="自然对数E"/>
<ComboBoxItem IsSelected="{Binding Flag, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:CurveType.E}}">
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" FontSize="32" Text="自然对数E"/>
</ComboBoxItem>
<ComboBoxItem IsSelected="{Binding Flag, Converter={StaticResource curvetype2boolconv}, ConverterParameter=Line}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" FontSize="32" Text="线性"/>
<ComboBoxItem IsSelected="{Binding Flag, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:CurveType.Line}}">
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" FontSize="32" Text="线性"/>
</ComboBoxItem>
<ComboBoxItem IsSelected="{Binding Flag, Converter={StaticResource curvetype2boolconv}, ConverterParameter=X2}" >
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" FontSize="32" Text="2次曲线"/>
<ComboBoxItem IsSelected="{Binding Flag, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:CurveType.X2}}" >
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" FontSize="32" Text="2次曲线"/>
</ComboBoxItem>
</ComboBox>
</StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="修正方式" />
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="修正方式" />
<ComboBox Width="191" HorizontalAlignment="Left">
<ComboBoxItem IsSelected="{Binding CorrectWay, Converter={StaticResource curvecorrway2boolconv}, ConverterParameter=OnePointIsScale}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" FontSize="32" Text="缩放"/>
<ComboBoxItem IsSelected="{Binding CorrectWay, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:CurveCorrectWay.OnePointIsScale}}">
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" FontSize="32" Text="缩放"/>
</ComboBoxItem>
<ComboBoxItem IsSelected="{Binding CorrectWay, Converter={StaticResource curvecorrway2boolconv}, ConverterParameter=OnePointIsOffset}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" FontSize="32" Text="平移"/>
<ComboBoxItem IsSelected="{Binding CorrectWay, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:CurveCorrectWay.OnePointIsOffset}}">
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" FontSize="32" Text="平移"/>
</ComboBoxItem>
</ComboBox>
</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>
<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>
<StackPanel Grid.Row="2" Margin="0,5">
<Button Content="缩放" Style="{StaticResource ButtonStyle2}" Command="{Binding ScaleCmd}"/>
<Button Content="应用" Style="{StaticResource ButtonStyle2}" Command="{Binding ApplyCmd}" />
</StackPanel>
<WrapPanel Grid.Row="2" Margin="{StaticResource ControlMargin}" Width="200">
<Button Content="应用" Style="{StaticResource Styles.Button.Square.Accent2}" Command="{Binding ApplyCmd}" />
</WrapPanel>
</Grid>
<WindowsFormsHost Grid.Column="1" Margin="{StaticResource ControlMargin}">
<Grid Grid.Column="1" >
<Grid.RowDefinitions>
<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>
</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 @@
<TextBlock Text="|" Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm_interval}" FontSize="24" />
<TextBlock Text="{Binding OrgAD}" Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" FontSize="12" />
</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>
</DataTemplate>
</ItemsControl.ItemTemplate>
......
......@@ -3,7 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:flyctrllib="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
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>
<ResourceDictionary>
<local:BytesConverter x:Key="bytesconv"/>
......@@ -14,24 +16,25 @@
</Window.Resources>
<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="Vertical" Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeader}" Text="原始AD" />
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="原始" />
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="{Binding Old}" />
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input}" Text="{Binding Old}" />
</StackPanel>
</StackPanel>
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeader}" Text="->" VerticalAlignment="Center" />
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="比例变化后AD" />
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="->" VerticalAlignment="Center" />
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="变化后" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding New}" />
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input}" Text="{Binding New}" />
</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>
</Grid>
......
......@@ -19,8 +19,8 @@ namespace FLY.Thick.Base.UI
/// </summary>
public partial class WdAdScale : FLY.ControlLibrary.WindowBigClose
{
public int Old { get; set; }
public int New { get; set; }
public double Old { get; set; }
public double New { get; set; }
public WdAdScale()
{
......
......@@ -42,14 +42,7 @@ namespace FLY.Thick.Base.Client
[PropertyChanged.DoNotCheckEquality]
public CurveCell[] Curves { get; set; }
public void SetRevised()
{
for (int i = 0; i < Curves.Count(); i++)
{
Curves[i].AD = Curves[i].RevisedAD;
}
}
public void Apply(CurveCorrectWay correctWay, CurveType flag, CurveCell[] curves)
public void Apply(CurveCorrectWay correctWay, CurveType flag, CurveCell2[] curves)
{
Call(nameof(Apply), new { correctWay, flag, curves });
}
......
......@@ -16,14 +16,14 @@ namespace FLY.Thick.Base.Common
{
return "value=" + Value.ToString() + " ad=" + AD.ToString() + " revisedad=" + RevisedAD.ToString();
}
/// <summary>
/// 面密度
/// </summary>
public int Value { get; set; }
public double Value { get; set; }
public int AD { get; set; }
/// <summary>
/// 校正后的AD值
/// </summary>
......@@ -34,6 +34,25 @@ namespace FLY.Thick.Base.Common
#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
{
/// <summary>
......
......@@ -17,28 +17,19 @@ namespace FLY.Thick.Base.Common
public event PropertyChangedEventHandler PropertyChanged;
public void SetRevised()
{
for (int i = 0; i < Curves.Count(); i++)
{
Curves[i].AD = Curves[i].RevisedAD;
}
}
#region E
int AD2Value_E(int ad, AD2ValueFlag flag)
double AD2Value_E(int ad, AD2ValueFlag flag)
{
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) ad = 1;
if (flag == AD2ValueFlag.NoRevised)
{
for (i = 0; i < Curves.Count; i++)
for (i = 0; i < Curves.Count(); i++)
{
if (ad < Curves[i].AD)
continue;
......@@ -48,7 +39,7 @@ namespace FLY.Thick.Base.Common
}
else
{
for (i = 0; i < Curves.Count; i++)
for (i = 0; i < Curves.Count(); i++)
{
if (ad < Curves[i].RevisedAD)
continue;
......@@ -56,51 +47,40 @@ namespace FLY.Thick.Base.Common
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)
{
double adi_ad0 = Math.Log(Curves[i].AD) - Math.Log(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 - 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);
ad0 = Math.Log(c0.AD, Math.E);
ad1 = Math.Log(c1.AD, Math.E);
ad2 = Math.Log(ad, Math.E);
}
else
{
double adi_ad0 = Math.Log(Curves[i].RevisedAD) - Math.Log(Curves[i - 1].RevisedAD);
double vi_v0 = Curves[i].Value - Curves[i - 1].Value;
double a = vi_v0 / adi_ad0;
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);
ad0 = Math.Log(c0.RevisedAD, Math.E);
ad1 = Math.Log(c1.RevisedAD, Math.E);
ad2 = Math.Log(ad, Math.E);
}
//if (thick < 0)
// return 0;
double u = (c1.Value - c0.Value) / (ad1 - ad0);
value = (ad2 - ad0) * u + c0.Value;
return thick;
return value;
}
#endregion
#region 线性
int AD2Value_Line(int ad, AD2ValueFlag flag)
double AD2Value_Line(int ad, AD2ValueFlag flag)
{
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) ad = 1;
bool isDescending = true;//降序排列
......@@ -112,7 +92,7 @@ namespace FLY.Thick.Base.Common
{
if (isDescending)//降序排列
{
for (i = 0; i < Curves.Count; i++)
for (i = 0; i < Curves.Count(); i++)
{
if (ad < Curves[i].AD)
continue;
......@@ -122,7 +102,7 @@ namespace FLY.Thick.Base.Common
}
else
{
for (i = 0; i < Curves.Count; i++)
for (i = 0; i < Curves.Count(); i++)
{
if (ad > Curves[i].AD)
continue;
......@@ -130,22 +110,12 @@ namespace FLY.Thick.Base.Common
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
{
if (isDescending)//降序排列
{
for (i = 0; i < Curves.Count; i++)
for (i = 0; i < Curves.Count(); i++)
{
if (ad < Curves[i].RevisedAD)
continue;
......@@ -155,7 +125,7 @@ namespace FLY.Thick.Base.Common
}
else
{
for (i = 0; i < Curves.Count; i++)
for (i = 0; i < Curves.Count(); i++)
{
if (ad > Curves[i].RevisedAD)
continue;
......@@ -163,29 +133,43 @@ namespace FLY.Thick.Base.Common
break;
}
}
if (i >= Curves.Count) i = Curves.Count - 1;
if (i == 0) i = 1;
}
double adi_ad0 = Curves[i].AD - Curves[i - 1].RevisedAD;
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;
if (i >= Curves.Count()) i = Curves.Count() - 1;
if (i == 0) i = 1;
thick = (int)(ad * a + b);
return thick;
var c0 = Curves[i - 1];
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
public int AD2Value(int ad, AD2ValueFlag flag)
public double AD2Value(int ad, AD2ValueFlag flag)
{
double value;
switch (Flag)
{
case CurveType.Line:
return AD2Value_Line(ad, flag);
value = AD2Value_Line(ad, flag);
break;
default:
return AD2Value_E(ad, flag);
value = AD2Value_E(ad, flag);
break;
}
return value;
}
#endregion
}
......
......@@ -24,6 +24,6 @@ namespace FLY.Thick.Base.IService
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
/// <summary>
/// 状态:当前测量的AD值 对应的 样品值
/// </summary>
public int SampleValue { get; set; }
public double SampleValue { get; set; }
/// <summary>
/// 采集失败了
/// </summary>
public bool IsFailure { get; set; }
#region INotifyPropertyChanged 成员
public event PropertyChangedEventHandler PropertyChanged;
......
......@@ -40,7 +40,7 @@ namespace FLY.Thick.Base.OBJ_INTERFACE
public class Pack_State_SampleCell
{
public int ad;
public int value;
public double value;
}
public class Pack_State_SampleFeature
{
......
......@@ -75,21 +75,22 @@ namespace FLY.Thick.Base.Server
Flag = CurveType.E;
Curves = new CurveCell[] {
new CurveCell() { AD = 57564, Value = 0 },
new CurveCell() { AD = 30850, Value = 8800 },
new CurveCell() { AD = 19000, Value = 17600 },
new CurveCell() { AD = 12528, Value = 26400 },
new CurveCell() { AD = 8409, Value = 35200 },
new CurveCell() { AD = 5650, Value = 44000 },
new CurveCell() { AD = 3779, Value = 52800 },
new CurveCell() { AD = 2513, Value = 61600 },
new CurveCell() { AD = 1660, Value = 70400 }
new CurveCell() { AD = 30850, Value = 88 },
new CurveCell() { AD = 19000, Value = 176 },
new CurveCell() { AD = 12528, Value = 264 },
new CurveCell() { AD = 8409, Value = 352 },
new CurveCell() { AD = 5650, Value = 440 },
new CurveCell() { AD = 3779, Value = 528 },
new CurveCell() { AD = 2513, Value = 616 },
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;
Flag = flag;
Curves = curves;
Curves = curves.Select(c2 => new CurveCell() { AD = c2.AD, Value = c2.Value }).ToArray();
ClearExChange();
ReviseCurve();
......@@ -202,10 +203,10 @@ namespace FLY.Thick.Base.Server
#region E
int AD2Value_E(int ad, AD2ValueFlag flag)
double AD2Value_E(int ad, AD2ValueFlag flag)
{
int i;
int thick;
double value;
if (Curves.Count() < 1) return -1;
if (ad < 0) return -1;
......@@ -230,35 +231,38 @@ namespace FLY.Thick.Base.Server
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)
{
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);
ad0 = Math.Log(c0.AD, Math.E);
ad1 = Math.Log(c1.AD, Math.E);
ad2 = Math.Log(ad, Math.E);
}
else
{
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);
ad0 = Math.Log(c0.RevisedAD, Math.E);
ad1 = Math.Log(c1.RevisedAD, Math.E);
ad2 = Math.Log(ad, Math.E);
}
//if (thick < 0)
// return 0;
double u = (c1.Value - c0.Value) / (ad1 - ad0);
value = (ad2 - ad0) * u + c0.Value;
return thick;
return value;
}
#endregion
#region 线性
int AD2Value_Line(int ad, AD2ValueFlag flag)
double AD2Value_Line(int ad, AD2ValueFlag flag)
{
int i;
int thick;
double value;
if (Curves.Count() < 2) return -1;
if (ad < 0) return -1;
......@@ -290,19 +294,8 @@ namespace FLY.Thick.Base.Server
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)//降序排列
{
for (i = 0; i < Curves.Count(); i++)
......@@ -323,23 +316,33 @@ namespace FLY.Thick.Base.Server
break;
}
}
}
if (i >= Curves.Count()) i = Curves.Count() - 1;
if (i == 0) i = 1;
double adi_ad0 = Curves[i].RevisedAD - Curves[i - 1].RevisedAD;
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);
return thick;
var c0 = Curves[i - 1];
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
public double AD2Value(int ad, AD2ValueFlag flag)
{
int value;
double value;
switch (Flag)
{
case CurveType.Line:
......@@ -349,7 +352,7 @@ namespace FLY.Thick.Base.Server
value = AD2Value_E(ad, flag);
break;
}
return value / 100.0;
return value;
}
......@@ -373,7 +376,15 @@ namespace FLY.Thick.Base.Server
{
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)
{
......@@ -418,16 +429,16 @@ namespace FLY.Thick.Base.Server
public CurveType Flag = CurveType.E;
public CurveCell[] Curves = new CurveCell[] {
new CurveCell() { AD = 57564, Value = 0 },
new CurveCell() { AD = 30850, Value = 8800 },
new CurveCell() { AD = 19000, Value = 17600 },
new CurveCell() { AD = 12528, Value = 26400 },
new CurveCell() { AD = 8409, Value = 35200 },
new CurveCell() { AD = 5650, Value = 44000 },
new CurveCell() { AD = 3779, Value = 52800 },
new CurveCell() { AD = 2513, Value = 61600 },
new CurveCell() { AD = 1660, Value = 70400 }
public CurveCell2[] Curves = new CurveCell2[] {
new CurveCell2() { AD = 57564, Value = 0 },
new CurveCell2() { AD = 30850, Value = 88 },
new CurveCell2() { AD = 19000, Value = 176 },
new CurveCell2() { AD = 12528, Value = 264 },
new CurveCell2() { AD = 8409, Value = 352 },
new CurveCell2() { AD = 5650, Value = 440 },
new CurveCell2() { AD = 3779, Value = 528 },
new CurveCell2() { AD = 2513, Value = 616 },
new CurveCell2() { AD = 1660, Value = 704 }
};
}
}
......@@ -277,7 +277,7 @@ namespace FLY.Thick.Base.Server
}
else {
//完成一次周期
if (gsample.OK())
if (!gsample.IsFailure())
orgStartTime = timer.Elapsed;
state = CTRLST.INIT;
}
......@@ -290,7 +290,7 @@ namespace FLY.Thick.Base.Server
{
gsample.Do(Misc.DIRECTION.BACKWARD);
//完成一次周期
if (gsample.OK())
if (!gsample.IsFailure())
orgStartTime = timer.Elapsed;
state = CTRLST.INIT;
} break;
......
......@@ -359,7 +359,6 @@ namespace FLY.Thick.Base.Server
}
bool mIsFailure = false;
/// <summary>
/// 样品取样,推送给thickm, 参数一定合法,不用检测
/// </summary>
......@@ -495,6 +494,7 @@ namespace FLY.Thick.Base.Server
{
sample.AD = ad;
}
sample.IsFailure = isFailure;
}
}
......@@ -509,7 +509,6 @@ namespace FLY.Thick.Base.Server
ERRNOs.Instance.SAMPLE_ERRNO_Failure.Descrption,
OBJComponents.Common.ERR_STATE.ON);
}
mIsFailure = isFailure;
}
/// <summary>
......@@ -520,21 +519,38 @@ namespace FLY.Thick.Base.Server
{
if (Enable)
{
if (mIsFailure)
foreach (SampleCell sample in Samples)
{
if (sample.Enable)
{
if ((sample.AD < 0))
return false;
//foreach (SampleCell sample in Samples)
//{
// if ((sample.Enable) && (sample.AD < 0))
// {
// return false;
// }
//}
}
}
}
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>
/// 获取N秒的数据,
/// </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