This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -0,0 +1,12 @@
|
||||
smargon:
|
||||
description: REST-based device which connects to Smargopolo
|
||||
deviceClass: pxii_bec.devices.smargopolo_smargon.Smargon
|
||||
deviceConfig: {prefix: 'http://localhost:8000'}
|
||||
onFailure: buffer
|
||||
enabled: True
|
||||
readoutPriority: baseline
|
||||
deviceTags:
|
||||
- smargon
|
||||
- motors
|
||||
readOnly: false
|
||||
softwareTrigger: false
|
||||
@@ -0,0 +1,49 @@
|
||||
#### find out about a certain class --
|
||||
#### retrieve the struct of dictionaries
|
||||
|
||||
# if you know the attribute you are searching for:
|
||||
|
||||
def check_attr(obj, attr):
|
||||
# att as string
|
||||
|
||||
attr = getattr(obj, attr)
|
||||
|
||||
if isinstance(attr, dict):
|
||||
print("keys:", attr.keys())
|
||||
print("values:", attr.values())
|
||||
print("items:", attr.items())
|
||||
|
||||
# Automatically Detect All Dictionary Attributes:
|
||||
|
||||
def list_dict_attr_single(obj):
|
||||
for attr_name, value in vars(obj).items():
|
||||
if isinstance(value, dict):
|
||||
print(f"\nDictionary attribute: {attr_name}")
|
||||
print(" Keys:", list(value.keys()))
|
||||
print(" Items:")
|
||||
for key, val in value.items():
|
||||
print(f" {key} -> {val}")
|
||||
|
||||
# Also Handle Nested Dictionaries:
|
||||
|
||||
|
||||
def list_dict_attr(obj):
|
||||
|
||||
def print_dict(d, indent=0): # start with zero indentation
|
||||
for key, value in d.items():
|
||||
print(" " * indent + str(key) + ":", end=" ")
|
||||
if isinstance(value, dict):
|
||||
print()
|
||||
print_dict(value, indent+1)
|
||||
else:
|
||||
print(value)
|
||||
|
||||
for attr_name, value in vars(obj).items():
|
||||
if isinstance(value, dict):
|
||||
print(f"\nDictionary attribute: {attr_name}")
|
||||
print_dict(value)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Executable
+75
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Script Name: set_kbox.sh
|
||||
# Description: Sets a value on a given device, such as scinti, diode, colli
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
#######################################
|
||||
# Usage
|
||||
#######################################
|
||||
usage() {
|
||||
echo "Usage: $(basename "$0") <device_name> <set_value>"
|
||||
echo
|
||||
echo "Example:"
|
||||
echo " $(basename "$0") colli_in 41.5"
|
||||
echo " $(basename "$0") colli_out 20."
|
||||
echo " $(basename "$0") scinti_in 40."
|
||||
echo " $(basename "$0") diode_in 44."
|
||||
echo " $(basename "$0") diode_out 20. or"
|
||||
echo " $(basename "$0") scinti_out 20."
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
#######################################
|
||||
# Validate Arguments
|
||||
#######################################
|
||||
if [[ $# -ne 2 ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
DEVICE_NAME="$1"
|
||||
SET_VALUE="$2"
|
||||
|
||||
if ! [[ "$SET_VALUE" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: set_value must be numeric"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
#######################################
|
||||
# Main
|
||||
#######################################
|
||||
main() {
|
||||
echo "Device: $DEVICE_NAME"
|
||||
echo "Value : $SET_VALUE"
|
||||
|
||||
# --- Your logic here ---
|
||||
# Example placeholder:
|
||||
|
||||
if [[ $DEVICE_NAME == "colli_in" ]]; then
|
||||
echo "caput X10SA-ES-COL:POS-SET-SEQ.DO2 $SET_VALUE"
|
||||
fi
|
||||
if [[ $DEVICE_NAME == "colli_out" ]]; then
|
||||
echo "caput X10SA-ES-COL:POS-SET-SEQ.DO1 $SET_VALUE"
|
||||
fi
|
||||
#
|
||||
if [[ $DEVICE_NAME == "scinti_in" ]]; then
|
||||
echo "caput X10SA-ES-SCL:POS-SET-SEQ.DO2 $SET_VALUE"
|
||||
fi
|
||||
if [[ $DEVICE_NAME == "diode_in" ]]; then
|
||||
echo "caput X10SA-ES-SCL:POS-SET-SEQ.DO3 $SET_VALUE"
|
||||
fi
|
||||
if [[ $DEVICE_NAME == "scinti_out" || $DEVICE_NAME == "diode_out" ]]; then
|
||||
echo "caput X10SA-ES-SCL:POS-SET-SEQ.DO1 $SET_VALUE"
|
||||
fi
|
||||
#
|
||||
echo "Setting device '$DEVICE_NAME' to '$SET_VALUE'..."
|
||||
|
||||
# Simulate success
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
main
|
||||
@@ -0,0 +1,38 @@
|
||||
import random
|
||||
import time
|
||||
|
||||
def test_mv():
|
||||
tol = 0.1
|
||||
if abs(dev.coll_y.position) < tol:
|
||||
value = 40
|
||||
else:
|
||||
value = 0
|
||||
print(f"Moving coll_y to {value}")
|
||||
s = scans.mv(dev.coll_y, value, relative=False)
|
||||
s.wait(timeout = 3)
|
||||
|
||||
def test_states():
|
||||
d = init_se_devices()
|
||||
states, allow_modifiers = get_states()
|
||||
deps = planner_deps()
|
||||
planner = StateManager(d, states, allow_modifiers, deps)
|
||||
states_to_test = [
|
||||
BeamlineState.ROBOT_SAMPLE_EXCHANGE,
|
||||
BeamlineState.DATA_COLLECTION,
|
||||
BeamlineState.MANUAL_SAMPLE_EXCHANGE,
|
||||
BeamlineState.XTAL_SNAPSHOT,
|
||||
|
||||
]
|
||||
previous = None
|
||||
tested_states = []
|
||||
for i in range(10):
|
||||
choices = [ s for s in states_to_test if s != previous]
|
||||
current = random.choice(choices)
|
||||
print(f"Moving to state {current}")
|
||||
planner.move_to(current)
|
||||
tested_states.append(current)
|
||||
time.sleep(5)
|
||||
previous = current
|
||||
print(f"Tested states: {tested_states}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user