Last active
December 3, 2019 17:56
-
-
Save cpascual/9355cd8ce61cddcec97ae2fdea47fc48 to your computer and use it in GitHub Desktop.
a simple attr monitor CLI done with taurus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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