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

添加 自动模头多级控制

parent c87c3df7
......@@ -7,8 +7,7 @@
xmlns:misc="clr-namespace:Misc;assembly=MISC"
mc:Ignorable="d"
d:DesignWidth="1024"
Background="WhiteSmoke"
d:DataContext="{d:DesignInstance local:PgSetupVm}">
Background="WhiteSmoke">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
......@@ -22,15 +21,16 @@
<local:HeatEffectConverter x:Key="heconv"/>
<local:MaxR2VisConverter x:Key="maxR2VisConv"/>
<local:Id2VisConverter x:Key="id2VisConv"/>
<local:PgSetupVmUt x:Key="viewModel"/>
</ResourceDictionary>
</Page.Resources>
<Grid >
<Grid d:DataContext="{StaticResource viewModel}" >
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid x:Name="grid_viewModel"/>
<Grid x:Name="grid_viewModel" />
<StackPanel Orientation="Horizontal" Background="{StaticResource Brushes.TitleBar.Background}" >
<Button Style="{StaticResource Styles.TitleBar.BackButton2}" Command="BrowseBack"/>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
......@@ -53,7 +53,7 @@
<ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" IsChecked="{Binding IsForbidUpDown}"/>
</StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="控制线" />
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="基本控制线" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding CtrlLine,StringFormat={}{0:0.#}}"/>
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="%" />
......@@ -89,7 +89,20 @@
</StackPanel>
</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}">
<StackPanel >
......@@ -118,7 +131,7 @@
</StackPanel>
</StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="厚度混合数" />
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="基本厚度混合数" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding Mix}"/>
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="次" />
......@@ -232,20 +245,20 @@
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" DataContext="{Binding HeatBuf}">
<StackPanel Orientation="Horizontal" >
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="相关性阀值" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding ThresholdR,StringFormat={}{0:F2}}"/>
</StackPanel>
</StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}">
<StackPanel Margin="{StaticResource ControlMargin}" DataContext="{Binding HeatBuf}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="稳定性" />
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding CurrR, StringFormat={}{0:F2}}" />
</StackPanel>
</StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}">
<StackPanel Margin="{StaticResource ControlMargin}" DataContext="{Binding HeatBuf}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="稳定状态" />
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding Stability, Converter={StaticResource stableconv}}" />
......
......@@ -18,6 +18,7 @@ using FLY.FilmCasting.AutoDie.IService;
using System.ComponentModel;
using Unity;
using GalaSoft.MvvmLight.Command;
using System.Collections.ObjectModel;
namespace FLY.FilmCasting.AutoDie.UI.Client
{
......@@ -93,6 +94,11 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
/// 膜距离
/// </summary>
public double FilmLength { get; set; } = 20;
/// <summary>
/// 分级控制
/// </summary>
public ObservableCollection<LvCtrlLine> LvCtrlLines { get; } = new ObservableCollection<LvCtrlLine>();
#endregion
#region Command
......@@ -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.RangeOfOffset), this, nameof(RangeOfOffset));
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));
......@@ -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.HasCheckFilmVelocity), this, nameof(HasCheckFilmVelocity));
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));
......@@ -201,10 +219,53 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
}
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()
{
if (CheckValid_HeatEffectCurve() == false)
return false;
if(CheckValid_LvCtrlLines()==false)
return false;
if (Mix < 2) {
FLY.ControlLibrary.Window_WarningTip.Show(
......@@ -218,6 +279,8 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
"参数异常", "模头到测厚仪距离<2m", TimeSpan.FromSeconds(2));
return false;
}
return true;
}
......@@ -237,13 +300,29 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
HeatCell.MaxHeat = this.MaxHeat;
HeatCell.RangeOfOffset = this.RangeOfOffset;
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.HasCheckFilmVelocity=this.HasCheckFilmVelocity;
Feedback.HasCheck=this.HasCheck;
Feedback.Delay=this.Delay;
Feedback.FilmLength = FilmLength;
Feedback.Mix = Mix;
......@@ -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
{
#region IValueConverter 成员
......@@ -339,22 +448,16 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
return "等待";
case STABILITY.ERROR_NO_ARRIVE:
return "等待:加热点还没到达测厚仪";
case STABILITY.ERROR_POSITION_NOTSURE:
return "等待:位置不能确定";
case STABILITY.ERROR_SIGMA_OVERSIZE:
return "等待:2σ太大 ";
case STABILITY.ERROR_ROTATE_CHANGED:
return "等待:旋转速度波动大 ";
case STABILITY.ERROR_PARAM_CHANGED:
return "等待:膜距离旋转角度被改变";
return "等待:膜宽变化大于100mm";
case STABILITY.ERROR_THICK_CHANGED:
return "等待:厚度均值波动大";
case STABILITY.ERROR_CORREL:
return "等待:相关性不够";
case STABILITY.OK_CORREL:
return "稳定:相关性高";
case STABILITY.OK_HEAT_AND_THICK_CORREL:
return "稳定:加热相关性高";
default:
return "???";
}
......
......@@ -6,6 +6,7 @@
<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/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.MergedDictionaries>
......
......@@ -309,6 +309,67 @@ xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" xmlns:lvc1="clr
</lvc:Axis>
</lvc:CartesianChart.AxisY>
</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"
MouseMove="UIElement_OnMouseMove" MouseDown="UIElement_MouseDown" MouseUp="UIElement_MouseUp">
<lvc:CartesianChart.Series>
......
......@@ -2,6 +2,7 @@
using GalaSoft.MvvmLight.Command;
using LiveCharts;
using LiveCharts.Configurations;
using Misc;
using System;
using System.ComponentModel;
using System.Linq;
......@@ -60,6 +61,8 @@ namespace FLY.FilmCasting.AutoDie.UI.Client.UiModule
/// </summary>
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 SubCmd { get; private set; }
......@@ -201,6 +204,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client.UiModule
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.RangeOfOffset), this, nameof(RangeOfOffset));
Misc.BindingOperations.SetBinding(mHeatCell, nameof(mHeatCell.CurrMix), this, nameof(CurrMix));
this.btnClearH = button_clear_h;
LPress.Init(btnClearH);
......@@ -257,7 +261,13 @@ namespace FLY.FilmCasting.AutoDie.UI.Client.UiModule
{
ThickPercents.Clear();
if (mHeatCell.ThickPercents != null)
{
ThickPercents.AddRange(mHeatCell.ThickPercents);
CurrSigma2 = mHeatCell.ThickPercents.Sigma() * 2;
}
else {
CurrSigma2 = 0;
}
}
void DataBindAll_Heats()
......
......@@ -33,10 +33,7 @@ namespace FLY.FilmCasting.AutoDie.Client
/// </summary>
public double FilmLength { get; set; } = 20;
/// <summary>
/// 测厚仪厚度数据混合数
/// </summary>
public int Mix { get; set; } = 8;
/// <summary>
/// 检测功能使能
......
......@@ -21,6 +21,11 @@ namespace FLY.FilmCasting.AutoDie.Client
/// </summary>
public double Kp { get; set; } = 3;
/// <summary>
/// 测厚仪厚度数据混合数
/// </summary>
public int Mix { get; set; } = 3;
/// <summary>
/// 平滑的阀值,只有超出阀值,才平滑
/// </summary>
......@@ -52,6 +57,11 @@ namespace FLY.FilmCasting.AutoDie.Client
/// 中心目标厚度 ,希望生产出来的产品中心比较厚点
/// </summary>
public double CenterTarget { get; set; }
/// <summary>
/// 分级控制线
/// </summary>
public LvCtrlLine[] LvCtrlLines { get; set; }
#endregion
......@@ -94,7 +104,10 @@ namespace FLY.FilmCasting.AutoDie.Client
/// </summary>
public double MaxHeatSigma { get; set; }
/// <summary>
/// 当前 thickPercents 混合数
/// </summary>
public int CurrMix { get; set; } = 1;
#endregion
#endregion
......
......@@ -42,38 +42,26 @@ namespace FLY.FilmCasting.AutoDie.Common
/// 加热点,还没到达测厚仪。 其它状态都是加热已经起效了,顶多不稳定而已。
/// </summary>
ERROR_NO_ARRIVE = -1,
/// <summary>
/// 旋转次数太少,位置不能确定
/// </summary>
ERROR_POSITION_NOTSURE = -2,
/// <summary>
/// 一副数据,Sigma > 15% : 不稳定,变化太大,超出控制范围
/// </summary>
ERROR_SIGMA_OVERSIZE = -3,
/// <summary>
/// 连续两幅图旋转时间变化 > 10%:不稳定,旋转速度波动大,测量不准确
/// </summary>
ERROR_ROTATE_CHANGED = -4,
/// <summary>
/// 连续两幅图厚度均值变化 > 10%: 不稳定,厚度波动大
/// </summary>
ERROR_THICK_CHANGED = -5,
/// <summary>
/// 膜距离,旋转角度被改变,无法判断
/// 膜宽变化大于100mm
/// </summary>
ERROR_PARAM_CHANGED = -7,
/// <summary>
/// 不稳定,不相关
/// </summary>
ERROR_CORREL = -6,
/// <summary>
/// 加热与厚度差,相关性很高
/// </summary>
OK_HEAT_AND_THICK_CORREL = 3,
/// <summary>
/// 加热为0,加热与厚度差,相关性很高
/// </summary>
......
......@@ -33,11 +33,6 @@ namespace FLY.FilmCasting.AutoDie.IService
/// </summary>
double FilmLength { get; set; }
/// <summary>
/// 测厚仪厚度数据混合数
/// </summary>
int Mix { get; set; }
/// <summary>
/// 有检测功能
/// </summary>
......
......@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;
using FObjBase.Reflect;
namespace FLY.FilmCasting.AutoDie.IService
{
......@@ -15,6 +16,10 @@ namespace FLY.FilmCasting.AutoDie.IService
/// </summary>
double Kp { get; set; }
/// <summary>
/// 测厚仪数据混合数
/// </summary>
int Mix { get; set; }
/// <summary>
/// 输出平滑的阀值,只有超出阀值,才平滑
/// </summary>
......@@ -44,6 +49,12 @@ namespace FLY.FilmCasting.AutoDie.IService
/// 中心目标厚度 ,希望生产出来的产品中心比较厚点
/// </summary>
double CenterTarget { get; set; }
/// <summary>
/// 分级控制线
/// </summary>
[PropertyPush]
LvCtrlLine[] LvCtrlLines { get; set; }
#endregion
#region 状态
......@@ -56,6 +67,7 @@ namespace FLY.FilmCasting.AutoDie.IService
/// 当前加热策略改变的时间
/// </summary>
DateTime LastHeatsChangedTime { get; }
/// <summary>
/// 当前加热策略,必须保证 0~100
/// </summary>
......@@ -76,6 +88,10 @@ namespace FLY.FilmCasting.AutoDie.IService
/// </summary>
double MaxHeatSigma { get; }
/// <summary>
/// 当前 thickPercents 混合数
/// </summary>
int CurrMix { get; }
#endregion
#region 功能
......@@ -122,6 +138,18 @@ namespace FLY.FilmCasting.AutoDie.IService
/// Heats = PreHeats, Offsets = 0, Base = 0
/// </summary>
void HeatApply();
#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
/// </summary>
public double FilmLength { get; set; } = 20;
/// <summary>
/// 测厚仪厚度数据混合数
/// </summary>
public int Mix { get; set; } = 8;
/// <summary>
/// 检测功能使能
/// </summary>
......@@ -577,7 +572,7 @@ namespace FLY.FilmCasting.AutoDie.Server
{
//有新数据,向bulkDb获取
bulkDb.GetFrame(
new Pack_GetFrameRequest() { Id = 0, Mix = Mix },
new Pack_GetFrameRequest() { Id = 0, Mix = mHeatCell.Mix },
(asyncContext, retData) =>
{
var reponse = retData as Pack_GetFrameReponse;
......
......@@ -26,7 +26,10 @@ namespace FLY.FilmCasting.AutoDie.Server
/// </summary>
public double Kp { get; set; } = 1;
/// <summary>
/// 测厚仪厚度数据混合数
/// </summary>
public int Mix { get; set; } = 3;
/// <summary>
/// 平滑的阀值,只有超出阀值,才平滑
/// </summary>
......@@ -58,6 +61,11 @@ namespace FLY.FilmCasting.AutoDie.Server
/// 中心目标厚度 ,希望生产出来的产品中心比较厚点
/// </summary>
public double CenterTarget { get; set; }
/// <summary>
/// 分级控制线
/// </summary>
public LvCtrlLine[] LvCtrlLines { get; set; }
#endregion
#region 状态
......@@ -104,7 +112,10 @@ namespace FLY.FilmCasting.AutoDie.Server
/// </summary>
public double MaxHeatSigma { get; set; } = 0;
/// <summary>
/// 当前 thickPercents 混合数
/// </summary>
public int CurrMix { get; private set; } = 1;
#endregion
#endregion
......@@ -120,11 +131,17 @@ namespace FLY.FilmCasting.AutoDie.Server
int dataBegin;
int dataEnd;
/// <summary>
/// 全部稳定的厚度%数据
/// </summary>
List<double[]> thickPercentsCollection = new List<double[]>();
public Func<object, bool> PreHeatApplyEvent;
public event Action<object> AfterHeatApplyEvent;
public event Action<object> AfterClearOffsetsEvent;
public HeatCell()
{
if (!Load())
......@@ -195,6 +212,7 @@ namespace FLY.FilmCasting.AutoDie.Server
PreHeats = new double[ChannelCnt];
Offsets = new double[ChannelCnt];
create_thickPercentTargets();
thickPercentsCollection.Clear();
}
void create_thickPercentTargets()
{
......@@ -227,6 +245,14 @@ namespace FLY.FilmCasting.AutoDie.Server
this.dataEnd = dataEnd;
}
/// <summary>
/// 初始化 分级控制
/// </summary>
void init_lvCtrl()
{
}
/// <summary>
/// 自动模式!!!!!
/// </summary>
......@@ -234,24 +260,54 @@ namespace FLY.FilmCasting.AutoDie.Server
{
if (mHeatBuf.mData.Count() == 0)
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++)
{
int index = LvCtrlLines.Count() - 1 - i;
if( thickPercentsCollection.Count() >= LvCtrlLines[index].Mix)
{
ctrlLine = LvCtrlLines[index].CtrlLine;
break;
}
}
}
//转为 加热棒数量
var thickPercents = ThickPercents;
double[] offsets = new double[ChannelCnt];
for (int i = 0; i < ChannelCnt; i++)
{
if (!double.IsNaN(thickPercents[i]) && !double.IsNaN(thickPercentTargets[i]) &&
mHeatBuf.BoltIsStable[i] && //稳定
(Math.Abs(thickPercents[i]) > CtrlLine))//在控制线已外
if (!double.IsNaN(thickPercents[i]) && !double.IsNaN(thickPercentTargets[i]))
{
double delta = (thickPercents[i] - thickPercentTargets[i]);
double d = Math.Abs(delta);
if (d >= ctrlLine)
{
}
else if (d >= ctrlLine * 2 / 3)
{
offsets[i] = (thickPercents[i] - thickPercentTargets[i]) * Kp;//保留一位小数
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();//这句一定要加!!!! 不然没法平滑,没法加热
......@@ -263,13 +319,69 @@ namespace FLY.FilmCasting.AutoDie.Server
HeatApply();//执行加热
}
}
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();
}
bool IsLvCtrlLinesValid()
{
if (LvCtrlLines != null && LvCtrlLines.Count() > 0 && LvCtrlLines.All(lv=>lv!=null))
{
return true;
}
return false;
}
void updateThickPercentTargets()
{
......@@ -577,10 +689,15 @@ namespace FLY.FilmCasting.AutoDie.Server
return;
}
}
bool isHeatsChanged = false;
bool isOffsetsChanged = false;
for (int i = 0; i < ChannelCnt; i++)
{
if (Offsets[i] != 0)
{
Offsets[i] = 0;
isOffsetsChanged = true;
}
var h = Math.Round(PreHeats[i], 1);
......@@ -594,16 +711,25 @@ namespace FLY.FilmCasting.AutoDie.Server
//需要整体调低
h = 100;
}
if (Heats[i] != h)
{
Heats[i] = h;
isHeatsChanged = true;
}
}
if(isOffsetsChanged)
NotifyPropertyChanged(nameof(Offsets));
if (isHeatsChanged)
{
NotifyPropertyChanged(nameof(Heats));
LastHeatsChangedTime = DateTime.Now;
Base = 0;
AfterHeatApplyEvent?.Invoke(this);
}
Base = 0;
}
/// <summary>
/// 修改Offsets, Base 后,执行PreHeats = Heats + Offsets + Base
......@@ -694,7 +820,10 @@ namespace FLY.FilmCasting.AutoDie.Server
/// </summary>
public double Kp = 1;
/// <summary>
/// 测厚仪数据混合数
/// </summary>
public int Mix = 3;
/// <summary>
/// 自动对位
/// </summary>
......@@ -730,6 +859,11 @@ namespace FLY.FilmCasting.AutoDie.Server
public double CenterTarget = 0;
/// <summary>
/// 分级控制线
/// </summary>
public LvCtrlLine[] LvCtrlLines;
#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