Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
correct way to define custom object type
October 30, 2012
15:31, EET
Avatar
oroulet
Member
Members
Forum Posts: 5
Member Since:
October 9, 2012
sp_UserOfflineSmall Offline

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

October 31, 2012
7:21, EET
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Yes, you will have to create the variable in the object as well with a new NodeId.

May 15, 2017
16:14, EEST
Avatar
hbbend
Member
Members
Forum Posts: 9
Member Since:
October 21, 2016
sp_UserOfflineSmall Offline

Hi,
I did the same thing but with property and with objects. Do i have to create them in the object instantiated?

Thank’s in Advance,

May 15, 2017
16:34, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

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).

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
13 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

ibrahim: 75

rocket science: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 707

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1466

Posts: 6253

Newest Members:

christi10l, ahamad1, Flores Frederick, ellenmoss, harriettscherer, shanonhumphreys, KupimotoblokfuB, tamhollander5, paulinafcf, bridgette18l

Moderators: Jouni Aro: 1009, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 982, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 319, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1