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

添加 自动模头多级控制

parent c87c3df7
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
xmlns:misc="clr-namespace:Misc;assembly=MISC" xmlns:misc="clr-namespace:Misc;assembly=MISC"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignWidth="1024" d:DesignWidth="1024"
Background="WhiteSmoke" Background="WhiteSmoke">
d:DataContext="{d:DesignInstance local:PgSetupVm}">
<Page.Resources> <Page.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
...@@ -22,15 +21,16 @@ ...@@ -22,15 +21,16 @@
<local:HeatEffectConverter x:Key="heconv"/> <local:HeatEffectConverter x:Key="heconv"/>
<local:MaxR2VisConverter x:Key="maxR2VisConv"/> <local:MaxR2VisConverter x:Key="maxR2VisConv"/>
<local:Id2VisConverter x:Key="id2VisConv"/> <local:Id2VisConverter x:Key="id2VisConv"/>
<local:PgSetupVmUt x:Key="viewModel"/>
</ResourceDictionary> </ResourceDictionary>
</Page.Resources> </Page.Resources>
<Grid > <Grid d:DataContext="{StaticResource viewModel}" >
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="auto" /> <RowDefinition Height="auto" />
<RowDefinition /> <RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid x:Name="grid_viewModel"/> <Grid x:Name="grid_viewModel" />
<StackPanel Orientation="Horizontal" Background="{StaticResource Brushes.TitleBar.Background}" > <StackPanel Orientation="Horizontal" Background="{StaticResource Brushes.TitleBar.Background}" >
<Button Style="{StaticResource Styles.TitleBar.BackButton2}" Command="BrowseBack"/> <Button Style="{StaticResource Styles.TitleBar.BackButton2}" Command="BrowseBack"/>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
<ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" IsChecked="{Binding IsForbidUpDown}"/> <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" IsChecked="{Binding IsForbidUpDown}"/>
</StackPanel> </StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}"> <StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="控制线" /> <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="基本控制线" />
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding CtrlLine,StringFormat={}{0:0.#}}"/> <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding CtrlLine,StringFormat={}{0:0.#}}"/>
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="%" /> <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="%" />
...@@ -89,7 +89,20 @@ ...@@ -89,7 +89,20 @@
</StackPanel> </StackPanel>
</Border> </Border>
<Border Style="{StaticResource Styles.Card.Border}" >
<StackPanel>
<TextBlock Grid.Column="1" Style="{StaticResource Styles.Card.Title}" Text="分级控制"/>
<StackPanel>
<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding LvCtrlLines}" MinWidth="204" MinHeight="100" TextBlock.FontSize="18" TextBlock.FontWeight="Normal">
<DataGrid.Columns>
<DataGridTextColumn Header="控制线%" Binding="{Binding CtrlLine}" Width="150"/>
<DataGridTextColumn Header="厚度混合数" Binding="{Binding Mix}" Width="150"/>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</StackPanel>
</Border>
<Border Style="{StaticResource Styles.Card.Border}"> <Border Style="{StaticResource Styles.Card.Border}">
<StackPanel > <StackPanel >
...@@ -118,7 +131,7 @@ ...@@ -118,7 +131,7 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}"> <StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="厚度混合数" /> <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="基本厚度混合数" />
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding Mix}"/> <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding Mix}"/>
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="次" /> <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="次" />
...@@ -232,20 +245,20 @@ ...@@ -232,20 +245,20 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" DataContext="{Binding HeatBuf}"> <StackPanel Orientation="Horizontal" >
<StackPanel Margin="{StaticResource ControlMargin}"> <StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="相关性阀值" /> <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="相关性阀值" />
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding ThresholdR,StringFormat={}{0:F2}}"/> <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding ThresholdR,StringFormat={}{0:F2}}"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}"> <StackPanel Margin="{StaticResource ControlMargin}" DataContext="{Binding HeatBuf}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="稳定性" /> <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="稳定性" />
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding CurrR, StringFormat={}{0:F2}}" /> <TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding CurrR, StringFormat={}{0:F2}}" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}"> <StackPanel Margin="{StaticResource ControlMargin}" DataContext="{Binding HeatBuf}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="稳定状态" /> <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="稳定状态" />
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding Stability, Converter={StaticResource stableconv}}" /> <TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding Stability, Converter={StaticResource stableconv}}" />
......
...@@ -18,6 +18,7 @@ using FLY.FilmCasting.AutoDie.IService; ...@@ -18,6 +18,7 @@ using FLY.FilmCasting.AutoDie.IService;
using System.ComponentModel; using System.ComponentModel;
using Unity; using Unity;
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
using System.Collections.ObjectModel;
namespace FLY.FilmCasting.AutoDie.UI.Client namespace FLY.FilmCasting.AutoDie.UI.Client
{ {
...@@ -93,6 +94,11 @@ namespace FLY.FilmCasting.AutoDie.UI.Client ...@@ -93,6 +94,11 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
/// 膜距离 /// 膜距离
/// </summary> /// </summary>
public double FilmLength { get; set; } = 20; public double FilmLength { get; set; } = 20;
/// <summary>
/// 分级控制
/// </summary>
public ObservableCollection<LvCtrlLine> LvCtrlLines { get; } = new ObservableCollection<LvCtrlLine>();
#endregion #endregion
#region Command #region Command
...@@ -137,6 +143,18 @@ namespace FLY.FilmCasting.AutoDie.UI.Client ...@@ -137,6 +143,18 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
Misc.BindingOperations.SetBinding(this.HeatCell, nameof(IHeatCellService.MaxHeat), this, nameof(MaxHeat)); Misc.BindingOperations.SetBinding(this.HeatCell, nameof(IHeatCellService.MaxHeat), this, nameof(MaxHeat));
Misc.BindingOperations.SetBinding(this.HeatCell, nameof(IHeatCellService.RangeOfOffset), this, nameof(RangeOfOffset)); Misc.BindingOperations.SetBinding(this.HeatCell, nameof(IHeatCellService.RangeOfOffset), this, nameof(RangeOfOffset));
Misc.BindingOperations.SetBinding(this.HeatCell, nameof(IHeatCellService.CenterTarget), this, nameof(CenterTarget)); Misc.BindingOperations.SetBinding(this.HeatCell, nameof(IHeatCellService.CenterTarget), this, nameof(CenterTarget));
Misc.BindingOperations.SetBinding(this.HeatCell, nameof(IHeatCellService.LvCtrlLines), ()=> {
LvCtrlLines.Clear();
if (this.HeatCell.LvCtrlLines == null)
return;
if (this.HeatCell.LvCtrlLines.Count() == 0)
return;
foreach (var lvCtrlLine in this.HeatCell.LvCtrlLines) {
LvCtrlLines.Add(new LvCtrlLine() { CtrlLine = lvCtrlLine.CtrlLine, Mix = lvCtrlLine.Mix });
}
});
Misc.BindingOperations.SetBinding(this.HeatCell, nameof(IHeatCellService.Mix), this, nameof(Mix));
Misc.BindingOperations.SetBinding(this.Feedback, nameof(IFeedbackHeatService.Step), this, nameof(Step)); Misc.BindingOperations.SetBinding(this.Feedback, nameof(IFeedbackHeatService.Step), this, nameof(Step));
...@@ -144,7 +162,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client ...@@ -144,7 +162,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
Misc.BindingOperations.SetBinding(this.Feedback, nameof(IFeedbackHeatService.Delay), this, nameof(Delay)); Misc.BindingOperations.SetBinding(this.Feedback, nameof(IFeedbackHeatService.Delay), this, nameof(Delay));
Misc.BindingOperations.SetBinding(this.Feedback, nameof(IFeedbackHeatService.HasCheckFilmVelocity), this, nameof(HasCheckFilmVelocity)); Misc.BindingOperations.SetBinding(this.Feedback, nameof(IFeedbackHeatService.HasCheckFilmVelocity), this, nameof(HasCheckFilmVelocity));
Misc.BindingOperations.SetBinding(this.Feedback, nameof(IFeedbackHeatService.FilmLength), this, nameof(FilmLength)); Misc.BindingOperations.SetBinding(this.Feedback, nameof(IFeedbackHeatService.FilmLength), this, nameof(FilmLength));
Misc.BindingOperations.SetBinding(this.Feedback, nameof(IFeedbackHeatService.Mix), this, nameof(Mix));
Misc.BindingOperations.SetBinding(this.HeatBuf, nameof(IHeatBufService.ThresholdSigmaMax), this, nameof(ThresholdSigmaMax)); Misc.BindingOperations.SetBinding(this.HeatBuf, nameof(IHeatBufService.ThresholdSigmaMax), this, nameof(ThresholdSigmaMax));
...@@ -158,7 +176,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client ...@@ -158,7 +176,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
}); });
Misc.BindingOperations.SetBinding(this.HeatBuf, nameof(IHeatBufService.ThresholdR), this, nameof(ThresholdR)); Misc.BindingOperations.SetBinding(this.HeatBuf, nameof(IHeatBufService.ThresholdR), this, nameof(ThresholdR));
#endregion #endregion
...@@ -201,10 +219,53 @@ namespace FLY.FilmCasting.AutoDie.UI.Client ...@@ -201,10 +219,53 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
} }
return true; return true;
} }
bool CheckValid_LvCtrlLines()
{
for(int i=0;i< LvCtrlLines.Count(); i++)
{
var lvCtrlLine = LvCtrlLines[i];
if (lvCtrlLine.CtrlLine >= CtrlLine)
{
FLY.ControlLibrary.Window_WarningTip.Show(
"参数异常", "多级控制 的每级控制线 必须小于 基本控制线", TimeSpan.FromSeconds(2));
return false;
}
if (lvCtrlLine.Mix <= Mix)
{
FLY.ControlLibrary.Window_WarningTip.Show(
"参数异常", "多级控制 的每级厚度混合数 必须大于 基本厚度混合数", TimeSpan.FromSeconds(2));
return false;
}
if ( i+1 < LvCtrlLines.Count())
{
var lvCtrlLine1 = LvCtrlLines[i+1];
if (lvCtrlLine.CtrlLine <= lvCtrlLine1.CtrlLine)
{
FLY.ControlLibrary.Window_WarningTip.Show(
"参数异常", "多级控制 的每级控制线 必须 从大到小排列", TimeSpan.FromSeconds(2));
return false;
}
if (lvCtrlLine.Mix >= lvCtrlLine1.Mix)
{
FLY.ControlLibrary.Window_WarningTip.Show(
"参数异常", "多级控制 的每级混合数 必须 从小到大排列", TimeSpan.FromSeconds(2));
return false;
}
}
}
return true;
}
bool CheckValid() bool CheckValid()
{ {
if (CheckValid_HeatEffectCurve() == false) if (CheckValid_HeatEffectCurve() == false)
return false; return false;
if(CheckValid_LvCtrlLines()==false)
return false;
if (Mix < 2) { if (Mix < 2) {
FLY.ControlLibrary.Window_WarningTip.Show( FLY.ControlLibrary.Window_WarningTip.Show(
...@@ -218,6 +279,8 @@ namespace FLY.FilmCasting.AutoDie.UI.Client ...@@ -218,6 +279,8 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
"参数异常", "模头到测厚仪距离<2m", TimeSpan.FromSeconds(2)); "参数异常", "模头到测厚仪距离<2m", TimeSpan.FromSeconds(2));
return false; return false;
} }
return true; return true;
} }
...@@ -237,13 +300,29 @@ namespace FLY.FilmCasting.AutoDie.UI.Client ...@@ -237,13 +300,29 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
HeatCell.MaxHeat = this.MaxHeat; HeatCell.MaxHeat = this.MaxHeat;
HeatCell.RangeOfOffset = this.RangeOfOffset; HeatCell.RangeOfOffset = this.RangeOfOffset;
HeatCell.CenterTarget = Math.Round(this.CenterTarget, 1); HeatCell.CenterTarget = Math.Round(this.CenterTarget, 1);
if (LvCtrlLines.Count() > 0)
{
var lvCtrlLines = new LvCtrlLine[LvCtrlLines.Count()];
for (int i=0;i<LvCtrlLines.Count();i++)
{
var lvCtrlLine = LvCtrlLines[i];
lvCtrlLines[i] = new LvCtrlLine() { CtrlLine = lvCtrlLine.CtrlLine, Mix = lvCtrlLine.Mix };
}
HeatCell.LvCtrlLines = lvCtrlLines;
}
else
{
HeatCell.LvCtrlLines = null;
}
HeatCell.Mix = Mix;
Feedback.Step=this.Step; Feedback.Step=this.Step;
Feedback.HasCheckFilmVelocity=this.HasCheckFilmVelocity; Feedback.HasCheckFilmVelocity=this.HasCheckFilmVelocity;
Feedback.HasCheck=this.HasCheck; Feedback.HasCheck=this.HasCheck;
Feedback.Delay=this.Delay; Feedback.Delay=this.Delay;
Feedback.FilmLength = FilmLength; Feedback.FilmLength = FilmLength;
Feedback.Mix = Mix;
...@@ -260,6 +339,36 @@ namespace FLY.FilmCasting.AutoDie.UI.Client ...@@ -260,6 +339,36 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
} }
} }
public class PgSetupVmUt : PgSetupVm
{
public PgSetupVmUt()
{
ThresholdHeatSigma = 7;
Step = 5;
HasCheckFilmVelocity = true;
HasCheck = true;
Delay = 60;
ThresholdSigmaMax = 4;
StableRange = 4;
HeatEffectCurve = new int[] { 2, 3, 7, 3, 2 };
IsForbidUpDown = true;
CtrlLine = 5;
Kp = 0.8;
ThresholdR = 0.7;
MaxHeat = 50;
RangeOfOffset = 30;
CenterTarget = 2;
Mix = 3;
FilmLength = 12;
LvCtrlLines.Add(new LvCtrlLine() { CtrlLine = 3, Mix = 6 });
LvCtrlLines.Add(new LvCtrlLine() { CtrlLine = 1, Mix = 100 });
}
}
public class HeatEffectConverter : IValueConverter public class HeatEffectConverter : IValueConverter
{ {
#region IValueConverter 成员 #region IValueConverter 成员
...@@ -339,22 +448,16 @@ namespace FLY.FilmCasting.AutoDie.UI.Client ...@@ -339,22 +448,16 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
return "等待"; return "等待";
case STABILITY.ERROR_NO_ARRIVE: case STABILITY.ERROR_NO_ARRIVE:
return "等待:加热点还没到达测厚仪"; return "等待:加热点还没到达测厚仪";
case STABILITY.ERROR_POSITION_NOTSURE:
return "等待:位置不能确定";
case STABILITY.ERROR_SIGMA_OVERSIZE: case STABILITY.ERROR_SIGMA_OVERSIZE:
return "等待:2σ太大 "; return "等待:2σ太大 ";
case STABILITY.ERROR_ROTATE_CHANGED:
return "等待:旋转速度波动大 ";
case STABILITY.ERROR_PARAM_CHANGED: case STABILITY.ERROR_PARAM_CHANGED:
return "等待:膜距离旋转角度被改变"; return "等待:膜宽变化大于100mm";
case STABILITY.ERROR_THICK_CHANGED: case STABILITY.ERROR_THICK_CHANGED:
return "等待:厚度均值波动大"; return "等待:厚度均值波动大";
case STABILITY.ERROR_CORREL: case STABILITY.ERROR_CORREL:
return "等待:相关性不够"; return "等待:相关性不够";
case STABILITY.OK_CORREL: case STABILITY.OK_CORREL:
return "稳定:相关性高"; return "稳定:相关性高";
case STABILITY.OK_HEAT_AND_THICK_CORREL:
return "稳定:加热相关性高";
default: default:
return "???"; return "???";
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/> <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/> <ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Themes/Styles.xaml"/> <ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Themes/Styles.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Themes/GraphStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.FilmCasting.AutoDie.UI.Client;component/Themes/Colors.xaml"/> <ResourceDictionary Source="pack://application:,,,/FLY.FilmCasting.AutoDie.UI.Client;component/Themes/Colors.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
......
...@@ -16,7 +16,7 @@ xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" xmlns:lvc1="clr ...@@ -16,7 +16,7 @@ xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" xmlns:lvc1="clr
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/> <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.FilmCasting.AutoDie.UI.Client;component/Themes/Colors.xaml"/> <ResourceDictionary Source="pack://application:,,,/FLY.FilmCasting.AutoDie.UI.Client;component/Themes/Colors.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.FilmCasting.AutoDie.UI.Client;component/Themes/Styles.xaml"/> <ResourceDictionary Source="pack://application:,,,/FLY.FilmCasting.AutoDie.UI.Client;component/Themes/Styles.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<ControlTemplate x:Key="picture_button" TargetType="Button"> <ControlTemplate x:Key="picture_button" TargetType="Button">
<Border Name="border" BorderThickness="1" CornerRadius="5"> <Border Name="border" BorderThickness="1" CornerRadius="5">
...@@ -268,47 +268,108 @@ xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" xmlns:lvc1="clr ...@@ -268,47 +268,108 @@ xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" xmlns:lvc1="clr
</Grid.RowDefinitions> </Grid.RowDefinitions>
<lvc:CartesianChart Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" Margin="5,2,2,2" <lvc:CartesianChart Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" Margin="5,2,2,2"
MouseMove="UIElement_OnMouseMove" MouseDown="UIElement_MouseDown" MouseUp="UIElement_MouseUp"> MouseMove="UIElement_OnMouseMove" MouseDown="UIElement_MouseDown" MouseUp="UIElement_MouseUp">
<lvc:CartesianChart.Series> <lvc:CartesianChart.Series>
<lvc1:Column2Series <lvc1:Column2Series
PointGeometry="{x:Null}" PointGeometry="{x:Null}"
StrokeThickness ="1" StrokeThickness ="1"
Stroke="Black" Stroke="Black"
Fill="{StaticResource Brushes.PreHeat}" Fill="{StaticResource Brushes.PreHeat}"
Values="{Binding HeatOffsets}" Values="{Binding HeatOffsets}"
Configuration="{Binding Mapper}"/> Configuration="{Binding Mapper}"/>
<lvc:LineSeries <lvc:LineSeries
PointGeometry="{x:Null}" PointGeometry="{x:Null}"
StrokeThickness ="3" StrokeThickness ="3"
Stroke="{StaticResource Brushes.Thick}" Stroke="{StaticResource Brushes.Thick}"
Fill="Transparent" Fill="Transparent"
Values="{Binding ThickPercents}" Values="{Binding ThickPercents}"
Configuration="{Binding MapperThickPercents}"/> Configuration="{Binding MapperThickPercents}"/>
</lvc:CartesianChart.Series> </lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisX> <lvc:CartesianChart.AxisX>
<lvc:Axis Foreground="{StaticResource Brushes.AxisLabel}" <lvc:Axis Foreground="{StaticResource Brushes.AxisLabel}"
MinValue="{Binding XMin}" MaxValue="{Binding XMax}" MinValue="{Binding XMin}" MaxValue="{Binding XMax}"
> >
<lvc:Axis.Separator> <lvc:Axis.Separator>
<lvc:Separator Stroke="{StaticResource Brushes.AxisSeparator}" Step ="5"/> <lvc:Separator Stroke="{StaticResource Brushes.AxisSeparator}" Step ="5"/>
</lvc:Axis.Separator> </lvc:Axis.Separator>
<lvc:Axis.Sections> <lvc:Axis.Sections>
<lvc:AxisSection Style="{StaticResource AxisSectionStyle}" <lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
Value="{Binding SelectBoltNo}" SectionWidth="{Binding SelectBoltNoWidth}" Value="{Binding SelectBoltNo}" SectionWidth="{Binding SelectBoltNoWidth}"
/> />
</lvc:Axis.Sections> </lvc:Axis.Sections>
</lvc:Axis> </lvc:Axis>
</lvc:CartesianChart.AxisX> </lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY> <lvc:CartesianChart.AxisY>
<lvc:Axis Foreground="{StaticResource Brushes.AxisLabel}" <lvc:Axis Foreground="{StaticResource Brushes.AxisLabel}"
LabelFormatter="{Binding YFormatter}" FontFamily="Courier New" LabelFormatter="{Binding YFormatter}" FontFamily="Courier New"
MinValue="{Binding YMinOffset}" MaxValue="{Binding YMaxOffset}" > MinValue="{Binding YMinOffset}" MaxValue="{Binding YMaxOffset}" >
<lvc:Axis.Separator> <lvc:Axis.Separator>
<lvc:Separator Stroke="{StaticResource Brushes.AxisSeparator}" Step="{Binding YStepOffset}"/> <lvc:Separator Stroke="{StaticResource Brushes.AxisSeparator}" Step="{Binding YStepOffset}"/>
</lvc:Axis.Separator> </lvc:Axis.Separator>
</lvc:Axis> </lvc:Axis>
</lvc:CartesianChart.AxisY> </lvc:CartesianChart.AxisY>
</lvc:CartesianChart> </lvc:CartesianChart>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="400*"/>
<ColumnDefinition Width="280*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="2" Grid.RowSpan="2" Panel.ZIndex="1"
Margin="10,0" VerticalAlignment="Top" HorizontalAlignment="Right">
<Viewbox MaxHeight="25">
<StackPanel Margin="{StaticResource ControlMargin}">
<StackPanel.Resources>
<Style TargetType="Viewbox">
<Setter Property="Height" Value="25"/>
<Setter Property="Width" Value="120"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top"/>
</Style>
</StackPanel.Resources>
<StackPanel Orientation="Horizontal">
<Viewbox >
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TitleStyle}"
Foreground="{StaticResource WhiteBrush}"
Background="{StaticResource TextBrush}"
Opacity="0.8"
Text="混合: "
/>
<TextBlock Style="{StaticResource ValueStyle}"
Foreground="{StaticResource WhiteBrush}"
Background="{StaticResource TextBrush}"
Text="{Binding CurrMix,Mode=OneWay}"
/>
</StackPanel>
</Viewbox>
<Viewbox>
<StackPanel Orientation="Horizontal" >
<TextBlock Style="{StaticResource TitleStyle}"
Foreground="{StaticResource WhiteBrush}"
Background="{StaticResource TextBrush}"
Text=" 2σ: "
/>
<TextBlock Style="{StaticResource ValueStyle}"
Foreground="{StaticResource WhiteBrush}"
Background="{StaticResource TextBrush}"
>
<Run Text="{Binding CurrSigma2,Mode=OneWay, StringFormat={}{0:F1}}"/>%
</TextBlock>
</StackPanel>
</Viewbox>
</StackPanel>
</StackPanel>
</Viewbox>
</Grid>
</Grid>
<lvc:CartesianChart Grid.Row="1" Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" Margin="5,2,2,2" <lvc:CartesianChart Grid.Row="1" Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" Margin="5,2,2,2"
MouseMove="UIElement_OnMouseMove" MouseDown="UIElement_MouseDown" MouseUp="UIElement_MouseUp"> MouseMove="UIElement_OnMouseMove" MouseDown="UIElement_MouseDown" MouseUp="UIElement_MouseUp">
<lvc:CartesianChart.Series> <lvc:CartesianChart.Series>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
using LiveCharts; using LiveCharts;
using LiveCharts.Configurations; using LiveCharts.Configurations;
using Misc;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
...@@ -60,6 +61,8 @@ namespace FLY.FilmCasting.AutoDie.UI.Client.UiModule ...@@ -60,6 +61,8 @@ namespace FLY.FilmCasting.AutoDie.UI.Client.UiModule
/// </summary> /// </summary>
public int SelectBoltNoWidth { get; set; } = 0; public int SelectBoltNoWidth { get; set; } = 0;
public int CurrMix { get; protected set; } = 1;
public double CurrSigma2 { get; protected set; } = 0;
public RelayCommand AddCmd { get; private set; } public RelayCommand AddCmd { get; private set; }
public RelayCommand SubCmd { get; private set; } public RelayCommand SubCmd { get; private set; }
...@@ -201,7 +204,8 @@ namespace FLY.FilmCasting.AutoDie.UI.Client.UiModule ...@@ -201,7 +204,8 @@ namespace FLY.FilmCasting.AutoDie.UI.Client.UiModule
Misc.BindingOperations.SetBinding(mHeatCell, nameof(mHeatCell.Kp), this, nameof(Kp)); Misc.BindingOperations.SetBinding(mHeatCell, nameof(mHeatCell.Kp), this, nameof(Kp));
Misc.BindingOperations.SetBinding(mHeatCell, nameof(mHeatCell.MaxHeat), this, nameof(MaxHeat)); Misc.BindingOperations.SetBinding(mHeatCell, nameof(mHeatCell.MaxHeat), this, nameof(MaxHeat));
Misc.BindingOperations.SetBinding(mHeatCell, nameof(mHeatCell.RangeOfOffset), this, nameof(RangeOfOffset)); Misc.BindingOperations.SetBinding(mHeatCell, nameof(mHeatCell.RangeOfOffset), this, nameof(RangeOfOffset));
Misc.BindingOperations.SetBinding(mHeatCell, nameof(mHeatCell.CurrMix), this, nameof(CurrMix));
this.btnClearH = button_clear_h; this.btnClearH = button_clear_h;
LPress.Init(btnClearH); LPress.Init(btnClearH);
LPress.LongClick += (s, e) => LPress.LongClick += (s, e) =>
...@@ -257,7 +261,13 @@ namespace FLY.FilmCasting.AutoDie.UI.Client.UiModule ...@@ -257,7 +261,13 @@ namespace FLY.FilmCasting.AutoDie.UI.Client.UiModule
{ {
ThickPercents.Clear(); ThickPercents.Clear();
if (mHeatCell.ThickPercents != null) if (mHeatCell.ThickPercents != null)
{
ThickPercents.AddRange(mHeatCell.ThickPercents); ThickPercents.AddRange(mHeatCell.ThickPercents);
CurrSigma2 = mHeatCell.ThickPercents.Sigma() * 2;
}
else {
CurrSigma2 = 0;
}
} }
void DataBindAll_Heats() void DataBindAll_Heats()
......
...@@ -33,10 +33,7 @@ namespace FLY.FilmCasting.AutoDie.Client ...@@ -33,10 +33,7 @@ namespace FLY.FilmCasting.AutoDie.Client
/// </summary> /// </summary>
public double FilmLength { get; set; } = 20; public double FilmLength { get; set; } = 20;
/// <summary>
/// 测厚仪厚度数据混合数
/// </summary>
public int Mix { get; set; } = 8;
/// <summary> /// <summary>
/// 检测功能使能 /// 检测功能使能
......
...@@ -21,6 +21,11 @@ namespace FLY.FilmCasting.AutoDie.Client ...@@ -21,6 +21,11 @@ namespace FLY.FilmCasting.AutoDie.Client
/// </summary> /// </summary>
public double Kp { get; set; } = 3; public double Kp { get; set; } = 3;
/// <summary>
/// 测厚仪厚度数据混合数
/// </summary>
public int Mix { get; set; } = 3;
/// <summary> /// <summary>
/// 平滑的阀值,只有超出阀值,才平滑 /// 平滑的阀值,只有超出阀值,才平滑
/// </summary> /// </summary>
...@@ -52,6 +57,11 @@ namespace FLY.FilmCasting.AutoDie.Client ...@@ -52,6 +57,11 @@ namespace FLY.FilmCasting.AutoDie.Client
/// 中心目标厚度 ,希望生产出来的产品中心比较厚点 /// 中心目标厚度 ,希望生产出来的产品中心比较厚点
/// </summary> /// </summary>
public double CenterTarget { get; set; } public double CenterTarget { get; set; }
/// <summary>
/// 分级控制线
/// </summary>
public LvCtrlLine[] LvCtrlLines { get; set; }
#endregion #endregion
...@@ -94,7 +104,10 @@ namespace FLY.FilmCasting.AutoDie.Client ...@@ -94,7 +104,10 @@ namespace FLY.FilmCasting.AutoDie.Client
/// </summary> /// </summary>
public double MaxHeatSigma { get; set; } public double MaxHeatSigma { get; set; }
/// <summary>
/// 当前 thickPercents 混合数
/// </summary>
public int CurrMix { get; set; } = 1;
#endregion #endregion
#endregion #endregion
......
...@@ -42,38 +42,26 @@ namespace FLY.FilmCasting.AutoDie.Common ...@@ -42,38 +42,26 @@ namespace FLY.FilmCasting.AutoDie.Common
/// 加热点,还没到达测厚仪。 其它状态都是加热已经起效了,顶多不稳定而已。 /// 加热点,还没到达测厚仪。 其它状态都是加热已经起效了,顶多不稳定而已。
/// </summary> /// </summary>
ERROR_NO_ARRIVE = -1, ERROR_NO_ARRIVE = -1,
/// <summary>
/// 旋转次数太少,位置不能确定
/// </summary>
ERROR_POSITION_NOTSURE = -2,
/// <summary> /// <summary>
/// 一副数据,Sigma > 15% : 不稳定,变化太大,超出控制范围 /// 一副数据,Sigma > 15% : 不稳定,变化太大,超出控制范围
/// </summary> /// </summary>
ERROR_SIGMA_OVERSIZE = -3, ERROR_SIGMA_OVERSIZE = -3,
/// <summary>
/// 连续两幅图旋转时间变化 > 10%:不稳定,旋转速度波动大,测量不准确
/// </summary>
ERROR_ROTATE_CHANGED = -4,
/// <summary> /// <summary>
/// 连续两幅图厚度均值变化 > 10%: 不稳定,厚度波动大 /// 连续两幅图厚度均值变化 > 10%: 不稳定,厚度波动大
/// </summary> /// </summary>
ERROR_THICK_CHANGED = -5, ERROR_THICK_CHANGED = -5,
/// <summary> /// <summary>
/// 膜距离,旋转角度被改变,无法判断 /// 膜宽变化大于100mm
/// </summary> /// </summary>
ERROR_PARAM_CHANGED = -7, ERROR_PARAM_CHANGED = -7,
/// <summary> /// <summary>
/// 不稳定,不相关 /// 不稳定,不相关
/// </summary> /// </summary>
ERROR_CORREL = -6, ERROR_CORREL = -6,
/// <summary>
/// 加热与厚度差,相关性很高
/// </summary>
OK_HEAT_AND_THICK_CORREL = 3,
/// <summary> /// <summary>
/// 加热为0,加热与厚度差,相关性很高 /// 加热为0,加热与厚度差,相关性很高
/// </summary> /// </summary>
......
...@@ -33,11 +33,6 @@ namespace FLY.FilmCasting.AutoDie.IService ...@@ -33,11 +33,6 @@ namespace FLY.FilmCasting.AutoDie.IService
/// </summary> /// </summary>
double FilmLength { get; set; } double FilmLength { get; set; }
/// <summary>
/// 测厚仪厚度数据混合数
/// </summary>
int Mix { get; set; }
/// <summary> /// <summary>
/// 有检测功能 /// 有检测功能
/// </summary> /// </summary>
......
...@@ -4,6 +4,7 @@ using System.Linq; ...@@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.ComponentModel; using System.ComponentModel;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using FObjBase.Reflect;
namespace FLY.FilmCasting.AutoDie.IService namespace FLY.FilmCasting.AutoDie.IService
{ {
...@@ -15,6 +16,10 @@ namespace FLY.FilmCasting.AutoDie.IService ...@@ -15,6 +16,10 @@ namespace FLY.FilmCasting.AutoDie.IService
/// </summary> /// </summary>
double Kp { get; set; } double Kp { get; set; }
/// <summary>
/// 测厚仪数据混合数
/// </summary>
int Mix { get; set; }
/// <summary> /// <summary>
/// 输出平滑的阀值,只有超出阀值,才平滑 /// 输出平滑的阀值,只有超出阀值,才平滑
/// </summary> /// </summary>
...@@ -44,6 +49,12 @@ namespace FLY.FilmCasting.AutoDie.IService ...@@ -44,6 +49,12 @@ namespace FLY.FilmCasting.AutoDie.IService
/// 中心目标厚度 ,希望生产出来的产品中心比较厚点 /// 中心目标厚度 ,希望生产出来的产品中心比较厚点
/// </summary> /// </summary>
double CenterTarget { get; set; } double CenterTarget { get; set; }
/// <summary>
/// 分级控制线
/// </summary>
[PropertyPush]
LvCtrlLine[] LvCtrlLines { get; set; }
#endregion #endregion
#region 状态 #region 状态
...@@ -56,6 +67,7 @@ namespace FLY.FilmCasting.AutoDie.IService ...@@ -56,6 +67,7 @@ namespace FLY.FilmCasting.AutoDie.IService
/// 当前加热策略改变的时间 /// 当前加热策略改变的时间
/// </summary> /// </summary>
DateTime LastHeatsChangedTime { get; } DateTime LastHeatsChangedTime { get; }
/// <summary> /// <summary>
/// 当前加热策略,必须保证 0~100 /// 当前加热策略,必须保证 0~100
/// </summary> /// </summary>
...@@ -76,6 +88,10 @@ namespace FLY.FilmCasting.AutoDie.IService ...@@ -76,6 +88,10 @@ namespace FLY.FilmCasting.AutoDie.IService
/// </summary> /// </summary>
double MaxHeatSigma { get; } double MaxHeatSigma { get; }
/// <summary>
/// 当前 thickPercents 混合数
/// </summary>
int CurrMix { get; }
#endregion #endregion
#region 功能 #region 功能
...@@ -122,6 +138,18 @@ namespace FLY.FilmCasting.AutoDie.IService ...@@ -122,6 +138,18 @@ namespace FLY.FilmCasting.AutoDie.IService
/// Heats = PreHeats, Offsets = 0, Base = 0 /// Heats = PreHeats, Offsets = 0, Base = 0
/// </summary> /// </summary>
void HeatApply(); void HeatApply();
#endregion #endregion
} }
/// <summary>
/// 分级控制线
/// </summary>
public class LvCtrlLine : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public double CtrlLine { get; set; }
public int Mix { get; set; }
}
} }
...@@ -50,11 +50,6 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -50,11 +50,6 @@ namespace FLY.FilmCasting.AutoDie.Server
/// </summary> /// </summary>
public double FilmLength { get; set; } = 20; public double FilmLength { get; set; } = 20;
/// <summary>
/// 测厚仪厚度数据混合数
/// </summary>
public int Mix { get; set; } = 8;
/// <summary> /// <summary>
/// 检测功能使能 /// 检测功能使能
/// </summary> /// </summary>
...@@ -217,7 +212,7 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -217,7 +212,7 @@ namespace FLY.FilmCasting.AutoDie.Server
//------------------------------------------------------------------- //-------------------------------------------------------------------
//HeatCell //HeatCell
mHeatCell.Init(mHeatBuf); mHeatCell.Init(mHeatBuf);
mHeatCell.PreHeatApplyEvent = (c) => mHeatCell.PreHeatApplyEvent = (c) =>
{ {
//有开风机才能加热 //有开风机才能加热
...@@ -577,7 +572,7 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -577,7 +572,7 @@ namespace FLY.FilmCasting.AutoDie.Server
{ {
//有新数据,向bulkDb获取 //有新数据,向bulkDb获取
bulkDb.GetFrame( bulkDb.GetFrame(
new Pack_GetFrameRequest() { Id = 0, Mix = Mix }, new Pack_GetFrameRequest() { Id = 0, Mix = mHeatCell.Mix },
(asyncContext, retData) => (asyncContext, retData) =>
{ {
var reponse = retData as Pack_GetFrameReponse; var reponse = retData as Pack_GetFrameReponse;
......
...@@ -26,7 +26,10 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -26,7 +26,10 @@ namespace FLY.FilmCasting.AutoDie.Server
/// </summary> /// </summary>
public double Kp { get; set; } = 1; public double Kp { get; set; } = 1;
/// <summary>
/// 测厚仪厚度数据混合数
/// </summary>
public int Mix { get; set; } = 3;
/// <summary> /// <summary>
/// 平滑的阀值,只有超出阀值,才平滑 /// 平滑的阀值,只有超出阀值,才平滑
/// </summary> /// </summary>
...@@ -58,6 +61,11 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -58,6 +61,11 @@ namespace FLY.FilmCasting.AutoDie.Server
/// 中心目标厚度 ,希望生产出来的产品中心比较厚点 /// 中心目标厚度 ,希望生产出来的产品中心比较厚点
/// </summary> /// </summary>
public double CenterTarget { get; set; } public double CenterTarget { get; set; }
/// <summary>
/// 分级控制线
/// </summary>
public LvCtrlLine[] LvCtrlLines { get; set; }
#endregion #endregion
#region 状态 #region 状态
...@@ -104,7 +112,10 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -104,7 +112,10 @@ namespace FLY.FilmCasting.AutoDie.Server
/// </summary> /// </summary>
public double MaxHeatSigma { get; set; } = 0; public double MaxHeatSigma { get; set; } = 0;
/// <summary>
/// 当前 thickPercents 混合数
/// </summary>
public int CurrMix { get; private set; } = 1;
#endregion #endregion
#endregion #endregion
...@@ -120,11 +131,17 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -120,11 +131,17 @@ namespace FLY.FilmCasting.AutoDie.Server
int dataBegin; int dataBegin;
int dataEnd; int dataEnd;
/// <summary>
/// 全部稳定的厚度%数据
/// </summary>
List<double[]> thickPercentsCollection = new List<double[]>();
public Func<object, bool> PreHeatApplyEvent; public Func<object, bool> PreHeatApplyEvent;
public event Action<object> AfterHeatApplyEvent; public event Action<object> AfterHeatApplyEvent;
public event Action<object> AfterClearOffsetsEvent; public event Action<object> AfterClearOffsetsEvent;
public HeatCell() public HeatCell()
{ {
if (!Load()) if (!Load())
...@@ -195,6 +212,7 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -195,6 +212,7 @@ namespace FLY.FilmCasting.AutoDie.Server
PreHeats = new double[ChannelCnt]; PreHeats = new double[ChannelCnt];
Offsets = new double[ChannelCnt]; Offsets = new double[ChannelCnt];
create_thickPercentTargets(); create_thickPercentTargets();
thickPercentsCollection.Clear();
} }
void create_thickPercentTargets() void create_thickPercentTargets()
{ {
...@@ -226,7 +244,15 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -226,7 +244,15 @@ namespace FLY.FilmCasting.AutoDie.Server
this.dataBegin = dataBegin; this.dataBegin = dataBegin;
this.dataEnd = dataEnd; this.dataEnd = dataEnd;
} }
/// <summary>
/// 初始化 分级控制
/// </summary>
void init_lvCtrl()
{
}
/// <summary> /// <summary>
/// 自动模式!!!!! /// 自动模式!!!!!
/// </summary> /// </summary>
...@@ -234,42 +260,128 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -234,42 +260,128 @@ namespace FLY.FilmCasting.AutoDie.Server
{ {
if (mHeatBuf.mData.Count() == 0) if (mHeatBuf.mData.Count() == 0)
return; return;
//&& mHeatBuf.IsStable()
if (mHeatBuf.Stability != STABILITY.OK_CORREL)//稳定 与 待定时 加热
if (mHeatBuf.Stability == STABILITY.OK_CORREL)//稳定 与 待定时 加热 return;
double ctrlLine = CtrlLine;
if (IsLvCtrlLinesValid())
{ {
//转为 加热棒数量 for (int i = 0; i < LvCtrlLines.Count(); i++)
var thickPercents = ThickPercents;
double[] offsets = new double[ChannelCnt];
for (int i = 0; i < ChannelCnt; i++)
{ {
if (!double.IsNaN(thickPercents[i]) && !double.IsNaN(thickPercentTargets[i]) && int index = LvCtrlLines.Count() - 1 - i;
mHeatBuf.BoltIsStable[i] && //稳定 if( thickPercentsCollection.Count() >= LvCtrlLines[index].Mix)
(Math.Abs(thickPercents[i]) > CtrlLine))//在控制线已外
{ {
offsets[i] = (thickPercents[i] - thickPercentTargets[i]) * Kp;//保留一位小数 ctrlLine = LvCtrlLines[index].CtrlLine;
break;
} }
} }
}
Offsets = offsets; //转为 加热棒数量
UpdatePreHeats();//这句一定要加!!!! 不然没法平滑,没法加热 var thickPercents = ThickPercents;
if (!IsForbidUpDown)//禁止整体上移下降 double[] offsets = new double[ChannelCnt];
ModifyBase();//自动整体上移下降 for (int i = 0; i < ChannelCnt; i++)
{
if (!double.IsNaN(thickPercents[i]) && !double.IsNaN(thickPercentTargets[i]))
{
double delta = (thickPercents[i] - thickPercentTargets[i]);
double d = Math.Abs(delta);
Smooth();//平滑,它会导致Offset被修改,<0的都被删除掉 if (d >= ctrlLine)
{
HeatApply();//执行加热 }
else if (d >= ctrlLine * 2 / 3)
{
d = (d - ctrlLine * 2 / 3) * 2 + (ctrlLine * 1 / 3);
}
else if (d >= ctrlLine * 1 / 3)
{
d = (d - ctrlLine * 1 / 3) * 1 + (ctrlLine * 0 / 3);
}
else
{
d = 0;
}
double offset = d * Kp;
offsets[i] = delta >= 0 ? offset : -offset;
}
} }
Offsets = offsets;
UpdatePreHeats();//这句一定要加!!!! 不然没法平滑,没法加热
if (!IsForbidUpDown)//禁止整体上移下降
ModifyBase();//自动整体上移下降
Smooth();//平滑,它会导致Offset被修改,<0的都被删除掉
HeatApply();//执行加热
} }
public void SetThickPercents(double[] thkpercents) public void SetThickPercents(double[] thkpercents)
{ {
ThickPercents = thkpercents.ToArray(); var thkPercents = thkpercents.ToArray();
if (mHeatBuf.Stability != STABILITY.OK_CORREL || IsLvCtrlLinesValid())
{
//数据非稳定, 清空列表
thickPercentsCollection.Clear();
CurrMix = Mix;
}
else {
thickPercentsCollection.Add(thkPercents);
int currMix = thickPercentsCollection.Count() + Mix - 1;
int maxMix = LvCtrlLines.Max(lv => lv.Mix);
if (currMix > maxMix)
{
int removeCnt = maxMix - currMix;
thickPercentsCollection.RemoveRange(0, thickPercentsCollection.Count()- removeCnt);
currMix = maxMix;
}
//计算均值
if (thickPercentsCollection.Count() > 1)
{
thkpercents = new double[ChannelCnt];
int[] cnts = new int[ChannelCnt];
for (int j = 0; j < thickPercentsCollection.Count(); j++)
{
for (int i = 0; i < ChannelCnt; i++)
{
if (!double.IsNaN(thickPercentsCollection[j][i]))
{
thkpercents[i] += thickPercentsCollection[j][i];
cnts[i]++;
}
}
}
for (int i = 0; i < ChannelCnt; i++)
{
if (cnts[i] > 0)
thkpercents[i] = thkpercents[i] / cnts[i];
else
thkpercents[i] = double.NaN;
}
}
CurrMix = currMix;
}
ThickPercents = thkPercents;
updateThickPercentTargets(); updateThickPercentTargets();
}
bool IsLvCtrlLinesValid()
{
if (LvCtrlLines != null && LvCtrlLines.Count() > 0 && LvCtrlLines.All(lv=>lv!=null))
{
return true;
}
return false;
} }
void updateThickPercentTargets() void updateThickPercentTargets()
{ {
...@@ -577,10 +689,15 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -577,10 +689,15 @@ namespace FLY.FilmCasting.AutoDie.Server
return; return;
} }
} }
bool isHeatsChanged = false;
bool isOffsetsChanged = false;
for (int i = 0; i < ChannelCnt; i++) for (int i = 0; i < ChannelCnt; i++)
{ {
Offsets[i] = 0; if (Offsets[i] != 0)
{
Offsets[i] = 0;
isOffsetsChanged = true;
}
var h = Math.Round(PreHeats[i], 1); var h = Math.Round(PreHeats[i], 1);
...@@ -594,15 +711,24 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -594,15 +711,24 @@ namespace FLY.FilmCasting.AutoDie.Server
//需要整体调低 //需要整体调低
h = 100; h = 100;
} }
Heats[i] = h; if (Heats[i] != h)
{
Heats[i] = h;
isHeatsChanged = true;
}
} }
NotifyPropertyChanged(nameof(Offsets));
NotifyPropertyChanged(nameof(Heats)); if(isOffsetsChanged)
LastHeatsChangedTime = DateTime.Now; NotifyPropertyChanged(nameof(Offsets));
Base = 0;
AfterHeatApplyEvent?.Invoke(this); if (isHeatsChanged)
{
NotifyPropertyChanged(nameof(Heats));
LastHeatsChangedTime = DateTime.Now;
AfterHeatApplyEvent?.Invoke(this);
}
Base = 0;
} }
/// <summary> /// <summary>
...@@ -618,7 +744,7 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -618,7 +744,7 @@ namespace FLY.FilmCasting.AutoDie.Server
h = 100; h = 100;
else if (h < 0) else if (h < 0)
h = 0; h = 0;
PreHeats[i] = h; PreHeats[i] = h;
} }
UpdateHeatSigmas(); UpdateHeatSigmas();
NotifyPropertyChanged(nameof(PreHeats)); NotifyPropertyChanged(nameof(PreHeats));
...@@ -694,7 +820,10 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -694,7 +820,10 @@ namespace FLY.FilmCasting.AutoDie.Server
/// </summary> /// </summary>
public double Kp = 1; public double Kp = 1;
/// <summary>
/// 测厚仪数据混合数
/// </summary>
public int Mix = 3;
/// <summary> /// <summary>
/// 自动对位 /// 自动对位
/// </summary> /// </summary>
...@@ -730,6 +859,11 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -730,6 +859,11 @@ namespace FLY.FilmCasting.AutoDie.Server
public double CenterTarget = 0; public double CenterTarget = 0;
/// <summary>
/// 分级控制线
/// </summary>
public LvCtrlLine[] LvCtrlLines;
#endregion #endregion
} }
} }
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