Sardana-Training by ALBA Synchrotron is licensed under the Creative Commons Attribution 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.
VM is a Debian Buster
Run the VM
sardana-icalepcs2019.ova with VirtualBox (VirtualBox -> File -> Import Appliance)vagrant & password vagrantIf you want to recreate this VM, or just view it in details, please check the Vagrantfile
h5py and taurus_pyqtgraph from /root/.local/... to ~/.local/...:
cd ~/sardana-training/
git pull
sudo ~/sardana-training/users/copy_modules
python3 -c "import h5py"
python3 -c "import taurus"
gevent and blender (optionally emacs and okular):
sudo apt-get install -y python3-gevent blender
sudo apt-get install -y emacs okular
cd ~/sardana-training
git pull
Sardana-Training by ALBA Synchrotron is licensed under the Creative Commons Attribution 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.
Taurus and Sardana aim to produce at least 2 official releases per year (in January and July) in PyPI. Additional installable files (.wheel, .msi, .deb, etc.) may also be released on GitHub.
The official releases are also pushed and tagged on the master branch of the official repositories.
The latest code can be found in the develop branch of the repositories.
For more details and information on how to contribute, see the CONTRIBUTING.md files (taurus / sardana)
(don't execute the following commands)
apt-get install python-taurus
# pip install taurus
pip3 install taurus
git clone https://github.com/taurus-org/taurus.git
# pip install -e ./taurus
pip3 install -e ./taurus
(don't execute the following commands)
apt-get install python-sardana
pip install sardana
git clone https://github.com/sardana-org/sardana.git
pip3 install -e ./sardana
pip3 install --user git+https://github.com/taurus-org/taurus.git@icalepcs2019
pip3 install --user git+https://github.com/sardana-org/sardana.git@icalepcs2019
Sardana demo1 --log-level=debug

spock
sar_demo environment (in Spock):
sar_demo
Sardana-Training by ALBA Synchrotron is licensed under the Creative Commons Attribution 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.
Create a new GUI with taurus newgui
taurus newgui
Follow the wizard of taurus newgui
/home/vagrant/demogui)demogui)/home/vagrant/sardana-training/users/res/demoBL.jdwMacroServer/demo1/1 and Door - Door/demo1/1 yes Install the freshly created Taurus GUI:
pip3 install --user /home/vagrant/demogui
Congratulations! You can already run your freshly created GUI:
demogui
JSONRecorder pop-up.ExperimentConfiguration panel, first switch to the "Simple View" (from the context menu) and then enable plotting ct1 and ct2Spectrum, PlotAxes: <mov> and don't forget to Apply)macrosinstrumentsmacros and instruments/slit with panel myslit --> OKdbtango://buster.localdomain:10000 as model and click on finishplot and click on finishform and click on finishsys/tg_test/1/ampli, and drag and drop it into "form". sys/tg_test/1/boolean_scalar, and drag and drop it into "form"sys/tg_test/1/wave, and drag and drop it into "plot"1V, the value will change to 1000 mV in both "ampli" and "voltage"
Sardana-Training by ALBA Synchrotron is licensed under the Creative Commons Attribution 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.
uct macro (in Spock):
uct
expconf (in Spock):
expconf
expconf e.g. ct02 and ct04 (Enabled column -> False) and run ct macro (in Spock):
ct
oned01 in expconf (Add channel + button), apply changes and run ct macrodefmeas macro and run ct afterwards (in Spock):
defmeas mntgrp02 ct01 twod01
ct
ct macroPool_demo1_1.put_property({"MotionLoop_StatesPerPosition":"1"})
taurus tpg trend mot01/position "eval:int(bool({ct01/state}))"
ascan mot01 0 10 10 1
ascanct mot01 0 10 10 1
ascanct mot01 0 10 10 1 0.1
ct01 in expconf (Synchronizer column -> tg01) and execute the scan without latency
time:
ascanct mot01 0 10 10 1
ct01ascan, dscan, a2scanc, ascanct, mesh, timescan, etc.GScan, SScan, CScan, etc.ActiveMntGrp, ScanFile, ApplyInterpolationpre-scan, post-acqexpconf (in Spock):
expconf
expconf Storage tab set scan file to test.h5 and directory to /tmp (equivalent in Spock with senv ScanFile test.h5 and senv ScanDir /tmp)ascan mot01 0 2 2 0.1
silx:
silx view
silx
Sardana-Training by ALBA Synchrotron is licensed under the Creative Commons Attribution 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.
mv macro and extend its funcionality)sardana.macroserver.macrosMacroPath directories:macros directory:
mkdir /home/vagrant/macros
MacroPath (in Spock):
_MACRO_SERVER.put_property({"MacroPath":["/home/vagrant/macros", "/home/vagrant/.local/lib/python3.7/site-packages/sardana/macroserver/macros/examples"]})
edmac <macro_name> [<module_name>]relmac, relmaclib, addmaclib, rellibwww, post_mortemdebug on|offhello_world macro (in Spock):
edmac hello_world mymacros
macro decorator that can be found in sardana.macroserver.macroself.output() to print something...hello_world macro (in Spock):
hello_world
from sardana.macroserver.macro import Macro, macro, Type
@macro()
def hello_world(self):
"""Macro hello_world"""
self.output("Running hello_world...")
hello_world macro and add a self.info("How are you?")
edmac hello_world
wa (table view)umv mot01 100 (update block view)macro decorator for the macro function or as param_def class member for the macro class~/macros/mymacros.py module with an external editor e.g.
kwrite ~/macros/mymacros.py
moveMoveableFloatmoveable.move(position))relmaclib macro (in Spock)
relmaclib mymacros
move?
moveable.getPosition())relmac macro macro (in Spock)move macro (in Spock):
move mot01 10
@macro([["moveable", Type.Moveable, None, "moveable to move"],
["position", Type.Float, None, "absolute position"]])
def move(self, moveable, position):
"""This macro moves a moveable to the specified position"""
moveable.move(position)
self.output("{} is now at {}".format(moveable.getName(), moveable.getPosition()))
prdef pt4pt4 mot01 mot02result_def class member of the macro classprdef twicetwice 2pickle) and to the wrapper macrotwice 3macrodataascan mot01 0 10 2 0.1macrodataedmac hello_world and add self.lsm()demogui and show Sequencer panellsm, wa and ascan and fill their parametersHookable class to allow hook placeslsgh, defgh, udefgh.Hookable class API (it requires defining a wrapper macro)sequencer widgetwa macro in the ascanpre-acq from the context menuprdef loop
loop 0 10 1
prdef captain_hook
captain_hook 0 10 1
lsgh
defgh "wm mot01" pre-acq
ct
udefgh "wm mot01"
ct
imacro decorator or interactive class member set to TrueSPOCK_INPUT_HANDLER in the sardana.sardanacustomsettingsprdef ask_number_of_points
ask_number_of_points
matplotlib.pyplot framework API e.g. pyplot.plotprdef random_image
random_image
checkPoint (or pausePoint) or any of the macro API method (Macro class methods decorated with mAPI)on_stop, on_abort and on_pause method that will be called on the corresponding interruptiongetMotion method (getMotor will not reserve the motor object!), are stopped/aborted on the corresponding interruption (before calling the on_stop/on_abort method)yield statement within the run methodgetEnv and setEnv or simply senv macrosenv ActiveMntGrp mntgrp01
ct
Execute the macrobutton code, which in this case executes the 'lsm' macro
macrobutton executing an lsm macro:
python3 ~/sardana-training/res/macrobutton/macrobutton_lsm.py
macrobutton executing an ascan macro:
python3 ~/sardana-training/res/macrobutton/macrobutton_scan.py
BL13-Xaloc Beamline uses Macrobuttons in a TaurusGUI for focusing the sample image and for looking for the best diffraction position on the sample

Sardana-Training by ALBA Synchrotron is licensed under the Creative Commons Attribution 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.
sardana.pool.poolcontrollersPoolPath directories:mkdir ~/controllers
PoolPath:
Pool_demo1_1.put_property({"PoolPath":["/home/vagrant/controllers"]})
kwrite ~/sardana-training/controllers/templates/BlenderBladesMotorCtrl.py
pip3 install --user ~/sardana-training/blender-slits
blender-slits-server
~/sardana-training/blender-slits/README.mdhost and portBlenderBlades in the constructorln -s ~/sardana-training/controllers/templates/BlenderBladesMotorCtrl.py ~/controllers
addctrllib BlenderBladesMotorCtrl
lsctrllib
defctrl BlenderBladesMotorController bleblactrl
bleblactrl.state()
?state <axis id>?pos <axis id>relctrlcls BlenderBladesMotorController
defelem top bleblactrl 1
top.state()
top.position
or
wm top
<axis id> <pos>relctrlcls BlenderBladesMotorController
umvr top 10
abortrelctrlcls BlenderBladesMotorController
umvr top 50
Ctrl+C in SpockGetAxisPar method?vel <axis id>?acc <axis id>?dec <axis id>top.velocity
top.acceleration
top.deceleration
SetAxisPar methodvel <axis id> <value>acc <axis id> <value>dec <axis id> <value>top.velocity = 1
umvr top 5
defm bottom bleblactrl 2
defm left bleblactrl 3
defm right bleblactrl 4
wm top bottom left right
bottom.sign = -1
left.sign = -1
set_user_pos macro (in Spock, line by line):
set_user_pos top 0
set_user_pos bottom 0
set_user_pos left 0
set_user_pos right 0
mv top 5 bottom 5 left 5 right 5
mv top 0 bottom 0 left 0 right 0
Slit controller - Sardana's standard slit controllerpseudo_motor_roles and motor_roles class members defines number of pseudo and physical axes used by the controllerdefctrl Slit vertctrl sl2t=top sl2b=bottom Gap=gapvert Offset=offsetvert
defctrl Slit horctrl sl2t=right sl2b=left Gap=gaphor Offset=offsethor
CalcPhysical method, for calculating physical axes positions based on pseudo axes positionCalcPseudo method, for calculating pseudo axes positions based on physical onesmv gapvert 10 gaphor 10dscan offsetvert -10 10 10 0.1
Sardana-Training by ALBA Synchrotron is licensed under the Creative Commons Attribution 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.
kwrite ~/sardana-training/controllers/templates/NetworkTrafficCTCtrl.py
cat /proc/net/dev | grep eth0
cd ~/sardana-training/controllers
python3 -c "from NetworkTrafficCTCtrl import read_network_counts; print(read_network_counts('eth0'))"
interfaceln -s ~/sardana-training/controllers/templates/NetworkTrafficCTCtrl.py ~/controllers
addctrllib NetworkTrafficCTCtrl
defctrl NetworkTrafficCounterTimerController netctrl interface eth0
netctrl.state()
""is called only on the controller's timer or monitor
store the integration time in the cache acq_time
* An advanced API is available for continuous acquisitions e.g. continuous scans
is called multiple times during the acquisition operation
latch network bytes
start_counts* An advanced API is available for continuous acquisitions e.g. continuous scans
relctrlcls NetworkTrafficCounterTimerController
defelem net netctrl 1
net.state()
start_counts and calcultate the end acquisition time in acq_end_timerelctrlcls NetworkTrafficCounterTimerController
uct 1 net
uct net 10
get sardana CHANGELOG with the wget tool:
wget https://github.com/sardana-org/sardana/blob/develop/CHANGELOG.md
ln -s ~/sardana-training/controllers/Blender2DCtrl.py ~/controllers
addctrllib Blender2DCtrl
defctrl Blender2DController ble2dctrl
ble2dctrl.state()
defelem ble2d ble2dctrl
ble2d.state()
ble2d.timer = "__self"
ct 1 ble2d
value attribute):
taurus form ble2d
expconf (started from Spock):ble2d channelmv gapvert 10 gaphor 10 offsetvert 0 offsethor 0
mv left 50
dscan offsetvert -10 10 10 0.1
silx (remember to close silx afterwards):
silx view
expconf configure data referencing:h5file:///tmp/ble2d_img{image_nb:03d}.h5dscan offsetvert -10 10 10 0.1
silx (remember to close silx afterwards):
silx view
dsconfig and sardana-dsconfig from MAX IVtaurus form eval:123.4*{tango:sys/tg_test/1/double_scalar}pint modulehklscan)ca or epics scheme gives direct access to EPICS systempyepics