Commit 582acd98 authored by 潘栩锋's avatar 潘栩锋 🚴

增加 flyad7 吹膜模拟器 显示更多信息。

parent adf9d9be
...@@ -4,14 +4,13 @@ using System.Linq; ...@@ -4,14 +4,13 @@ using System.Linq;
using System.Text; using System.Text;
using System.ComponentModel; using System.ComponentModel;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO;
using Newtonsoft.Json;
namespace FLY.Simulation.Blowing namespace FLY.Simulation.Blowing
{ {
/// <summary> [JsonObject(MemberSerialization.OptIn)]
/// 吹膜模拟
/// 1.加载数据
/// </summary>
public class Blowing:INotifyPropertyChanged public class Blowing:INotifyPropertyChanged
{ {
#region 参数 #region 参数
...@@ -20,82 +19,89 @@ namespace FLY.Simulation.Blowing ...@@ -20,82 +19,89 @@ namespace FLY.Simulation.Blowing
/// <summary> /// <summary>
/// 两个限位间的角度范围 != 旋转的总角度,限位值 ° /// 两个限位间的角度范围 != 旋转的总角度,限位值 °
/// </summary> /// </summary>
public double AngleRange; [JsonProperty]
public double AngleRange { get; set; }
/// <summary> /// <summary>
/// 旋转的速度, min/R 1R = 360° /// 旋转的速度, min/R 1R = 360°
/// </summary> /// </summary>
[JsonProperty]
public double AngleVelocity { get; set; } public double AngleVelocity { get; set; }
/// <summary> /// <summary>
/// 加速时间 单位 s /// 加速时间 单位 s
/// </summary> /// </summary>
public double AngleAccTime; [JsonProperty]
public double AngleAccTime { get; set; }
/// <summary> /// <summary>
/// 减速时间 单位 s /// 减速时间 单位 s
/// </summary> /// </summary>
public double AngleDecTime; [JsonProperty]
public double AngleDecTime { get; set; }
/// <summary> /// <summary>
/// 换方向冷却时间 单位s /// 换方向冷却时间 单位s
/// </summary> /// </summary>
public double AngleCoolTime; [JsonProperty]
public double AngleCoolTime { get; set; }
#endregion #endregion
#region #region
private double filmwidth;
/// <summary> /// <summary>
/// 膜泡压扁后总宽度,单位m /// 膜泡压扁后总宽度,单位 脉冲
/// </summary> /// </summary>
public double FilmWidth { get; set; } public double FilmWidth { get; set; }
/// <summary> /// <summary>
/// 膜走带速度, m/min /// 膜走带速度, m/min
/// </summary> /// </summary>
[JsonProperty]
public double FilmVelocity { get; set; } public double FilmVelocity { get; set; }
/// <summary> /// <summary>
/// 人字架到测厚仪的距离 23m /// 人字架到测厚仪的距离 23m
/// </summary> /// </summary>
public double FilmDistance; [JsonProperty]
public double FilmDistance { get; set; }
/// <summary> /// <summary>
/// 辊轴承,单位mm /// 辊轴承,单位mm
/// </summary> /// </summary>
public double RollPerimeter; [JsonProperty]
public double RollPerimeter { get; set; }
/// <summary> /// <summary>
/// 测辊信号,信号长,单位mm /// 测辊信号,信号长,单位mm
/// </summary> /// </summary>
public double RollSignLength; [JsonProperty]
public double RollSignLength { get; set; }
#endregion #endregion
//#region 风环 #region 风环
///// <summary> /// <summary>
///// 加热棒数量 /// 加热棒数量
///// </summary> /// </summary>
//public int ChannelCnt; [JsonProperty]
public int ChannelCnt { get; set; }
///// <summary> ///// <summary>
///// 加热功率, 1~100 ///// 加热功率, 1~100
///// </summary> ///// </summary>
//public int[] Heats; //public int[] Heats;
///// <summary> /// <summary>
///// 第1根加热棒对应角度 /// 第1根加热棒对应角度
///// </summary> /// </summary>
//public int Channel1stAngle; [JsonProperty]
public double Channel1stAngle { get; set; }
///// <summary> ///// <summary>
///// 温度影响厚度变化比例, 1厚度,对应多少加热 ///// 温度影响厚度变化比例, 1厚度,对应多少加热
///// </summary> ///// </summary>
//public int Factor;// //public int Factor;//
//#endregion #endregion
public bool IsShieldI9 { get; set; } public bool IsShieldI9 { get; set; }
...@@ -105,21 +111,21 @@ namespace FLY.Simulation.Blowing ...@@ -105,21 +111,21 @@ namespace FLY.Simulation.Blowing
/// <summary> /// <summary>
/// 当前人字架角度 ° /// 当前人字架角度 °
/// </summary> /// </summary>
public double CurrAngle { get; set; } public double CurrAngle { get; private set; }
/// <summary> /// <summary>
/// 当前速度,单位 °/s /// 当前速度,单位 °/s
/// </summary> /// </summary>
public double CurrAngleVelocity; public double CurrAngleVelocity { get; private set; }
/// <summary> /// <summary>
/// 当前加速度, 单位 °/s^2 /// 当前加速度, 单位 °/s^2
/// </summary> /// </summary>
public double CurrAngleAccV; public double CurrAngleAccV { get; private set; }
/// <summary> /// <summary>
/// 当前已经走到长度, 通过编码器获取 单位 m /// 当前已经走到长度, 通过编码器获取 单位 m
/// </summary> /// </summary>
public double CurrFilmLength; public double CurrFilmLength { get; private set; }
#endregion #endregion
public HMI mHMI; public HMI mHMI;
...@@ -177,6 +183,13 @@ namespace FLY.Simulation.Blowing ...@@ -177,6 +183,13 @@ namespace FLY.Simulation.Blowing
RollPerimeter = 314;//辊周长mm RollPerimeter = 314;//辊周长mm
RollSignLength = 30;//辊信号长度mm RollSignLength = 30;//辊信号长度mm
ChannelCnt = 88;//加热棒数量
Channel1stAngle = 100;//第1根加热棒对应角度
if (!Load())
Save();
//整个膜片1000个数据 //整个膜片1000个数据
int[] datas = OrgData.GetData(1000); int[] datas = OrgData.GetData(1000);
for(int i=0;i<1000;i++) for(int i=0;i<1000;i++)
...@@ -186,12 +199,12 @@ namespace FLY.Simulation.Blowing ...@@ -186,12 +199,12 @@ namespace FLY.Simulation.Blowing
AfterDatas.Add(datas[i]);//系统扰动后 再 加热数据 AfterDatas.Add(datas[i]);//系统扰动后 再 加热数据
} }
mAirRing = new AirRing(88);//44支加热棒 mAirRing = new AirRing(ChannelCnt);//88支加热棒
mAirRing.Init(BeforeDatas, BeforeDatas2, 0); mAirRing.Init(BeforeDatas, BeforeDatas2, 0);
mAirRing2 = new AirRing(88);//44支加热棒; mAirRing2 = new AirRing(ChannelCnt);//88支加热棒;
mAirRing2.Init(BeforeDatas2, AfterDatas, 400);//加热偏移了 400个数据, 总数是1000 mAirRing2.Init(BeforeDatas2, AfterDatas, (int)(1000*Channel1stAngle/360));//加热偏移了
mAirRing2.AfterDatasUpdateEvent += new Action<ObservableCollection<int>>(mAirRing2_AfterDatasUpdateEvent); mAirRing2.AfterDatasUpdateEvent += new Action<ObservableCollection<int>>(mAirRing2_AfterDatasUpdateEvent);
Avg = (int)(BeforeDatas.Average());//原始平均值 Avg = (int)(BeforeDatas.Average());//原始平均值
...@@ -208,7 +221,7 @@ namespace FLY.Simulation.Blowing ...@@ -208,7 +221,7 @@ namespace FLY.Simulation.Blowing
void mAirRing2_AfterDatasUpdateEvent(ObservableCollection<int> obj) void mAirRing2_AfterDatasUpdateEvent(ObservableCollection<int> obj)
{ {
NotifyPropertyChanged("AfterDatas"); NotifyPropertyChanged(nameof(AfterDatas));
} }
...@@ -377,7 +390,7 @@ namespace FLY.Simulation.Blowing ...@@ -377,7 +390,7 @@ namespace FLY.Simulation.Blowing
void Blowing_PropertyChanged(object sender, PropertyChangedEventArgs e) void Blowing_PropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == "Avg") if (e.PropertyName == nameof(Avg))
{ {
int avg = (int)(BeforeDatas.Average()); int avg = (int)(BeforeDatas.Average());
int offset = Avg - avg; int offset = Avg - avg;
...@@ -389,7 +402,7 @@ namespace FLY.Simulation.Blowing ...@@ -389,7 +402,7 @@ namespace FLY.Simulation.Blowing
} }
} }
} }
else if (e.PropertyName == "TestPos") else if (e.PropertyName == nameof(TestPos))
{ {
UpdateTestHeat(); UpdateTestHeat();
} }
...@@ -661,6 +674,30 @@ namespace FLY.Simulation.Blowing ...@@ -661,6 +674,30 @@ namespace FLY.Simulation.Blowing
} }
} }
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
private string param_path = "simulation_blowing.json";
public void Save()
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(this, Formatting.Indented);
File.WriteAllText(param_path, json);
}
bool Load()
{
if (!File.Exists(param_path))
return false;
try
{
string json = File.ReadAllText(param_path);
Newtonsoft.Json.JsonConvert.PopulateObject(json, this);
return true;
}
catch {
return false;
}
}
} }
public class FilmData public class FilmData
{ {
...@@ -669,4 +706,6 @@ namespace FLY.Simulation.Blowing ...@@ -669,4 +706,6 @@ namespace FLY.Simulation.Blowing
public int data1; public int data1;
public int data2; public int data2;
} }
} }
...@@ -35,30 +35,35 @@ namespace FLY.Simulation.Blowing ...@@ -35,30 +35,35 @@ namespace FLY.Simulation.Blowing
public int FilmBegin; public int FilmBegin;
/// <summary> /// <summary>
/// 传感器直径 /// 传感器直径,单位脉冲
/// </summary> /// </summary>
public int SenserWidth; public int SenserWidth;
public int[] AirDatas; public int[] AirDatas;
CurveCollection curve; CurveCollection curve;
double ppmm;
public GageAD() public GageAD()
{ {
curve = new CurveCollection(); curve = new CurveCollection();
double mm_gagelen = 3000;//设备总长3m
double mm_filmwidth = 2300;//膜宽2.3m mBlowing = new Blowing();
double m_filmwidth = mBlowing.FilmWidth;//膜宽2.3m
double m_gagelen = 3;//设备总长3m
double mm_senserwidth = 15;//传感器15mm double mm_senserwidth = 15;//传感器15mm
double mm_filmbegin = 300;//mm double mm_filmbegin = 300;//mm
PosLen = 8030; PosLen = 8030;
double ppmm = PosLen / mm_gagelen; ppmm = PosLen / (m_gagelen*1000);
FilmWidth = (int)(mm_filmwidth * ppmm); FilmWidth = (int)(m_filmwidth *1000 * ppmm);
FilmBegin = (int)(mm_filmbegin * ppmm); FilmBegin = (int)(mm_filmbegin * ppmm);
SenserWidth = (int)(mm_senserwidth * ppmm); SenserWidth = (int)(mm_senserwidth * ppmm);
mBlowing = new Blowing();
mBlowing.FilmWidth = FilmWidth;
AirDatas = new int[PosLen]; AirDatas = new int[PosLen];
NewAirDatas(); NewAirDatas();
...@@ -96,7 +101,9 @@ namespace FLY.Simulation.Blowing ...@@ -96,7 +101,9 @@ namespace FLY.Simulation.Blowing
if ((idx >= FilmBegin) && (idx<(FilmBegin+FilmWidth))) if ((idx >= FilmBegin) && (idx<(FilmBegin+FilmWidth)))
{ {
FilmData fd = mBlowing.GetData(idx-FilmBegin); int position = idx-FilmBegin;
double pos_m = position / ppmm / 1000.0;
FilmData fd = mBlowing.GetData(pos_m);
if (fd != null) if (fd != null)
{ {
data += fd.data1 + fd.data2; data += fd.data1 + fd.data2;
......
...@@ -147,23 +147,22 @@ namespace FLYAD7_Simulation_Wpf ...@@ -147,23 +147,22 @@ namespace FLYAD7_Simulation_Wpf
private void Window_Loaded(object sender, RoutedEventArgs e) private void Window_Loaded(object sender, RoutedEventArgs e)
{ {
this.DataContext = mBlowing; this.DataContext = mBlowing;
this.groupBox1.DataContext = mBlowing.mHMI; this.spPlc.DataContext = mBlowing.mHMI;
mBlowing.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(mBlowing_PropertyChanged); mBlowing.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(mBlowing_PropertyChanged);
DataBindAll(); DataBindAll();
chart1.ChartAreas["Default"].CursorX.Position = mBlowing.TestPos; chart1.ChartAreas["Default"].CursorX.Position = mBlowing.TestPos;
DataBindAll_chart2(); DataBindAll_chart2();
this.checkbox_isShieldI9.DataContext = mBlowing;
} }
void mBlowing_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) void mBlowing_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{ {
if (e.PropertyName == "TestPos") if (e.PropertyName == nameof(mBlowing.TestPos))
{ {
chart1.ChartAreas["Default"].CursorX.Position = mBlowing.TestPos; chart1.ChartAreas["Default"].CursorX.Position = mBlowing.TestPos;
} }
else if (e.PropertyName == "AfterDatas") else if (e.PropertyName == nameof(mBlowing.AfterDatas))
{ {
this.Dispatcher.Invoke(new Action(DataBindAll2_chart2)); this.Dispatcher.Invoke(new Action(DataBindAll2_chart2));
this.Dispatcher.Invoke(new Action(DataBindAll2)); this.Dispatcher.Invoke(new Action(DataBindAll2));
...@@ -220,6 +219,11 @@ namespace FLYAD7_Simulation_Wpf ...@@ -220,6 +219,11 @@ namespace FLYAD7_Simulation_Wpf
{ {
mBlowing.Test(); mBlowing.Test();
} }
private void btnSaveClick(object sender, RoutedEventArgs e)
{
mBlowing.Save();
MessageBox.Show("已经保存数据,请重启");
}
} }
} }
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