Commit 72a516b2 authored by 潘栩锋's avatar 潘栩锋 🚴

修复 自动模头的分区表异常

添加 对位 添加收缩率测试
parent 7d96b486
......@@ -187,6 +187,21 @@
<iconPacks:PackIconMaterial Kind="ArrowExpandVertical" />
</Button>
</StackPanel>
<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 UniformShrinkPercent,Converter={StaticResource percentconv}}"/>
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="%" />
</StackPanel>
</StackPanel>
<Button Style="{StaticResource Styles.Button.Icon.Rectangle}" Command="{Binding UspCollapseCmd}" >
<iconPacks:PackIconMaterial Kind="ArrowCollapseHorizontal" />
</Button>
<Button Style="{StaticResource Styles.Button.Icon.Rectangle}" Command="{Binding UspExpandCmd}" >
<iconPacks:PackIconMaterial Kind="ArrowExpandHorizontal" />
</Button>
</StackPanel>
</WrapPanel>
</WrapPanel>
</Grid>
......
......@@ -107,14 +107,18 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
#endregion
public RelayCommand KpCollapseCmd { get; }
public RelayCommand KpExpandCmd { get; }
public RelayCommand KpCollapseCmd { get; private set; }
public RelayCommand KpExpandCmd { get; private set; }
public RelayCommand ApplyCmd { get; }
public RelayCommand ApplyCmd { get; private set; }
public RelayCommand TestMapCmd { get; }
public RelayCommand TestMapCmd { get; private set; }
public RelayCommand DelMapCmd { get; private set; }
public RelayCommand UspCollapseCmd { get; private set; }
public RelayCommand UspExpandCmd { get; private set; }
public RelayCommand DelMapCmd { get; }
public UcThickHeatVm[] ucThickHeatVms;
......@@ -152,7 +156,8 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
KpCollapseCmd = new RelayCommand(KpCollapse);
KpExpandCmd = new RelayCommand(KpExpand);
UspCollapseCmd = new RelayCommand(UspCollapse);
UspExpandCmd = new RelayCommand(UspExpand);
ApplyCmd = new RelayCommand(Apply);
TestMapCmd = new RelayCommand(TestMap);
DelMapCmd = new RelayCommand(DelMap);
......@@ -208,6 +213,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
for (int i = 0; i < 2; i++)
{
ucThickHeatVms[i] = new UcThickHeatVm();
ucThickHeatVms[i].Init($"记录{i + 1}", bulkDbService, 0 - i, Kp, MaxHeat);
Misc.BindingOperations.SetBinding(this, nameof(Kp), ucThickHeatVms[i], nameof(UcThickHeatVm.Kp));
Misc.BindingOperations.SetBinding(this, nameof(MaxHeat), ucThickHeatVms[i], nameof(UcThickHeatVm.MaxHeat));
......@@ -227,13 +233,20 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
}
private void PgHeatAnalyseVm_FrameUpdated()
private void PgHeatAnalyseVm_FrameUpdated(object sender)
{
if (sender == ucThickHeatVms[1])
{
var ucThickHeatVm = ucThickHeatVms[1];
if (ucThickHeatVm.frame !=null && ucThickHeatVm.frame.BoltMapInfo!=null)
UniformShrinkPercent = ucThickHeatVm.frame.BoltMapInfo.UniformShrinkPercent;
}
UpdateD();
}
string[] propertyNames_updateD = new string[] {
nameof(Kp), nameof(HeatEffectCurve), nameof(IsUsedMap) };
nameof(Kp), nameof(HeatEffectCurve), nameof(IsUsedMap), nameof(UniformShrinkPercent) };
private void PgHeatAnalyseVm_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (propertyNames_updateD.Contains(e.PropertyName))
......@@ -300,7 +313,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
public double kp;
}
CallDiffResult CalDiff(IEnumerable<BoltMapCell> boltmap, IEnumerable<double> heatEffectCurve)
CallDiffResult CalDiff(IEnumerable<BoltMapCell> boltmap, double uniformShrinkPercent,IEnumerable<double> heatEffectCurve)
{
if (!IsValid())
{
......@@ -309,10 +322,10 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
}
CallDiffResult result = new CallDiffResult();
double[] thickpercents0 = ucThickHeatVms[0].GetThickPercents(boltmap);
double[] thickpercents0 = ucThickHeatVms[0].GetThickPercents(boltmap, uniformShrinkPercent);
int[] heats0 = ucThickHeatVms[0].GetHeats();
double[] thickpercents1 = ucThickHeatVms[1].GetThickPercents(boltmap);
double[] thickpercents1 = ucThickHeatVms[1].GetThickPercents(boltmap, uniformShrinkPercent);
int[] heats1 = ucThickHeatVms[1].GetHeats();
int channelCnt = feedback.ChannelCnt;
......@@ -356,7 +369,10 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
HeatDiffs.Clear();
HeatDiffEffects.Clear();
var result = CalDiff(IsUsedMap ? BoltMap.ToArray() : null, HeatEffectCurve == null ? null : HeatEffectCurve.Select(d => (double)d));
var result = CalDiff(
IsUsedMap ? BoltMap.ToArray() : null,
UniformShrinkPercent,
HeatEffectCurve == null ? null : HeatEffectCurve.Select(d => (double)d));
if (result != null)
{
......@@ -383,6 +399,17 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
private void TestMap()
{
var list = BoltMap.ToList();
list.Sort((b1, b2) =>
{
return b1.OldNo.CompareTo(b2.OldNo);
});
BoltMap.Clear();
foreach (var b in list)
BoltMap.Add(b);
if (!checkValid_map())
{
FLY.ControlLibrary.Window_WarningTip.Show("异常", "分区表格式出错");
......@@ -496,6 +523,20 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
if (!WdPassword.Authorize("AutoDie"))
return;
var ucThickHeatVm = ucThickHeatVms[1];
if (ucThickHeatVm.frame != null && ucThickHeatVm.frame.BoltMapInfo != null)
{
if (UniformShrinkPercent != ucThickHeatVm.frame.BoltMapInfo.UniformShrinkPercent)
{
//收缩率被修改,请到产品界面 设置
FLY.ControlLibrary.Window_WarningTip.Show("警告","收缩率被修改,请到产品界面 设置", TimeSpan.FromSeconds(2));
return;
}
}
if (IsUsedMap && BoltMap.Count() > 0)
{
this.heatBuf.Boltmap = BoltMap.ToArray();
......@@ -530,5 +571,15 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
if (Kp > 0.2)
Kp -= 0.1;
}
private void UspCollapse()
{
UniformShrinkPercent -= 0.01;
}
private void UspExpand()
{
UniformShrinkPercent += 0.01;
}
}
}
......@@ -132,9 +132,9 @@
<TextBlock Style="{StaticResource Text.FieldContent2}" Text="未起效" Foreground="Red" Visibility="{Binding IsStable,Converter={StaticResource visbilityconv}, ConverterParameter=HiddenWhenTrue}"/>
</StackPanel>
</StackPanel>
<!--<StackPanel Orientation="Horizontal" Visibility="{Binding IsVaild,Converter={StaticResource visbilityconv}}">
<StackPanel Orientation="Horizontal" Visibility="{Binding IsVaild,Converter={StaticResource visbilityconv}}">
<StackPanel Orientation="Horizontal" Background="{StaticResource Badges.Background}" Margin="{StaticResource Badges.Margin}">
<!--<StackPanel Orientation="Horizontal" Background="{StaticResource Badges.Background}" Margin="{StaticResource Badges.Margin}">
<TextBlock Style="{StaticResource Text.FieldHeader2}" Text="左无效:" />
<TextBlock Style="{StaticResource Text.FieldContent2}" Text="{Binding LeftEmptyBolts}" />
<TextBlock Style="{StaticResource Text.FieldContentMm2}" Text="螺丝"/>
......@@ -143,19 +143,19 @@
<TextBlock Style="{StaticResource Text.FieldHeader2}" Text="右无效:" />
<TextBlock Style="{StaticResource Text.FieldContent2}" Text="{Binding RightEmptyBolts}" />
<TextBlock Style="{StaticResource Text.FieldContentMm2}" Text="螺丝"/>
</StackPanel>
</StackPanel>-->
<StackPanel Orientation="Horizontal" Background="{StaticResource Badges.Background}" Margin="{StaticResource Badges.Margin}">
<TextBlock Style="{StaticResource Text.FieldHeader2}" Text="收缩率:" />
<TextBlock Style="{StaticResource Text.FieldContent2}" Text="{Binding UniformShrinkPercent,StringFormat={}{0:P1}}" />
<TextBlock Style="{StaticResource Text.FieldContent2}" Text="{Binding CurrUsp,StringFormat={}{0:P1}}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Background="{StaticResource Badges.Background}" Margin="{StaticResource Badges.Margin}">
<!--<StackPanel Orientation="Horizontal" Background="{StaticResource Badges.Background}" Margin="{StaticResource Badges.Margin}">
<TextBlock Style="{StaticResource Text.FieldHeader2}" Text="偏移:" />
<TextBlock Style="{StaticResource Text.FieldContent2}" Text="{Binding MidOffset}" />
<TextBlock Style="{StaticResource Text.FieldContentMm2}" Text="mm"/>
</StackPanel>
</StackPanel>-->
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
<StackPanel Grid.Column="2" Grid.RowSpan="2" Panel.ZIndex="1" VerticalAlignment="Top" HorizontalAlignment="Right">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
......
......@@ -106,6 +106,10 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
/// </summary>
public double FilmWidth { get; set; }
/// <summary>
/// 当前收缩率
/// </summary>
public double CurrUsp { get; set; }
/// <summary>
/// 纵向速度
/// </summary>
......@@ -155,7 +159,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
})
.Y((value) =>
{
return value * Kp + 50;
return value * Kp + MaxHeat /2 ;
});
PreCmd = new RelayCommand(Pre);
......@@ -165,7 +169,22 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
NewestCmd = new RelayCommand(Newest);
}
public void Init(string title,
IBulkDbService bulkDbService,
int number)
{
this.bulkDbService = bulkDbService;
Title = title;
Misc.BindingOperations.SetBinding(bulkDbService, nameof(bulkDbService.LastId), this, nameof(LastId));
Number = number;
UpdateFrame();
this.PropertyChanged += UcThickHeatVm_PropertyChanged;
}
public void Init(string title,
IBulkDbService bulkDbService,
......@@ -196,7 +215,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
UpdateFrame();
}
}
public event Action FrameUpdated;
public event Action<object> FrameUpdated;
public void UpdateFrame()
{
PollModule.Current.Poll_JustOnce(() =>
......@@ -217,6 +236,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
EndTime = frame.EndTime;
FilmWidth = frame.FilmWidth;
FilmVelocity = frame.FilmVelocity;
CurrUsp = frame.BoltMapInfo.UniformShrinkPercent;
Average = frame.Thicks.AverageNoNull();
Sigma2Percent = frame.Thicks.Sigma() / Average * 2;
......@@ -243,7 +263,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
IsVaild = false;
}
FrameUpdated?.Invoke();
FrameUpdated?.Invoke(this);
}
private void Next()
......@@ -284,14 +304,14 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
else
IsVaild = false;
FrameUpdated?.Invoke();
FrameUpdated?.Invoke(this);
}
/// <summary>
/// 以指定分区表 导出厚度%
/// </summary>
/// <param name="boltmap">分区表</param>
/// <returns></returns>
public double[] GetThickPercents(IEnumerable<BoltMapCell> boltmap)
public double[] GetThickPercents(IEnumerable<BoltMapCell> boltmap, double uniformShrinkPercent)
{
if (frame == null)
return null;
......@@ -300,20 +320,26 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
double[] thks_x10 = FLY.FilmCasting.AutoDie.Common.MyMath.ZoomIn(thks, 10);
//偏移量
//int midOffsetIdx_x10 = (int)(frame.BoltMapInfo.MidOffset / (frame.BoltMapInfo.BoltWidth * (1 - frame.BoltMapInfo.UniformShrinkPercent)) * 10);
int midOffsetIdx_x10 = (int)(frame.BoltMapInfo.MidOffset / (frame.BoltMapInfo.BoltWidth * (1 - frame.BoltMapInfo.UniformShrinkPercent)) * 10);
//计算 thks_x10 中间的螺丝序号
//int r_l = frame.BoltMapInfo.RightEmptyBolts - frame.BoltMapInfo.LeftEmptyBolts;
//int midBoltIdx_x10 = 10 * (frame.BoltMapInfo.BoltCnt - r_l * 2) / 2;
int r_l = frame.BoltMapInfo.RightEmptyBolts - frame.BoltMapInfo.LeftEmptyBolts;
int midBoltIdx_x10 = 10 * (frame.BoltMapInfo.BoltCnt - r_l * 2) / 2;
//偏移后
//midBoltIdx_x10 += midOffsetIdx_x10;
midBoltIdx_x10 += midOffsetIdx_x10;
//收缩率 =0,每个分区,就是原始螺丝宽度25.4mm
//收缩率 =10%, 每个分区,就是原始螺丝宽度25.4mm * (100%-10%), 由于 分区是固定了,所以看起来图会横向拉宽了 新数据是原来的 100%/(100%-10%) 倍
//收缩率 =-10%, 每个分区,就是原始螺丝宽度25.4mm * (100%+10%), 由于 分区是固定了,所以看起来图会横向收窄了 新数据是原来的 100%/(100%+10%) 倍
//if (Math.Abs(frame.BoltMapInfo.UniformShrinkPercent - uniformShrinkPercent) > 0.01) //大于1%以上
//{
// //放大
// thks_x10 = FLY.FilmCasting.AutoDie.Common.MyMath.ZoomX(thks_x10, midBoltIdx_x10, uniformShrinkPercent / frame.BoltMapInfo.UniformShrinkPercent);
//}
if (Math.Abs(frame.BoltMapInfo.UniformShrinkPercent - uniformShrinkPercent) > 0.01) //大于1%以上
{
//放大
double scale =(1 - frame.BoltMapInfo.UniformShrinkPercent) / (1 - uniformShrinkPercent);
//所以需要新数据 比原来要横向拉宽 scale倍 新的 收缩率 = uniformShrinkPercent = 1 - ((1 - frame.BoltMapInfo.UniformShrinkPercent)/scale)
thks_x10 = FLY.FilmCasting.AutoDie.Common.MyMath.ZoomX(thks_x10, midBoltIdx_x10, scale);
}
//新的偏移量
//int midOffsetIdx_new_x10 = (int)(midOffset / (frame.BoltMapInfo.BoltWidth * (1 - frame.BoltMapInfo.UniformShrinkPercent)) * 10.0);
......@@ -356,7 +382,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
public double[] GetThickPercents()
{
//return GetThickPercents(frame.BoltMapInfo.UniformShrinkPercent, frame.BoltMapInfo.MidOffset, frame.Boltmap);
return GetThickPercents(frame.Boltmap);
return GetThickPercents(frame.Boltmap, frame.BoltMapInfo.UniformShrinkPercent);
}
public int[] GetHeats()
{
......
......@@ -52,7 +52,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client
ScanDataId = 1121;
FilmWidth = 2130;
FilmVelocity = 30.2;
CurrUsp = 0;
Average = datas.AverageNoNull();
Sigma2Percent = datas.Sigma() / Average * 2;
......
......@@ -51,7 +51,7 @@ using System.Windows;
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.0.0.0")]
[assembly: AssemblyFileVersion("7.0.0.0")]
[assembly: AssemblyVersion("7.0.1.0")]
[assembly: AssemblyFileVersion("7.0.1.0")]
[assembly: Guid("281B0472-B641-4FA9-BF3B-5180E745AEFC")]
......@@ -51,7 +51,7 @@ using System.Windows;
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.0.4.0")]
[assembly: AssemblyFileVersion("7.0.4.0")]
[assembly: AssemblyVersion("7.0.5.0")]
[assembly: AssemblyFileVersion("7.0.5.0")]
[assembly: Guid("CC6F2BB4-E648-47BE-8223-B6157E35403D")]
......@@ -957,22 +957,30 @@ namespace FLY.FilmCasting.AutoDie.Common
for (int i = 0; i < map.Count(); i++)
{
//第0组
int old_idx0 = map.Keys.ElementAt(i);
int new_idx0 = map[old_idx0];
int old_idx1 = map.Keys.ElementAt(i);
int new_idx1 = map[old_idx1];
if (i == 0)
{
MapX(data, data_new, 0, 0, old_idx0, new_idx0);
MapX(data, data_new, 0, 0, old_idx1, new_idx1);
}
else if(i== map.Count()-1)
{
MapX(data, data_new, old_idx0, new_idx0, data.Count()-1, data.Count() - 1);
//最后一组
int old_idx0 = map.Keys.ElementAt(i - 1);
int new_idx0 = map[old_idx0];
MapX(data, data_new, old_idx0, new_idx0, old_idx1, new_idx1);
//后面的
MapX(data, data_new, old_idx1, new_idx1, data.Count()-1, data.Count() - 1);
}
else
{
//第1组
int old_idx1 = map.Keys.ElementAt(i+1);
int new_idx1 = map[old_idx1];
int old_idx0 = map.Keys.ElementAt(i-1);
int new_idx0 = map[old_idx0];
MapX(data, data_new, old_idx0, new_idx0, old_idx1, new_idx1);
}
......
......@@ -24,7 +24,7 @@ namespace FLY.FilmCasting.AutoDie.Server
/// <summary>
/// HeatOffset = ThickPercent * Kp
/// </summary>
public double Kp { get; set; } = 3;
public double Kp { get; set; } = 1;
/// <summary>
......@@ -125,9 +125,9 @@ namespace FLY.FilmCasting.AutoDie.Server
}
void checkParamErr()
{
if (Kp < 1 || Kp > 10)
if (Kp < 0.2 || Kp > 10)
{
Kp = 3;
Kp = 1;
}
if (ThresholdHeatSigma < 1 || ThresholdHeatSigma > 50)
......@@ -615,7 +615,7 @@ namespace FLY.FilmCasting.AutoDie.Server
/// <summary>
/// HeatOffset = ThickPercent * Kp
/// </summary>
public double Kp = 3;
public double Kp = 1;
/// <summary>
......
......@@ -51,6 +51,6 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.5.6.0")]
[assembly: AssemblyFileVersion("7.5.6.0")]
[assembly: AssemblyVersion("7.5.7.0")]
[assembly: AssemblyFileVersion("7.5.7.0")]
[assembly: Guid("BD20A921-953E-44CA-8FAB-4619D3CBCD06")]
{
"InstallZipVersion":"7.5.6",
"InstallZipUrl":"http://server.flyautomation.net:8889/download/流延测厚仪安装包_v7.5.6_20220411.7z"
"InstallZipVersion":"7.5.7",
"InstallZipUrl":"http://server.flyautomation.net:8889/download/流延测厚仪安装包_v7.5.7_20220510.7z"
}
\ No newline at end of file
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