打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
LightOPC FAQ
userphoto

2015.12.23

关注
Is there other documentation about LightOPC?

Hmm... 
In english: This FAQ; lightopc.h and README.txt in sources. That's all. 
In russian only: The manual (gzip).



My function ldReadTags() never gets called!

The ldReadTags() is called only for OPC_DS_DEVICE operations. Most of OPC clients uses OPC_DS_CACHE rather than perform device reading.

The cache reading is handled completely inside LightOPC as well as OnDataChange() update generation and deadband calculations.

Therefore you have to use either loCacheXXXX() to keep the cache actual. In fact, if the ldReadTags() performs real reading it should update the cache by an explicit call to loCacheUpdate().

Usage ldReadTags() is optional. It useful to implement a "destructive" reading. It guarantees the athomicity and the ordering of DEVICEs' requests.



How should I deal with UpdateRate?

Probably nothing to do. You have to initialize ldRefreshRate according your system performance and device's requirements. The reasonable range is 30...1000 mS. The LightOPC does all updates for the clients internally.

Usally a client makes a lot of different update rates for different groups. And there are bunch of different clients might be connected. And the LightOPC library cut them off to to protect the driver from touching by each OnDataChange() invocation.

The UpdateRate specified by a client used to schedule OnDataChange notifications. Such notifications performed using cached data becuse by definition the OnDataChange logic is operate on the cached data and may not affect the device state. The driver have to place the data into the cache by using loUpdateCache() or loLockCache() / loUnlockCache(). These cached data are also used to satisfy the clients' Read() / Refresh() requests with OPC_DS_CACHE attribute set.

Thus your driver should keep the cache up to date and may not worry about client's Update Rate.

In many cases it's desirable to preserve the frequency of devices' polling unrelated to number of clients connected and their update rates.

The driver may call loCacheUpdate() as often as required by underlying hardware. The function is especially designed to be fast and be usable in time-critical loops. It doesn't make inpredictable delays. If an extra call to VariantCopy() seems too slow for you then try loCacheLock() / loCacheUnlock().

This technique allows you to satisfy your device's timings easily and don't pay much attention for clients' requests.



How to reduce device accessing?

There are two ways to reduce devices' polling frequency: 
poll for active tags only. These tags can be tracked via loDriver::ldSubscribe(). 
update tags by interrupts if devices allowed that. 
The interrupt-driven tags should seems "fresh" in the cache. To ensure that you have to update periodically the timestamp of such tags. The loCacheUpdate() can set arbitrary timestamp for several tags very quickly.



Why can't I create more than XXX tags?

Probably you wrote somting like 
   loServiceCreate(&my_service, &ld, XXX);
Where the XXX is the total amount of available tags. Simply increase this number.

The total of tags can not be changed without loService recreating due to performance reasons.



Is it possible to add and delete tags to a running server?

Once a tag added it can not be deleted. Therefore in general case you have to restart the server. But... 
It's possible to add tags to a running server as much as specified in loCreateService(). 
It's possible to create unnamed tags and assign them different names dynamically using ldAskItemId(). Unfortunately, such tags will not be shown by BrowseAdressSpace and their types and other attributes can not be changed. 
It's possible to create separate server for each device if devices might appear and disappear at any time. 
Finally, server can be restarted gracefully. It's possible to run several loService in the single process and replace an obsolete server by another without process' restarting.

IMHO the dynamically created tags cause problems for clients. In most cases it's desirable to have a tag browseable even it isn't connected to a data source at the moment. It simplify clients' setup.



Can I bind my private information to a tag? 
What's purpose of the loRealTag?

The 
loRealTag rt
parameter of loAddRealTag() is optional. LightOPC make no use of it, rather it will be passed back to your code in loTagPair::tpRt.

You may define pointer to your private data and pass it to loAddTagXXX() as (loRealTag)rt argument. You're free even define your own struct loRealTag_ to avoid pointer casting.



How to create a "hint" string for BrowseAddressSpace?

Define the ldAskItemId() callback for mapping derived names to unnamed tags.

Create a "hint" tag with desired name (like "Reg[0...32727]") and NULL or VT_EMPTY tdValue or loTF_EMPTY specified. This bogus tag will be visible for BrowseAddresSpace only.

Create required amount of nameless tags (with NULL or empty tdName).



OPC Security?

Make distinction of the IOPCSecurity interface and OPC Security in general. The LightOPC conforms to several security issues.

The IOPCSecurity isn't provided directly because this silly interface doesn't provide any useful service. But it can be implemented easily and attached to loClient via loClientChain().

In general a "security" consists of authentication and authorization. The IOPCSecurity doesn't provide authorization stuff (i.e. no access rights to userid map).

In the simplest case you may split your tags to few sets and serve them via different servers with different DCOM authorization. These servers can be run in one process.

To make your server secured at items level you have to do following things: 
Catch the action requested by an OPC client. 
You're able to catch following actions: 
Any writing by catching ldWriteTags(). 
Device reading by catcing ldReadTags(). 
Connecting a client to a tag by hooking ldAskItemId() & loDF_CHECKITEM / loTF_CHECKITEM. In this case you may prohibit AddItems() any access (either cache or device) for a particular client - tag combination. 
Identify the client. It's possible in several ways: 
Obtain the caller's context through usual DCOM practice. 
Verify item's access_path for a magic key. 
Make 2 (userid / password) or even 3 (challenge / userid / response) additional per-client tags. A client have to initialize them properly before access anything else. 
Check permissions and resume (or reject) the catched action. You're free to use either native NT's security (which is noticeable slow for 100 or more accounts) or a private ACL. 
That's all.



What threading model should I use?

Oh... The LightOPC itself is "freethreaded" as a bird.

For a out-of-proc server the model of the thread supporting IClassFactory is significant. The COINIT_MULTITHREADED is seems preferable. The COINIT_APARTMENTTHREADED is also acceptable, but such thread must implement a message loop and process windows messages.

In order to utilize threading models other than "free" you also have to specify (loDf_BOTHMODEL | loDf_FREEMARSH) in loDriver::ldFlags instead of loDf_FREEMODEL.

To show excellent performance for a singlethreaded client connected to inproc server the BOTH model supported. Support for BOTH model should be enabled (or disabled) at compile time (by LO_USE_BOTHMODEL and LO_USE_FREEMARSHALL) and at the run time (by loDf_BOTHMODEL and loDf_FREEMARSH). Because the BOTH model may slowdown freethreaded clients it's possible to enable it for arbitrary clients connections.

The loDf_BOTHMODEL & loDf_FREEMARSH forces some overhead and local message loops in lightopc library. Thus it makes a server less tolerant to clients' faults.



How to reach better performance?

Are you really confused by benchmarks? 
The EventLog is extremely slow. Set the lower log level or redirect the logs to files. See README.txt for details about unilog tunings. 
In case of extremely many named tags try to replace them by unnamed ones and "hint strings". 
For an in-proc server choose right threading model
Try to force clients to accept canonical datatype. 
Increase ldRefreshRate and make it multiple of system's scheduler granularity. 
Make no use of loDF_IGNCASE, xmalloc() & Co, LO_USE_OBJXREF. 
Try to disable OPC_READABLE / OPC_WRITEABLE checking via LO_CHECK_RIGHTS, but it will not help much. 



What's about compliance testing? 
Are the Data Access Automation wrapper files available at your site?

We're not a member of OPC Foundation and probably never become. Thus we haven't Automation Wrapper DLL and didn't perform compliance tests.

The executables of opcXXXauto.dll are included in the free downloads from many commercial vendors. For example Matrikon Explorer & Simulator, KEPware, etc.

We've tested LightOPC with such automation wrappers.



What if the OPC DA Standard ambiguous? 
the deadband calculated using canonical datatype; 
single lastsent is used by both AsyncIO & AsyncIO2; 
the Read() / Write() doesn't modify lastsent, it changed by Refresh() / OnDataChange() only; 
error codes returned (ajustable in most obscured cases); 
empty enumerators. The LightOPC allows run time adjustments on per-client basis of behavior in case of an empty enumerator have to be returned. 


if you maybe have also a development library for OPC clients...

We haven't it. 
IMHO the OPC provides a client oriented API and writing a client on top of bare OPC is quite easy.

Look at following links, they can be useful: 
http://lhcb-comp.web.cern.ch/lhcb-comp/ECS/opcevaluation/opcclienttutorial/ 
ftp://ftp.mysst.com/ pub/beta/ client.zip 



WinCC: "This OPC Server does not support a Browser Interface"?

Before call to 
loServiceCreate()
set the appropriate 
loDriver::ldRefreshRate
= 1 or another fraction of 1000 ms. 
See lightopc.h for details about 
ldRefreshRate
.



"lwsynch.h: No such file or directory"?

ftp://ftp.ipi.ac.ru/pub/LightOPC/ unilog-current.tgz

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
RockWell Use OPC Test Client to test the connection 罗克韦尔 OPC Test使用教程
ADB源码分析(一)
西门子1200做Server和Client以及AM401做Client和Server相互通信
OPC。NET
西门子300PLC连接LABVIEW实现ModbusTCP通信连接案例
关于OPC Client 编写|LinkPLC工控论坛|Link PLC Forum
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服