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 fast write reply after value change
May 15, 2019
9:55, EEST
Avatar
marttin
Member
Members
Forum Posts: 4
Member Since:
March 20, 2019
sp_UserOfflineSmall Offline

Hello ,

I use MonitoredDataItemListener for notifications data change in Node, how to after detect data change fast writen new data to node ?
The server data is changed every 200ms, to 200ms, I need a write new data for Node.

@Override
public void onDataChange(MonitoredDataItem sender, DataValue prevValue, DataValue value) {
Thread thread = new Thread() {
public void run() {
System.out.println("Thread Running");

String data = (client.getDataValue(sender.getNodeId(), sender.getAttributeId(), value));
logger.info(data);
System.out.println(data);
try {
client.writeValue(String nodeID, String value);
client.writeValue(String nodeID, String value);
logger.info("OK " + data + "HL, NV -> 10 ; 3");
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
thread.start();
}

May 15, 2019
13:33, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 347
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

I’m not exactly sure what you are trying to do. If you can clarify that and describe what is the problem I could help better.

I do not recommend starting a new Thread per onDtaChange, as that might take a while. Use e.g. some ExecutorService that is initialized outside of onDataChange.

May 15, 2019
20:48, EEST
Avatar
marttin
Member
Members
Forum Posts: 4
Member Since:
March 20, 2019
sp_UserOfflineSmall Offline

I need to monitoring the space where are 200 Node structures to change values. The value would be changed every 200 ms. After that change I need to record data of databases as soon as possible to Node. Could you please tell me how can I make 200 MonitoredDataItemListener for listening of changes and writing values if the change come in?

May 16, 2019
11:02, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 347
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Make 200 MonitoredDataItems, add MonitoredDataItemListener to them and then add items to a Subscription. Look at the tutorials and the sample programs.

I do not understand “After that change I need to record data of databases as soon as possible to Node.”. Do you want to write them to a database OR to a server node?? The latter doesn’t make much sense, I would need to know more about your use case. But basically use UaClient.writeValue. Storing data to a database is outside of the scope of the support.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 78

Currently Online:
11 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 89

pramanj: 86

ibrahim: 68

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 36

Rainer Versteeg: 32

peterrob45: 25

Member Stats:

Guest Posters: 0

Members: 831

Moderators: 11

Admins: 1

Forum Stats:

Groups: 3

Forums: 14

Topics: 850

Posts: 3588

Newest Members:

stielerit, FonsCarver, THX, Automate, gamebaisunwin, reilev, brigettei47, olaloos025, leslieangles9, tomprodehl

Moderators: Jouni Aro: 824, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 347, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 14

Administrators: admin: 0