11:22, EEST
April 13, 2016
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.
12:23, EEST
December 21, 2011
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.
13:35, EEST
April 13, 2016
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.
Most Users Ever Online: 1919
Currently Online:
19 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