I am developing a custom module based on the OPC UA device example. When a device is running, folders and tags are created. When the device gets disabled, all tags are set to bad quality. When i enable the device, i have to delete it in the Tag Browser in the designer and put it in again so that the tags and folders are updating. This is because i always create new instances of folders and tags in my module. Instead i want that the tags work without dragging the device again and again into the tag browser. In my onStartup i try to get all tags with this approach:
dataItems = deviceContext.getSubscriptionModel().getDataItems(deviceContext.getName());
but dataItems is always empty, i also tried to get the references but nothing worked out.
this is what happens in the onShutdown (when device gets disabled or deleted):
private void onShutdown() {
deviceContext.getSubscriptionModel()
.getDataItems(deviceContext.getName())
.forEach(item -> item.setQuality(new StatusCode(StatusCodes.Uncertain_LastUsableValue)));
subscriptionModel.shutdown();
deviceContext.getGatewayContext()
.getExecutionManager()
.unRegister(EuromapDeviceType.TYPE_ID, deviceContext.getName());
euromapDataMonitor.stopFileWatch();
}
How can i use the folders and tags that were created at the first start of the device?