Query on persistante device settings

Hi,

We’ve created a module which manages devices. These devices can be manually added by user in Ignition but there is also an automatic device discovery function (using UPnp).

When a device is automatically discovered, we need to check if this device wasn’t previously configured by the user (check the address meta data of each configured device).

I’m looking for Ingnition PersistenceInterface class and I found two interesting methods .

  • find(RecordMeta meta, java.lang.Object… primaryKeys)
    what is or are the primary keys ? How can the be configured ? How can they be specified in this query ?

  • queryOne(simpleorm.dataset.SQuery query)
    How can the query be specified ? Is there any documentation or example ?

Thanks for your help :astonished:

For information, I found how to create a query in the online Ignition documentation at this address https://docs.inductiveautomation.com/display/SE/Storing+data+with+PersistentRecords. (see “chapter Querying Records”)

Basically, if your driver setting class is called “EcoSpecDriverSettings” and if this setting class has an “ADDRESS” field, you can create a query to check for a field which contains a specific address with the following instructions :

PersistenceInterface persistenceInterface = getContext().getPersistenceInterface();
PersistenceSession   session              = persistenceInterface.getSession();

SQuery<EcoSpecDriverSettings> query = new SQuery<EcoSpecDriverSettings>(EcoSpecDriverSettings.META).eq(EcoSpecDriverSettings.ADDRESS,aIPAddress) ;

EcoSpecDriverSettings result = session.queryOne(query);

I hope this will also be usefull for somebody :smiley: