35 lines
933 B
C#
35 lines
933 B
C#
|
|
using CirculateTool;
|
|||
|
|
using WcsMain.Common;
|
|||
|
|
using WcsMain.PlcOperation;
|
|||
|
|
|
|||
|
|
namespace WcsMain.Business.CirculationTask;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 定时器检测 PLC 是否连接,若没有连接则重新连接
|
|||
|
|
/// </summary>
|
|||
|
|
[Circulation]
|
|||
|
|
public class ConnectPlcWithCirculation(ConnectPLCs connectPLCs)
|
|||
|
|
{
|
|||
|
|
private readonly ConnectPLCs _connectPLCs = connectPLCs;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 当plc断开时重新连接 PLC
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[Circulation("连接PLC", 5000)]
|
|||
|
|
public bool ReconnectPlc()
|
|||
|
|
{
|
|||
|
|
if (CommonData.IsConnectPlc == false)
|
|||
|
|
{
|
|||
|
|
// 如果处于未连接的状态则需要连接
|
|||
|
|
/* 连接 PLC */
|
|||
|
|
bool isContinue = _connectPLCs.ConnectPlc();
|
|||
|
|
if (!isContinue)
|
|||
|
|
{
|
|||
|
|
return false; // 没有需要连接PLC可能,不需要接着继续检测了
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|