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
fbf1f8dc
Commit
fbf1f8dc
authored
May 21, 2016
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update prosys example client for events
parent
16db1975
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
examples/client_to_prosys_events.py
examples/client_to_prosys_events.py
+44
-0
No files found.
examples/client_to_prosys_events.py
0 → 100644
View file @
fbf1f8dc
import
sys
sys
.
path
.
insert
(
0
,
".."
)
import
logging
from
opcua
import
Client
from
opcua
import
ua
from
IPython
import
embed
class
SubHandler
(
object
):
"""
Subscription Handler. To receive events from server for a subscription
"""
def
datachange_notification
(
self
,
node
,
val
,
data
):
print
(
"Python: New data change event"
,
node
,
val
)
def
event_notification
(
self
,
event
):
print
(
"Python: New event"
,
event
.
EventType
)
if
__name__
==
"__main__"
:
#from IPython import embed
logging
.
basicConfig
(
level
=
logging
.
WARN
)
client
=
Client
(
"opc.tcp://localhost:53530/OPCUA/SimulationServer/"
)
#client = Client("opc.tcp://olivier:olivierpass@localhost:53530/OPCUA/SimulationServer/")
try
:
client
.
connect
()
root
=
client
.
get_root_node
()
print
(
"Root is"
,
root
)
handler
=
SubHandler
()
sub
=
client
.
create_subscription
(
500
,
handler
)
handle
=
sub
.
subscribe_events
(
evtype
=
2788
)
# refresh server condition to force generation of events
cond
=
root
.
get_child
([
"0:Types"
,
"0:EventTypes"
,
"0:BaseEventType"
,
"0:ConditionType"
])
cond
.
call_method
(
"0:ConditionRefresh"
,
ua
.
Variant
(
sub
.
subscription_id
,
ua
.
VariantType
.
UInt32
))
embed
()
finally
:
client
.
disconnect
()
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