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 Monitor Data changes in Android
February 10, 2016
15:56, EET
Avatar
keshang
Member
Members
Forum Posts: 6
Member Since:
February 9, 2016
sp_UserOfflineSmall Offline

Hi, I am trying to connect the Prosys SampleServer ,then monitor the data changes and show it in a Surfaceview. codes are in below. But these words “Monitor Data Change successfully” and the current time only appear once. i think the sentence “Monitor Data Change successfully” should always and continuous to be shown. How can I make that happen or can you show me another example? thank you in advance.

new Thread() {
@Override
public void run() {
try {
myClient = createClient(“opc.tcp://uademo.prosysopc.com:52520/OPCUA/SampleConsoleServer”);
myClient.connect();
MonitoredDataItem dataItem = new MonitoredDataItem(Identifiers.Server_ServerStatus_CurrentTime);// is this possible?
Subscription subscription = new Subscription();
subscription.addItem(dataItem);
myClient.addSubscription(subscription);
MonitoredDataItemListener dataChangeListener = new MonitoredDataItemListener() {
@Override
public void onDataChange(MonitoredDataItem sender, DataValue prevValue,
DataValue value) {
System.out.println(“Monitor Data Change successfully”);
if(value!=null){
System.out.println(“————->”+value.getValue().getValue().toString());
}
}
};
dataItem.setDataChangeListener(dataChangeListener);
} catch (Exception e) {
}
}
}.start();

February 11, 2016
8:29, EET
Avatar
Heikki Tahvanainen
Member
Members
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hello,

In SampleConsoleServer, the ServerStatus’s CurrentTime node will not produce data changes. Otherwise your code seems fine. Maybe you can use some other node? For example, the node ns=2;s=MyLevel provides constant value changes in SampleConsoleServer.

February 11, 2016
18:22, EET
Avatar
keshang
Member
Members
Forum Posts: 6
Member Since:
February 9, 2016
sp_UserOfflineSmall Offline

Heikki Tahvanainen said

Hello,

In SampleConsoleServer, the ServerStatus’s CurrentTime node will not produce data changes. Otherwise your code seems fine. Maybe you can use some other node? For example, the node ns=2;s=MyLevel provides constant value changes in SampleConsoleServer.

hi, perfect! it works with
NodeId id = new NodeId(2,”MyLevel”);
MonitoredDataItem dataItem = new MonitoredDataItem(id);

Thank you so much. Best Regards.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
41 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: 726

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7, franciscagrimwad, adult_gallery

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

Administrators: admin: 1