diff --git a/Tool/PlcConnect.cs b/Tool/PlcConnect.cs new file mode 100644 index 0000000..1da5904 --- /dev/null +++ b/Tool/PlcConnect.cs @@ -0,0 +1,33 @@ +using System; +using HslCommunication.Profinet.AllenBradley; +using HslCommunication.Profinet.Siemens; + +namespace Tool +{ + public class PlcConnect + { + + + private static readonly Lazy lazy = new Lazy(() => new PlcConnect().CreateAb()); + public static AllenBradleyNet Instance => lazy.Value; + + private PlcConnect() + { + + } + + private AllenBradleyNet CreateAb() + { + var rfidSetting = RfidSetting.Current; + + AllenBradleyNet ab = new AllenBradleyNet(); + ab.IpAddress = rfidSetting.PlcIp; + ab.Port = rfidSetting.Port; + ab.ConnectServer(); + return ab; + } + } +} + + + diff --git a/Tool/Class1.cs b/Tool/RfidSetting.cs similarity index 79% rename from Tool/Class1.cs rename to Tool/RfidSetting.cs index d342656..145ae3e 100644 --- a/Tool/Class1.cs +++ b/Tool/RfidSetting.cs @@ -14,5 +14,11 @@ namespace Tool public class RfidSetting : Config { public string Db { get; set; } = "server=127.0.0.1;database=postgres;uid=postgres;pwd=yangwei"; + + + public string PlcIp { get; set; } = "127.0.0.1"; + + public int Port { get; set; }=44818; + } } diff --git a/Tool/Tool.csproj b/Tool/Tool.csproj index 4ca5971..68b7f66 100644 --- a/Tool/Tool.csproj +++ b/Tool/Tool.csproj @@ -58,7 +58,8 @@ - + +