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
d538b57a
Commit
d538b57a
authored
May 03, 2016
by
ORD
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #177 from iirob/master
Event implementation moved to server
parents
94390d6e
e722031b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
27 deletions
+25
-27
opcua/__init__.py
opcua/__init__.py
+1
-1
opcua/common/subscription.py
opcua/common/subscription.py
+18
-2
opcua/server/event.py
opcua/server/event.py
+0
-18
opcua/server/server.py
opcua/server/server.py
+1
-1
tests/tests_common.py
tests/tests_common.py
+2
-2
tests/tests_server.py
tests/tests_server.py
+3
-3
No files found.
opcua/__init__.py
View file @
d538b57a
...
...
@@ -10,10 +10,10 @@ Pure Python OPC-UA library
from
opcua.common.node
import
Node
from
opcua.common.methods
import
uamethod
from
opcua.common.event
import
EventGenerator
from
opcua.common.subscription
import
Subscription
from
opcua.client.client
import
Client
from
opcua.server.server
import
Server
from
opcua.server.event
import
EventGenerator
from
opcua.common.instanciate
import
instanciate_node
...
...
opcua/common/subscription.py
View file @
d538b57a
...
...
@@ -7,7 +7,6 @@ from threading import Lock
from
opcua
import
ua
from
opcua
import
Node
from
opcua.common
import
event
class
SubHandler
(
object
):
...
...
@@ -202,7 +201,7 @@ class Subscription(object):
def
_get_filter_from_event_type
(
self
,
eventtype
):
eventtype
=
self
.
_get_node
(
eventtype
)
evfilter
=
ua
.
EventFilter
()
for
property
in
event
.
get_event_properties_from_type_node
(
eventtype
):
for
property
in
get_event_properties_from_type_node
(
eventtype
):
op
=
ua
.
SimpleAttributeOperand
()
op
.
TypeDefinitionId
=
eventtype
.
nodeid
op
.
AttributeId
=
ua
.
AttributeIds
.
Value
...
...
@@ -308,3 +307,20 @@ class Subscription(object):
del
(
self
.
_monitoreditems_map
[
k
])
return
def
get_event_properties_from_type_node
(
node
):
properties
=
[]
curr_node
=
node
while
True
:
properties
.
extend
(
curr_node
.
get_properties
())
if
curr_node
.
nodeid
.
Identifier
==
ua
.
ObjectIds
.
BaseEventType
:
break
parents
=
curr_node
.
get_referenced_nodes
(
refs
=
ua
.
ObjectIds
.
HasSubtype
,
direction
=
ua
.
BrowseDirection
.
Inverse
,
includesubtypes
=
False
)
if
len
(
parents
)
!=
1
:
# Something went wrong
return
None
curr_node
=
parents
[
0
]
return
properties
opcua/
common
/event.py
→
opcua/
server
/event.py
View file @
d538b57a
...
...
@@ -121,24 +121,6 @@ def get_event_from_type_node(node):
return
CustomEvent
()
def
get_event_properties_from_type_node
(
node
):
properties
=
[]
curr_node
=
node
while
True
:
properties
.
extend
(
curr_node
.
get_properties
())
if
curr_node
.
nodeid
.
Identifier
==
ua
.
ObjectIds
.
BaseEventType
:
break
parents
=
curr_node
.
get_referenced_nodes
(
refs
=
ua
.
ObjectIds
.
HasSubtype
,
direction
=
ua
.
BrowseDirection
.
Inverse
,
includesubtypes
=
False
)
if
len
(
parents
)
!=
1
:
# Something went wrong
return
None
curr_node
=
parents
[
0
]
return
properties
def
_find_parent_eventtype
(
node
):
parents
=
node
.
get_referenced_nodes
(
refs
=
ua
.
ObjectIds
.
HasSubtype
,
direction
=
ua
.
BrowseDirection
.
Inverse
,
includesubtypes
=
False
)
...
...
opcua/server/server.py
View file @
d538b57a
...
...
@@ -13,8 +13,8 @@ from opcua import ua
#from opcua.binary_server import BinaryServer
from
opcua.server.binary_server_asyncio
import
BinaryServer
from
opcua.server.internal_server
import
InternalServer
from
opcua.server.event
import
EventGenerator
from
opcua.common.node
import
Node
from
opcua.common.event
import
EventGenerator
from
opcua.common.subscription
import
Subscription
from
opcua.common
import
xmlimporter
from
opcua.common.manage_nodes
import
delete_nodes
...
...
tests/tests_common.py
View file @
d538b57a
...
...
@@ -290,14 +290,14 @@ class CommonTests(object):
def
test_get_event_from_type_node_BaseEvent
(
self
):
etype
=
self
.
opc
.
get_node
(
ua
.
ObjectIds
.
BaseEventType
)
properties
=
opcua
.
common
.
event
.
get_event_properties_from_type_node
(
etype
)
properties
=
opcua
.
common
.
subscription
.
get_event_properties_from_type_node
(
etype
)
for
child
in
etype
.
get_properties
():
self
.
assertTrue
(
child
in
properties
)
def
test_get_event_from_type_node_CustomEvent
(
self
):
etype
=
self
.
srv
.
create_custom_event_type
(
2
,
'MyEvent'
,
ua
.
ObjectIds
.
AuditEventType
,
[(
'PropertyNum'
,
ua
.
VariantType
.
Float
),
(
'PropertyString'
,
ua
.
VariantType
.
String
)])
properties
=
opcua
.
common
.
event
.
get_event_properties_from_type_node
(
etype
)
properties
=
opcua
.
common
.
subscription
.
get_event_properties_from_type_node
(
etype
)
for
child
in
self
.
opc
.
get_node
(
ua
.
ObjectIds
.
BaseEventType
).
get_properties
():
self
.
assertTrue
(
child
in
properties
)
...
...
tests/tests_server.py
View file @
d538b57a
...
...
@@ -161,11 +161,11 @@ class TestServer(unittest.TestCase, CommonTests):
# This should work for following BaseEvent tests to work (maybe to write it a bit differentlly since they are not independent)
def
test_get_event_from_type_node_BaseEvent
(
self
):
ev
=
opcua
.
common
.
event
.
get_event_from_type_node
(
opcua
.
Node
(
self
.
opc
.
iserver
.
isession
,
ua
.
NodeId
(
ua
.
ObjectIds
.
BaseEventType
)))
ev
=
opcua
.
server
.
event
.
get_event_from_type_node
(
opcua
.
Node
(
self
.
opc
.
iserver
.
isession
,
ua
.
NodeId
(
ua
.
ObjectIds
.
BaseEventType
)))
check_base_event
(
self
,
ev
)
def
test_get_event_from_type_node_Inhereted_AuditEvent
(
self
):
ev
=
opcua
.
common
.
event
.
get_event_from_type_node
(
opcua
.
Node
(
self
.
opc
.
iserver
.
isession
,
ua
.
NodeId
(
ua
.
ObjectIds
.
AuditEventType
)))
ev
=
opcua
.
server
.
event
.
get_event_from_type_node
(
opcua
.
Node
(
self
.
opc
.
iserver
.
isession
,
ua
.
NodeId
(
ua
.
ObjectIds
.
AuditEventType
)))
self
.
assertIsNot
(
ev
,
None
)
# we did not receive event
self
.
assertIsInstance
(
ev
,
ua
.
BaseEvent
)
self
.
assertIsInstance
(
ev
,
ua
.
AuditEvent
)
...
...
@@ -270,7 +270,7 @@ class TestServer(unittest.TestCase, CommonTests):
def
test_get_event_from_type_node_CustomEvent
(
self
):
etype
=
self
.
opc
.
create_custom_event_type
(
2
,
'MyEvent'
,
ua
.
ObjectIds
.
BaseEventType
,
[(
'PropertyNum'
,
ua
.
VariantType
.
Float
),
(
'PropertyString'
,
ua
.
VariantType
.
String
)])
ev
=
opcua
.
common
.
event
.
get_event_from_type_node
(
etype
)
ev
=
opcua
.
server
.
event
.
get_event_from_type_node
(
etype
)
check_custom_event
(
self
,
ev
,
etype
)
self
.
assertEqual
(
ev
.
PropertyNum
,
None
)
self
.
assertEqual
(
ev
.
PropertyString
,
None
)
...
...
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