I’m attempting to retrieve a list of devices from a specified server. I know that the listDevices() function doesn’t have any parameters that can be passed into it (like an OPC server name to list devices from). Is there any other function that would allow me to retrieve a list of devices from a specified server?
The devices being list are only the ones configured on the local gateway, exposed by the local UA server - the idea of specifying a server doesn’t make any sense.
What about in the case of remote tag providers? How might I go about listing the devices from them?
Tag providers don’t have devices.
This hasn’t been specified, yet (as a reminder, the more detailed the questions, the better the answers become… ;)), I will assume the following:
- Multiple Ignition servers in a hub and spoke architecture.
- The spoke servers have their SQLTags exposed.
Write your device list to an SQLTag.
If your spoke servers are recent enough to have a Dataset tag type, it’s amazingly simple:
devices=system.device.listDevices()
system.tag.write("[default]DeviceList", devices)
If not, it gets a bit more complex, but you can write it to a String as a list of lists. Easy enough to put back into a dataset, if needed:
devices=system.dataset.toPyDataSet(system.device.listDevices())
dataOut = []
for row in devices:
newRow = []
for col in row:
newRow.append(col)
dataOut.append(newRow)
system.tag.write("[default]DeviceList", dataOut)