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
Codegenerator in Java SDK
August 25, 2014
7:10, EEST
Avatar
ibrahim
Member
Members
Forum Posts: 75
Member Since:
August 20, 2014
sp_UserOfflineSmall Offline

Hello,
i’m using the Java SDK Evaluation- 2.0.0-194.
I wanted to try the codegenerator. So i downloaded the UaModeler an created an xml file based on my informationmodel (very small, only 7 nodes).
Then i followed the readme.md from the folder codegen. I copied the xml file into the codegen folder. Then i edited the codegen.properties file.
Then i ran the codegen-2.0.0-standalone with all the necessary Parameters.
Now i dont’t know what i’m doing wrong?
My result is: the impl- folder is empty, in the intf- folder i have only 1 file InormationModel.java.

Tanks
Ibrahim

August 25, 2014
14:05, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Did you define types or only objects and variables in your information model?

August 25, 2014
14:15, EEST
Avatar
ibrahim
Member
Members
Forum Posts: 75
Member Since:
August 20, 2014
sp_UserOfflineSmall Offline

I defined Variables with th UaModeler. I think the Modeler automatically creates the types?
I created for example two AnalogItemTypes.
What do i have to create with the Modeler, to make the codegen understand it?
Thanks.

August 26, 2014
8:59, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

You need code generation to convert the UA type definitions to the respective Java classes, which you can then use in application development.

If you only define instances (objects and variables), you can just load the information model XML to your application to get the instances in the address space.

August 26, 2014
9:34, EEST
Avatar
ibrahim
Member
Members
Forum Posts: 75
Member Since:
August 20, 2014
sp_UserOfflineSmall Offline

Thanks a lot.
Now, since i have created types instead of objects the codegen outputs classes.
I will do some testings and read the dokumentation.
up to this point many thanks.

August 28, 2014
8:17, EEST
Avatar
ibrahim
Member
Members
Forum Posts: 75
Member Since:
August 20, 2014
sp_UserOfflineSmall Offline

Hi,
i have problems creating a Server and using the generated code. Do you have a tutorial, how to integrate the generated code into a Server and how to create a server?
Thanks

August 28, 2014
9:16, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

That’s explained in the codegen/Readme.md and ReadmeSample.md files.

August 29, 2014
8:06, EEST
Avatar
ibrahim
Member
Members
Forum Posts: 75
Member Since:
August 20, 2014
sp_UserOfflineSmall Offline

Thanks…
I followed the instuctions in the ReadmeSample.md. Now i have a question:
Do i have to load the XML file again? I mean i registered the created InformationModel. I thougt this should be enough to be able to create instances?

August 29, 2014
10:08, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Yes, you need to load the XML to read the type definitions into the address space. Then you can instantiate objects based on the generated Java classes in your application.

August 29, 2014
15:20, EEST
Avatar
ibrahim
Member
Members
Forum Posts: 75
Member Since:
August 20, 2014
sp_UserOfflineSmall Offline

Thanks a lot..
Now i’m able to create instances an methods..

September 2, 2014
9:21, EEST
Avatar
ibrahim
Member
Members
Forum Posts: 75
Member Since:
August 20, 2014
sp_UserOfflineSmall Offline

Hi,
i’m trying to make one of the variableTypes created by the generator historising.I tried to use the class MyHistorian from the SDK, but that doesen’t work, because the function addVariableHistory needs a UaVariableNode as parameter. So, how can i historise my custom created Variables?
Thanks.

September 2, 2014
12:33, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

MyHistorian is just an example. You should create your own according to your own needs, but you can take that one as a basis.

All variable nodes generated by the code generator should descend from UaVariableNode, though, so it should work for those variables as well. You cannot add a variable type, you need to add variable instances.

September 2, 2014
14:08, EEST
Avatar
ibrahim
Member
Members
Forum Posts: 75
Member Since:
August 20, 2014
sp_UserOfflineSmall Offline

Ok,
i will try it.
Thanks…

September 3, 2014
13:41, EEST
Avatar
ibrahim
Member
Members
Forum Posts: 75
Member Since:
August 20, 2014
sp_UserOfflineSmall Offline

Hi,
i still have the same problem. My generated Class extends from BaseDataVariableType. I create an instance from that type. What do i have to do now, to make that instance hitorizing? The funktion addVariableHistory does not accept that instance as parameter. Could you please post an example of how to create an instance from my generated classes which will be accepted from addVariableHistory?
Thanks..

September 4, 2014
9:06, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

If you have a variable instance of your variable type, you can just add it to the Historian.

Maybe you should show how you are trying to do it, so I can tell what goes wrong.

September 4, 2014
9:28, EEST
Avatar
ibrahim
Member
Members
Forum Posts: 75
Member Since:
August 20, 2014
sp_UserOfflineSmall Offline

OK,
first i create an instance of DHT22 in my NodeManager, DHT22 extends BaseDataVariableType. The class DHT22 was created by the codegen.

MyHistorian history = new MyHistorian();
DHT22 dht22;

then i try the following:

public void inithistory() throws StatusException{
getHistoryManager().setListener(history);
dht22.setHistorizing(true);
history.addVariableHistory(dht22);
}
but the funktion addVariableHistory doesent accept dht22, because it is not UaVariableNode.

September 4, 2014
12:40, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Ah, OK, I think I get it, now.

DHT22 is the interface type. You must declare the variable as DHT22Node, which is the generated server implementation. It descends from UaVariableNode – whereas DHT22 descends from UaVariable.

The NodeBuilder or NodeManagerUaNode.createInstance() will create it as a DHT22Node anyway.

The usage of the interface vs. the class type is not perfectly clear yet in every respect. So you may need to use the class types (XxxNode) in the server for certain things instead of the interface.

September 4, 2014
13:00, EEST
Avatar
ibrahim
Member
Members
Forum Posts: 75
Member Since:
August 20, 2014
sp_UserOfflineSmall Offline

OK,
thanks.
Maybe you noticed, that i am not an experienced java developer…Laugh
So, thanks for your patience…

September 4, 2014
13:23, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

No problem. It’s good to get feedback like this, so we can think if the documentation could be improved to make these things easier to understand. I don’t always understand the design at first sight myself either :)

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
17 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

ibrahim: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

TimK: 41

Member Stats:

Guest Posters: 0

Members: 678

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6259

Newest Members:

DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com, aytule, rashadbrownrigg, christi10l, ahamad1, Flores Frederick

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

Administrators: admin: 1