mirror of
				https://github.com/FreeOpcUa/opcua-asyncio
				synced 2025-10-29 17:07:18 +08:00 
			
		
		
		
	Add pre-commit-config
This commit is contained in:
		
							
								
								
									
										2
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
								
							| @@ -9,7 +9,7 @@ assignees: '' | ||||
|  | ||||
| ### Please read, before you post! | ||||
|  | ||||
| This is a _**BUG REPORT for issues in the existing code**_.  | ||||
| This is a _**BUG REPORT for issues in the existing code**_. | ||||
|  | ||||
| If you have general questions, code handling problems or ideas, please use the: | ||||
|  | ||||
|   | ||||
							
								
								
									
										2
									
								
								.github/dependabot.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/dependabot.yml
									
									
									
									
										vendored
									
									
								
							| @@ -8,4 +8,4 @@ updates: | ||||
|     directory: "/" | ||||
|     schedule: | ||||
|       # Check for updates to GitHub Actions every week | ||||
|       interval: "weekly" | ||||
|       interval: "weekly" | ||||
|   | ||||
							
								
								
									
										25
									
								
								.github/workflows/python-package.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										25
									
								
								.github/workflows/python-package.yml
									
									
									
									
										vendored
									
									
								
							| @@ -32,13 +32,24 @@ jobs: | ||||
|         python -m pip install pytest mypy ruff | ||||
|         if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||||
|         if [ -f dev_requirements.txt ]; then pip install -r dev_requirements.txt; fi | ||||
|     - name: Lint with ruff | ||||
|       run: | | ||||
|         ruff check . | ||||
|     - name: mypy | ||||
|       run: | | ||||
|         python -m pip install types-aiofiles types-python-dateutil types-pytz typing-extensions | ||||
|         python -m mypy asyncua/ | ||||
|     - name: Test with pytest | ||||
|       run: | | ||||
|         pytest -v -s | ||||
|  | ||||
|   lint: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|     - uses: actions/checkout@v4 | ||||
|       with: | ||||
|         submodules: true | ||||
|     - name: Set up Python ${{ matrix.python-version }} | ||||
|       uses: actions/setup-python@v5 | ||||
|       with: | ||||
|         python-version: "3.12" | ||||
|     - name: Install dependencies | ||||
|       run: | | ||||
|         python -m pip install --upgrade pip | ||||
|         python -m pip install pre-commit | ||||
|     - name: Lint with ruff | ||||
|       run: | | ||||
|         pre-commit run -a | ||||
|   | ||||
							
								
								
									
										22
									
								
								.pre-commit-config.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								.pre-commit-config.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| repos: | ||||
|   - repo: https://github.com/pre-commit/pre-commit-hooks | ||||
|     rev: v5.0.0 | ||||
|     hooks: | ||||
|       - id: check-merge-conflict | ||||
|       - id: check-yaml | ||||
|         args: [--unsafe] | ||||
|       - id: end-of-file-fixer | ||||
|       - id: trailing-whitespace | ||||
|  | ||||
|   - repo: https://github.com/charliermarsh/ruff-pre-commit | ||||
|     rev: 'v0.6.9' | ||||
|     hooks: | ||||
|       - id: ruff | ||||
|         args: ['--fix'] | ||||
|  | ||||
|   - repo: https://github.com/pre-commit/mirrors-mypy | ||||
|     rev: v1.12.0 | ||||
|     hooks: | ||||
|     -   id: mypy | ||||
|         additional_dependencies: [types-aiofiles, types-python-dateutil, types-pytz, typing-extensions, aiosqlite, types-pyOpenSSL] | ||||
|         files: ^asyncua/.* | ||||
| @@ -21,4 +21,4 @@ python: | ||||
|   install: | ||||
|     - requirements: docs/requirements.txt | ||||
|     - method: pip | ||||
|       path: . | ||||
|       path: . | ||||
|   | ||||
							
								
								
									
										24
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								CHANGELOG.md
									
									
									
									
									
								
							| @@ -19,7 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | ||||
|   [#1277](https://github.com/FreeOpcUa/opcua-asyncio/pull/1277) | ||||
| - Fixed incorrect function signature in Node and it's Sync wrapper | ||||
|   [#1690](https://github.com/FreeOpcUa/opcua-asyncio/pull/1690) | ||||
|    | ||||
|  | ||||
| ## [1.0.2] - 2022-04-05 | ||||
|  | ||||
| ### Added | ||||
| @@ -68,16 +68,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | ||||
|  | ||||
| ### Fixes | ||||
|  | ||||
| - Fix publishing in high load situations  | ||||
| - Fix publishing in high load situations | ||||
|   [#1265](https://github.com/FreeOpcUa/opcua-asyncio/pull/1265) | ||||
| - Fix MonitoredItemServer._is_data_changed, when as trigger | ||||
|   ua.DataChangeTrigger.StatusValueTimestamp is used | ||||
|   [#1253](https://github.com/FreeOpcUa/opcua-asyncio/pull/1253) | ||||
| - fix monitoritem for mutable values | ||||
|   [#1243](https://github.com/FreeOpcUa/opcua-asyncio/pull/1243) | ||||
| - Respect EndpointUrl request parameter in GetEndpoints, FindServers and CreateSession  | ||||
| - Respect EndpointUrl request parameter in GetEndpoints, FindServers and CreateSession | ||||
|   [#1232](https://github.com/FreeOpcUa/opcua-asyncio/pull/1232) | ||||
| - fix server history save event; init list before use  | ||||
| - fix server history save event; init list before use | ||||
|   [#1222](https://github.com/FreeOpcUa/opcua-asyncio/pull/1222) | ||||
| - xmlexporter: fix extensionobjects typeid indentifier missing namespace mapping to idx_in_exported_file | ||||
|   [#1201](https://github.com/FreeOpcUa/opcua-asyncio/pull/1201) | ||||
| @@ -129,7 +129,7 @@ in `__enter__` in sync wrapper | ||||
| ### Added | ||||
| - add feat: subscription.py optional param for sampling_interval | ||||
|   [#1087](https://github.com/FreeOpcUa/opcua-asyncio/pull/1087) | ||||
|    | ||||
|  | ||||
|  | ||||
| ### Changed | ||||
|  | ||||
| @@ -154,7 +154,7 @@ in `__enter__` in sync wrapper | ||||
| - Fix typo in in XmlImporte._check_if_namespace_meta_information_is_add ed which | ||||
| results in an exception | ||||
|   [#1066](https://github.com/FreeOpcUa/opcua-asyncio/pull/1066) | ||||
|    | ||||
|  | ||||
|  | ||||
| ## [0.9.98] - 2022-09-27 | ||||
|  | ||||
| @@ -165,7 +165,7 @@ results in an exception | ||||
| - enhance nodeset generator: add Windows support and allow targeting a branch | ||||
|   [#1049](https://github.com/FreeOpcUa/opcua-asyncio/pull/1049) | ||||
|  | ||||
| ### Changed  | ||||
| ### Changed | ||||
| - review all big exception handlings and try to better follow best practices | ||||
|   [#1048](https://github.com/FreeOpcUa/opcua-asyncio/pull/1048) | ||||
| - update schema to v1.05.01 2022-02-24 | ||||
| @@ -209,7 +209,7 @@ results in an exception | ||||
|   [#1005](https://github.com/FreeOpcUa/opcua-asyncio/pull/1005) | ||||
| - Properly close session if `connect` fails in `activate_session` | ||||
|   [#1001](https://github.com/FreeOpcUa/opcua-asyncio/pull/1001) | ||||
| - xmlimport change datatype field default  | ||||
| - xmlimport change datatype field default | ||||
|   [#1008](https://github.com/FreeOpcUa/opcua-asyncio/pull/1008) | ||||
| - fixed an UnboundLocalError | ||||
|   [#1012](https://github.com/FreeOpcUa/opcua-asyncio/pull/1012) | ||||
| @@ -237,7 +237,7 @@ results in an exception | ||||
| - Completion of the Sync api: add some missing methods | ||||
|   [#975](https://github.com/FreeOpcUa/opcua-asyncio/pull/975) | ||||
|  | ||||
| ### Changed  | ||||
| ### Changed | ||||
| - Rework struct1_04 resolution | ||||
|   [#901](https://github.com/FreeOpcUa/opcua-asyncio/pull/901) | ||||
| - Handle objects in EventTypes. If a EventType has a object as child, add it's | ||||
| @@ -260,7 +260,7 @@ import continues. | ||||
|   [#911](https://github.com/FreeOpcUa/opcua-asyncio/pull/911) | ||||
| - Fix _open_secure_channel_exchange typehints | ||||
|   [#920](https://github.com/FreeOpcUa/opcua-asyncio/pull/920) | ||||
| - Fix: Value in DataValue can be optional  | ||||
| - Fix: Value in DataValue can be optional | ||||
|   [#931](https://github.com/FreeOpcUa/opcua-asyncio/pull/931) | ||||
| - You can now call `activate_session()` without arguments without discarding a | ||||
| certificate previously set with `load_client_certificate()`. | ||||
| @@ -294,7 +294,7 @@ _node_to_string correctly maps namespaces idxs | ||||
|  | ||||
| - Fix default value for structs with lists | ||||
|   [#894](https://github.com/FreeOpcUa/opcua-asyncio/pull/894) | ||||
| - Fix enum regression  | ||||
| - Fix enum regression | ||||
|   [#898](https://github.com/FreeOpcUa/opcua-asyncio/pull/898) | ||||
| - Set Client locale  | ||||
| - Set Client locale | ||||
|   [#890](https://github.com/FreeOpcUa/opcua-asyncio/pull/890) | ||||
|   | ||||
							
								
								
									
										12
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								README.md
									
									
									
									
									
								
							| @@ -210,3 +210,15 @@ Or | ||||
| ``` | ||||
| ./run-test.sh -v -s --cov asyncua --cov-report=html | ||||
| ``` | ||||
|  | ||||
| ## Linting | ||||
|  | ||||
| To apply linting checks (including ruff, and mypy) at each commit run, | ||||
| ```bash | ||||
| pip install pre-commit | ||||
| pre-commit install | ||||
| ``` | ||||
| You can also run all linters on all files with, | ||||
| ```bash | ||||
| pre-commit run -a | ||||
| ``` | ||||
| @@ -857,5 +857,3 @@ class BadMaxConnectionsReached(UaStatusCodeError): | ||||
|  | ||||
| class BadDataSetIdInvalid(UaStatusCodeError): | ||||
|     code = 0x80E70000 | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -11,7 +11,7 @@ from dataclasses import dataclass, field | ||||
| from asyncua.ua.uatypes import FROZEN | ||||
| from asyncua.ua.uatypes import SByte, Byte, Bytes, ByteString, Int16, Int32, Int64, UInt16, UInt32 | ||||
| from asyncua.ua.uatypes import UInt64, Boolean, Float, Double, Null, String, CharArray, DateTime, Guid | ||||
| from asyncua.ua.uatypes import AccessLevel, EventNotifier   | ||||
| from asyncua.ua.uatypes import AccessLevel, EventNotifier | ||||
| from asyncua.ua.uatypes import LocalizedText, Variant, QualifiedName, StatusCode, DataValue | ||||
| from asyncua.ua.uatypes import RelativePath, RelativePathElement | ||||
| from asyncua.ua.uatypes import NodeId, FourByteNodeId, ExpandedNodeId, ExtensionObject, DiagnosticInfo | ||||
|   | ||||
| @@ -36,4 +36,3 @@ asyncua.client.ha.virtual\_subscription module | ||||
|    :members: | ||||
|    :undoc-members: | ||||
|    :show-inheritance: | ||||
|  | ||||
|   | ||||
| @@ -44,4 +44,3 @@ asyncua.client.ua\_file\_transfer module | ||||
|    :members: | ||||
|    :undoc-members: | ||||
|    :show-inheritance: | ||||
|  | ||||
|   | ||||
| @@ -172,4 +172,3 @@ asyncua.common.xmlparser module | ||||
|    :members: | ||||
|    :undoc-members: | ||||
|    :show-inheritance: | ||||
|  | ||||
|   | ||||
| @@ -25,4 +25,3 @@ asyncua.crypto.uacrypto module | ||||
|    :members: | ||||
|    :undoc-members: | ||||
|    :show-inheritance: | ||||
|  | ||||
|   | ||||
| @@ -124,4 +124,3 @@ asyncua.server.users module | ||||
|    :members: | ||||
|    :undoc-members: | ||||
|    :show-inheritance: | ||||
|  | ||||
|   | ||||
| @@ -20,4 +20,3 @@ asyncua.server.standard\_address\_space.standard\_address\_space\_services modul | ||||
|    :members: | ||||
|    :undoc-members: | ||||
|    :show-inheritance: | ||||
|  | ||||
|   | ||||
| @@ -10,4 +10,3 @@ asyncua.ua.uaerrors package | ||||
|    :members: | ||||
|    :undoc-members: | ||||
|    :show-inheritance: | ||||
|  | ||||
|   | ||||
| @@ -6,4 +6,4 @@ API Reference | ||||
| .. toctree:: | ||||
|    :maxdepth: 4 | ||||
|  | ||||
|    asyncua | ||||
|    asyncua | ||||
|   | ||||
| @@ -16,7 +16,7 @@ Most code is autogenerated from xml specification using same code as the one tha | ||||
| - A simple GUI client is available: https://github.com/FreeOpcUa/opcua-client-gui | ||||
| - Examples: https://github.com/FreeOpcUa/opcua-asyncio/tree/master/examples | ||||
| - Source Code: https://github.com/FreeOpcUa/opcua-asyncio | ||||
|   | ||||
|  | ||||
|  | ||||
| .. toctree:: | ||||
|    :maxdepth: 2 | ||||
|   | ||||
| @@ -3,4 +3,4 @@ pydata-sphinx-theme>=0.9.0 | ||||
| # sphinx-copybutton>=0.5.0 | ||||
|  | ||||
| # Optional Dependencies | ||||
| sphinx-autobuild>=2021.3.14 | ||||
| sphinx-autobuild>=2021.3.14 | ||||
|   | ||||
| @@ -24,5 +24,3 @@ Browsing and accessing nodes | ||||
| ============================ | ||||
|  | ||||
| .. todo:: Usage of shortcut objects (root, objects, ...) | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,7 @@ The NodeId Class | ||||
| ================ | ||||
|  | ||||
| :class:`asyncua.ua.uatypes.NodeId` objects are used as unique ids for :class:`~asyncua.common.node.Node`'s | ||||
| and are therefore used on the server and client side to access specific nodes. The two classes  | ||||
| and are therefore used on the server and client side to access specific nodes. The two classes | ||||
| :class:`~asyncua.ua.uatypes.NodeId` and :class:`~asyncua.common.node.Node` should not | ||||
| be confused: The NodeId is the unique identifier of an actual Node. While the NodeId is used to identify | ||||
| a specific node, the Node object can be used to access the underlying data. | ||||
| @@ -17,7 +17,7 @@ A NodeId contains two main pieces of information that allow a unique mapping in | ||||
| The :attr:`~asyncua.ua.uatypes.NodeId.Identifier` and the :attr:`~asyncua.ua.uatypes.NodeId.NamespaceIndex`. | ||||
| In addition there is the :attr:`~asyncua.ua.uatypes.NodeId.NodeIdType` attribute which is used | ||||
| to specify which opc-ua type is used for the Identifier. In addition to the :class:`~asyncua.ua.uatypes.NodeId` | ||||
| class, there is also the a :class:`~asyncua.ua.uatypes.ExpandedNodeId` which adds the  | ||||
| class, there is also the a :class:`~asyncua.ua.uatypes.ExpandedNodeId` which adds the | ||||
| :attr:`~asyncua.ua.uatypes.ExpandedNodeId.NamespaceUri` and :attr:`~asyncua.ua.uatypes.ExpandedNodeId.ServerIndex` | ||||
| attributes to make the ID unique across different servers and namespaces. | ||||
|  | ||||
| @@ -55,7 +55,7 @@ The following keys are supported: | ||||
| ns | ||||
|     The ns key will map to the Namespace of the NodeId | ||||
| i, s, g, b | ||||
|     These keys will map to the Identifier of the NodeId. The character specifies the  | ||||
|     These keys will map to the Identifier of the NodeId. The character specifies the | ||||
|     type: Numeric, String, Guid or Bytes. | ||||
| srv, nsu: | ||||
|     If one of this keys is set, a :class:`~asyncua.ua.uatypes.ExpandedNodeId` will be returned | ||||
| @@ -98,11 +98,11 @@ and client side. Therefore, both, the server and client, provide a :code:`get_no | ||||
| :meth:`asyncua.client.client.Client.get_node` & :meth:`asyncua.server.server.Server.get_node`. | ||||
| These functions can be used to get a node by it's NodeId, for example: | ||||
|  | ||||
| .. code-block::  | ||||
| .. code-block:: | ||||
|  | ||||
|     >>> client.get_node("ns=2;i=2") | ||||
|     Node(NodeId(Identifier=2, NamespaceIndex=2, NodeIdType=<NodeIdType.Numeric: 2>)) | ||||
|      | ||||
|  | ||||
| Note that using :code:`get_node` does not check if the node actually exists! The method | ||||
| just creates a new node which later can be used to query data. | ||||
|  | ||||
| @@ -111,7 +111,7 @@ just creates a new node which later can be used to query data. | ||||
|  | ||||
| The node now can be used to read / write / ... data from the server: | ||||
|  | ||||
| .. code-block::  | ||||
| .. code-block:: | ||||
|  | ||||
|     >>> node = client.get_node("ns=2;i=2") | ||||
|     >>> name = (await node.read_browse_name()).Name | ||||
| @@ -134,13 +134,13 @@ result in a error as the sent datatype does not match the expected type on the s | ||||
| The node object can also be used to browse to other nodes. There are several methods available | ||||
| as shown in the following short example: | ||||
|  | ||||
| .. code-block::  | ||||
| .. code-block:: | ||||
|  | ||||
|     >>> # Get the parent of a node | ||||
|     >>> parent = await node.get_parent() | ||||
|     >>> print(parent) | ||||
|     Node(NodeId(Identifier=1, NamespaceIndex=2, NodeIdType=<NodeIdType.FourByte: 1>)) | ||||
|      | ||||
|  | ||||
|     >>> # Get all children of a node | ||||
|     >>> await parent.get_children() | ||||
|     [Node(NodeId(Identifier=2, NamespaceIndex=2, NodeIdType=<NodeIdType.FourByte: 1>))] | ||||
| @@ -153,7 +153,7 @@ Note that in the last example we use the browse path of child as argument to | ||||
| :meth:`~asyncua.common.node.Node.get_child`. With the same method it's also possible | ||||
| to access a child several levels deeper than the current node: | ||||
|  | ||||
| .. code-block::  | ||||
| .. code-block:: | ||||
|  | ||||
|     >>> await c.nodes.objects.get_child(['2:MyObject', '2:MyVariable']) | ||||
|     Node(NodeId(Identifier=2, NamespaceIndex=2, NodeIdType=<NodeIdType.FourByte: 1>)) | ||||
| @@ -162,4 +162,4 @@ Here we start at the objects node an traverse via MyObject to MyVariable. Always | ||||
| mind that browsing through the nodes will create network traffic and server load. If | ||||
| you already know the NodeId using :meth:`~asyncua.client.client.Client.get_node` should | ||||
| be preferred. You might also consider caching NodeIds which you found through browsing | ||||
| to reduce the traffic.  | ||||
| to reduce the traffic. | ||||
|   | ||||
| @@ -31,5 +31,3 @@ asyncua.crypto package | ||||
|  | ||||
| Code related to permissions, security and encryption is located in the :mod:`asyncua.crypto` | ||||
| package. | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -25,7 +25,7 @@ Once the installation is completed, the package is ready to be used. To verify t | ||||
| or the report the version if you create a bugreport, the following code can be run in a python interpreter: | ||||
|  | ||||
| .. code-block:: python | ||||
|   | ||||
|  | ||||
|     import asyncua | ||||
|     print(asyncua.__version__) | ||||
|  | ||||
| @@ -33,12 +33,12 @@ or the report the version if you create a bugreport, the following code can be r | ||||
| Command Line Tools | ||||
| ================== | ||||
|  | ||||
| Alongside the package some utility command line tools are installed:  | ||||
| Alongside the package some utility command line tools are installed: | ||||
|  | ||||
| :code:`uabrowse`:  | ||||
| :code:`uabrowse`: | ||||
|     Browse OPC-UA node and print result | ||||
|  | ||||
| :code:`uacall`:  | ||||
| :code:`uacall`: | ||||
|     Call method of a node | ||||
|  | ||||
| :code:`uaclient`: | ||||
|   | ||||
| @@ -33,7 +33,7 @@ Read / Write Variables | ||||
| ====================== | ||||
|  | ||||
| To read or write a variable of an object, we first need to get the :class:`~asyncua.common.node.Node` | ||||
| of the variable. The :meth:`~asyncua.common.node.Node.get_child` method of the root node  | ||||
| of the variable. The :meth:`~asyncua.common.node.Node.get_child` method of the root node | ||||
| (which is just a regular node) is used to transform the known path to a Node. | ||||
|  | ||||
| .. note:: Using :meth:`~asyncua.common.node.Node.get_child` will perform a server request | ||||
| @@ -41,7 +41,7 @@ of the variable. The :meth:`~asyncua.common.node.Node.get_child` method of the r | ||||
|     create a lot of network traffic which is not strictly required if the node id is known. | ||||
|     If you know the node id it's better to use the :meth:`~asyncua.client.client.Client.get_node` | ||||
|     method of the client. For example :code:`client.get_node("ns=2;i=2")` or | ||||
|     :code:`client.get_node(ua.NodeId(2, 2))` could be used in the example.  | ||||
|     :code:`client.get_node(ua.NodeId(2, 2))` could be used in the example. | ||||
|     Note that the latter call is not :code:`async`! | ||||
|  | ||||
| Once we have our node object, the variable value can be read or written directly using | ||||
|   | ||||
| @@ -44,14 +44,14 @@ the server. The following session gives you an idea how the tools can be used. | ||||
|     7.599999999999997 | ||||
|     $ uaread --url=opc.tcp://127.0.0.1:4840 --path "0:Objects,2:MyObject,2:MyVariable" # By BrowsePath | ||||
|     12.199999999999996 | ||||
|      | ||||
|  | ||||
| Seems like our server is working and we can browse through the nodes, read values, ... | ||||
| So let's start working through the code! | ||||
|  | ||||
| Imports, Basic Setup & Configuration | ||||
| ==================================== | ||||
|  | ||||
| In the first few lines the relevant packages, classes and methods are imported.  | ||||
| In the first few lines the relevant packages, classes and methods are imported. | ||||
| While the :mod:`logging` module is optional (just remove all calls to the logging module), | ||||
| :mod:`asyncio` is required to actually run our main function. From the :mod:`asyncua` | ||||
| package we need the :class:`~asyncua.server.server.Server`, the :mod:`asyncua.ua` | ||||
| @@ -83,7 +83,7 @@ Creating Objects and Variables | ||||
| In the next lines, the custom object "MyObject" is created and a variable is added to this object. | ||||
| Note that by default all variables are read-only, so we need to be explicit and make it writable. | ||||
| The :meth:`~asyncua.common.node.Node.add_object` / :meth:`~asyncua.common.node.Node.add_variable` calls | ||||
| are actually just calling :meth:`~asyncua.common.manage_nodes.create_object`, respectively  | ||||
| are actually just calling :meth:`~asyncua.common.manage_nodes.create_object`, respectively | ||||
| :meth:`~asyncua.common.manage_nodes.create_variable` internally. You can find more information on | ||||
| how nodes and variables are created in the API docs of these methods. | ||||
|  | ||||
| @@ -96,7 +96,7 @@ by clients: | ||||
|  | ||||
| .. literalinclude:: ../../../examples/server-minimal.py | ||||
|     :caption: server-minimal.py, Line 8 - 11 | ||||
|     :lines: 8 - 11  | ||||
|     :lines: 8 - 11 | ||||
|  | ||||
| .. literalinclude:: ../../../examples/server-minimal.py | ||||
|     :caption: server-minimal.py, Line 30 - 36 | ||||
| @@ -114,7 +114,7 @@ Starting the Server | ||||
|     :caption: server-minimal.py, Line 37 - | ||||
|     :lines: 37 - | ||||
|  | ||||
| Using the server as a context manager with :code:`async with server: ...` allows us to  | ||||
| Using the server as a context manager with :code:`async with server: ...` allows us to | ||||
| hide starting and shutting down the server nicely. In order to keep the server alive | ||||
| a endless loop must be present. In this example the loop is also used to periodically | ||||
| update the variable in our custom object. | ||||
|   | ||||
| @@ -2,8 +2,8 @@ | ||||
| OPC-UA Basics | ||||
| ============= | ||||
|  | ||||
| .. todo:: How much should be in this chapter?  | ||||
|      | ||||
| .. todo:: How much should be in this chapter? | ||||
|  | ||||
|     Are we only going to link to external references and skip explaining the OPC-UA basics? | ||||
|     The `open62541 documentation <http://www.open62541.org/doc/master/>`_ for example | ||||
|     contains a lot of information about how OPC-UA works but in many chapters it also | ||||
| @@ -16,7 +16,7 @@ OPC-UA Basics | ||||
| External References | ||||
| =================== | ||||
|  | ||||
| .. note:: We are open to suggestions for this section!  | ||||
| .. note:: We are open to suggestions for this section! | ||||
|     You know good tutorials, help pages, blogs or other resources? Share them with us! | ||||
|  | ||||
|  | ||||
| @@ -33,4 +33,3 @@ https://www.open62541.org | ||||
| https://www.unified-automation.com | ||||
|     Unified Automation provides different products for the OPC-UA ecosystem. Most of the | ||||
|     tools are available as a free download with an evaluation license (non commercial use). | ||||
|  | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
| Usage Guide | ||||
| =========== | ||||
|  | ||||
| .. toctree::  | ||||
| .. toctree:: | ||||
|     :maxdepth: 2 | ||||
|     :caption: Get started | ||||
|  | ||||
| @@ -11,14 +11,14 @@ Usage Guide | ||||
|     get-started/minimal-server | ||||
|     get-started/minimal-client | ||||
|  | ||||
| .. toctree::  | ||||
| .. toctree:: | ||||
|     :maxdepth: 2 | ||||
|     :caption: Common | ||||
|  | ||||
|     common/overview | ||||
|     common/node-nodeid | ||||
|  | ||||
| .. toctree::  | ||||
| .. toctree:: | ||||
|     :maxdepth: 2 | ||||
|     :caption: Client | ||||
|  | ||||
| @@ -30,7 +30,7 @@ Usage Guide | ||||
|  | ||||
|     server/overview | ||||
|  | ||||
| .. toctree::  | ||||
| .. toctree:: | ||||
|     :maxdepth: 2 | ||||
|     :caption: Sync Interface | ||||
|  | ||||
|   | ||||
| @@ -1,2 +1,2 @@ | ||||
| Server Overview | ||||
| =============== | ||||
| =============== | ||||
|   | ||||
| @@ -6,4 +6,4 @@ You don't like to work with ``asyncio`` and ``async`` / ``await`` or you need to | ||||
| the package in code which is not using ``asyncio``? The :mod:`asyncua.sync` module provides | ||||
| a convenient wrapper around the client and server and provides synchronous versions of | ||||
| the node and subscription classes. This allows direct usage of the package, using the same | ||||
| interface as for ``async`` code, without writing custom wrappers. | ||||
| interface as for ``async`` code, without writing custom wrappers. | ||||
|   | ||||
| @@ -1,12 +1,12 @@ | ||||
| ## How to update the UA-Nodesets from the OPC Foundation   | ||||
| ## How to update the UA-Nodesets from the OPC Foundation | ||||
|  | ||||
| 1) Have a working internet connection (otherwise it will regenerate the old set or fail)  | ||||
| 1) Have a working internet connection (otherwise it will regenerate the old set or fail) | ||||
| 2) run update_ua_nodeset.py | ||||
| 3) That's it | ||||
|  | ||||
| Path to the .pickle file: opcua-asyncio/asyncua/binary_address_space.pickle   | ||||
| Path to the .xml Nodesets: opcua-asyncio/schemas/UA-Nodeset-master/Schema/   | ||||
| Path to the standard_address_space.py files: opcua-asyncio/asyncua/server/standard_address_space/   | ||||
| Path to the .pickle file: opcua-asyncio/asyncua/binary_address_space.pickle | ||||
| Path to the .xml Nodesets: opcua-asyncio/schemas/UA-Nodeset-master/Schema/ | ||||
| Path to the standard_address_space.py files: opcua-asyncio/asyncua/server/standard_address_space/ | ||||
|  | ||||
|  | ||||
| ##Warnings: | ||||
| @@ -16,4 +16,3 @@ Path to the standard_address_space.py files: opcua-asyncio/asyncua/server/standa | ||||
|     - our Github Discussions: https://github.com/FreeOpcUa/opcua-asyncio/discussions | ||||
|     - our Gitter Channel: https://gitter.im/FreeOpcUa/opcua-asyncio | ||||
| - in case of Bugs with the updater, please make an issue: https://github.com/FreeOpcUa/opcua-asyncio/issues | ||||
|      | ||||
| @@ -66,8 +66,8 @@ class Parser(object): | ||||
|         node = Node_struct() | ||||
|         for child in root: | ||||
|             if nodeId == child.attrib.get('NodeId'): | ||||
|                 # The xml-tag is the type of an xml-element e.g. <Reference> then tag is Reference.  | ||||
|                 # The tag also includes the namespace which needs to be removed  | ||||
|                 # The xml-tag is the type of an xml-element e.g. <Reference> then tag is Reference. | ||||
|                 # The tag also includes the namespace which needs to be removed | ||||
|                 # e.g. '{http://opcfoundation.org/UA/2011/03/UANodeSet.xsd}Reference' | ||||
|                 node.tag = child.tag.split(self.nameSpace)[1] | ||||
|                 node.browseName = str(child.attrib.get('BrowseName')) | ||||
|   | ||||
| @@ -218,7 +218,7 @@ class CodeGenerator: | ||||
| if __name__ == '__main__': | ||||
|     import generate_model_from_nodeset as gm | ||||
|  | ||||
|     xml_path = BASE_DIR.joinpath('schemas', 'UA-Nodeset-master', 'Schema', 'Opc.Ua.NodeSet2.Services.xml')  | ||||
|     xml_path = BASE_DIR.joinpath('schemas', 'UA-Nodeset-master', 'Schema', 'Opc.Ua.NodeSet2.Services.xml') | ||||
|     protocol_path = BASE_DIR.joinpath("asyncua", "ua", "uaprotocol_auto.py") | ||||
|     p = gm.Parser(xml_path) | ||||
|     model = p.parse() | ||||
|   | ||||
| @@ -74,4 +74,4 @@ | ||||
|             <opc:EnumeratedValue Name="StartSignal" Value="1" /> | ||||
|             <opc:EnumeratedValue Name="StopSignal" Value="2" /> | ||||
|          </opc:EnumeratedType> | ||||
|    </opc:TypeDictionary> | ||||
|    </opc:TypeDictionary> | ||||
|   | ||||
| @@ -51,26 +51,26 @@ | ||||
|  | ||||
|   <UAVariable NodeId="ns=1;i=30006" BrowseName="1:MyXMLVariableWithoutValue" DataType="String"> | ||||
|     <References> | ||||
|      | ||||
|  | ||||
|       <Reference ReferenceType="HasTypeDefinition">i=69</Reference> | ||||
|       <Reference ReferenceType="Organizes" IsForward="false">ns=1;i=30002</Reference> | ||||
|     </References> | ||||
|   </UAVariable> | ||||
|    | ||||
|  | ||||
|   <UADataType NodeId="ns=1;i=3008" BrowseName="1:MyCustomString"> | ||||
|     <DisplayName>MyCustomString</DisplayName> | ||||
|       <References> | ||||
|           <Reference ReferenceType="HasSubtype" IsForward="false">i=12</Reference> | ||||
|     </References> | ||||
|   </UADataType> | ||||
| 	 | ||||
|  | ||||
|   <UAVariable NodeId="ns=1;i=30007" BrowseName="1:MyCustomTypeVar" DataType="MyCustomString"> | ||||
|     <References> | ||||
|       <Reference ReferenceType="HasTypeDefinition">i=69</Reference> | ||||
|       <Reference ReferenceType="Organizes" IsForward="false">ns=1;i=30002</Reference> | ||||
|     </References> | ||||
|   </UAVariable> | ||||
|    | ||||
|  | ||||
|   <!-- test data Enumeration with EnumStrings --> | ||||
|   <UADataType NodeId="ns=1;i=3010" BrowseName="1:MyEnum"> | ||||
|         <DisplayName>MyEnum</DisplayName> | ||||
| @@ -85,7 +85,7 @@ | ||||
|             <Field Name="error" Value="2"/> | ||||
|         </Definition> | ||||
|   </UADataType> | ||||
|      | ||||
|  | ||||
|   <UAVariable DataType="LocalizedText" ParentNodeId="ns=1;i=3010" ValueRank="1" NodeId="ns=1;i=6001" ArrayDimensions="3" BrowseName="EnumStrings"> | ||||
|         <DisplayName>EnumStrings</DisplayName> | ||||
|         <References> | ||||
| @@ -107,8 +107,8 @@ | ||||
|             </uax:ListOfLocalizedText> | ||||
|         </Value> | ||||
|   </UAVariable> | ||||
|    | ||||
|   <!-- test data Enumeration with EnumValues -->   | ||||
|  | ||||
|   <!-- test data Enumeration with EnumValues --> | ||||
|   <UADataType NodeId="ns=1;i=3011" BrowseName="1:MyEnumVal"> | ||||
|         <DisplayName>MyEnumVal</DisplayName> | ||||
|         <References> | ||||
| @@ -120,7 +120,7 @@ | ||||
|             <Field Name="error" Value="4"/> | ||||
|         </Definition> | ||||
|   </UADataType> | ||||
|    | ||||
|  | ||||
|   <UAVariable DataType="EnumValueType" ParentNodeId="i=120" ValueRank="1" NodeId="ns=1;i=99002" ArrayDimensions="3" BrowseName="EnumValues1"> | ||||
|         <DisplayName>EnumValues</DisplayName> | ||||
|         <References> | ||||
| @@ -323,6 +323,6 @@ | ||||
|               </uax:ExtensionObject> | ||||
|           </uax:ListOfExtensionObject> | ||||
|       </Value> | ||||
|   </UAVariable>     | ||||
|        | ||||
|   </UAVariable> | ||||
|  | ||||
| </UANodeSet> | ||||
|   | ||||
| @@ -135,7 +135,7 @@ | ||||
|         <DisplayName>MyBaseObject</DisplayName> | ||||
|         <References> | ||||
|             <Reference ReferenceType="Organizes" IsForward="false">i=85</Reference> | ||||
|             <Reference ReferenceType="HasComponent">ns=1;i=6001</Reference>             | ||||
|             <Reference ReferenceType="HasComponent">ns=1;i=6001</Reference> | ||||
|         </References> | ||||
|    </UAObject> | ||||
|    <UAVariable DataType="Int32" ParentNodeId="ns=1;i=5002" NodeId="ns=1;i=6001" BrowseName="1:MyVar"> | ||||
| @@ -147,5 +147,5 @@ | ||||
|        <Value> | ||||
|            <uax:Int32>0</uax:Int32> | ||||
|        </Value> | ||||
|    </UAVariable>     | ||||
|    </UAVariable> | ||||
| </UANodeSet> | ||||
|   | ||||
| @@ -137,7 +137,7 @@ | ||||
|         <DisplayName>MyBaseObject</DisplayName> | ||||
|         <References> | ||||
|             <Reference ReferenceType="HasComponent" IsForward="false">ns=2;i=5002</Reference> | ||||
|             <Reference ReferenceType="HasComponent">ns=1;i=6001</Reference>             | ||||
|             <Reference ReferenceType="HasComponent">ns=1;i=6001</Reference> | ||||
|         </References> | ||||
|    </UAObject> | ||||
|    <UAVariable DataType="Int32" ParentNodeId="ns=1;i=5002" NodeId="ns=1;i=6001" BrowseName="1:MySecondLevelVar"> | ||||
| @@ -149,5 +149,5 @@ | ||||
|        <Value> | ||||
|            <Int32>0</Int32> | ||||
|        </Value> | ||||
|    </UAVariable>     | ||||
|    </UAVariable> | ||||
| </UANodeSet> | ||||
|   | ||||
| @@ -150,5 +150,5 @@ | ||||
|        <Value> | ||||
|            <uax:Int32>0</uax:Int32> | ||||
|        </Value> | ||||
|    </UAVariable>     | ||||
|    </UAVariable> | ||||
| </UANodeSet> | ||||
|   | ||||
| @@ -141,10 +141,10 @@ | ||||
|         <DisplayName>MyBaseObject</DisplayName> | ||||
|         <References> | ||||
|             <Reference ReferenceType="HasComponent" IsForward="false">ns=3;i=5002</Reference> | ||||
|             <Reference ReferenceType="HasComponent">ns=1;i=6001</Reference>             | ||||
|             <Reference ReferenceType="HasComponent">ns=1;i=6001</Reference> | ||||
|         </References> | ||||
|    </UAObject> | ||||
|           | ||||
|  | ||||
|    <UAVariable DataType="Int32" ParentNodeId="ns=1;i=5002" NodeId="ns=1;i=6001" BrowseName="1:MyForthLevelVar"> | ||||
|        <DisplayName>MyVar</DisplayName> | ||||
|        <References> | ||||
| @@ -154,5 +154,5 @@ | ||||
|        <Value> | ||||
|            <uax:Int32>0</uax:Int32> | ||||
|        </Value> | ||||
|    </UAVariable>     | ||||
|    </UAVariable> | ||||
| </UANodeSet> | ||||
|   | ||||
| @@ -234,4 +234,4 @@ | ||||
|     <opc:Field Name="VariantDataType" TypeName="ua:Variant" LengthField="NoOfVariantDataType" /> | ||||
|   </opc:StructuredType> | ||||
|  | ||||
| </opc:TypeDictionary> | ||||
| </opc:TypeDictionary> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ from pathlib import Path | ||||
| logging.basicConfig(level=logging.DEBUG) | ||||
| sys.path.append(f'{Path(__file__).parent.parent}') | ||||
|  | ||||
| from asyncua.tools import uaserver | ||||
| from asyncua.tools import uaserver # noqa: E402 | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|     uaserver() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Roman Yurchak
					Roman Yurchak