if nothing specified, collect all Adjustables

This commit is contained in:
2023-04-11 12:44:11 +02:00
parent 410d06896b
commit 91bf5da794
+9 -2
View File
@@ -1,6 +1,9 @@
import pcaspy
from pcaspy import SimpleServer
from pcaspy.tools import ServerThread
from slic.core.adjustable import Adjustable
from slic.utils.registry import instances
from .adjdrv import AdjustableDriver
@@ -17,11 +20,15 @@ DEFAULTS = {
class IOC(ServerThread):
def __init__(self, adjs, prefix="slic"):
def __init__(self, adjs=None, prefix="slic"):
# ensure prefix ends with colon
if not prefix.endswith(":"):
prefix += ":"
# if nothing specified, collect all Adjustables
if adjs is None:
adjs = instances(Adjustable, weak=True)
# allow dict with custom IDs
if not isinstance(adjs, dict):
adjs = {a.ID: a for a in adjs}