|
@@ -12,27 +12,27 @@ using TFT_MelsecMcNet;
|
|
|
|
|
|
namespace PLCTool.Common
|
|
|
{
|
|
|
- public class PLCCom:IPLCConnection
|
|
|
+ public class FinsPLCConnection: IPLCConnection
|
|
|
{
|
|
|
private static string plcIp = ConfigurationManager.AppSettings["PLCIp"];
|
|
|
private static string plcPort = ConfigurationManager.AppSettings["PLCPort"];
|
|
|
private static EtherNetPLC ENT = new EtherNetPLC();
|
|
|
- private static PLCCom instance;
|
|
|
+ private static FinsPLCConnection instance;
|
|
|
private static bool isConnect=false;
|
|
|
|
|
|
|
|
|
- private PLCCom()
|
|
|
+ private FinsPLCConnection()
|
|
|
{
|
|
|
ConnectPLC();
|
|
|
}
|
|
|
|
|
|
- public static PLCCom Instance
|
|
|
+ public static FinsPLCConnection Instance
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
if ((!ENT.IsConnect))
|
|
|
{
|
|
|
- instance = new PLCCom();
|
|
|
+ instance = new FinsPLCConnection();
|
|
|
}
|
|
|
return instance;
|
|
|
}
|
|
@@ -67,13 +67,11 @@ namespace PLCTool.Common
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- short re = -1;
|
|
|
- await Task.Run(() =>
|
|
|
- {
|
|
|
- re = ENT.Link(plcIp, short.Parse(plcPort), 500);
|
|
|
- });
|
|
|
+ var result=await Task.Run(() =>
|
|
|
+ ENT.Link(plcIp, short.Parse(plcPort), 500)
|
|
|
+ );
|
|
|
|
|
|
- if (re == 0)
|
|
|
+ if (result == 0)
|
|
|
{
|
|
|
isConnect = true;
|
|
|
return true;
|