Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
bb2d2633
Commit
bb2d2633
authored
Mar 20, 2015
by
Olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: add add_nodes method
parent
13fb1e80
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
opcua/binary_client.py
opcua/binary_client.py
+9
-0
opcua/binary_server.py
opcua/binary_server.py
+16
-4
opcua/node.py
opcua/node.py
+2
-2
No files found.
opcua/binary_client.py
View file @
bb2d2633
...
...
@@ -353,5 +353,14 @@ class BinaryClient(object):
response
.
ResponseHeader
.
ServiceResult
.
check
()
return
response
.
Results
def
add_nodes
(
self
,
nodestoadd
):
self
.
logger
.
info
(
"add_nodes"
)
request
=
ua
.
AddNodesRequest
()
request
.
Parameters
.
NodesToAdd
=
nodestoadd
data
=
self
.
_send_request
(
request
)
response
=
ua
.
AddNodesResponse
.
from_binary
(
data
)
response
.
ResponseHeader
.
ServiceResult
.
check
()
return
response
.
Results
opcua/binary_server.py
View file @
bb2d2633
...
...
@@ -51,7 +51,7 @@ class UAHandler(socketserver.BaseRequestHandler):
try
:
processor
.
loop
()
except
ua
.
SocketClosedException
as
ex
:
logger
.
warn
(
"Client has closed connection
"
)
logger
.
warn
(
"Client has closed connection
: %s"
,
ex
)
class
ThreadingTCPServer
(
socketserver
.
ThreadingMixIn
,
socketserver
.
TCPServer
):
...
...
@@ -128,7 +128,6 @@ class UAProcessor(object):
self
.
channel
=
self
.
iserver
.
open_secure_channel
(
request
.
Parameters
,
self
.
channel
)
#send response
hdr
=
ua
.
Header
(
ua
.
MessageType
.
SecureOpen
,
ua
.
ChunkType
.
Single
,
self
.
channel
.
SecurityToken
.
TokenId
)
response
=
ua
.
OpenSecureChannelResponse
()
response
.
Parameters
=
self
.
channel
self
.
send_response
(
request
.
RequestHeader
.
RequestHandle
,
algohdr
,
seqhdr
,
response
,
ua
.
MessageType
.
SecureOpen
)
...
...
@@ -145,13 +144,13 @@ class UAProcessor(object):
elif
header
.
MessageType
==
ua
.
MessageType
.
SecureMessage
:
algohdr
=
ua
.
SymmetricAlgorithmHeader
.
from_binary
(
body
)
seqhdr
=
ua
.
SequenceHeader
.
from_binary
(
body
)
self
.
process_message
(
header
,
algohdr
,
seqhdr
,
body
)
self
.
process_message
(
algohdr
,
seqhdr
,
body
)
else
:
self
.
logger
.
warn
(
"Unsupported message type: %s"
,
header
.
MessageType
)
return
True
def
process_message
(
self
,
hdr
,
algohdr
,
seqhdr
,
body
):
def
process_message
(
self
,
algohdr
,
seqhdr
,
body
):
typeid
=
ua
.
NodeId
.
from_binary
(
body
)
requesthdr
=
ua
.
RequestHeader
.
from_binary
(
body
)
if
typeid
==
ua
.
NodeId
(
ua
.
ObjectIds
.
CreateSessionRequest_Encoding_DefaultBinary
):
...
...
@@ -235,6 +234,19 @@ class UAProcessor(object):
self
.
send_response
(
requesthdr
.
RequestHandle
,
algohdr
,
seqhdr
,
response
)
elif
typeid
==
ua
.
NodeId
(
ua
.
ObjectIds
.
AddNodesRequest_Encoding_DefaultBinary
):
self
.
logger
.
info
(
"add nodes request"
)
params
=
ua
.
AddNodesParameters
.
from_binary
(
body
)
results
=
self
.
iserver
.
add_nodes
(
params
.
NodesToAdd
)
response
=
ua
.
AddNodesResponse
()
response
.
Results
=
results
self
.
send_response
(
requesthdr
.
RequestHandle
,
algohdr
,
seqhdr
,
response
)
else
:
self
.
logger
.
warn
(
"Uknown message received %s"
,
typeid
)
...
...
opcua/node.py
View file @
bb2d2633
...
...
@@ -190,10 +190,10 @@ class Node(object):
node
.
ParentNodeId
=
self
.
nodeid
if
isproperty
:
node
.
ReferenceTypeId
=
ua
.
NodeId
(
ua
.
ObjectIds
.
HasProperty
)
node
.
TypeDefinition
=
ua
.
NodeId
(
ua
.
ObjectIds
.
PropertyType
)
node
.
TypeDefinition
=
ua
.
NodeId
(
ua
.
ObjectIds
.
PropertyType
)
else
:
node
.
ReferenceTypeId
=
ua
.
NodeId
(
ua
.
ObjectIds
.
HasComponent
)
node
.
TypeDefinition
=
ua
.
NodeId
(
ua
.
ObjectIds
.
BaseDataVariableType
)
node
.
TypeDefinition
=
ua
.
NodeId
(
ua
.
ObjectIds
.
BaseDataVariableType
)
attrs
=
ua
.
VariableAttributes
()
attrs
.
Description
=
ua
.
LocalizedText
(
qname
.
Name
)
attrs
.
DisplayName
=
ua
.
LocalizedText
(
qname
.
Name
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment