12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using S7.Net;
- using System;
- using HslCommunication.Profinet.Siemens;
- namespace WCS.DeviceProtocol
- {
- public class DevicePlcS7
- {
-
- public static Plc S7(string ip,string type)
- {
- Plc s7Plc = new Plc(CpuType.S71500, ip, 0, 1);
- if (type == "S7_1200")
- {
- s7Plc = new Plc(CpuType.S71200, ip, 0, 1);
- }
- else if (type == "S7_400")
- {
- s7Plc = new Plc(CpuType.S7400, ip, 0, 1);
- }
- else if (type == "S7_300")
- {
- s7Plc = new Plc(CpuType.S7300, ip, 0, 1);
- }
- s7Plc.Open();
- return s7Plc;
- }
- public static SiemensS7Net SiemensS7(string ip, int port = 102)
- {
- SiemensS7Net SiemensS7Net = new SiemensS7Net(SiemensPLCS.S1200, ip) { ConnectTimeOut = 5000 };
- SiemensS7Net.ConnectionId = Guid.NewGuid().ToString();
- return SiemensS7Net;
- }
- }
- }
|