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
13fb1e80
Commit
13fb1e80
authored
Mar 19, 2015
by
Olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: fixe subs default values, work with prosys server
parent
aaaa08e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
7 deletions
+12
-7
opcua/binary_client.py
opcua/binary_client.py
+7
-6
opcua/client.py
opcua/client.py
+1
-1
opcua/subscription.py
opcua/subscription.py
+4
-0
No files found.
opcua/binary_client.py
View file @
13fb1e80
...
...
@@ -47,12 +47,12 @@ class BinaryClient(object):
self
.
_thread
=
Thread
(
target
=
self
.
_run
)
self
.
_thread
.
start
()
def
_send_request
(
self
,
request
,
callback
=
None
):
def
_send_request
(
self
,
request
,
callback
=
None
,
timeout
=
1000
):
#HACK to make sure we can convert our request to binary before increasing request counter etc ...
request
.
to_binary
()
#END HACK
with
self
.
_lock
:
request
.
RequestHeader
=
self
.
_create_request_header
()
request
.
RequestHeader
=
self
.
_create_request_header
(
timeout
)
hdr
=
ua
.
Header
(
ua
.
MessageType
.
SecureMessage
,
ua
.
ChunkType
.
Single
,
self
.
_security_token
.
ChannelId
)
symhdr
=
self
.
_create_sym_algo_header
()
seqhdr
=
self
.
_create_sequence_header
()
...
...
@@ -147,14 +147,14 @@ class BinaryClient(object):
alle
.
append
(
data
)
alle
.
insert
(
0
,
hdr
.
to_binary
())
alle
=
b""
.
join
(
alle
)
self
.
_socket
.
send
(
alle
)
self
.
_socket
.
send
all
(
alle
)
def
_create_request_header
(
self
):
def
_create_request_header
(
self
,
timeout
=
1000
):
hdr
=
ua
.
RequestHeader
()
hdr
.
AuthenticationToken
=
self
.
_authentication_token
self
.
_request_handle
+=
1
hdr
.
RequestHandle
=
self
.
_request_handle
hdr
.
TimeoutHint
=
10000
hdr
.
TimeoutHint
=
timeout
return
hdr
def
_create_sym_algo_header
(
self
):
...
...
@@ -177,6 +177,7 @@ class BinaryClient(object):
"""
self
.
logger
.
info
(
"opening connection"
)
self
.
_socket
=
socket
.
create_connection
((
host
,
port
))
self
.
_socket
.
setsockopt
(
socket
.
IPPROTO_TCP
,
socket
.
TCP_NODELAY
,
1
)
#nodelay ncessary to avoid packing in one frame, some servers do not like it
self
.
start
()
def
disconnect_socket
(
self
):
...
...
@@ -332,7 +333,7 @@ class BinaryClient(object):
acks
=
[]
request
=
ua
.
PublishRequest
()
request
.
SubscriptionAcknowledgements
=
acks
self
.
_send_request
(
request
,
self
.
_call_publish_callback
)
self
.
_send_request
(
request
,
self
.
_call_publish_callback
,
timeout
=
0
)
def
_call_publish_callback
(
self
,
rcall
):
self
.
logger
.
info
(
"call_publish_callback"
)
...
...
opcua/client.py
View file @
13fb1e80
...
...
@@ -209,7 +209,7 @@ class Client(object):
params
.
RequestedPublishingInterval
=
period
params
.
RequestedLifetimeCount
=
3000
params
.
RequestedMaxKeepAliveCount
=
10000
params
.
MaxNotificationsPerPublish
=
0
params
.
MaxNotificationsPerPublish
=
4294967295
params
.
PublishingEnabled
=
True
params
.
Priority
=
0
return
Subscription
(
self
.
bclient
,
params
,
handler
)
...
...
opcua/subscription.py
View file @
13fb1e80
...
...
@@ -74,14 +74,18 @@ class Subscription(object):
self
.
_client_handle
+=
1
mparams
.
ClientHandle
=
self
.
_client_handle
mparams
.
SamplingInterval
=
self
.
parameters
.
RequestedPublishingInterval
mparams
.
QueueSize
=
1
mparams
.
DiscardOldest
=
True
mir
=
ua
.
MonitoredItemCreateRequest
()
mir
.
ItemToMonitor
=
rv
mir
.
MonitoringMode
=
ua
.
MonitoringMode
.
Reporting
mir
.
RequestedParameters
=
mparams
params
=
ua
.
CreateMonitoredItemsParameters
()
params
.
SubscriptionId
=
self
.
subscription_id
params
.
ItemsToCreate
.
append
(
mir
)
params
.
TimestampsToReturn
=
ua
.
TimestampsToReturn
.
Neither
results
=
self
.
server
.
create_monitored_items
(
params
)
result
=
results
[
0
]
...
...
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