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
How to read out a complex type from an event
March 13, 2014
10:10, EET
Avatar
infraview.schmidt
Member
Members
Forum Posts: 7
Member Since:
August 13, 2013
sp_UserOfflineSmall Offline

I have a Event with an Attribute which is a complex type, so in the modeler it looks like this:

–BaseEventType
—-MyEvent
——–MyVariable
———-MySubVariable1
———-MySubVariable2

MyVariable has the value Rank of Array and stores several Objects with MySubVariable1 and MySubVariable2.

How do i have to subscribe the Array MyVariable and how do I read it out?

From my understanding the filter select clause should look like this:
filter.setSelectClause(new SimpleAttributeOperand[] {new SimpleAttributeOperand(NodeIdOfMyVariable, BrowsePathOfMyVariable, Attributes.Value, null)});

The reading out could look like this, but I do not know what I get from getValue() and how i read out all the values of the MyVariable in the array.

onEvent(MonitoredEventItem monitoredItem, Variant[] values) {
Object var = values[0].getValue();
}

March 13, 2014
13:20, EET
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 960
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

You will get the value that your server provides for MyVariable :) There is nothing automatic that will make up the MyVariable value from the sub-variables, so you need to create the array value yourself in the server.

You can read information about the value from the Variant (such as isArray and compositeClass).

If you wish to get the array components separately, you can of course create a separate field for each in the filter.

March 13, 2014
14:08, EET
Avatar
infraview.schmidt
Member
Members
Forum Posts: 7
Member Since:
August 13, 2013
sp_UserOfflineSmall Offline

Lets see if I understood this.

So the solution would be to create a class MyVariable:

class MyVariable {
String MySubVariable1;
String MySubVariable2;
}

Then I have to make a jar and use the same Class in Client and Server.

i can then cast the Variant-Value to MyVariable:

onEvent(MonitoredEventItem monitoredItem, Variant[] values) {
MyVariable[] vars = (MyVariable[]) values[0].getValue();
}

March 13, 2014
14:41, EET
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 960
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Yes, except that it’s not quite that simple in practice… You need to define it as a Structure and ensure that the type is also encoded properly through the stack. You should take a look at the blog post Using Complex DataTypes, which explains it in detail.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 267

Currently Online:
16 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 124

pramanj: 86

ibrahim: 74

rocket science: 65

kapsl: 57

Sabari: 51

gjevremovic: 49

Xavier: 43

fred: 41

TimK: 41

Member Stats:

Guest Posters: 0

Members: 1749

Moderators: 15

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1323

Posts: 5649

Newest Members:

WalterFOUNC, datafastproxiespx01, LenkaLok, seoninet, justinevillanuev, namtrott5457, DonaldWibip, AlfredoEthix, andreidla, everangel7021

Moderators: Jouni Aro: 960, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 860, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 25, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 222, Lusetti: 0

Administrators: admin: 1