首页 新闻 会员 周边

utgard在使用异步(Async20Access)读取数据时,总是出错,我的邮箱:sangjingrui@163.com

0
悬赏园豆:15 [待解决问题]

在使用utgard访问OPC服务器,使用异步(Async20Access)读取数据时,总是出错,同步读取就可以,我想问一下,这是什么问题? 下面是console输出:Recieved FAULT 最后接到一个FAULT,不知道什么原因,请赐教!
代码:
public static void main ( final String[] args ) throws Throwable
{
// create connection information
final ConnectionInformation ci = new ConnectionInformation ();
ci.setHost("127.0.0.1"); // 电脑IP
ci.setDomain(""); // 域,为空就行
ci.setUser("opcuser"); // 电脑上自己建好的用户名
ci.setPassword("123456"); //密码

// 使用KEPServer的配置
ci.setClsid("7BC0CC8E-482C-47CA-ABDC-0FE7F9C6E729");

final Set<String> items = new HashSet<String> ();

if ( items.isEmpty () )
{
items.add ("ch1.d1.tag1");
items.add ("ch1.d1.tag2");
}

// create a new server
final Server server = new Server ( ci, Executors.newSingleThreadScheduledExecutor () );
try
{
// connect to server
server.connect ();

// add sync access
final AccessBase access = new Async20Access ( server, 100, false );
for ( final String itemId : items )
{
    access.addItem ( itemId, new DataCallbackDumper () );
}

// start reading
access.bind ();

// wait a little bit
_log.info ( "Sleep for some seconds to give events a chance..." );
Thread.sleep ( 10 * 1000 );
_log.info ( "Returned from sleep" );

// stop reading
access.unbind ();

}
catch ( final JIException e )
{
System.out.println ( String.format ( "%08X: %s", e.getErrorCode (), server.getErrorMessage ( e.getErrorCode () ) ) );
}
}
}

我发现同样的代码,采用同步读取就没有问题,这是为什么?是不是对异步需要对环境进一步配置?
我的邮箱:sangjingrui@163.com

小船1968的主页 小船1968 | 初学一级 | 园豆:187
提问于:2019-11-15 15:33

请问解决了吗,求分享解决方案

安静打代码 4年前
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册