Fandango (Fun for Tango)
Functional tools for PyTango
NOTE: Fandango package is a refactored version of the old PyTango_utils package, which is now deprecated
Downloading
Fandango can be downloaded from sourceforge:
svn co https://tango-cs.svn.sourceforge.net/svnroot/tango-cs/share/fandango/trunk/fandango fandango
Requirements
- It requires PyTango to access Tango
- It requires Taurus to use Tango Events.
- Some submodules have its own dependencies (Qt,MySQL), so they are always imported within try,except clauses.
Features
This library provides submodules with utilities for PyTango device servers and applications written in python:
- functional: functional programming, data format conversions, caseless regular expressions
- tango: tango api helper methods, search/modify using regular expressions
- dynamic: dynamic attributes, online python code evaluation
- server: Astor-like python API
- device: some templates for Tango device servers, TangoEval for fast "tango code" evaluation.
- interface: device server inheritance
- db: MySQL access
- dicts,arrays: advanced containers, sorted/caseless list/dictionaries, .csv parsing
- log: logging
- objects: object templates, singletones, structs
- threads: serialized hardware access, multiprocessing
- linos: some linux tricks
- web: html parsing
- qt: some custom Qt classes, including worker-like threads.
- ...
What it is used for
Several PyTango APIs and device servers use Fandango modules:
- PyTangoArchiving
- PyPLC
- !SplitterBoxDS
- PyStateComposer
- PySignalSimulator
- PyAlarm
- !CSVReader
- ...
Recipes for fandango modules usage
dynamic.DynamicDS: template for Dynamic Attributes
see [ http://www.tango-controls.org/howtos/dynamicattributes ]
servers.ServersDict: the Astor-like python API
start/stop all device servers in a machine (like Astor -> Stop All)
Stopping
import fandango fandango.Astor(hosts=['my.host']).stop_all_servers()
and the other way round ...
astor = fandango.Astor(hosts=['my.host']) astor.start_all_servers()
if you just want to see if things are effectively running or not:
astor.states()
Search for device attribute/properties matching a regular expression
fandango.tango.get_matching_device_properties('s01/*/*ct*','serial*') {'S01/VC/IPCT-01': {'SerialLine': 'S01/VC/SERIAL-01'}, 'S01/VC/IPCT-02': {'SerialLine': 'S01/VC/SERIAL-02'}, 'S01/VC/VGCT-01': {'SerialLine': 'S01/VC/SERIAL-10'}}
Use TangoEval to evaluate strings containing Tango Attributes
TangoEval evaluates tango code replacing attribute names by its values
from fandango import TangoEval te = TangoEval('(s01/vc/gauge-01/pressure + s01/vc/gauge-01/pressure) / 2.') [Out]: TangoEval: result = 7.2e-10

