Replies: 1 comment
-
You have to match the correct datatype. To do this we have types:
A example how to use:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When I run this Script I keep getting the mismatch error. Any insights? New to this. Thanks in advance!
`import logging
import asyncio
import pandas as pd
import nest_asyncio
from asyncua import ua, Server
from asyncua.common.methods import uamethod
logging.basicConfig(level=logging.INFO)
_logger = logging.getLogger('asyncua')
@uamethod
def func(parent, value):
return value * 2
async def main():
# setup our server
server = Server()
await server.init()
server.set_endpoint('opc.tcp://127.0.0.1:4843/opcua/')
server.set_server_name("DevNet OPC-UA Test Server")
if name == 'main':
#python 3.6 or lower
loop = asyncio.get_event_loop() #- deprecated
loop.run_until_complete(main())
nest_asyncio.apply()
OUTPUT FROM CODE:
INFO:asyncua.server.internal_server:No user manager specified. Using default permissive manager instead.
INFO:asyncua.server.internal_session:Created internal session Internal
INFO:asyncua.server.address_space:add_node: while adding node NumericNodeId(Identifier=15957, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>), requested parent node NumericNodeId(Identifier=11715, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>) does not exists
INFO:asyncua.server.address_space:add_node: while adding node NumericNodeId(Identifier=15958, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>), requested parent node NumericNodeId(Identifier=15957, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>) does not exists
INFO:asyncua.server.address_space:add_node: while adding node NumericNodeId(Identifier=15959, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>), requested parent node NumericNodeId(Identifier=15957, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>) does not exists
INFO:asyncua.server.address_space:add_node: while adding node NumericNodeId(Identifier=15960, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>), requested parent node NumericNodeId(Identifier=15957, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>) does not exists
INFO:asyncua.server.address_space:add_node: while adding node NumericNodeId(Identifier=15961, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>), requested parent node NumericNodeId(Identifier=15957, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>) does not exists
INFO:asyncua.server.address_space:add_node: while adding node NumericNodeId(Identifier=15962, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>), requested parent node NumericNodeId(Identifier=15957, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>) does not exists
INFO:asyncua.server.address_space:add_node: while adding node NumericNodeId(Identifier=15963, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>), requested parent node NumericNodeId(Identifier=15957, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>) does not exists
INFO:asyncua.server.address_space:add_node: while adding node NumericNodeId(Identifier=15964, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>), requested parent node NumericNodeId(Identifier=15957, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>) does not exists
INFO:asyncua.server.address_space:add_node: while adding node NumericNodeId(Identifier=16134, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>), requested parent node NumericNodeId(Identifier=15957, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>) does not exists
INFO:asyncua.server.address_space:add_node: while adding node NumericNodeId(Identifier=16135, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>), requested parent node NumericNodeId(Identifier=15957, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>) does not exists
INFO:asyncua.server.address_space:add_node: while adding node NumericNodeId(Identifier=16136, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>), requested parent node NumericNodeId(Identifier=15957, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>) does not exists
INFO:asyncua:Starting server!
WARNING:asyncua.server.server:Endpoints other than open requested but private key and certificate are not set.
INFO:asyncua.server.internal_server:starting internal server
INFO:asyncua.server.binary_server_asyncio:Listening on 127.0.0.1:4843
WARNING:asyncua.server.address_space:Write refused: Variant: Variant(Value=46.31076, VariantType=<VariantType.Double: 11>, Dimensions=None, is_array=False) with type VariantType.Double does not have expected type: VariantType.Int64
INFO:asyncua.server.binary_server_asyncio:Closing asyncio socket server
INFO:asyncua.server.internal_server:stopping internal server
INFO:asyncua.server.internal_session:close session Internal
INFO:asyncua.server.subscription_service:delete subscriptions: []
Traceback (most recent call last):
File "C:\Users\andyc.vscode\CNC.venv\opc-ua-sensor-simulator\opc-ua-server-copy.py", line 71, in
asyncio.run(main())
File "C:\Users\andyc\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\andyc\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\andyc\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 684, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\andyc.vscode\CNC.venv\opc-ua-sensor-simulator\opc-ua-server-copy.py", line 58, in main
await var_temperature.write_value(float(row[1]))
File "C:\Users\andyc.vscode\CNC.venv\Lib\site-packages\asyncua\common\node.py", line 269, in write_value
await self.write_attribute(ua.AttributeIds.Value, dv)
File "C:\Users\andyc.vscode\CNC.venv\Lib\site-packages\asyncua\common\node.py", line 323, in write_attribute
result[0].check()
File "C:\Users\andyc.vscode\CNC.venv\Lib\site-packages\asyncua\ua\uatypes.py", line 375, in check
raise UaStatusCodeError(self.value)
asyncua.ua.uaerrors._auto.BadTypeMismatch: The value supplied for the attribute is not of the same type as the attribute"s value.(BadTypeMismatch)
Beta Was this translation helpful? Give feedback.
All reactions