Commit 87bd01c2 authored by 潘栩锋's avatar 潘栩锋 🚴

添加 AD盒模拟器 电池涂布 添加泵损坏导致纵向波动模拟

parent 6c67770d
......@@ -57,7 +57,10 @@ namespace FLY.Simulation.Coating
public List<DataInfo> Datas_Horizontal = new List<DataInfo>();//横向数据
double datas_horizontal_avg = 0;
int datas_vertical_position=0;
/// <summary>
/// 由于泵损坏带来的纵向波动
/// </summary>
double datas_vertical_pumpDamaged = 0;
//30m 后的数据
public List<DataInfo> Datas_Vertical_30m = new List<DataInfo>();//纵向数据
......@@ -65,6 +68,7 @@ namespace FLY.Simulation.Coating
int datas_vertical_30m_position=0;
/// <summary>
/// 膜宽
/// </summary>
......@@ -123,9 +127,24 @@ namespace FLY.Simulation.Coating
/// </summary>
public bool HSignal2;
/// <summary>
/// 设备状态
/// </summary>
public bool DeviceState { get; set; }
/// <summary>
/// 泵的转子坏了, 会看到有周期的波动,周期为 泵速
/// </summary>
public bool IsPumpDamaged { get; set; }
/// <summary>
/// 由于 泵的转子坏了 导致 面密度 周期的波动 的变化公差,单位g/m²
/// </summary>
public double ToleranceOfPumpBeDamaged { get; set; } = 1;
/// <summary>
/// 均值
/// </summary>
public double Avg { get; set; }
void Load_Vertical()
......@@ -143,7 +162,7 @@ namespace FLY.Simulation.Coating
int pos_mm = int.Parse(ss[0]);
bool isLight = bool.Parse(ss[1]);
bool isLight2 = bool.Parse(ss[2]);
double thick = double.Parse(ss[3]);
double thick = double.Parse(ss[3]);//单位 g/m²
Datas_Vertical.Add(new DataInfo() { IsLight = isLight, IsLight2 = isLight2, Thick = thick });
Datas_Vertical_30m.Add(new DataInfo() { IsLight = isLight, IsLight2 = isLight2, Thick = thick });
......@@ -216,8 +235,12 @@ namespace FLY.Simulation.Coating
return 0;
if (mm >= FilmWidth)
return 0;
return Datas_Vertical_30m[datas_vertical_position].Thick * Datas_Horizontal_30m[mm].Thick / datas_horizontal_avg;
double d = Datas_Vertical_30m[datas_vertical_position].Thick * Datas_Horizontal_30m[mm].Thick / datas_horizontal_avg;
if (IsPumpDamaged)
{
d += datas_vertical_pumpDamaged;
}
return d;
}
public double GetData(int mm)
{
......@@ -226,7 +249,13 @@ namespace FLY.Simulation.Coating
if (mm >= FilmWidth)
return 0;
return Datas_Vertical[datas_vertical_position].Thick * Datas_Horizontal[mm].Thick / datas_horizontal_avg;
double d = Datas_Vertical[datas_vertical_position].Thick * Datas_Horizontal[mm].Thick / datas_horizontal_avg;
if (IsPumpDamaged)
{
d += datas_vertical_pumpDamaged;
}
return d;
}
/// <summary>
/// 上一个时间点
......@@ -249,18 +278,33 @@ namespace FLY.Simulation.Coating
double filmMove = ts.TotalMinutes * FilmVelocity;
FilmLength += filmMove;//膜位置
int p1 = (int)(FilmLength * 1000 % Datas_Vertical.Count());
if (p1 != datas_vertical_position)
{
datas_vertical_position = p1;
Avg = Datas_Vertical[datas_vertical_position].Thick / 100.0;
if (AvgChanged != null)
double avg = Datas_Vertical[datas_vertical_position].Thick;
if (hmi_cc.NowCtrl.Pump > 0 && IsPumpDamaged)
{
AvgChanged(FilmLength, (int)(Avg*100));
// 泵损坏 周期 m
double intervalOfPumpDamage = FilmVelocity / hmi_cc.NowCtrl.Pump;
double index = FilmLength % intervalOfPumpDamage;
double percent = index / intervalOfPumpDamage;
double v = ToleranceOfPumpBeDamaged * Math.Sin(Math.PI * 2 * percent);
datas_vertical_pumpDamaged = v;
avg += datas_vertical_pumpDamaged;
}
Avg = avg;
AvgChanged?.Invoke(this, new AvgChangedEventArgs() { filmLength = FilmLength, avg = Avg });
}
datas_vertical_30m_position = (int)((FilmLength - OvenLength) * 1000 % Datas_Vertical.Count());
if (datas_vertical_30m_position < 0)
datas_vertical_30m_position += Datas_Vertical.Count();
......@@ -288,7 +332,12 @@ namespace FLY.Simulation.Coating
/// <summary>
/// 每1mm更新一次
/// </summary>
public event Action<double, int> AvgChanged;
public event AvgChangedEventHandler AvgChanged;
public delegate void AvgChangedEventHandler(object sender, AvgChangedEventArgs args);
public class AvgChangedEventArgs : EventArgs {
public double filmLength;
public double avg;
}
public event Action DatasChanged;
public event Action Datas30mChanged;
public void NotifyDatasChanged()
......@@ -317,12 +366,13 @@ namespace FLY.Simulation.Coating
public string[] GetSavePropertyNames()
{
return new string[] {
"Port",
"CoatingMode"
nameof(Port),
nameof(CoatingMode)
};
}
}
/// <summary>
/// 涂布控制量
/// </summary>
......
......@@ -330,8 +330,8 @@ namespace FLY.Simulation.Flyad7
}
else
{
Now += FlyADBase.TimeGridAdvHelperExt.ad_ts;
systick += FlyADBase.TimeGridAdvHelperExt.ad_ts_ms;
Now += TimeSpan.FromTicks((long)(1.28 * TimeSpan.TicksPerMillisecond));
systick += 1.28;
}
UpdateAD();
......@@ -385,7 +385,7 @@ namespace FLY.Simulation.Flyad7
TimeGridEvent.Invoke(this,
new TimeGridEventArgs(
Now,
FlyADBase.TimeGridAdvHelperExt.ad_ts,
TimeSpan.FromTicks((long)(1.28 * TimeSpan.TicksPerMillisecond)),
TimeGrid.ToArray()));
}
TimeGrid.Clear();
......
......@@ -97,8 +97,13 @@
</Grid>
<StackPanel>
<CheckBox Content="设置位" FontSize="18" FontWeight="Bold" Height="23" Margin="3" VerticalAlignment="Center" FlowDirection="RightToLeft" IsChecked="{Binding OK}" DataContext="{Binding DataContext,ElementName=hmi}"/>
<CheckBox Content="涂布状态" FontSize="18" FontWeight="Bold" Height="23" Margin="3" VerticalAlignment="Center" FlowDirection="RightToLeft" IsChecked="{Binding DeviceState}" IsEnabled="False"/>
<CheckBox Content="设置位" FontSize="18" FontWeight="Bold" Height="23" Margin="3" IsChecked="{Binding OK}" DataContext="{Binding DataContext,ElementName=hmi}"/>
<CheckBox Content="涂布状态" FontSize="18" FontWeight="Bold" Height="23" Margin="3" IsChecked="{Binding DeviceState}" IsEnabled="False"/>
<CheckBox Content="泵损坏" FontSize="18" FontWeight="Bold" Height="23" Margin="3" IsChecked="{Binding IsPumpDamaged}" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="泵公差" FontSize="18" FontWeight="Bold" Height="23" Margin="3" />
<TextBox Text="{Binding ToleranceOfPumpBeDamaged }" FontSize="18" MinWidth="50"/>
</StackPanel>
</StackPanel>
</StackPanel>
......@@ -122,7 +127,7 @@
</ComboBox>
<TextBlock FontSize="18" FontWeight="Bold" Height="23" Margin="3" VerticalAlignment="Center" >
<Run Text="当前平均值:" />
<Run Text="{Binding Avg}" />
<Run Text="{Binding Avg,StringFormat={}{0:F2}}" />
</TextBlock>
</StackPanel>
<Grid Margin="12,3" Grid.Row="2">
......
......@@ -44,12 +44,13 @@ namespace FLYAD7_Simulation_Wpf
DataBindAll();
mCoating.DatasChanged += new Action(mCoating_DatasChanged);
mCoating.AvgChanged += new Action<double, int>(mCoating_AvgChanged);
mCoating.AvgChanged += MCoating_AvgChanged;
}
void mCoating_AvgChanged(double arg1, int arg2)
private void MCoating_AvgChanged(object sender, Coating.AvgChangedEventArgs args)
{
int filmlength_cm = (int)(arg1*100);
int filmlength_cm = (int)(args.filmLength * 100);
if(FilmLength_cm == filmlength_cm)
{
......@@ -73,7 +74,7 @@ namespace FLYAD7_Simulation_Wpf
}
datas.Clear();
}
datas.Add(arg2);
datas.Add(args.avg);
}
void mCoating_DatasChanged()
......
......@@ -150,14 +150,32 @@ namespace Misc
};
if (r.End < r.Begin)
{
return new RangeStruct();
return InvalidValue;
}
else
{
return r;
}
}
/// <summary>
/// 范围 减
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static RangeStruct operator -(RangeStruct a, RangeStruct b)
{
if (a.Begin < b.Begin)
{
return new RangeStruct(a.Begin, b.Begin - 1);
}
else {
if (a.End > b.End)
return new RangeStruct(b.End + 1, a.End);
else
return InvalidValue;
}
}
/// <summary>
/// 范围 a小于b
/// </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