change-修改启动方式

dev
liuwf 3 months ago
parent 32c69b63fd
commit 926ff42b5b

@ -1,5 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using SlnMesnac.Business;
using SlnMesnac.Business.@base;
using SlnMesnac.Plc;
@ -110,26 +111,25 @@ namespace SlnMesnac.WPF.Page
bool Spiral1Status = StartSpiral1();
if (!MagNetStatus) return;
#endregion
//4.烘干机:烘干螺旋、烘干风机、烘干燃烧
#region 烘干机
SendPulseSignal("烘干机螺旋启动");
Thread.Sleep(MachineSleep);
SendPulseSignal("烘干机风机启动");
Thread.Sleep(MachineSleep);
SendPulseSignal("烘干机燃烧启动");
#endregion
bool DryerStatus1 = StartDryerMagNet();
if (!DryerStatus1) return;
bool DryerStatus2 = StartDryerFan();
if (!DryerStatus2) return;
bool DryerStatus3 = StartDryerHot();
if (!DryerStatus3) return;
#region 拆包机
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程急停"), false);
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程停止"), false);
SendPulseSignal("拆包机远程启动");
//5.拆包机
bool unpackStatus = StartUnPack();
#endregion
Thread.Sleep(MachineSleep);
});
if (unpackStatus)
{
MessageBoxAndLog("一键启动所有机器成功!");
}
});
}catch(Exception ex)
{
_logger.LogError($"一键启动:{ex.Message}");
@ -186,7 +186,7 @@ namespace SlnMesnac.WPF.Page
Thread.Sleep(MachineSleep);
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
#endregion
MessageBoxAndLog("一键停止所有机器成功!");
});
#endregion
//StopButton.IsEnabled = false;
@ -411,10 +411,7 @@ namespace SlnMesnac.WPF.Page
{
try
{
Task.Run(() =>
{
SendPulseSignal("烘干机螺旋启动");
});
StartDryerMagNet();
}
catch (Exception ex)
{
@ -451,20 +448,7 @@ namespace SlnMesnac.WPF.Page
/// <param name="e"></param>
private void StartDryerHotButton_Click(object sender, RoutedEventArgs e)
{
try
{
Task.Run(() =>
{
SendPulseSignal("烘干机燃烧启动");
});
}
catch (Exception ex)
{
_logger.LogError($"烘干机燃烧启动:{ex.Message}");
}
StartDryerHot();
}
/// <summary>
@ -581,7 +565,7 @@ namespace SlnMesnac.WPF.Page
int value2 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度值")) * 100;
bool startFlag = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"));
int speed2 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度反馈"));
if (startFlag)
if (!startFlag)
{
MessageBox.Show($"前提条件螺旋2未成功启动,请检查后重新启动");
return false;
@ -640,7 +624,7 @@ namespace SlnMesnac.WPF.Page
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), true);
plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), value1 * 100);
Thread.Sleep(MachineSleep);
result = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"));
result = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"));
}
catch (Exception ex)
@ -652,6 +636,132 @@ namespace SlnMesnac.WPF.Page
}
#region 烘干机
/// <summary>
/// 烘干机螺旋启动/前提check:螺旋1启动且速度达到值
/// </summary>
private bool StartDryerMagNet()
{
bool result = false;
try
{
int value1 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度值")) * 100;
bool startFlag = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"));
int speed1 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度反馈"));
if (!startFlag)
{
MessageBox.Show($"烘干机螺旋启动失败:前提条件螺旋1未成功启动,请检查后重新启动");
return false;
}
if (speed1 < value1 * 0.8)
{
// plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
MessageBox.Show($"烘干机螺旋启动失败:前提条件螺旋1速度{speed1}未达到设定值{value1}的下限阈值80%,请检查后重新启动");
return false;
}
int value = int.Parse(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定值"));
SendPulseSignal("烘干机螺旋启动");
plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定"), value1 * 100);
Thread.Sleep(MachineSleep/2);
return true;
}
catch (Exception ex)
{
MessageBoxAndLog($"烘干机螺旋启动异常:{ex.Message}", true);
result = false;
}
return result;
}
/// <summary>
/// 烘干机风机启动/前提check:烘干机螺旋启动
/// </summary>
private bool StartDryerFan()
{
bool result = false;
try
{
bool startFlag = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机反馈传动启动"));
if (!startFlag)
{
MessageBox.Show($"烘干机风机启动失败:前提条件烘干机螺旋未成功启动,请检查后重新启动");
return false;
}
SendPulseSignal("烘干机风机启动");
Thread.Sleep(MachineSleep);
return true;
}
catch (Exception ex)
{
MessageBoxAndLog($"烘干机风机启动异常:{ex.Message}", true);
result = false;
}
return result;
}
/// <summary>
/// 烘干机燃烧启动/前提check:烘干机风机启动
/// </summary>
private bool StartDryerHot()
{
bool result = false;
try
{
bool startFlag = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机反馈风机启动"));
if (!startFlag)
{
MessageBox.Show($"烘干机燃烧启动失败:前提条件烘干机风机未成功启动,请检查后重新启动");
return false;
}
int value = int.Parse(baseBusiness.GetPlcAddressByConfigKey("烘干机温度设定值"));
SendPulseSignal("烘干机燃烧启动");
plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机温度设定"), value *100);
Thread.Sleep(MachineSleep);
return true;
}
catch (Exception ex)
{
MessageBoxAndLog($"烘干机燃烧启动异常:{ex.Message}", true);
result = false;
}
return result;
}
#endregion
/// <summary>
/// 拆包机启动/前提check:燃烧机启动
/// </summary>
private bool StartUnPack()
{
bool result = false;
try
{
bool startFlag = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机反馈燃烧启动"));
if (!startFlag)
{
MessageBox.Show($"拆包机启动失败:前提条件烘干机燃烧未成功启动,请检查后重新启动");
return false;
}
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程急停"), false);
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程停止"), false);
SendPulseSignal("拆包机远程启动");
Thread.Sleep(MachineSleep);
return plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机运行状态系统"));
}
catch (Exception ex)
{
MessageBoxAndLog($"拆包机启动异常:{ex.Message}", true);
result = false;
}
return result;
}
private void MessageBoxAndLog(string message,bool isError = false)
{

Loading…
Cancel
Save