fix: add saxs_scan_macro
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
"""
|
||||
saxs_scan_macro_py macro - Created at 2026-07-15 10:57:40
|
||||
"""
|
||||
|
||||
|
||||
def saxs_scan_macro_py(
|
||||
session_name: str, use_index: int = -1, phone_numbers: list[str] | None = None
|
||||
):
|
||||
"""
|
||||
Description of what this macro does.
|
||||
|
||||
Add your macro implementation here.
|
||||
"""
|
||||
print("Executing macro: saxs_scan_macro_py")
|
||||
# TODO: Add your macro code here
|
||||
|
||||
# If not Swiss numbers, please provide +<country_code> prefix. If empty, no signal notifications will be sent.
|
||||
# List of phone numbers to send signal notifications to, example: ["+1234567890", "+0987654321"].
|
||||
if phone_numbers is None:
|
||||
phone_numbers = []
|
||||
|
||||
# count = -1 means latest saved table from the SAXS widget, 0 means first saved table, 1 means second saved table, etc. -1 is DEFAULT
|
||||
# Provide it as a kwargs if you need to fetch older table data.
|
||||
msg = get_saxs_widget_table_data(session_name=session_name, count=use_index)
|
||||
|
||||
print(
|
||||
f"Fetched {len(msg.value)} rows from SAXS widget table for session '{msg.metadata.get('session_name')}'. Table data created at {msg.metadata.get('timestamp')}"
|
||||
)
|
||||
|
||||
total_rows = len(msg.value)
|
||||
for ii, row in enumerate(msg.value):
|
||||
print(f"Running continuous grid scan for row {ii + 1}/{total_rows}: {row}")
|
||||
run_cont_grid_scan_for_table_row(
|
||||
session_name=session_name, row=row, phone_numbers=phone_numbers
|
||||
)
|
||||
if ii % 10 == 0:
|
||||
# Send update to scilog every 10 scans to avoid spamming the log
|
||||
message = bec.messaging.scilog.new()
|
||||
message.add_text(
|
||||
f"Completed {ii + 1}/{total_rows} continuous grid scans for session '{session_name}'"
|
||||
)
|
||||
message.send()
|
||||
# Send update to signal if phone numbers are provided
|
||||
if phone_numbers:
|
||||
message = bec.messaging.signal.new()
|
||||
message.add_text(
|
||||
f"Completed {ii + 1}/{total_rows} continuous grid scans for session '{session_name}'"
|
||||
)
|
||||
message.send(scope=phone_numbers)
|
||||
@@ -1,38 +0,0 @@
|
||||
# List of phone numbers to send signal notifications to, example: ["+1234567890", "+0987654321"].
|
||||
# If not Swiss numbers, please provide +<country_code> prefix. If empty, no signal notifications will be sent.
|
||||
|
||||
#############
|
||||
### Example script, copy from here and edit to your needs
|
||||
#############
|
||||
TELEFON_NUMBERS = []
|
||||
SESSION_NAME = "test_session"
|
||||
|
||||
|
||||
# count = -1 means latest saved table from the SAXS widget, 0 means first saved table, 1 means second saved table, etc. -1 is DEFAULT
|
||||
# Provide it as a kwargs if you need to fetch older table data.
|
||||
msg = get_saxs_widget_table_data(SESSION_NAME)
|
||||
|
||||
print(
|
||||
f"Fetched {len(msg.value)} rows from SAXS widget table for session '{msg.metadata.get('session_name')}'. Table data created at {msg.metadata.get('timestamp')}"
|
||||
)
|
||||
|
||||
total_rows = len(msg.value)
|
||||
for ii, row in enumerate(msg.value):
|
||||
print(f"Running continuous grid scan for row {ii + 1}/{len(msg.value)}: {row}")
|
||||
run_cont_grid_scan_for_table_row(
|
||||
session_name=SESSION_NAME, row=row, phone_numbers=TELEFON_NUMBERS
|
||||
)
|
||||
if ii % 10 == 0:
|
||||
# Send update to scilog every 10 scans to avoid spamming the log
|
||||
msg = bec.messaging.scilog.new()
|
||||
msg.add_text(
|
||||
f"Completed {ii + 1}/{total_rows} continuous grid scans for session '{SESSION_NAME}'"
|
||||
)
|
||||
msg.send()
|
||||
# Send update to signal if phone numbers are provided
|
||||
if TELEFON_NUMBERS:
|
||||
msg = bec.messaging.signal.new()
|
||||
msg.add_text(
|
||||
f"Completed {ii + 1}/{total_rows} continuous grid scans for session '{SESSION_NAME}'"
|
||||
)
|
||||
msg.send(scope=TELEFON_NUMBERS)
|
||||
Reference in New Issue
Block a user