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: 1009
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: 1009
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: 518

Currently Online:
15 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

TimK: 41

Member Stats:

Guest Posters: 0

Members: 708

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1465

Posts: 6252

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