List Tag Providers

ignition80
#1

I am attempting to create user-selectable list of tag providers.

private List getProviderList() {
List result = new ArrayList<>();
GatewayContext context = ApplicationInstallerGatewayHook.getInstance().getContext();
GatewayNetworkManager netmgr = context.getGatewayAreaNetworkManager();
ServerId metro = netmgr.getServerAddress(); // Local gateway
TagProviderService tps = (TagProviderService)netmgr.getServiceManager().getService(metro, TagProviderService.class);
List providerNames = tps.getProviders();
for( String name:providerNames) {
result.add(tps.getInformation(name));
}
return result;
}

But I get an exception on the line with italics:

java.lang.ClassCastException: class com.inductiveautomation.metro.impl.services.ServiceManagerImpl$ServerWrapper$ServerService cannot be cast to class com.inductiveautomation.ignition.gateway.sqltags.distributed.TagProviderService (com.inductiveautomation.metro.impl.services.ServiceManagerImpl$ServerWrapper$ServerService and com.inductiveautomation.ignition.gateway.sqltags.distributed.TagProviderService are in unnamed module of loader ‘app’)

Thanks in advance,
— chuck

0 Likes

#2

I am guessing that you are trying to list tag providers from a remote gateway via the gateway network. You didn’t specify 7.9 or 8.0, so I’ll post both examples here.

7.9, where the remote machine is named “agent-7-ide-8088”:

        GatewayAreaNetworkManager gm = context.getGatewayContext().getGatewayAreaNetworkManager();
        Collection<ConnectionWatcher> connections = gm.getAvailableConnections();
        // We need the ServerId of the remote machine to be able to call the service on it.
        ServerId remoteServerId = null; 
        for (ConnectionWatcher conn : connections) {
            if (conn.getRemoteServerAddress().getServerName().equals("agent-7-ide-8088")) {
                remoteServerId = conn.getRemoteServerAddress();
                break;
            }
        }
        ServiceManager sm = gm.getServiceManager();
        List<String> remoteProviders = sm.getService(remoteServerId, TagProviderService.class).get().getProviders();

8.0, where the remote machine is named “agent-ide-8088”:

GatewayNetworkManager gm = context.getGatewayContext().getGatewayAreaNetworkManager();
        Collection<ConnectionWatcher> connections = gm.getAvailableConnections();
        // We need the ServerId of the remote machine to be able to call the service on it.
        ServerId remoteServerId = null;
        for (ConnectionWatcher conn : connections) {
            if (conn.getRemoteServerAddress().getServerName().equals("agent-ide-8088")) {
                remoteServerId = conn.getRemoteServerAddress();
                break;
            }
        }
        ServiceManager sm = gm.getServiceManager();
        List<String> remoteProviders = sm.getService(remoteServerId, TagProviderService2.class).get().getProviders();

Hopefully that helps.

0 Likes

#3

Thanks for the quick response.
This is for Ignition 8. I’m trying to list the TagProviderMeta values for the providers on my local gateway. In 7.9 I could use context.getTagManager().getTagInformation().
My gm.getAvailableConnections() returns an empty list.

— chuck

0 Likes

#4

It looks like you would call

        List<TagProvider> tagProviders = context.getTagManager().getTagProviders();
        for (TagProvider tagProvider : tagProviders) {
            TagProviderProps tagProviderProps = tagProvider.getPropertiesAsync().get();
        }

to fetch the information locally

2 Likes

#5

… that’s it. Thanks much.

0 Likes