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
d5b0f7b0
Commit
d5b0f7b0
authored
Feb 22, 2019
by
oroulet
Committed by
oroulet
Feb 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add minimal sync Server and make test for it
parent
098b35d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
7 deletions
+24
-7
opcua/sync.py
opcua/sync.py
+16
-3
tests/test_sync.py
tests/test_sync.py
+8
-4
No files found.
opcua/sync.py
View file @
d5b0f7b0
...
...
@@ -2,7 +2,6 @@
sync API of asyncua
"""
import
asyncio
import
inspect
from
threading
import
Thread
,
Condition
import
logging
...
...
@@ -109,8 +108,8 @@ def syncmethod(func):
class
Client
(
client
.
Client
):
def
__init__
(
self
,
url
:
str
,
timeout
:
int
=
4
):
self
.
_tloop
=
get_thread_loop
()
client
.
Client
.
__init__
(
self
,
url
,
timeout
,
loop
=
self
.
_tloop
.
loop
)
global
_tloop
client
.
Client
.
__init__
(
self
,
url
,
timeout
,
loop
=
_tloop
.
loop
)
@
syncmethod
def
connect
(
self
):
...
...
@@ -121,4 +120,18 @@ class Client(client.Client):
pass
class
Server
(
server
.
Server
):
def
__init__
(
self
,
shelf_file
=
None
):
global
_tloop
server
.
Server
.
__init__
(
self
)
_tloop
.
post
(
self
.
init
(
shelf_file
))
@
syncmethod
def
start
(
self
):
pass
@
syncmethod
def
stop
(
self
):
pass
tests/test_sync.py
View file @
d5b0f7b0
...
...
@@ -2,12 +2,16 @@ import time
import
pytest
from
opcua.sync
import
Client
,
start_thread_loop
,
stop_thread_loop
from
opcua.sync
import
Client
,
start_thread_loop
,
stop_thread_loop
,
Server
@
pytest
.
fixture
def
server
():
pass
s
=
Server
()
s
.
set_endpoint
(
'opc.tcp://*:8840/freeopcua/server/'
)
s
.
start
()
yield
s
s
.
stop
()
@
pytest
.
fixture
...
...
@@ -18,8 +22,8 @@ def tloop():
@
pytest
.
fixture
def
client
(
tloop
):
c
=
Client
(
"opc.tcp://localhost:
4
840/freeopcua/server"
)
def
client
(
tloop
,
server
):
c
=
Client
(
"opc.tcp://localhost:
8
840/freeopcua/server"
)
c
.
connect
()
yield
c
c
.
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