Files
maloja/colors.py
2022-11-08 20:28:14 +01:00

149 lines
2.8 KiB
Python

from time import sleep
from epics import caget, caput
from slic.utils import as_shortcut
KSET_FMT = "SATUN{:02}-UIND030:K_SET"
RADIALGO_FMT = "SATUN{:02}-UIND030:RADIAL-GO"
#PHASESET_FMT = "SATUN{:02}-CHIC:PHASE"
N_UND_CHIC = 14
N_UNDS = list(range(6, 22+1))
N_UNDS.remove(N_UND_CHIC)
#FMT_G1 = "SATUN{:02}-CHIC:G1"
#FMT_G2 = "SATUN{:02}-CHIC:G2"
#FMT_GD = "SATUN{:02}-UDLY060:GAP-D-SET"
#FMT_GU = "SATUN{:02}-UDLY060:GAP-U-SET"
#ksets = {n: caget(KSET_FMT.format(n)) for n in n_unds}
#ksets
color1 = {
6: 2.5782081923331286,
7: 2.5782000000000003,
8: 2.5782081923331286,
9: 2.5782000000000003,
10: 2.5782269928449404,
11: 2.5782457933506078,
12: 2.5735,
13: 2.568807163979898,
15: 3.1,
16: 1.8714000000000002,
17: 1.8,
18: 2.0,
19: 3.4000000000000004,
20: 2.3000000000000003,
21: 2.9000000000000004,
22: 1.6
}
color2 = {
6: 2.0782000000000003,
7: 3.0782000000000003,
8: 1.5782,
9: 3.1782000000000004,
10: 1.7782,
11: 3.2882000000000002,
12: 1.9635,
13: 1.2688000000000001,
15: 2.9713000000000003,
16: 2.971323113370471,
17: 2.97130268459635,
18: 2.9713128989831805,
19: 2.9713128989831805,
20: 2.9713000000000003,
21: 2.9713000000000003,
22: 2.9613
}
colors_both = {
6: 2.5782081923331286,
7: 2.5782000000000003,
8: 2.5782081923331286,
9: 2.5782000000000003,
10: 2.5782269928449404,
11: 2.5782457933506078,
12: 2.5735,
13: 2.568807163979898,
15: 2.9713000000000003,
16: 2.971323113370471,
17: 2.97130268459635,
18: 2.9713128989831805,
19: 2.9713128989831805,
20: 2.9713000000000003,
21: 2.9713000000000003,
22: 2.9613
}
#colors_reset = colors_both
#phases_reset = {
# 6: 6.271830001886656,
# 7: 4.2,
# 8: 11.700000000000001,
# 9: 4.2,
# 10: 333.76497589650967,
# 11: 5.9,
# 12: 5.800000000000001,
# 13: 303.1292805364285,
# 15: 26.939664715067693,
# 16: 131.94293079970862,
# 17: 276.5058000202555,
# 18: 287.6856327168946,
# 19: 207.38583858800666,
# 20: 128.34546121694189,
# 21: 61.3287322695885
#}
def put_color(cols):
for n, k in cols.items():
pv = KSET_FMT.format(n)
caput(pv, k)
# press the go buttons ...
for n in cols:
pv = RADIALGO_FMT.format(n)
caput(pv, 1)
print("color done")
#def put_phases(phs):
# for n, k in phs.items():
# pv = PHASESET_FMT.format(n)
# caput(pv, k)
# print("phases done")
@as_shortcut
def enable_color1():
put_color(color1)
@as_shortcut
def enable_color2():
put_color(color2)
@as_shortcut
def enable_colors_both():
put_color(colors_both)
#@as_shortcut
#def reset_undulators():
# put_color(colors_reset)
# sleep(2)
# put_phases(phases_reset)