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
3fa5c055
Commit
3fa5c055
authored
Jan 24, 2016
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BinaryClient -> UaClient
parent
443f8518
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
22 deletions
+22
-22
examples/example-client_deleting.py
examples/example-client_deleting.py
+1
-1
opcua/client/client.py
opcua/client/client.py
+19
-19
opcua/client/ua_client.py
opcua/client/ua_client.py
+1
-1
tests/tests.py
tests/tests.py
+1
-1
No files found.
examples/example-client_deleting.py
View file @
3fa5c055
...
...
@@ -91,7 +91,7 @@ if __name__ == "__main__":
deletenode
=
ua
.
DeleteNodesItem
()
deletenode
.
NodeId
=
obj
.
get_child
([
"2:MyVariable"
]).
nodeid
deletenode
.
DeleteTargetReferences
=
True
results
=
client
.
b
client
.
delete_nodes
([
deletenode
])
results
=
client
.
ua
client
.
delete_nodes
([
deletenode
])
results
[
0
].
check
()
print
(
"Children of MyObject are: "
,
obj
.
get_children
())
print
(
"myvar should disapear"
)
...
...
opcua/client/client.py
View file @
3fa5c055
...
...
@@ -7,7 +7,7 @@ except ImportError: # support for python2
from
urlparse
import
urlparse
from
opcua
import
ua
from
opcua.client.
binary_client
import
Binary
Client
from
opcua.client.
ua_client
import
Ua
Client
from
opcua.common.node
import
Node
from
opcua.common.subscription
import
Subscription
from
opcua.common
import
utils
...
...
@@ -65,7 +65,7 @@ class Client(object):
This class makes it easy to connect and browse address space.
It attemps to expose as much functionality as possible
but if you want to do to special things you will probably need
to work with the
BinaryClient object, available as self.b
client
to work with the
UaClient object, available as self.ua
client
which offers a raw OPC-UA interface.
"""
...
...
@@ -90,7 +90,7 @@ class Client(object):
self
.
secure_channel_timeout
=
self
.
default_timeout
self
.
session_timeout
=
self
.
default_timeout
self
.
_policy_ids
=
[]
self
.
bclient
=
Binary
Client
(
timeout
)
self
.
uaclient
=
Ua
Client
(
timeout
)
self
.
user_certificate
=
None
self
.
user_private_key
=
None
self
.
_session_counter
=
1
...
...
@@ -147,7 +147,7 @@ class Client(object):
cert
=
uacrypto
.
load_certificate
(
certificate_path
)
pk
=
uacrypto
.
load_private_key
(
private_key_path
)
self
.
security_policy
=
policy
(
server_cert
,
cert
,
pk
,
mode
)
self
.
b
client
.
set_security
(
self
.
security_policy
)
self
.
ua
client
.
set_security
(
self
.
security_policy
)
def
load_client_certificate
(
self
,
path
):
"""
...
...
@@ -218,16 +218,16 @@ class Client(object):
"""
connect to socket defined in url
"""
self
.
b
client
.
connect_socket
(
self
.
server_url
.
hostname
,
self
.
server_url
.
port
)
self
.
ua
client
.
connect_socket
(
self
.
server_url
.
hostname
,
self
.
server_url
.
port
)
def
disconnect_socket
(
self
):
self
.
b
client
.
disconnect_socket
()
self
.
ua
client
.
disconnect_socket
()
def
send_hello
(
self
):
"""
Send OPC-UA hello to server
"""
ack
=
self
.
b
client
.
send_hello
(
self
.
server_url
.
geturl
())
ack
=
self
.
ua
client
.
send_hello
(
self
.
server_url
.
geturl
())
# FIXME check ack
def
open_secure_channel
(
self
,
renew
=
False
):
...
...
@@ -243,17 +243,17 @@ class Client(object):
params
.
RequestedLifetime
=
self
.
secure_channel_timeout
nonce
=
utils
.
create_nonce
(
self
.
security_policy
.
symmetric_key_size
)
# length should be equal to the length of key of symmetric encryption
params
.
ClientNonce
=
nonce
# this nonce is used to create a symmetric key
result
=
self
.
b
client
.
open_secure_channel
(
params
)
result
=
self
.
ua
client
.
open_secure_channel
(
params
)
self
.
security_policy
.
make_symmetric_key
(
nonce
,
result
.
ServerNonce
)
self
.
secure_channel_timeout
=
result
.
SecurityToken
.
RevisedLifetime
def
close_secure_channel
(
self
):
return
self
.
b
client
.
close_secure_channel
()
return
self
.
ua
client
.
close_secure_channel
()
def
get_endpoints
(
self
):
params
=
ua
.
GetEndpointsParameters
()
params
.
EndpointUrl
=
self
.
server_url
.
geturl
()
return
self
.
b
client
.
get_endpoints
(
params
)
return
self
.
ua
client
.
get_endpoints
(
params
)
def
register_server
(
self
,
server
,
discovery_configuration
=
None
):
"""
...
...
@@ -271,9 +271,9 @@ class Client(object):
params
=
ua
.
RegisterServer2Parameters
()
params
.
Server
=
serv
params
.
DiscoveryConfiguration
=
discovery_configuration
return
self
.
b
client
.
register_server2
(
params
)
return
self
.
ua
client
.
register_server2
(
params
)
else
:
return
self
.
b
client
.
register_server
(
serv
)
return
self
.
ua
client
.
register_server
(
serv
)
def
find_servers
(
self
,
uris
=
None
):
"""
...
...
@@ -286,11 +286,11 @@ class Client(object):
params
=
ua
.
FindServersParameters
()
params
.
EndpointUrl
=
self
.
server_url
.
geturl
()
params
.
ServerUris
=
uris
return
self
.
b
client
.
find_servers
(
params
)
return
self
.
ua
client
.
find_servers
(
params
)
def
find_servers_on_network
(
self
):
params
=
ua
.
FindServersOnNetworkParameters
()
return
self
.
b
client
.
find_servers_on_network
(
params
)
return
self
.
ua
client
.
find_servers_on_network
(
params
)
def
create_session
(
self
):
desc
=
ua
.
ApplicationDescription
()
...
...
@@ -308,7 +308,7 @@ class Client(object):
params
.
SessionName
=
self
.
description
+
" Session"
+
str
(
self
.
_session_counter
)
params
.
RequestedSessionTimeout
=
3600000
params
.
MaxResponseMessageSize
=
0
# means no max size
response
=
self
.
b
client
.
create_session
(
params
)
response
=
self
.
ua
client
.
create_session
(
params
)
self
.
security_policy
.
asymmetric_cryptography
.
verify
(
self
.
security_policy
.
client_certificate
+
nonce
,
response
.
ServerSignature
.
Signature
)
self
.
_server_nonce
=
response
.
ServerNonce
if
not
self
.
security_policy
.
server_certificate
:
...
...
@@ -368,7 +368,7 @@ class Client(object):
params
.
UserIdentityToken
.
Password
=
data
params
.
UserIdentityToken
.
PolicyId
=
self
.
server_policy_id
(
ua
.
UserTokenType
.
UserName
,
b"username_basic256"
)
params
.
UserIdentityToken
.
EncryptionAlgorithm
=
'http://www.w3.org/2001/04/xmlenc#rsa-oaep'
return
self
.
b
client
.
activate_session
(
params
)
return
self
.
ua
client
.
activate_session
(
params
)
def
close_session
(
self
):
"""
...
...
@@ -376,7 +376,7 @@ class Client(object):
"""
if
self
.
keepalive
:
self
.
keepalive
.
stop
()
return
self
.
b
client
.
close_session
(
True
)
return
self
.
ua
client
.
close_session
(
True
)
def
get_root_node
(
self
):
return
self
.
get_node
(
ua
.
TwoByteNodeId
(
ua
.
ObjectIds
.
RootFolder
))
...
...
@@ -391,7 +391,7 @@ class Client(object):
"""
Get node using NodeId object or a string representing a NodeId
"""
return
Node
(
self
.
b
client
,
nodeid
)
return
Node
(
self
.
ua
client
,
nodeid
)
def
create_subscription
(
self
,
period
,
handler
):
"""
...
...
@@ -412,7 +412,7 @@ class Client(object):
params
.
MaxNotificationsPerPublish
=
10000
params
.
PublishingEnabled
=
True
params
.
Priority
=
0
return
Subscription
(
self
.
b
client
,
params
,
handler
)
return
Subscription
(
self
.
ua
client
,
params
,
handler
)
def
get_namespace_array
(
self
):
ns_node
=
self
.
get_node
(
ua
.
NodeId
(
ua
.
ObjectIds
.
Server_NamespaceArray
))
...
...
opcua/client/
binary
_client.py
→
opcua/client/
ua
_client.py
View file @
3fa5c055
...
...
@@ -178,7 +178,7 @@ class UASocketClient(object):
# some servers send a response here, most do not ... so we ignore
class
Binary
Client
(
object
):
class
Ua
Client
(
object
):
"""
low level OPC-UA client.
...
...
tests/tests.py
View file @
3fa5c055
...
...
@@ -1074,7 +1074,7 @@ class AdminTestClient(unittest.TestCase, CommonTests):
request
=
ua
.
ReadRequest
()
request
.
TypeId
=
ua
.
FourByteNodeId
(
999
)
# bad type!
with
self
.
assertRaises
(
ua
.
UaStatusCodeError
):
self
.
clt
.
b
client
.
_uasocket
.
send_request
(
request
)
self
.
clt
.
ua
client
.
_uasocket
.
send_request
(
request
)
def
test_objects_anonymous
(
self
):
objects
=
self
.
ro_clt
.
get_objects_node
()
...
...
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