You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using HslCommunication;
|
|
|
|
|
using HslCommunication.LogNet;
|
|
|
|
|
using HslCommunication.Profinet.AllenBradley;
|
|
|
|
|
using HslCommunication.Profinet.Siemens;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OperateResult Write(string db, string value)
|
|
|
|
|
{
|
|
|
|
|
return Instance.Write(db, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|