15:56, EET
February 9, 2016
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();
8:29, EET
April 17, 2013
18:22, EET
February 9, 2016
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.
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_galleryModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1