change-修改启动方式

dev
liuwf 3 months ago
parent 32c69b63fd
commit 926ff42b5b

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

Loading…
Cancel
Save