初始化上传
This commit is contained in:
47
常用工具集/Utility/Network/S7netplus/ORM/S7Client.cs
Normal file
47
常用工具集/Utility/Network/S7netplus/ORM/S7Client.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using S7.Net;
|
||||
|
||||
namespace MES.Utility.Network.S7netplus.ORM
|
||||
{
|
||||
public class S7Client : IDisposable
|
||||
{
|
||||
public S7Helper Plc;
|
||||
public bool IsConnected;
|
||||
public S7Client(CpuType cpu, string ip)
|
||||
{
|
||||
try
|
||||
{
|
||||
Plc = new S7Helper(cpu, ip);
|
||||
IsConnected = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
IsConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
public S7Read<T> Readable<T>() where T : class, new()
|
||||
{
|
||||
return new S7Read<T>(this);
|
||||
}
|
||||
|
||||
public S7Write<T> Writeable<T>(T entity) where T : class, new()
|
||||
{
|
||||
return new S7Write<T>(this, entity);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Plc != null)
|
||||
{
|
||||
Plc.Dispose();
|
||||
Plc = null;
|
||||
}
|
||||
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user