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: 1026
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: 1026
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: 1919

Currently Online:
6 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 734

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1524

Posts: 6453

Newest Members:

rickie5305, shaylamaggard4, rickyjuarez140, jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1027, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1