15:31, EET
October 9, 2012
I used the C++ sdk to create custom types. When instanciating them all the components of the types were instanciated.
Now I am wondering how to do the same in Java.
I tried the following
//create custom object type
final NodeId VegSensorTypeId = new NodeId(ns, “VegSensorType”);
UaObjectType vegSensorType = new UaObjectTypeNode(myNodeManager, VegSensorTypeId, “VegSensorType”, Locale.ENGLISH);
myNodeManager.addNodeAndReference(baseObjectType, vegSensorType, Identifiers.HasSubtype);
//Add a variable to object type
final NodeId hastighetId = new NodeId(ns, “Hastighet”);
UaVariableNode SpeedNode;
SpeedNode = new CacheVariable(myNodeManager, hastighetId, “Hastighet”, Locale.ENGLISH);
SpeedNode.setDataType(doubleType);
SpeedNode.setModellingRule(Identifiers.ModellingRule_Mandatory);
myNodeManager.addNodeAndReference(vegSensorType, SpeedNode, Identifiers.HasComponent);
// now instanciate my object type
final NodeId VegSensorId = new NodeId(ns, “VegSensor”);
VegSensor = new UaObjectNode(myNodeManager, VegSensorId, “VegSensor 1”, Locale.ENGLISH);
VegSensor.setTypeDefinition(vegSensorType);
//registrationPoint.addReference(VegSensor, Identifiers.HasComponent, false);
myNodeManager.addNodeAndReference(registrationPoint, VegSensor, Identifiers.Organizes);
The object is intanciated but its varaiable is not.
What is the correct way to do that ?
Thank you
7:21, EET
December 21, 2011
16:34, EEST
December 21, 2011
This has changed somewhat since the original posting here in 2012. Nowadays, the recommended way is to define types with UaModeler and then generate Java classes respective to the types using the Java Code Generator included in the Java SDK. After that you can use the NodeManagerUaNode.createInstance() method to instantiate your objects and variables – it will take care of building the “complete” object or variable for you.
See the SDK documentation for more details about the code generation (in codegen directory).
Most Users Ever Online: 1919
Currently Online:
59 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 737
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6450
Newest Members:
fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerleyModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1