I’m looking for the ability to add a ModbusTcp device via a module, and am a little lost. Basically, I just need the equivalent of system.device.addDevice (which we’ve successfully used for this purpose within a Vision application).
I’ve looked through a lot of the code around this topic, but most of it seems to be focused on the development of new drivers (which makes sense in the context of module development), but in this case, I’m just looking for the simplest route to actually add an OPC device.
Can someone point me in the right direction? Thanks in advance.
This is the manual page for the IA Modbus module. I’m not sure what you mean by adding via module, but if you just want data, this is probably the easiest way. I also think @pturmel has a modbus module that has more/different configuration options, but I’ve never used it.
Module development is probably not the best place to ask this question. I think you’ll get better answers in the ‘Ignition’ category.
My module is managing communication to a very specific set of devices that communicate via both REST API and Modbus. We understand that we need a Modbus module, and indeed we have it installed and are using it to communicate with these devices.
However, I need the ability to add new instances of these devices using information obtained from the REST API. (Once the OPC device is added, we have a UDT definition that is configured to leverage the data.)
What I’m asking here is how to get the same result from Java (within our module) as I can get within Ignition using system.device.addDevice in Python.
Consider not doing it within your module. If possible at all, it will be ugly. Consider instead architecting your solution so that java add-ins provide core functionality needed, but scripts and general designer-based or client-based “configuration” ties it all together. Those scripts would use IA’s provided and supported mechanism for adding devices.
system.device.addDevice relies on internal API and implementation details.
There is no public API available in the module SDK to mimic this. I think at best you could run raw insert queries against the internal DB, but I'm not sure how you would trigger or fire the necessary events to notify the device manager new records were added, so it probably wouldn't pick them up until some kind of restart.
@pturmel, I hear what you’re saying, but in this case it’s very helpful to the customer to have the module “import” the devices from a master system. We’ve been able to deliver this feature with Python scripts, and are now trying to figure out how to do this from within our module, as we are attempting to eliminate the dependencies on scripting (for various non-related architecture reasons).
I’ve considered executing the Python command from the module (which came from a previous recommendation of yours – thank you) which I think would work, but was trying to figure out how to “do it right”.
@Kevin.Herron Well that makes me feel a little better about not being able to figure it out, but of course, I’d rather feel stupid and have a solution.
I think this might be a mistake. Ignition deployments are glued together with jython. Reducing the glue by moving intellectual property into module-supplied scripting functions is as far as I recommend going.
I think this might be a mistake. Ignition deployments are glued together with jython. Reducing the glue by moving intellectual property into module-supplied scripting functions is as far as I recommend going.
It's a long story that's been written over a couple years. I'd love to have coffee with you (and throw in @Kevin.Herron and @Kevin.McClusky, who has already seen some of this) and share all the gory details, then get as much feedback as possible. I think the context matters a lot, but am always open to improvement, particularly on strategy decisions. For now, the ship has sailed, and moreover, the destination is on the horizon..
You could leave the dev crew for Perspective behind… save big travel $$, reduce the backlog when nobody’s paying attention, and shield them from integrator catcalls. Win all around!