How to create a new tag from a java application

Hello,

I am using Ignition server … and I would like to know how to create a new tag on the server from a java application?

1/ What package should I use?

2/ I have some experiences with the prosys SDK, but when I try to create a tag I got an exception on the ignition server …

(log of ignition server)
INFO | jvm 1 | 2015/09/23 17:41:24 | INFO [ActivateSessionService ] [17:41:24,183]: Anonymous user connected.
INFO | jvm 1 | 2015/09/23 17:41:24 | WARN [AddNodesService ] [17:41:24,665]: Returning ServiceFault for request: com.inductiveautomation.opcua.types.messages.AddNodesRequest@3e0fd438. StatusCode=StatusCode[Severity=Bad, Subcode=Bad_ServiceUnsupported]
INFO | jvm 1 | 2015/09/23 17:44:46 | ERROR [XOPCServer ] [17:44:46,813]: Could not find Service for class com.inductiveautomation.opcua.types.messages.CloseSecureChannelRequest.

and in the java application, I got this exception …
com.prosysopc.ua.ServiceException: ServiceFault: Bad_ServiceUnsupported (0x800B0000) “The server does not support the requested service.”
Diagnostic Info: ServiceResult=Bad_ServiceUnsupported (0x800B0000) “The server does not support the requested service.”
at com.prosysopc.ua.client.AddressSpace.addNode(Unknown Source)
at com.ora.neptis.opc.SimpleNodeTest.test(SimpleNodeTest.java:33)
at com.ora.neptis.opc.SimpleNodeTest.main(SimpleNodeTest.java:59)
Caused by: ServiceFault: Bad_ServiceUnsupported (0x800B0000) “The server does not support the requested service.”
Diagnostic Info:
at org.opcfoundation.ua.transport.impl.AsyncResultImpl.waitForResult(Unknown Source)
at org.opcfoundation.ua.transport.tcp.io.SecureChannelTcp.serviceRequest(Unknown Source)
at org.opcfoundation.ua.transport.tcp.io.SecureChannelTcp.serviceRequest(Unknown Source)
at org.opcfoundation.ua.application.SessionChannel.serviceRequest(Unknown Source)
at org.opcfoundation.ua.transport.ChannelService.AddNodes(Unknown Source)
… 3 more

Please find below the code I am using to do so …

package test.opc;

import org.opcfoundation.ua.builtintypes.NodeId;
import org.opcfoundation.ua.transport.security.SecurityMode;

import com.prosysopc.ua.client.UaClient;
import com.prosysopc.ua.nodes.UaNode;

public class SimpleNodeTest {

private static String serverUri = "opc.[tcp://10.0.1.228:4096/ignition_opc_ua_server](tcp://10.0.1.228:4096/ignition_opc_ua_server)";
private static UaClient client;
protected final static String APP_NAME = "SimpleNodeTest";
protected SecurityMode securityMode = SecurityMode.NONE;

private void test() {
    try {
        client = new UaClient(serverUri);
        client.setSecurityMode(securityMode);
        client.connect();

        NodeId parentIdNode = new NodeId(1,
                "[AB1]Global.SUP_RO_STR_PA_LICENSE_ID");
        NodeId newNodeId = new NodeId(1,
                "[AB1]Global.SUP_RO_STR_PA_LICENSE_ID.MyNewNode");
        UaNode parentNode = client.getAddressSpace().getNode(parentIdNode);

        System.out.println("browserName= " + parentNode.getBrowseName());
        System.out.println("nodeClass= " + parentNode.getNodeClass());
        System.out.println("nodeAttributes= " + parentNode.getAttributes());
        System.out.println("references= " + parentNode.getReferences());

        client.getAddressSpace().addNode(
                // this call generate the exception
                parentIdNode,
                client.getAddressSpace().getReferenceTypeId(), // is it
                                                                // correct?
                newNodeId, parentNode.getBrowseName(),
                parentNode.getNodeClass(), parentNode.getAttributes(),
                parentNode.getNodeId() // is it correct?
                );

        // Try to write something on it
        client.writeValue(newNodeId, 1);
        // Read the written value
        System.out.println("read= " + client.readValue(newNodeId));

        // Stop after 10 seconds
        Thread.sleep(20 * 1000);
        System.out.println("Disconnection");
        client.disconnect();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

public static void main(String[] args) {
    SimpleNodeTest me = new SimpleNodeTest();
    me.test();
}

}

I’m not sure if you’re trying to create an Ignition tag, or just a tag/node in the OPC-UA server, but either way I don’t think you can do it from another app like you’re hoping.

The only way to create/expose nodes in the UA server is by using the SDK to write a driver.

SQLTags can be created dynamically from the scripting language, but that’s only available from within an Ignition project.

Maybe you can share a little more about what you’re hoping to accomplish?

Hello Kevin,

Well, basically, I would like to add a new tag on the OPC-UA server … I believe that this is technically possible using my java example. But this service seem to be refused by ignition server implementation…

(log of ignition server)
INFO | jvm 1 | 2015/09/23 17:41:24 | INFO [ActivateSessionService ] [17:41:24,183]: Anonymous user connected.
INFO | jvm 1 | 2015/09/23 17:41:24 | WARN [AddNodesService ] [17:41:24,665]: Returning ServiceFault for request: com.inductiveautomation.opcua.types.messages.AddNodesRequest@3e0fd438. StatusCode=StatusCode[Severity=Bad, Subcode=Bad_ServiceUnsupported]

1/ Is there any version of ignition that support a “AddNodesRequest”? Do you plan to develop such service soon?

2/ If not, is there java example available that I can use as support to create new tag?

3/ If I need to use the ignition SDK to create new tag on the server, is this SDK license free?

Thanks a lot for your support,

Laurent

There’s no planned support for the Node Management services, but that doesn’t mean you can’t get the data you’re looking for.

If you try to read or subscribe to a node that belongs to one of the devices configured on the server, and the NodeId uses the syntax defined for the type of device to point to the right address (e.g. “[MyLogixDevice]My.ControlLogix.Tag” or “[MyModbusDevice]HR1”, the server will return valid results. Unfortunately this does not make the node appear in the address space in such a way that it can be browsed. The addressing syntax for each of the devices is explained in Ignition’s user manual for each driver, if applicable.

The Ignition SDK is free to download and use, there are no licensing fees associated with it. You can see the latest examples of how to use it in the examples we have hosted on Github.

Thanks a lot Kevin,

This is really useful example …

  • I am still wondering if I have any limitation if I create my own module … (license)
    I saw that the current license of this example is “Trial” … Is there any limitation if I develop a module for a customer as example?
    (I believe that I should sign it using the ignition web site to be able to use the module without the developer mode … Am I right?)

  • Is there a way to subscribe to a tag (in a module) and be notified in java if anybody change the value of this tag (example trough an external opc client …) Is there example for this?

Thanks a lot
Laurent