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
7c15fc91
Commit
7c15fc91
authored
Dec 26, 2015
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new method for datachange notification in handler
parent
68b0ec39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
4 deletions
+49
-4
opcua/subscription.py
opcua/subscription.py
+49
-4
No files found.
opcua/subscription.py
View file @
7c15fc91
"""
high level interface to subscriptions
"""
import
io
import
time
import
logging
from
threading
import
Lock
...
...
@@ -13,15 +12,41 @@ from opcua import AttributeIds
#from opcua import Event
class
EventResult
():
class
SubHandler
(
object
):
"""
Subscription Handler. To receive events from server for a subscription
This class is just a sample class. Whatever class having these methods can be used
"""
def
data_change
(
self
,
handle
,
node
,
val
,
attr
):
"""
Deprecated, use datachange_notification
"""
pass
def
datachange_notification
(
self
,
node
,
val
,
data
):
"""
called for every datachange notfication from server
"""
pass
def
event
(
self
,
handle
,
event
):
"""
called for every event notfication from server
"""
pass
class
EventResult
():
def
__str__
(
self
):
return
"EventResult({})"
.
format
([
str
(
k
)
+
":"
+
str
(
v
)
for
k
,
v
in
self
.
__dict__
.
items
()])
__repr__
=
__str__
class
SubscriptionItemData
():
"""
To store usefull data from a monitored item
"""
def
__init__
(
self
):
self
.
node
=
None
self
.
client_handle
=
None
...
...
@@ -30,6 +55,19 @@ class SubscriptionItemData():
self
.
mfilter
=
None
class
DataChangeNotif
():
"""
To be send to clients for every notification from server
"""
def
__init__
(
self
,
subscription_data
,
monitored_item
):
self
.
monitored_item
=
monitored_item
self
.
subscription_data
=
subscription_data
def
__str__
(
self
):
return
"DataChangeNotfication({}, {})"
.
format
(
self
.
suscription_data
,
self
.
monitored_item
)
__repr__
=
__str__
class
Subscription
(
object
):
"""
Subscription object returned by Server or Client objects.
...
...
@@ -88,7 +126,14 @@ class Subscription(object):
continue
data
=
self
.
_monitoreditems_map
[
item
.
ClientHandle
]
try
:
self
.
_handler
.
data_change
(
data
.
server_handle
,
data
.
node
,
item
.
Value
.
Value
.
Value
,
data
.
attribute
)
if
hasattr
(
self
.
_handler
,
"datachange_notification"
):
event_data
=
DataChangeNotif
(
data
,
item
)
self
.
_handler
.
datachange_notification
(
data
.
node
,
item
.
Value
.
Value
.
Value
,
event_data
)
elif
hasattr
(
self
.
_handler
,
"data_change"
):
self
.
logger
.
warning
(
"data_change method is deprecated, use datavalue_changed"
)
self
.
_handler
.
data_change
(
data
.
server_handle
,
data
.
node
,
item
.
Value
.
Value
.
Value
,
data
.
attribute
)
else
:
self
.
logger
.
error
(
"DataChange subscription created but handler has no datachange_notification method"
)
except
Exception
:
self
.
logger
.
exception
(
"Exception calling data change handler"
)
...
...
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