Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alisher Gaibulaev
bliss
Commits
8aaef0b9
Commit
8aaef0b9
authored
Oct 31, 2016
by
Jose Tiago Macara Coutinho
Browse files
motion: add support for units
parent
e78752f5
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
bliss/common/axis.py
View file @
8aaef0b9
This diff is collapsed.
Click to expand it.
bliss/common/standard.py
View file @
8aaef0b9
...
...
@@ -33,6 +33,7 @@ from bliss.config.settings import QueueSetting
from
bliss.controllers.motor_group
import
Group
from
bliss.common.units
import
ureg
as
ur
_ERR
=
'!ERR'
_MAX_COLS
=
9
...
...
@@ -302,7 +303,14 @@ def __row_positions(positions, motors, fmt, sep=' '):
def
__row
(
cols
,
fmt
,
sep
=
' '
):
return
sep
.
join
([
format
(
col
,
fmt
)
for
col
in
cols
])
data
=
[]
for
col
in
cols
:
if
isinstance
(
col
,
ur
.
Quantity
):
col
=
str
(
col
)
else
:
col
=
format
(
col
,
fmt
)
data
.
append
(
col
)
return
sep
.
join
(
data
)
def
__umove
(
*
args
,
**
kwargs
):
...
...
bliss/common/units.py
0 → 100644
View file @
8aaef0b9
from
pint
import
UnitRegistry
ureg
=
UnitRegistry
()
# use short ASCII print format
ureg
.
default_format
=
'~'
bliss/controllers/motors/mockup.py
View file @
8aaef0b9
...
...
@@ -11,7 +11,7 @@ import random
from
bliss.controllers.motor
import
Controller
from
bliss.common
import
log
as
elog
from
bliss.common.axis
import
AxisState
from
bliss.common.axis
import
AxisState
,
to_magnitude
from
bliss.common
import
event
from
bliss.common.utils
import
object_method
...
...
@@ -90,13 +90,13 @@ class Mockup(Controller):
if
axis
.
config
.
get
(
"persistent_position"
,
bool
,
default
=
False
,
inherited
=
True
):
try
:
dial_pos
=
axis
.
settings
.
get
(
"dial_position"
)
dial_pos
=
axis
.
settings
.
get
(
"dial_position"
)
or
0
except
:
pass
def
set_pos
(
move_done
,
axis
=
axis
):
if
move_done
:
self
.
set_position
(
axis
,
axis
.
dial
()
*
axis
.
steps_per_unit
)
dial
=
to_magnitude
(
axis
.
dial
(),
axis
.
unit
)
self
.
set_position
(
axis
,
dial
*
axis
.
steps_per_unit
)
self
.
_axis_moves
[
axis
]
=
{
"measured_simul"
:
False
,
...
...
requirements.txt
View file @
8aaef0b9
...
...
@@ -20,6 +20,7 @@ six >= 1.10
tabulate
sphinx
>= 1.4
pyserial
>= 3.0
pint
# --- optional dependencies --------------------------------
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment