Package: asyncua-fork-for-eta-utility
THIS IS A FORKED VERSION FOR ETA_UTILITY!OPC UA / IEC 62541 Client and Server for Python >= 3.7 and pypy3 .http://freeopcua.github.io/,https://github.com/FreeOpcUa/opcua-asyncioopcua-asyncioopcua-asyncio is an asyncio-based asynchronous OPC UA client and server based on python-opcua, removing support of python < 3.7.
Asynchronous programming allows for simpler code (e.g. less need for locks) and can potentially provide performance improvements.
This library also provides asynchronous wrapperover the async API, which can be used in synchronous code instead of python-opcua.The OPC UA binary protocol implementation has undergone extensive testing with various OPC UA stacks. The API offers both a low level interface to send and receive all UA defined structures and high level classes allowing to write a server or a client in a few lines. It is easy to mix high level objects and low level UA calls in one application. Most low level code is autogenerated from xml specification.The test coverage reported by coverage.py is over 95%, with the majority of the non-tested code being autogenerated code that is not currently in use.Warningsopcua-asyncio is open-source and comes with absolutely no warranty. We try to keep it as bug-free as possible, and try to keep the API stable, but bugs and API changes will happen! In particular, API changes are expected to take place prior to any 1.0 release.Some renaming of methods from get_xx to read_xx and set_xx to write_xxx have been made to better follow OPC UA naming conventionsVersion 0.9.9 introduces some argument renaming due to more automatic code generation. Especially the arguments to NodeId, BrowseName, LocalizedText and DataValue, which are now CamelCase instead of lower case, following the OPC UA conventions used in all other structures in this libraryInstallationWith pippip install asyncuaUsageWe assume that you already have some experience with Python, the asyncio module, the async / await syntax and the concept of asyncio Tasks.Client classTheClientclass provides a high level API for connecting to OPC UA servers, session management and access to basic
address space services.
The client can be used as a context manager. The client will then automatically connect and disconnect withing thewithsyntax.fromasyncuaimportClientasyncwithClient(url='opc.tcp://localhost:4840/freeopcua/server/')asclient:whileTrue:# Do something with clientnode=client.get_node('i=85')value=awaitnode.read_value()Of course, you can also call theconnect,disconnectmethods yourself if you do not want to use the context manager.See the example folder and the code for more information on the client API.Node classTheNodeclass provides a high level API for management of nodes as well as data access services.Subscription classTheSubscriptionclass provides a high level API for management of monitored items.Server classTheServerclass provides a high level API for creation of OPC UA server instances.DocumentationThe documentation is available hereReadTheDocs.The API remains mostly unchanged with regards topython-opcua.
The main difference is that most methods are now asynchronous.
Please have a look atthe examplesand/or the code.A simple GUI client is available at:https://github.com/FreeOpcUa/opcua-client-guiBrowse the examples:https://github.com/FreeOpcUa/opcua-asyncio/tree/master/examplesThe minimal examples are a good starting point.
Minimal client example:https://github.com/FreeOpcUa/opcua-asyncio/blob/master/examples/client-minimal.pyMinimal server example:https://github.com/FreeOpcUa/opcua-asyncio/blob/master/examples/server-minimal.pyA set of command line tools also available:https://github.com/FreeOpcUa/opcua-asyncio/tree/master/toolsuadiscover(find_servers, get_endpoints and find_servers_on_network calls)uals(list children of a node)uahistoryreaduaread(read attribute of a node)uawrite(write attribute of a node)uacall(call method of a node)uasubscribe(subscribe to a node and print datachange events)uaclient(connect to server and start python shell)uaserver(starts a demo OPC UA server)tools/uaserver --populate --certificate cert.pem --private_key pk.pemHow to generate certificate:https://github.com/FreeOpcUa/opcua-asyncio/tree/master/examples/generate_certificate.shClient supportWhat works:connection to server, opening channel, sessionbrowsing and reading attributes valuegetting nodes by path and nodeidscreating subscriptionssubscribing to items for data changesubscribing to eventsadding nodesmethod calluser and passwordhistory readlogin with certificatecommunication encryptionremoving nodesTested servers: freeopcua C++, freeopcua Python, prosys, kepware, beckhoff, winCC, B&R, …Not implemented yet:localized text featureXML protocolUDP (PubSub stuff)WebSocketmaybe automatic reconnection...Server supportWhat works:creating channel and sessionsread/set attributes and browsegetting nodes by path and nodeidsautogenerate address space from specadding nodes to address spacedatachange eventseventsmethodsbasic user implementation (one existing user called admin, which can be disabled, all others are read only)encryptioncertificate handlingremoving nodeshistory support for data change and eventsmore high level solution to create custom structuresTested clients: freeopcua C++, freeopcua Python, uaexpert, prosys, quickopcNot yet implemented:UDP (PubSub stuff)WebSocketsession restorealarmsXML protocolviewslocalized text featuresbetter security model with users and passwordRunning a server on a Raspberry PiSetting up the standard address-space from XML is the most time-consuming step of the startup process which may lead to
long startup times on less powerful devices like a Raspberry Pi. By passing a path to a cache-file to the server constructor,
a shelve holding the address space will be created during the first startup. All following startups will make use of the
cache-file which leads to significantly better startup performance (~3.5 vs 125 seconds on a Raspberry Pi Model B).DevelopmentCode follows PEP8 apart for line lengths which should be max 160 characters and OPC UA structures that keep camel case
from XML definition.All protocol code is under opcua directoryasyncua/uacontains all UA structures from specification, most are autogeneratedasyncua/commoncontains high level objects and methods used both in server and clientasyncua/clientcontains client specific codeasyncua/servercontains server specific codeasyncua/utilscontains some utilities function and classesasyncua/toolscontains code for command lines toolsschemascontains the XML and text files from specification and the python scripts used to autogenerate codetestscontains testsdocscontains files to auto generate documentation from doc stringsexamplescontains many example filesexamples/synccontains many example files using sync APItoolscontains python scripts that can be used to run command line tools from repository without installingRunning tests:python -m pip install -r requirements.txt
python -m pip install -r dev_requirements.txt
pytest -v -sOr./run-test.sh -v -sCoveragepytest -v -s --cov asyncua --cov-report=htmlOr./run-test.sh -v -s --cov asyncua --cov-report=html