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
b756f0ab
Commit
b756f0ab
authored
May 13, 2016
by
joaovitor8
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify Monitored Item function and Deadband Monitor in the client side
parent
3b749590
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
opcua/client/ua_client.py
opcua/client/ua_client.py
+11
-0
opcua/common/subscription.py
opcua/common/subscription.py
+42
-0
No files found.
opcua/client/ua_client.py
View file @
b756f0ab
...
@@ -477,3 +477,14 @@ class UaClient(object):
...
@@ -477,3 +477,14 @@ class UaClient(object):
self
.
logger
.
debug
(
response
)
self
.
logger
.
debug
(
response
)
response
.
ResponseHeader
.
ServiceResult
.
check
()
response
.
ResponseHeader
.
ServiceResult
.
check
()
return
response
.
Results
return
response
.
Results
def
modify_monitored_item_low
(
self
,
params
):
self
.
logger
.
info
(
"modify_monitored_items"
)
request
=
ua
.
ModifyMonitoredItemsRequest
()
request
.
Parameters
=
params
data
=
self
.
_uasocket
.
send_request
(
request
)
response
=
ua
.
ModifyMonitoredItemsResponse
.
from_binary
(
data
)
self
.
logger
.
debug
(
response
)
response
.
ResponseHeader
.
ServiceResult
.
check
()
return
response
.
Results
opcua/common/subscription.py
View file @
b756f0ab
...
@@ -272,4 +272,46 @@ class Subscription(object):
...
@@ -272,4 +272,46 @@ class Subscription(object):
del
(
self
.
_monitoreditems_map
[
k
])
del
(
self
.
_monitoreditems_map
[
k
])
return
return
def
modify_monitored_item
(
self
,
handle
,
new_samp_time
,
new_queuesize
=
0
,
mod_filter
=
None
):
"""
Modify a monitored item.
:param handle: Handle returned when originally subscribing
:param new_samp_time: New wanted sample time
:param new_queuesize: New wanted queuesize, default is 0
:param mod_filter: New wanted filter, default is None
:return: Return a Modify Monitored Item Result
"""
modif_item
=
ua
.
MonitoredItemModifyRequest
()
modif_item
.
MonitoredItemId
=
handle
modif_item
.
RequestedParameters
=
self
.
_modify_monitored_item_request
(
new_queuesize
,
new_samp_time
,
mod_filter
)
params
=
ua
.
ModifyMonitoredItemsParameters
()
params
.
SubscriptionId
=
self
.
subscription_id
params
.
ItemsToModify
.
append
(
modif_item
)
results
=
self
.
server
.
modify_monitored_items
(
params
)
return
results
def
_modify_monitored_item_request
(
self
,
new_queuesize
,
new_samp_time
,
mod_filter
):
req_params
=
ua
.
MonitoringParameters
()
with
self
.
_lock
:
req_params
.
ClientHandle
=
self
.
_client_handle
req_params
.
QueueSize
=
new_queuesize
req_params
.
Filter
=
mod_filter
req_params
.
SamplingInterval
=
new_samp_time
return
req_params
def
deadband_monitor
(
self
,
var
,
deadband_val
,
deadbandtype
=
1
,
queuesize
=
0
,
attr
=
ua
.
AttributeIds
.
Value
):
"""
Function to create a subscription with a Deadband Value.
Default deadband value type is absolute.
Return a handle which can be used to unsubscribe
:param var: Variable to which you want to subscribe
:param deadband_val: Absolute float value
:param deadbandtype: Default value is 1 (absolute), change to 2 for percentage deadband
:param queuesize: Wanted queue size, default is 1
"""
deadband_filter
=
ua
.
DataChangeFilter
()
deadband_filter
.
Trigger
=
DataChangeTrigger
(
1
)
# send notification when status or value change
deadband_filter
.
DeadbandType
=
deadbandtype
deadband_filter
.
DeadbandValue
=
deadband_val
# absolute float value or from 0 to 100 for percentage deadband
return
self
.
_subscribe
(
var
,
attr
,
deadband_filter
,
queuesize
)
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