Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NQontrol
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Automate
Agent sessions
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
las-nq
NQontrol
Commits
516a6ad2
Commit
516a6ad2
authored
Jan 10, 2019
by
Christian Darsow-Fromm
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' of gitlab.aei.uni-hannover.de:las-nq/adwin-control into develop
parents
f937abef
c8462f2d
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/make_test.sh
+1
-1
1 addition, 1 deletion
bin/make_test.sh
src/adwin_control/servo.py
+42
-9
42 additions, 9 deletions
src/adwin_control/servo.py
src/tests/test_servo.py
+23
-0
23 additions, 0 deletions
src/tests/test_servo.py
with
66 additions
and
10 deletions
bin/make_test.sh
+
1
−
1
View file @
516a6ad2
...
...
@@ -11,7 +11,7 @@ function ctrl_c() {
}
export
PYTHONPATH
=
$PYTHONPATH
:
`
pwd
`
/src
python3 src/tests/mock_server.py &
py.test
-x
--cov-report
=
html src/tests
py.test
-x
--no-cov-on-fail
--cov-report
=
html src/tests
result
=
$?
echo
"RETURN
$result
"
...
...
This diff is collapsed.
Click to expand it.
src/adwin_control/servo.py
+
42
−
9
View file @
516a6ad2
...
...
@@ -504,6 +504,9 @@ class Servo:
@snapSw.setter
def
snapSw
(
self
,
enabled
):
if
not
isinstance
(
enabled
,
bool
):
raise
TypeError
(
'
the value must be a bool.
'
)
self
.
_state
[
'
snapSw
'
]
=
enabled
self
.
_sendFilterControl
()
...
...
@@ -516,12 +519,18 @@ class Servo:
:setter: Set the limit to a value.
:type: :obj:`float`
"""
self
.
_snapRead
()
return
self
.
_snap
[
'
limit
'
]
@snap.setter
def
snap
(
self
,
value
):
assert
(
isinstance
(
float
(
value
),
float
)),
'
Has to be a real number.
'
try
:
float
(
value
)
except
ValueError
:
raise
TypeError
(
'
value must be a float or int.
'
)
self
.
_snap
[
'
limit
'
]
=
value
self
.
snapSend
()
@property
def
snapGreater
(
self
):
...
...
@@ -532,27 +541,51 @@ class Servo:
:setter: Set the condition.
:type: :obj:`bool`
"""
self
.
_snapRead
()
return
self
.
_snap
[
'
greater
'
]
@snapGreater.setter
def
snapGreater
(
self
,
value
):
assert
(
isinstance
(
value
,
bool
)),
'
Has to be a boolean value.
'
if
not
isinstance
(
value
,
bool
):
raise
TypeError
(
'
value must be a bool.
'
)
self
.
_snap
[
'
greater
'
]
=
value
self
.
snapSend
()
def
snapSend
(
self
,
valu
e
,
greater
=
Tru
e
):
def
snapSend
(
self
,
limit
=
Non
e
,
greater
=
Non
e
):
"""
Value to enable locking.
Parameters
----------
value
: :obj:`float`
Threshold
value
to start locking.
limit
: :obj:`float`
Threshold
limit
to start locking.
greater: :obj:`bool`
Start locking when the aux value is lower or greater than :obj:`
value
`.
Start locking when the aux value is lower or greater than :obj:`
limit
`.
"""
value
=
_convertVolt2Int
(
value
,
self
.
auxSensitivity
,
True
)
value
=
general
.
changeBit
(
value
,
16
,
greater
)
self
.
_adw
.
SetData_Long
([
value
],
7
,
self
.
_channel
,
1
)
if
limit
is
None
:
limit
=
self
.
_snap
[
'
limit
'
]
if
greater
is
None
:
greater
=
self
.
_snap
[
'
greater
'
]
try
:
float
(
limit
)
except
ValueError
:
raise
TypeError
(
'
limit must be a float or int.
'
)
if
not
isinstance
(
greater
,
bool
):
raise
TypeError
(
'
greater must be a bool.
'
)
self
.
_snap
[
'
limit
'
]
=
limit
self
.
_snap
[
'
greater
'
]
=
greater
limit
=
_convertVolt2Int
(
limit
,
self
.
auxSensitivity
,
True
)
limit
=
general
.
changeBit
(
limit
,
16
,
greater
)
self
.
_adw
.
SetData_Long
([
limit
],
7
,
self
.
_channel
,
1
)
def
_snapRead
(
self
):
snapping_config
=
self
.
_adw
.
GetData_Long
(
7
,
self
.
_channel
,
1
)[
0
]
self
.
_snap
[
'
limit
'
]
=
_convertInt2Volt
(
snapping_config
&
0xffff
,
mode
=
self
.
auxSensitivity
)
self
.
_snap
[
'
greater
'
]
=
general
.
readBit
(
snapping_config
,
16
)
@property
def
outputSw
(
self
):
...
...
This diff is collapsed.
Click to expand it.
src/tests/test_servo.py
+
23
−
0
View file @
516a6ad2
...
...
@@ -638,6 +638,29 @@ class TestServo(unittest.TestCase):
self
.
s
.
_state
[
'
auxSw
'
]
=
False
self
.
assertTrue
(
self
.
s
.
auxSw
)
def
test__snapping_getters_and_setters
(
self
):
with
self
.
assertRaises
(
TypeError
):
self
.
s
.
snapSw
=
'
wrong type
'
with
self
.
assertRaises
(
TypeError
):
self
.
s
.
snapSw
=
345
with
self
.
assertRaises
(
TypeError
):
self
.
s
.
snapGreater
=
345
with
self
.
assertRaises
(
TypeError
):
self
.
s
.
snapGreater
=
'
bla
'
# Test it reads the real values from adwin
self
.
s
.
snap
=
4.7
self
.
s
.
_snap
[
'
limit
'
]
=
'
something different
'
self
.
assertAlmostEqual
(
self
.
s
.
snap
,
4.7
,
places
=
4
)
# Different sensitivity
self
.
auxSensitivity
=
3
self
.
s
.
snap
=
.
7
self
.
s
.
_snap
[
'
limit
'
]
=
'
something different
'
self
.
assertAlmostEqual
(
self
.
s
.
snap
,
.
7
,
places
=
3
)
self
.
s
.
snapGreater
=
False
self
.
s
.
_snap
[
'
greater
'
]
=
'
something different
'
self
.
assertEqual
(
self
.
s
.
snapGreater
,
False
)
class
TestServoDevice
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment