Skip to content

Instantly share code, notes, and snippets.

@cpascual
Last active December 3, 2019 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpascual/9355cd8ce61cddcec97ae2fdea47fc48 to your computer and use it in GitHub Desktop.
Save cpascual/9355cd8ce61cddcec97ae2fdea47fc48 to your computer and use it in GitHub Desktop.
a simple attr monitor CLI done with taurus
# this is an example to answer the question in
# https://www.tango-controls.org/community/forum/c/development/python/quickest-way-to-write-a-command-line-taurus-client/
import taurus
import time
def print_attr_value(src, _type, value):
print("[{t:}] {name:}={rvalue:}".format(
t=value.time.isoformat(),
name=src.getSimpleName(),
rvalue=value.rvalue
))
def monitor(attr_names=(), period=1000):
taurus.Manager().changeDefaultPollingPeriod(period)
attrs = []
for n in attr_names:
a = taurus.Attribute(n)
a.addListener(print_attr_value)
attrs.append(a)
time.sleep(10)
if __name__ == '__main__':
monitor(attr_names=('sys/tg_test/1/ampli', 'eval:rand()'), period=500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment