I don’t find in the SDK javadoc how to create a device.
I would like to achieve it from a driver module in order to bulk create device.
Are you trying to bulk create instances a driver type provided by your module or of some other module?
@Kevin.Herron, a driver type provided by my module
Ok, using the PersistenceInterface
from GatewayContext
, create a new instance of DeviceSettingsRecord
and of your driver type’s setting record, point the one at the other, then make sure to call PersistenceInterface#notifyRecordAdded
with the DeviceSettingsRecord
instance.
@Kevin.Herron, My module is an AbstractTagDriver,
from the DriverContext and can’t reach the context.getPersistenceInterface() ?
oops, driverContext.getGatewayContext().getPersistenceInterface() will do the job,
Your module hook gets a GatewayContext
too, which is likely the one you’ll want to use. I don’t see how bulk creating instances of a driver from within an instance of the driver itself makes any sense.
I have lots of device to create with a “device model” (common parameters and only IP address which vary)
I create a “device model” with the ignition gateway webpage, with the common settings for all the others and a list of IP adress. The “device model” create the other “sub device”.
So the driver enable to create a single device or lots of device with the same settings excepted the IP adresse for example.
…hummm, you’re right this way would certainly generate some recursion issue…
Sounds like you may have to create two different modules, with your “device model” module depending on the device module itself
Consider making a separate PersistentRecord type for the model and use a foreign key in your device’s PersistentRecord to reference it. Then create a set of regular config pages to list and edit your models. Have an option in those config pages to create multiple devices from a model. And in the devices, have a drop-down to select or change which model is used.
Thanks for this solution.