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
OPC client doesn't know that OPC server rejected value
July 6, 2017
11:22, EEST
Avatar
kursar
Member
Members
Forum Posts: 4
Member Since:
April 13, 2016
sp_UserOfflineSmall Offline

I created OPC server and OPC client using SDK Sentrol. But when my OPC server rejects new tag value OPC client doesn’t know about it and value in client isn’t reverted. Is there possibility to somehow inform client that value was rejected? Is there any event which is triggered on the client in this case?

I’m using asynchronous mode in OPC client and I don’t want to set AsyncRefreshInterval because it would slow down my OPC server.

July 11, 2017
12:23, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1010
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

It depends a bit how you are doing the write.

I assume that you are using variable components and PsOPCConnector to link the variables to the OPC Items in the server. In this case, the connector is reacting to requests in the variables to change the value by making a write request to the OPC server. Again several options:

1. PsOPCConnector.AsyncWrite = False

The write is made immediately and if it succeeds, the variable value is changed respectively. In case of an error, you should get an exception.

2. PsOPCConnector.AsyncWrite = True

The write is made immediately using IOPCAsyncIO2.Write (or IOPCAsyncIO.Write for DA1.0 servers), but the value is not changed in the variable. If the write succeeds, the value will be changed when the next data change message confirms that it was changed in the server.

Writing errors are really not handled in this case, but you can handle them in your own code by using the event of the internal OPCGroup object: PsOPCConnector.OPCGroup.OnWriteCompleted, which is triggered whenever the client gets a response to the write request from the server.

So the easier way would be to use synchronous writes, even if you are monitoring the data changes asynchronously, by setting AsyncWrite := False, even if you have Async := True. Async writes are possible, but not necessary for efficient functionality, unless you have very slow writes to the server or if you are writing often to the server (in which case it may be also good to pack the writes together by setting PsOPCConnector.TriggerVarChange := tmDelayed, which makes it really asynchronous)

AsyncRefreshInterval is actually just a safe guard. Unfortunately, OPC DA does not enable a mechanism to guarantee that the client gets all data changes from the server, for example during short-term network breaks, if the messages are lost. In this case it is theoretically possible that the item values in the client are no more in sync with the server. By using AsyncRefreshInterval, the PsOPCConnector will send a specific Refresh request to the server that makes the server to send all current values to the client ensuring that all values are always up to date. But, if you don’t have problems in your network, this is indeed unnecessary. Or you can make it happen very rarely, e.g. every 10 minutes.

July 15, 2017
13:35, EEST
Avatar
kursar
Member
Members
Forum Posts: 4
Member Since:
April 13, 2016
sp_UserOfflineSmall Offline

Thank you for the reply.

Yes I’m using PsOPCConnector to link the variables but I don’t use OPCGroups. I tried to set synchronous writes by setting AsyncWrite = False but it didn’t helped.
Finally I found workaround for this issue which is ok for me. I give up using event OnChanging so I always allow to change value by the client. When execution of OnValueChange event is finished I verify whether new value can be accepted or not. If value can’t be accepted my server reverts variable value. It always reverts of value in the client as well.

July 17, 2017
10:31, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1010
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Good that you found a way to do it. This is not always that simple as the exact behaviour depends very much on the server.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
14 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 681

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com

Moderators: Jouni Aro: 1010, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1