using HslCommunication.Profinet.Siemens; using System; namespace DataBlockHelper { public class PlcConnect { private static readonly Lazy lazy = new Lazy(() => new PlcConnect().SiemensS7NetConnection()); public static SiemensS7Net Instance => lazy.Value; private PlcConnect() { } public SiemensS7Net SiemensS7NetConnection() { SiemensPLCS siemensPLCS = SiemensPLCS.S1500; SiemensS7Net s7 = new SiemensS7Net(siemensPLCS); s7.SetPersistentConnection(); s7.IpAddress = "192.168.1.110"; s7.Port = 102; var su = s7.ConnectServer(); if (!su.IsSuccess) { } return s7; } } }