In order to manage the set of items to be acquired in a UA Device I am trying to use the hooks:
@Override
public void onDataItemsCreated(List dataItems) {
subscriptionModel.onDataItemsCreated(dataItems);
}
@Override
public void onDataItemsModified(List dataItems) {
subscriptionModel.onDataItemsModified(dataItems);
}
@Override
public void onDataItemsDeleted(List dataItems) {
subscriptionModel.onDataItemsDeleted(dataItems);
}
But these methods never fire in the debugger when referencing/displaying the datapoints in the application. So I tried to use these hooks:
`/**
Called when a new item (tag) is added to this device.
*/ @Override
public void onDeviceItemAdded(DeviceItem item) {
logger.info("Item added for data acquisition: {}", item.getNodeId());
super.onDeviceItemAdded(item);
}`
`/**
Called when an item becomes active (Ignition client starts subscribing to it).
*/ @Override
public void onDeviceItemActivated(DeviceItem item) {
logger.info("Item activated: {}", item.getNodeId());
// You could start polling or reading hardware here.
super.onDeviceItemActivated(item);
}`
`/**
Called when the item is deactivated (no subscribers).
*/ @Override
public void onDeviceItemDeactivated(DeviceItem item) {
logger.info("Item deactivated: {}", item.getNodeId());
super.onDeviceItemDeactivated(item);
}`
But the corresonding references don't resolve in the POM:
Hello Phil, thanks for the reply. Yes I certainly added the browse address space on startup. But I certainly don't want to acquire data for all items unconditionally (these could be several 100k items). I need to have a hook were the device gets informed which items are actually requested in the application, which would be a dynamically changing subset. Please advise
That call just retrieves the items for your device. Tags, on startup, are likely to request their OPC items for your device before your device gets started. So you would miss the method calls at that point. That's why your device startup needs to ask the subscription manager for the items that are already requested.
Explain.
Data items are created/deleted only for subscriptions. Polling and explicit OPC reads do not create monitored items.
I understand: the call onDataItemsCreated in device startup provides the items already activated before startup. But I created the scenario that after startup I added items in Perspective and the method onDataItemsCreated or onDataItemsModified did not break in the debugger. So just to confirm, these are the correct callbacks for the device to manage the activation and deactivation of subscribed items (plus onDataItemDeleted)?