I'm looking for some advice on the best approach for quickly polling OPC values from a remote gateway.
Generally, I know that for quickly collecting data, you would create a buffer in the device and pull large chunks in a single request. However, in this case I am creating a popup for a vision application and I need the device, tag paths, and sampling rate to be dynamic.
I had planned on the sampling rate being variable in set intervals with the shortest being 250ms and largest being 1 min.
The other roadblock I am looking at is that the device connections all live on a remote I/O only gateway.
I can use system.util.sendRequest()
to execute system.opc.readValues()
on the remote gateway, however, I'm "guessing" that making a call over the GAN at a high rate is a poor idea.
My thought was to send a message to the gateway to start an ExecutorSerive
to poll for the values at the sampling rate, where I would build a buffer of an appropriate size, and then send that as a payload back to the front end gateway to be handled periodically. This raises some issues, because I would be collecting data to be displayed in the UI outside of the UI thread.
I am trying to be very cautious because if I were to do that, I would need to have a way to:
- Shutdown the service when I am finished with it.
- Change the sampling rate if needed.
- Somehow handle comm loss across the GAN (A user closes the popup, but because of a network issue the Shutdown can not be sent/received).
#3 is what I'm having issues with, I see this as a great way to have a memory leak if it isn't handled correctly, and I'm just not certain I understand how to do that.
I don't really want to expose the remote gateway's OPC server to a gateway where I'm already using it as a remote provider, but if that is really the best way to handle it I suppose that I will. I don't really have a good reason not to want to do that other than it just seems like a security issue.
Any advice on how to approach this would be greatly appreciated.