Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
bliss
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
483
Issues
483
List
Boards
Labels
Service Desk
Milestones
Jira
Jira
Merge Requests
126
Merge Requests
126
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bliss
bliss
Commits
1c8ee64a
Commit
1c8ee64a
authored
Jan 26, 2018
by
Vincent Michel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pepu hardware tests
parent
bddc34f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
0 deletions
+90
-0
tests/controllers_hw/pepu.py
tests/controllers_hw/pepu.py
+90
-0
No files found.
tests/controllers_hw/pepu.py
0 → 100644
View file @
1c8ee64a
"""PEPU hardware tests.
Run with:
$ pytest -c /dev/null tests/controllers_hw/pepu.py -v
\
--cov bliss.controllers.pepu --cov-report html --cov-report term
"""
import
pytest
from
bliss.controllers.pepu
import
PEPU
,
Signal
,
Trigger
@
pytest
.
fixture
def
pepu
():
pepu
=
PEPU
(
'test'
,
{
'tcp'
:
{
'url'
:
'pepudcm2'
}})
try
:
pepu
.
calc_channels
[
1
].
formula
=
'1.5'
pepu
.
calc_channels
[
2
].
formula
=
'-1.5'
pepu
.
out_channels
[
7
].
source
=
pepu
.
calc_channels
[
1
].
name
pepu
.
out_channels
[
8
].
source
=
pepu
.
calc_channels
[
2
].
name
yield
pepu
finally
:
pepu
.
conn
.
close
()
def
test_simple_connection
(
pepu
):
assert
pepu
.
app_name
==
'PEPU'
assert
pepu
.
version
==
'00.01'
assert
pepu
.
up_time
>
0
assert
pepu
.
sys_info
.
startswith
(
'DANCE'
)
uptime
,
uname
=
pepu
.
dance_info
.
splitlines
()
assert
uptime
.
startswith
(
'UPTIME'
)
assert
uname
.
startswith
(
'UNAME'
)
assert
pepu
.
config
.
startswith
(
'# %APPNAME% PEPU'
)
@
pytest
.
mark
.
parametrize
(
"channel_id"
,
range
(
1
,
7
))
def
test_read_in_channels
(
pepu
,
channel_id
):
channel
=
pepu
.
in_channels
[
channel_id
]
assert
channel
.
value
in
[
-
1.
,
0.
]
@
pytest
.
mark
.
parametrize
(
"channel_id"
,
[
7
,
8
])
def
test_read_out_channels
(
pepu
,
channel_id
):
channel
=
pepu
.
out_channels
[
channel_id
]
value
=
channel
.
value
pytest
.
xfail
()
assert
value
in
(
1.5
,
-
1.5
)
@
pytest
.
mark
.
parametrize
(
"channel_id"
,
[
1
,
2
])
def
test_read_calc_channels
(
pepu
,
channel_id
):
channel
=
pepu
.
calc_channels
[
channel_id
]
value
=
channel
.
value
pytest
.
xfail
()
assert
value
in
(
1.5
,
-
1.5
)
@
pytest
.
mark
.
parametrize
(
"acquisitions"
,
[
1
,
2
,
10
])
@
pytest
.
mark
.
parametrize
(
"blocks"
,
[
1
,
2
,
10
])
@
pytest
.
mark
.
parametrize
(
"block_size"
,
[
1
,
2
,
10
])
def
test_streams_acquisition
(
pepu
,
acquisitions
,
blocks
,
block_size
):
# Create stream
stream
=
pepu
.
create_stream
(
name
=
'TEST'
,
trigger
=
Trigger
(
Signal
.
SOFT
,
Signal
.
SOFT
),
frequency
=
10
,
nb_points
=
blocks
*
block_size
,
sources
=
(
'CALC1'
,
'CALC2'
),
overwrite
=
True
)
# Argument testing
assert
stream
.
name
==
'TEST'
assert
stream
.
trigger
==
Trigger
(
Signal
.
SOFT
,
Signal
.
SOFT
)
assert
stream
.
frequency
==
10
assert
stream
.
nb_points
==
blocks
*
block_size
assert
stream
.
sources
==
[
'CALC1'
,
'CALC2'
]
assert
not
stream
.
active
# Loop over acquisitions
for
_
in
range
(
acquisitions
):
stream
.
start
()
# Loop over blocks
for
_
in
range
(
blocks
):
# Loop over points
for
_
in
range
(
block_size
):
pepu
.
software_trigger
()
# Read block
assert
stream
.
nb_points_ready
==
block_size
data
=
stream
.
read
(
n
=
block_size
)
expected
=
[[
1.5
,
-
1.5
]]
*
block_size
assert
pytest
.
approx
(
data
,
expected
)
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