Create a Modbus Opcua device inside a module

Hi everyone,
I have a Modbus Python server with a specific IP address and some data points. I’m am trying to create a Modbus Opcua inside my module. I have referenced some examples such as ModbusDriverExample - Ignition 7.9 and opc-ua-device-gateway.
Opc-ua-device-gateway is an example to demonstrate how to create a new OPC Device in the gateway. As my understanding, we can create any devices based on the DeviceType like this example.

I guest I need to install another package into Maven’s configuration file for Modbus driver like ModbusDriverExample above.

Thank you for your time!

1 Like

Are you trying to implement the Modbus protocol yourself? If so, then yes, the Modbus driver example is a start, but you’ll have to rework it for Ignition 8.x. For that, start from the opc-ua-device example. (Modbus was dropped as an example.)

If you are trying to create a different driver’s instance from within your own module, you are on your own–it really isn’t supported by the module architecture. Not that it can’t be done, if you have detailed knowledge of the driver’s internals and are willing to do unsupported operations in the SDK. I don’t recommend that.

1 Like

Thanks for your reply.
I do not want to create a new driver. I just wonder how to create Modbus device instead of using UI in the gateway for my personal purpose. We can create many kinds of OPC devices via UI in the gateway.
As my understanding, each OPC device is a driver which has been implemented by Iginition. Therefore, I just want to reuse it in my module. In my case, it is the Modus driver. I still do not know how to use it in my module.

I recommend you reconsider what you are trying to do in you module.

Well, it would be great if some drivers were available in com.inductiveautomation.opcua packages. I supposed something like com.inductiveautomation.opcua.modbusdriver or com.inductiveautomation.opcua.siemendriver existing in that package.

There are scripting functions that let you create driver instances with the most common properties (with docs for the IA-supplied drivers). Don’t try to do this in your module.

Thanks for your suggestion.
You mean we can create devices using Python script as mentioned in this document system.device.addDevice - Ignition User Manual 8.1 - Ignition Documentation.
There are some reasons why I want to create devices in Java code module instead of calling Python script.

If you must, use the ScriptManager from your gateway context to run code. Ugly, but you can make that work.

2 Likes

Yeah, I know it isn’t a good way. But I really want to test this inside my module.
From your recommendation, I chose the runCode function in Script Manager interface which requires 3 parameters: String code, Pyobject locals, File filename) for my testing. I find it hard to complete the second and third parameters. I hope you could give me some instructions.

1 Like