Avatar
Please consider registering
guest
sp_LogInOut Log Insp_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 RSSsp_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: 1029
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: 1029
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: 1919
Currently Online:
Guest(s) 33
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 90
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 734
Moderators: 8
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1545
Posts: 6521
Newest Members:
wilfredoforeman, ptdenriqueta, basilpullman, Richardmip, mood edibles, LouieWreve, daniellabdx, janessan21, sammiebeak359, gena7127517
Moderators: Jouni Aro: 1029, Pyry: 1, Petri: 1, Bjarne Boström: 1047, Jimmy Ni: 26, Matti Siponen: 353, Lusetti: 0, Elias: 0
Administrators: admin: 1