|
|
|
@ -6,18 +6,27 @@ 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 void Init()
|
|
|
|
|
{
|
|
|
|
|
// 授权示例 Authorization example
|
|
|
|
|
if (!HslCommunication.Authorization.SetAuthorizationCode(RfidSetting.Current.HslKey))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine( "Authorization failed! The current program can only be used for 8 hours!" );
|
|
|
|
|
return; // 激活失败应该退出系统
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private AllenBradleyNet CreateAb()
|
|
|
|
|
{
|
|
|
|
|
Init();
|
|
|
|
|
var rfidSetting = RfidSetting.Current;
|
|
|
|
|
|
|
|
|
|
AllenBradleyNet ab = new AllenBradleyNet();
|
|
|
|
|