Historical Tag Path in Ignition SDK

I’m trying to write a historical query from a component in a module I’m developing. I’m using the standard gateway interface “runTagHistoryQuery” function. It’s all working very well, except I have to set it up with a fully qualified tag path in the client (histprov:historian:/drv:ignition-cody-pc:default:/tag:tags/ramp/ramp0). Obviously I think this is far from intuitive for someone to use so I’d like to whittle my tag path down to one or all of the following:
[ul]

  1. tags/ramp/ramp0
  2. [~]tags/ramp/ramp0
  3. [historian/ignition-cody-pc:default]tags/ramp/ramp0
    [/ul]

Now my question is, how do I take a less than fully qualified tag path from the client and turn it into the a fully qualified historical tag path. I can retrieve the default data source and default tag provider from the client context with:

    ClientContext context = getAppContext();
    defaultDatasource = context.getDefaultDatasourceName();
    defaultTagProvider = context.getDefaultSQLTagsProviderName();

But I’m missing the system name. So I guess my question is
[ul]

  1. What java Class would I use to get the system name?
  2. Am I even approaching this the right way or is there already a class to do this? (I’ve found classes to parse SQL tag paths but not historical).
    [/ul]

Thanks!

Ok so with the help of Kyle Chase I’ve retrieved the system name via an RPC call to query the gateway’s internal database.

    PersistenceInterface gwDBInterface = context.getPersistenceInterface();
    PersistentRecord systemRecord = gwDBInterface.find(SystemPropertiesRecord.META, 0);

    return systemRecord.getString(SystemPropertiesRecord.SystemName);

Now I still have to wonder, isn’t there an easier/better way?

Hey Cody, did you ever find out if there's a better way? I'm trying to figure out how to handle these properly myself...

The proper way to do this nowadays is to use getSystemPropertiesManager() on the GatewayContext, and call that object's getSystemName().

In jython, you can use the netbeans shortcut properties (and should--they are more efficient).

1 Like

Thanks!