我们开发了一个Java应用程序,该应用程序使用TwinCat ADS库(DLL)从Beckhoff PLC(CX5120)读取,写入和处理事件。我们已经成功地在多台机器上运行了该程序,但是不幸的是,当前遇到了一个事件处理突然停止的问题。这是我们经历的确切场景:
使用另一台带有Java应用程序的PC进行测试,同样的问题。因此,PLC中的某些内容似乎冻结/停止工作。
这是我们设置事件处理的方式:
// Implementation of the CallbackListenerAdsState interface
public class ADSEventController implements CallbackListenerAdsState {
......
// Register itself as listener for the ADS events (in constructor)
callObject = new AdsCallbackObject();
callObject.addListenerCallbackAdsState(this);
....
// Event handling
public void onEvent(AmsAddr addr, AdsNotificationHeader notification, long user) {
log.info("Got ADS event for handle[{}] and with raw data[{}]", user, notification.getData());
......
// Registering notification handles for PLC variables
// If we already assigned a notification, delete …Run Code Online (Sandbox Code Playgroud)