added "goto" command (PV.put all values as stored in csv)
This commit is contained in:
30
commands.py
30
commands.py
@ -1,9 +1,10 @@
|
||||
from datetime import datetime
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import epics
|
||||
|
||||
from utils.df import drop_col, compare_dfs, count_true
|
||||
from utils.epics import DataGetter
|
||||
from utils.epics import DataGetter, DataPutter
|
||||
from utils.execute import parallel, serial
|
||||
from utils.fileio import load_config, load_csv, store_csv
|
||||
from utils.printing import print_good, print_bad
|
||||
@ -12,7 +13,8 @@ from utils.printing import print_good, print_bad
|
||||
def run(clargs):
|
||||
commands = {
|
||||
"check": run_check,
|
||||
"compare": run_compare
|
||||
"compare": run_compare,
|
||||
"goto": run_goto
|
||||
}
|
||||
commands[clargs.command](clargs)
|
||||
|
||||
@ -65,4 +67,28 @@ def run_compare(clargs):
|
||||
print(diff)
|
||||
|
||||
|
||||
def run_goto(clargs):
|
||||
fn = clargs.filename
|
||||
df = load_csv(fn)
|
||||
|
||||
df = df["value"]
|
||||
df.dropna(inplace=True)
|
||||
|
||||
values = df.values
|
||||
chans = df.index
|
||||
pvs = (epics.PV(ch) for ch in chans)
|
||||
|
||||
put_data = DataPutter(clargs.timeout, clargs.quiet)
|
||||
run = serial if clargs.serial else parallel
|
||||
status = run(put_data, pvs, values)
|
||||
|
||||
status = np.array(status)
|
||||
if status.all():
|
||||
print_good("all puts successful")
|
||||
else:
|
||||
ntotal = len(status)
|
||||
ngood = count_true(status)
|
||||
print_bad(f"only {ngood}/{ntotal} puts successful")
|
||||
|
||||
|
||||
|
||||
|
6
sani.py
6
sani.py
@ -24,6 +24,12 @@ def handle_clargs():
|
||||
parser_compare.add_argument("filenames", metavar="filename", nargs=2, help="name of input CSV file, two are needed")
|
||||
parser_compare.add_argument("-v", "--ignore-values", help="do not check values", action="store_true")
|
||||
|
||||
parser_goto = subparsers.add_parser("goto", help="go to stored values")
|
||||
parser_goto.add_argument("filename", help="name of input CSV file")
|
||||
parser_goto.add_argument("-q", "--quiet", help="do not show each channel's answer", action="store_true")
|
||||
parser_goto.add_argument("-s", "--serial", help="do not run checks in parallel", action="store_true")
|
||||
parser_goto.add_argument("-t", "--timeout", help="connection timeout in seconds", type=float, default=1)
|
||||
|
||||
clargs = parser.parse_args()
|
||||
|
||||
if not clargs.command:
|
||||
|
Reference in New Issue
Block a user