Commit 39bb3d32 authored by 潘栩锋's avatar 潘栩锋 🚴

自动模头程序 通过 模拟器调试。 应该没问题

parent 8bc081e4
...@@ -10,10 +10,10 @@ namespace FLY.FilmCasting.AutoDie.Common ...@@ -10,10 +10,10 @@ namespace FLY.FilmCasting.AutoDie.Common
{ {
static ERRNOs() static ERRNOs()
{ {
ERRNO_PLC_DISCONNECTED = new ERRNO() { Code = 65535, Descrption = "风环 PLC连接断开" }; ERRNO_PLC_DISCONNECTED = new ERRNO() { Code = 65535, Descrption = "PLC连接断开" };
#region 收卷 #region 收卷
ERRNO_NO_FAN = new ERRNO() { Code = 0, Descrption = "风机没开,不能加热" }; ERRNO_NO_FAN = new ERRNO() { Code = 0, Descrption = "总开关没打开,不能加热" };
ERRNO_OPEN_CIRCUIT = new ERRNO() { Code = 1, Descrption = "加热棒断路" }; ERRNO_OPEN_CIRCUIT = new ERRNO() { Code = 1, Descrption = "加热棒断路" };
ERRNO_SHORT_CIRCUIT = new ERRNO() { Code = 2, Descrption = "加热控制板短路" }; ERRNO_SHORT_CIRCUIT = new ERRNO() { Code = 2, Descrption = "加热控制板短路" };
ERRNO_POWER_OFF = new ERRNO() { Code = 3, Descrption = "电源没开启或电流计损坏" }; ERRNO_POWER_OFF = new ERRNO() { Code = 3, Descrption = "电源没开启或电流计损坏" };
......
...@@ -96,12 +96,6 @@ namespace FLY.FilmCasting.AutoDie.IService ...@@ -96,12 +96,6 @@ namespace FLY.FilmCasting.AutoDie.IService
/// </summary> /// </summary>
bool CheckEnable { set; get; } bool CheckEnable { set; get; }
/// <summary>
/// 当前正在检测的加热通道
/// </summary>
int CheckNo { get; }
/// <summary> /// <summary>
/// 烧了的加热棒 /// 烧了的加热棒
/// </summary> /// </summary>
......
...@@ -11,14 +11,10 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -11,14 +11,10 @@ namespace FLY.FilmCasting.AutoDie.Server
public interface IPLCLink:INotifyPropertyChanged public interface IPLCLink:INotifyPropertyChanged
{ {
#region 输出 #region 输出
/// <summary>
/// 加热通道数
/// </summary> void SetChannelCnt(UInt16 channelCnt);
UInt16 ChannelCnt { get; set; } void SetHeatUpdate(UInt16 heatUpdate);
/// <summary>
/// 加热量更新 写
/// </summary>
UInt16 HeatUpdate { get; set; }
/// <summary> /// <summary>
/// 设置加热量 /// 设置加热量
/// </summary> /// </summary>
...@@ -43,7 +39,7 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -43,7 +39,7 @@ namespace FLY.FilmCasting.AutoDie.Server
#endregion #endregion
#region 状态 #region 状态
int Errno { get; set; } bool IsConected { get; }
#endregion #endregion
} }
......
...@@ -121,23 +121,11 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -121,23 +121,11 @@ namespace FLY.FilmCasting.AutoDie.Server
/// </summary> /// </summary>
public bool HasCheckFilmVelocity { get; set; } public bool HasCheckFilmVelocity { get; set; }
/// <summary>
/// 当前正在检测的加热通道
/// </summary>
public int CheckNo { get; set; } = -2;
/// <summary> /// <summary>
/// 正在检测中 /// 正在检测中
/// </summary> /// </summary>
public bool CheckEnable { get; set; } = false; public bool CheckEnable { get; set; } = false;
/// <summary>
/// 1块加热控制板 接多少路加热
/// </summary>
public int HeatsOfGroup { get; set; } = 12;
#endregion #endregion
#endregion #endregion
...@@ -178,9 +166,10 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -178,9 +166,10 @@ namespace FLY.FilmCasting.AutoDie.Server
public FeedbackHeat() public FeedbackHeat()
{ {
Load(); if (!Load())
Save();
plc = new PLCLink(Misc.StringConverter.ToIPEndPoint("192.168.50.60:502"));
} }
...@@ -194,16 +183,28 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -194,16 +183,28 @@ namespace FLY.FilmCasting.AutoDie.Server
) )
{ {
this.boltMapFilmCasting = boltMapFilmCasting; this.boltMapFilmCasting = boltMapFilmCasting;
this.bulkDb = bulkDb; this.bulkDb = bulkDb;
this.gageService = gageService; this.gageService = gageService;
mWarning = warning; mWarning = warning;
mHistoryDb = historyDb; mHistoryDb = historyDb;
plc.PropertyChanged += new PropertyChangedEventHandler(hmi_PropertyChanged);
HasElectricity = plc.HasElectricity; plc = new PLCLink(Misc.StringConverter.ToIPEndPoint(PLCep));
HasFan = plc.HasFan; Misc.BindingOperations.SetBinding(plc, nameof(plc.IsConected), this, nameof(IsConnectedWithPLC));
Misc.BindingOperations.SetBinding(plc, nameof(plc.HasElectricity), this, nameof(HasElectricity));
Misc.BindingOperations.SetBinding(plc, nameof(plc.HasFan), this, nameof(HasFan));
Misc.BindingOperations.SetBinding(plc, nameof(plc.IsConected), () => {
if (plc.IsConected == true)
{
//刚成功连接上
//重新复制数据到 PLC
RecoverPLC();
}
});
...@@ -291,12 +292,9 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -291,12 +292,9 @@ namespace FLY.FilmCasting.AutoDie.Server
Misc.BindingOperations.SetBinding(this, nameof(HasElectricity), mHeatCheck, nameof(mHeatCheck.HasElectricity)); Misc.BindingOperations.SetBinding(this, nameof(HasElectricity), mHeatCheck, nameof(mHeatCheck.HasElectricity));
Misc.BindingOperations.SetBinding(this, nameof(HasCheck), mHeatCheck, nameof(mHeatCheck.Has)); Misc.BindingOperations.SetBinding(this, nameof(HasCheck), mHeatCheck, nameof(mHeatCheck.Has));
Misc.BindingOperations.SetBinding(mHeatCheck, nameof(mHeatCheck.Enable), this, nameof(CheckEnable), Misc.BindingOperations.BindingMode.TwoWay); Misc.BindingOperations.SetBinding(mHeatCheck, nameof(mHeatCheck.Enable), this, nameof(CheckEnable), Misc.BindingOperations.BindingMode.TwoWay);
Misc.BindingOperations.SetBinding(mHeatCheck, nameof(mHeatCheck.CheckNo), this, nameof(CheckNo));
Misc.BindingOperations.SetBinding(mHeatCheck, nameof(mHeatCheck.Bads), this, nameof(Bads)); Misc.BindingOperations.SetBinding(mHeatCheck, nameof(mHeatCheck.Bads), this, nameof(Bads));
Misc.BindingOperations.SetBinding(this, nameof(HeatsOfGroup), mHeatCheck, nameof(mHeatCheck.HeatsOfGroup));
//mHeatCell.Init3(blowingService);
Misc.BindingOperations.SetBinding(boltMapFilmCasting, nameof(boltMapFilmCasting.NBolts), this, nameof(ChannelCnt)); Misc.BindingOperations.SetBinding(boltMapFilmCasting, nameof(boltMapFilmCasting.NBolts), this, nameof(ChannelCnt));
...@@ -465,7 +463,7 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -465,7 +463,7 @@ namespace FLY.FilmCasting.AutoDie.Server
void InitBuf() void InitBuf()
{ {
plc.ChannelCnt = (UInt16)ChannelCnt; plc.SetChannelCnt((UInt16)ChannelCnt);
//Currs = new int[ChannelCnt]; //Currs = new int[ChannelCnt];
mHeatBuf.Init(ChannelCnt); mHeatBuf.Init(ChannelCnt);
mHeatCell.Init2(ChannelCnt); mHeatCell.Init2(ChannelCnt);
...@@ -476,36 +474,7 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -476,36 +474,7 @@ namespace FLY.FilmCasting.AutoDie.Server
//复位undo模块 //复位undo模块
resetUndo(); resetUndo();
} }
void hmi_PropertyChanged(object s, PropertyChangedEventArgs _e)
{
FObjBase.PollModule.Current.Dispatcher.Invoke(
new PropertyChangedEventHandler(
(sender, e) =>
{
if (e.PropertyName == nameof(plc.Errno))
{
if (plc.Errno == -1)
{
IsConnectedWithPLC = false;
}
else
{
IsConnectedWithPLC = true;
//刚成功连接上
//重新复制数据到 PLC
RecoverPLC();
}
}
else if (e.PropertyName == nameof(plc.HasElectricity))
{
HasElectricity = plc.HasElectricity;
}
else if (e.PropertyName == nameof(plc.HasFan))
{
HasFan = plc.HasFan;
}
}), s, _e);
}
...@@ -660,11 +629,11 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -660,11 +629,11 @@ namespace FLY.FilmCasting.AutoDie.Server
UInt16 heatupdate = (UInt16)(plc.HeatUpdate_R + 1); UInt16 heatupdate = (UInt16)(plc.HeatUpdate_R + 1);
if (heatupdate > 100) if (heatupdate > 100)
heatupdate = 1; heatupdate = 1;
plc.HeatUpdate = heatupdate; plc.SetHeatUpdate(heatupdate);
} }
void RecoverPLC() void RecoverPLC()
{ {
plc.ChannelCnt = (UInt16)ChannelCnt; plc.SetChannelCnt((UInt16)ChannelCnt);
if (lastHeats != null) if (lastHeats != null)
{ {
plc.SetHeat(lastHeats.Select(h => (UInt16)h)); plc.SetHeat(lastHeats.Select(h => (UInt16)h));
...@@ -675,10 +644,15 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -675,10 +644,15 @@ namespace FLY.FilmCasting.AutoDie.Server
//设置全部0进去 //设置全部0进去
plc.SetHeat(new UInt16[ChannelCnt]); plc.SetHeat(new UInt16[ChannelCnt]);
} }
//这里是在 plc.IsConnected = true, 才会触发。
//只有读取一次PLC后,IsConnected 才会=true,
//所以 HeatUpdate_R 肯定是对的
UInt16 heatupdate = (UInt16)(plc.HeatUpdate_R + 1); UInt16 heatupdate = (UInt16)(plc.HeatUpdate_R + 1);
if (heatupdate > 100) if (heatupdate > 100)
heatupdate = 1; heatupdate = 1;
plc.HeatUpdate = heatupdate; plc.SetHeatUpdate(heatupdate);
} }
...@@ -773,37 +747,11 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -773,37 +747,11 @@ namespace FLY.FilmCasting.AutoDie.Server
string file_path = "feedback.json"; string file_path = "feedback.json";
bool Load() bool Load()
{ {
if (File.Exists(file_path)) return FeedbackHeatJsonDb.Load(this, file_path);
{
try
{
string json = File.ReadAllText(file_path);
var jsonDb = JsonConvert.DeserializeObject<FeedbackHeatJsonDb>(json);
FeedbackHeatJsonDb.Mapper.Map(jsonDb, this);
return true;
}
catch
{
//异常,没有json 解码失败
}
return false;
}
return false;
} }
void Save() void Save()
{ {
try FeedbackHeatJsonDb.Save(this, file_path);
{
var jsonDb = FeedbackHeatJsonDb.Mapper.Map<FeedbackHeatJsonDb>(this);
string json = JsonConvert.SerializeObject(jsonDb, Formatting.Indented);
File.WriteAllText(file_path, json);
}
catch
{
//异常,没有json 编码失败
}
} }
#region 撤销 #region 撤销
...@@ -956,9 +904,45 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -956,9 +904,45 @@ namespace FLY.FilmCasting.AutoDie.Server
}); });
})); }));
public static bool Load(FeedbackHeat src, string file_path)
{
if (!File.Exists(file_path))
return false;
try
{
string json = File.ReadAllText(file_path);
var jsonDb = JsonConvert.DeserializeObject<FeedbackHeatJsonDb>(json);
FeedbackHeatJsonDb.Mapper.Map(jsonDb, src);
return true;
}
catch
{
//异常,没有json 解码失败
return false;
}
}
public static bool Save(FeedbackHeat src, string file_path)
{
try
{
var jsonDb = FeedbackHeatJsonDb.Mapper.Map<FeedbackHeatJsonDb>(src);
string json = JsonConvert.SerializeObject(jsonDb, Formatting.Indented);
File.WriteAllText(file_path, json);
return true;
}
catch
{
//异常,没有json 编码失败
}
return false;
}
#region 参数 #region 参数
public string PLCep; public string PLCep = "192.168.50.60:502";
/// <summary> /// <summary>
/// 加热后起效延时(s) /// 加热后起效延时(s)
...@@ -987,10 +971,6 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -987,10 +971,6 @@ namespace FLY.FilmCasting.AutoDie.Server
/// </summary> /// </summary>
public bool HasCheckFilmVelocity; public bool HasCheckFilmVelocity;
/// <summary>
/// 1块加热控制板 接多少路加热
/// </summary>
public int HeatsOfGroup = 12;
#endregion #endregion
} }
......
...@@ -15,6 +15,7 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -15,6 +15,7 @@ namespace FLY.FilmCasting.AutoDie.Server
class HeatCheck : IHeatCheck, INotifyPropertyChanged class HeatCheck : IHeatCheck, INotifyPropertyChanged
{ {
const int HEAT_WAIT = 3;//3s const int HEAT_WAIT = 3;//3s
const int HeatsOfGroup = 12;//1块加热板 12路
HeatCell mHeatCell; HeatCell mHeatCell;
enum CHECK_MODE enum CHECK_MODE
...@@ -39,7 +40,7 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -39,7 +40,7 @@ namespace FLY.FilmCasting.AutoDie.Server
CHECK_MODE checkMode = CHECK_MODE.IDLE; CHECK_MODE checkMode = CHECK_MODE.IDLE;
int counter = 0; int counter = 0;
#region IHeatCheck #region IHeatCheck
public int HeatsOfGroup { get; set; } = 12;
/// <summary> /// <summary>
/// 有这个功能 /// 有这个功能
/// </summary> /// </summary>
......
...@@ -40,17 +40,6 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -40,17 +40,6 @@ namespace FLY.FilmCasting.AutoDie.Server
/// </summary> /// </summary>
public TimeSpan ActUpdateInterval { get; private set; } public TimeSpan ActUpdateInterval { get; private set; }
/// <summary>
/// 加热通道数
/// </summary>
[DoNotCheckEquality]
public UInt16 ChannelCnt { get; set; }
/// <summary>
/// 加热量更新
/// </summary>
[DoNotCheckEquality]
public UInt16 HeatUpdate { get; set; }
/// <summary> /// <summary>
/// 当前电流 有没? /// 当前电流 有没?
...@@ -65,8 +54,7 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -65,8 +54,7 @@ namespace FLY.FilmCasting.AutoDie.Server
/// </summary> /// </summary>
public UInt16 HeatUpdate_R { get; private set; } public UInt16 HeatUpdate_R { get; private set; }
public int Errno { get; set; } = -1; public bool IsConected { get; private set; }
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
...@@ -84,7 +72,6 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -84,7 +72,6 @@ namespace FLY.FilmCasting.AutoDie.Server
public PLCLink(IPEndPoint ep) public PLCLink(IPEndPoint ep)
{ {
mclient = new Modbus.WithThread.ClientTCP(ep); mclient = new Modbus.WithThread.ClientTCP(ep);
this.PropertyChanged += PLCLink_PropertyChanged;
} }
class RegWrite class RegWrite
...@@ -102,30 +89,31 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -102,30 +89,31 @@ namespace FLY.FilmCasting.AutoDie.Server
} }
List<RegWrite> rws = new List<RegWrite>(); List<RegWrite> rws = new List<RegWrite>();
public void SetChannelCnt(UInt16 channelCnt)
private void PLCLink_PropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == nameof(ChannelCnt)) if (!IsConected)
return;
//D200 4x201 通道数量
RegWrite regWrite = new RegWrite(PLCAddressArea.Register, 200, new UInt16[] { channelCnt });
lock (rws)
{ {
//D200 4x201 通道数量 rws.Add(regWrite);
RegWrite regWrite = new RegWrite(PLCAddressArea.Register, 200, new UInt16[] { ChannelCnt });
lock (rws)
{
rws.Add(regWrite);
}
} }
else if (e.PropertyName == nameof(HeatUpdate)) }
public void SetHeatUpdate(UInt16 heatUpdate)
{
if (!IsConected)
return;
//D201 4x202 设置值 更新
RegWrite regWrite = new RegWrite(PLCAddressArea.Register, 201, new UInt16[] { heatUpdate });
lock (rws)
{ {
//D201 4x202 设置值 更新 rws.Add(regWrite);
RegWrite regWrite = new RegWrite(PLCAddressArea.Register, 201, new UInt16[] { HeatUpdate });
lock (rws)
{
rws.Add(regWrite);
}
} }
} }
public void Start() public void Start()
{ {
lock (this) lock (this)
...@@ -196,7 +184,7 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -196,7 +184,7 @@ namespace FLY.FilmCasting.AutoDie.Server
goto _error;//连接断开,终止更新线程 goto _error;//连接断开,终止更新线程
} }
Errno = 0; IsConected = true;
} }
//输出写入数据 //输出写入数据
...@@ -212,13 +200,13 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -212,13 +200,13 @@ namespace FLY.FilmCasting.AutoDie.Server
} }
_error: _error:
Errno = -1; IsConected = false;
ErrorCnt++; ErrorCnt++;
goto _connect; goto _connect;
_end: _end:
mclient.Close(); mclient.Close();
Errno = -1; IsConected = true;
IsRunning = false; IsRunning = false;
} }
...@@ -270,6 +258,9 @@ namespace FLY.FilmCasting.AutoDie.Server ...@@ -270,6 +258,9 @@ namespace FLY.FilmCasting.AutoDie.Server
/// <param name="values"></param> /// <param name="values"></param>
public void SetHeat(IEnumerable<UInt16> values) public void SetHeat(IEnumerable<UInt16> values)
{ {
if (!IsConected)
return;
UInt16[] buf = values.ToArray(); UInt16[] buf = values.ToArray();
List<RegWrite> writes = new List<RegWrite>(); List<RegWrite> writes = new List<RegWrite>();
//D400 4x401 设置值 160个 //D400 4x401 设置值 160个
......
...@@ -57,7 +57,7 @@ namespace FLY.Thick.FilmCasting.Client ...@@ -57,7 +57,7 @@ namespace FLY.Thick.FilmCasting.Client
/// <summary> /// <summary>
/// 收缩率 Uniform(均匀区)Shrink(收缩)Percent(比例) /// 收缩率 Uniform(均匀区)Shrink(收缩)Percent(比例)
/// </summary> /// </summary>
public double UniformShrinkPercent { get; set; } public double UniformShrinkPercent { get; set; } = 0.03;
/// <summary> /// <summary>
/// 膜中心位置偏移 mm /// 膜中心位置偏移 mm
...@@ -67,12 +67,12 @@ namespace FLY.Thick.FilmCasting.Client ...@@ -67,12 +67,12 @@ namespace FLY.Thick.FilmCasting.Client
/// <summary> /// <summary>
/// 总分区数 /// 总分区数
/// </summary> /// </summary>
public int NBolts { get; set; } public int NBolts { get; set; } = 100;
/// <summary> /// <summary>
/// 第1个分区号 /// 第1个分区号
/// </summary> /// </summary>
public int FirstBoltNo { get; set; } public int FirstBoltNo { get; set; } = 1;
#endregion #endregion
......
...@@ -59,7 +59,7 @@ namespace FLY.Thick.FilmCasting.IService ...@@ -59,7 +59,7 @@ namespace FLY.Thick.FilmCasting.IService
/// 膜中心位置偏移 mm /// 膜中心位置偏移 mm
/// </summary> /// </summary>
int MidOffset { get; } int MidOffset { get; }
/// <summary> /// <summary>
/// 总分区数 /// 总分区数
/// </summary> /// </summary>
......
Subproject commit f445c84c07690898037a1034fd1f1320c7907920 Subproject commit e1da25832b00c4020934eaa83041354b7d545cff
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