master
锄头 3 months ago
parent 69c66055d7
commit a6ec5f0bd1

@ -0,0 +1,33 @@
using System;
using HslCommunication.Profinet.AllenBradley;
using HslCommunication.Profinet.Siemens;
namespace Tool
{
public class PlcConnect
{
private static readonly Lazy<AllenBradleyNet> lazy = new Lazy<AllenBradleyNet>(() => 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;
}
}
}

@ -14,5 +14,11 @@ namespace Tool
public class RfidSetting : Config<RfidSetting>
{
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;
}
}

@ -58,7 +58,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="RfidSetting.cs" />
<Compile Include="PlcConnect.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup />

Loading…
Cancel
Save