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();
}
}