refactor(flomni): rt_settings texts as class attributes (STAFF_ONLY, DOC, HELP_EXAMPLE) for subclasses
Same change as on fix/omny_commissioning (omny.rt_settings), taken over unchanged so both branches merge cleanly; used by lamni.rt_settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M8zoDygkWk6LupmHh3tyET
This commit is contained in:
1 parent
d59b385403
commit
37f25e45e8
1 file changed
+11
-5
@@ -27,6 +27,8 @@ from csaxs_bec.devices.omny.webhmi_client import WebHmiClient
|
||||
from csaxs_bec.devices.omny.webhmi_client import WebHmiError as RealtimeSystemError # name kept for BEC users
|
||||
|
||||
|
||||
_MODULE_DOC = __doc__ # help() prints it (a class body's __doc__ would be the class docstring)
|
||||
|
||||
STAFF_ONLY = ("flomni.rt_settings: beamline scientists / local contact only - not for users "
|
||||
"(plugins/flomni/docs/local_contact_only-realtime_system.md).")
|
||||
|
||||
@@ -45,6 +47,10 @@ class FlomniRealtimeSystem(WebHmiClient):
|
||||
devices/omny/webhmi_client.py; token from token_file / ~/.flomni_webhmi_token)."""
|
||||
|
||||
DEVICE = "flomni_loop_settings"
|
||||
# texts per instrument (OMNY: plugins/omny/omny_realtime_system.py subclasses this class, 2026-11-17)
|
||||
STAFF_ONLY = STAFF_ONLY
|
||||
DOC = _MODULE_DOC
|
||||
HELP_EXAMPLE = "move_beyond_um_x"
|
||||
|
||||
def __init__(self, url=None, token_file=None, device_manager=None, timeout=5.0, token=None):
|
||||
super().__init__(url=url, token=token, token_file=token_file, device_manager=device_manager, timeout=timeout)
|
||||
@@ -92,7 +98,7 @@ class FlomniRealtimeSystem(WebHmiClient):
|
||||
wanted = (group,) if isinstance(group, str) else tuple(group or ())
|
||||
groups = {g["name"]: g for g in snap["groups"]}
|
||||
sc = snap.get("scan") or {}
|
||||
print(STAFF_ONLY)
|
||||
print(self.STAFF_ONLY)
|
||||
print(f"Loop settings {snap.get('instrument', '')} ({self.route}) - "
|
||||
+ (f"scan running (mode {_fmt(sc.get('mode'))})" if sc.get("active") else "no scan"))
|
||||
for gname, g in groups.items():
|
||||
@@ -264,18 +270,18 @@ class FlomniRealtimeSystem(WebHmiClient):
|
||||
does, unit, range, the loop parameters it sets, live and saved value), from the definition on the loop
|
||||
machine (the same text as the tooltips of the web HMI tab)."""
|
||||
if name is None:
|
||||
print(__doc__.split("\n\nConnection:")[0])
|
||||
print(self.DOC.split("\n\nConnection:")[0])
|
||||
print("\nShortcuts: trigger_show(), trigger_set_tolerance_nm(v), trigger_set_hold_ms(v),"
|
||||
" trigger_set_after_move(True/False), trigger_set_soft(True/False, exposure_ms), tracking_targets(), tracking_show(), tracking_set_target_y(v),"
|
||||
" tracking_set_target_z(v), tracking_set_interferometer_threshold(v), tracking_set_psd_threshold_low(v);"
|
||||
" profiles(), unsaved(), get(name)")
|
||||
print('Explanations: help("all") or help("<setting>"), e.g. help("move_beyond_um_x")')
|
||||
print(f'Explanations: help("all") or help("<setting>"), e.g. help("{self.HELP_EXAMPLE}")')
|
||||
return
|
||||
snap = self.read()
|
||||
settings = {s["name"]: s for s in snap["settings"]}
|
||||
groups = {g["name"]: g for g in snap["groups"]}
|
||||
if name == "all":
|
||||
print(STAFF_ONLY)
|
||||
print(self.STAFF_ONLY)
|
||||
for gname, g in groups.items():
|
||||
rows = [s for s in snap["settings"] if s["group"] == gname]
|
||||
if not rows:
|
||||
@@ -291,7 +297,7 @@ class FlomniRealtimeSystem(WebHmiClient):
|
||||
if s is None:
|
||||
raise RealtimeSystemError(f"unknown setting '{name}'; help('all') lists them")
|
||||
g = groups.get(s["group"], {})
|
||||
print(STAFF_ONLY)
|
||||
print(self.STAFF_ONLY)
|
||||
print(f"{s['name']} - {s.get('title', '')} (group {g.get('title', s['group'])}"
|
||||
+ (", only between scans)" if g.get("interlock") else ")"))
|
||||
if s.get("help"):
|
||||
|
||||
Reference in new issue
Block a user