mirror of
https://github.com/bec-project/ophyd_devices.git
synced 2025-06-02 01:50:40 +02:00
Better config
This commit is contained in:
parent
5725af8307
commit
6c2ae5c166
@ -8,42 +8,41 @@ Created on Wed Oct 13 17:06:51 2021
|
|||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
from ophyd.ophydobj import OphydObject
|
from ophyd.ophydobj import OphydObject
|
||||||
from ophyd import EpicsSignal, EpicsSignalRO, EpicsMotor
|
|
||||||
from ophyd.sim import SynAxis, SynSignal, SynPeriodicSignal
|
|
||||||
from ophyd.quadem import QuadEM
|
|
||||||
import pathlib
|
|
||||||
|
|
||||||
|
from devices import *
|
||||||
|
|
||||||
|
# ####################################################
|
||||||
|
# Test connection to beamline devices
|
||||||
|
# ####################################################
|
||||||
|
# Current file path
|
||||||
path = os.path.dirname(os.path.abspath(__file__))
|
path = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
# Load simulated device database
|
||||||
from proxies import *
|
|
||||||
|
|
||||||
|
|
||||||
# Load SLS common database
|
|
||||||
fp = open(f"{path}/db/test_database.yml", "r")
|
fp = open(f"{path}/db/test_database.yml", "r")
|
||||||
lut_db = yaml.load(fp, Loader=yaml.Loader)
|
lut_db = yaml.load(fp, Loader=yaml.Loader)
|
||||||
|
|
||||||
# Load SLS common database (already in DB)
|
|
||||||
# fp = open(f"{path}/db/machine_database.yml", "r")
|
|
||||||
# lut_db = yaml.load(fp, Loader=yaml.Loader)
|
|
||||||
|
|
||||||
# Load beamline specific database
|
# Load beamline specific database
|
||||||
bl = os.getenv("BEAMLINE_XNAME", "X12SA")
|
bl = os.getenv("BEAMLINE_XNAME", "TESTENV")
|
||||||
fp = open(f"{path}/db/{bl.lower()}_database.yml", "r")
|
if bl!="TESTENV":
|
||||||
lut_db.update(yaml.load(fp, Loader=yaml.Loader))
|
fp = open(f"{path}/db/{bl.lower()}_database.yml", "r")
|
||||||
|
lut_db.update(yaml.load(fp, Loader=yaml.Loader))
|
||||||
|
|
||||||
|
|
||||||
def createProxy(name: str, connect=True) -> OphydObject:
|
def createProxy(name: str, connect=True) -> OphydObject:
|
||||||
"""Factory routine to create an ophyd device with a pre-defined schema.
|
""" Create an ophyd device from its alias
|
||||||
|
|
||||||
|
Factory routine that uses the beamline database to instantiate
|
||||||
|
instantiate ophyd devices from their alias and pre-defined
|
||||||
|
configuration parameters.
|
||||||
Does nothing if the device is already an OphydObject!
|
Does nothing if the device is already an OphydObject!
|
||||||
"""
|
"""
|
||||||
if issubclass(type(name), OphydObject):
|
if issubclass(type(name), OphydObject):
|
||||||
return name
|
return name
|
||||||
|
|
||||||
entry = lut_db[name]
|
entry = lut_db[name]
|
||||||
|
# Yeah, using global namespace
|
||||||
cls_candidate = globals()[entry["type"]]
|
cls_candidate = globals()[entry["type"]]
|
||||||
print(f"Device candidate: {cls_candidate}")
|
#print(f"Class candidate: {cls_candidate}")
|
||||||
|
|
||||||
if issubclass(cls_candidate, OphydObject):
|
if issubclass(cls_candidate, OphydObject):
|
||||||
ret = cls_candidate(**entry["config"])
|
ret = cls_candidate(**entry["config"])
|
||||||
@ -56,7 +55,13 @@ def createProxy(name: str, connect=True) -> OphydObject:
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
for key in lut_db:
|
for key in lut_db:
|
||||||
print("")
|
try:
|
||||||
dut = createProxy(str(key))
|
dut = createProxy(str(key))
|
||||||
print(f"{key}\t:\t{dut.read()}")
|
#print(f"{key}\t: {type(dut)}\t{dut.read()}")
|
||||||
|
print(f"{key}\t: {type(dut)}")
|
||||||
|
except Exception as ex:
|
||||||
|
print(ex)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
10
ophyd_devices/epics/__init__.py
Normal file
10
ophyd_devices/epics/__init__.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from .devices.DelayGeneratorDG645 import DelayGeneratorDG645
|
||||||
|
from .devices.slits import SlitH, SlitV
|
||||||
|
from .devices.XbpmBase import XbpmBase, XbpmCsaxsOp
|
||||||
|
from .devices.SpmBase import SpmBase
|
||||||
|
from .devices.InsertionDevice import InsertionDevice
|
||||||
|
|
||||||
|
# Standard ophyd classes
|
||||||
|
from ophyd import EpicsSignal, EpicsSignalRO, EpicsMotor
|
||||||
|
from ophyd.sim import SynAxis, SynSignal, SynPeriodicSignal
|
||||||
|
from ophyd.quadem import QuadEM
|
@ -565,34 +565,191 @@ led:
|
|||||||
deviceGroup: monitor
|
deviceGroup: monitor
|
||||||
status: {enabled: true}
|
status: {enabled: true}
|
||||||
type: EpicsSignalRO
|
type: EpicsSignalRO
|
||||||
|
fal0:
|
||||||
|
desc: 'Some scaler...'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: fal0, read_pv: X12SA-ES1-SCALER.S4}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
fal1:
|
||||||
|
desc: 'Some scaler...'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: fal1, read_pv: X12SA-ES1-SCALER.S5}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
fal2:
|
||||||
|
desc: 'Some scaler...'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: fal2, read_pv: X12SA-ES1-SCALER.S6}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
|
||||||
|
bpm1i:
|
||||||
|
desc: 'Some VME XBPM...'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm1i, read_pv: X12SA-OP-BPM1:SUM}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
bpm1:
|
||||||
|
desc: 'XBPM 1: Somewhere around mono (VME)'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm1, prefix: 'X12SA-OP-BPM2:'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: XbpmCsaxsOp
|
||||||
|
bpm2i:
|
||||||
|
desc: 'Some VME XBPM...'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm2i, read_pv: X12SA-OP-BPM2:SUM}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
bpm2:
|
||||||
|
desc: 'XBPM 2: Somewhere around mono (VME)'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm2, prefix: 'X12SA-OP-BPM2:'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: XbpmCsaxsOp
|
||||||
|
|
||||||
bpm3:
|
bpm3:
|
||||||
desc: 'XBPM 3: White beam before mono (VME)'
|
desc: 'XBPM 3: White beam AH501 before mono'
|
||||||
acquisition: {schedule: sync}
|
acquisition: {schedule: sync}
|
||||||
config: {name: bpm3, prefix: 'X12SA-OP-BPM1:'}
|
config: {name: bpm3, prefix: 'X12SA-OP-BPM3:'}
|
||||||
deviceGroup: monitor
|
deviceGroup: monitor
|
||||||
status: {enabled: true}
|
status: {enabled: true}
|
||||||
type: XbpmCsaxsOp
|
type: QuadEM
|
||||||
bpm4:
|
bpm3a:
|
||||||
desc: 'XBPM 4: Somewhere around mono (VME)'
|
desc: 'XBPM 3: White beam AH501 before mono'
|
||||||
acquisition: {schedule: sync}
|
acquisition: {schedule: sync}
|
||||||
config: {name: bpm4, prefix: 'X12SA-OP-BPM2:'}
|
config: {name: bpm3a, read_pv: 'X12SA-OP-BPM3:Current1:MeanValue_RBV'}
|
||||||
deviceGroup: monitor
|
deviceGroup: monitor
|
||||||
status: {enabled: true}
|
status: {enabled: true}
|
||||||
type: XbpmCsaxsOp
|
type: EpicsSignalRO
|
||||||
|
bpm3b:
|
||||||
|
desc: 'XBPM 3: White beam AH501 before mono'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm3b, read_pv: 'X12SA-OP-BPM3:Current2:MeanValue_RBV'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
bpm3c:
|
||||||
|
desc: 'XBPM 3: White beam AH501 before mono'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm3c, read_pv: 'X12SA-OP-BPM3:Current3:MeanValue_RBV'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
bpm3d:
|
||||||
|
desc: 'XBPM 3: White beam AH501 before mono'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm3d, read_pv: 'X12SA-OP-BPM3:Current4:MeanValue_RBV'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
|
||||||
|
bpm4a:
|
||||||
|
desc: 'XBPM 4: VME between mono and mirror'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm4a, read_pv: 'X12SA-OP1-SCALER.S2'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
bpm4b:
|
||||||
|
desc: 'XBPM 4: VME between mono and mirror'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm4b, read_pv: 'X12SA-OP1-SCALER.S3'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
bpm4c:
|
||||||
|
desc: 'XBPM 4: VME between mono and mirror'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm4c, read_pv: 'X12SA-OP1-SCALER.S4'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
bpm4d:
|
||||||
|
desc: 'XBPM 4: VME between mono and mirror'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm4d, read_pv: 'X12SA-OP1-SCALER.S5'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
bpm5:
|
bpm5:
|
||||||
desc: 'XBPM 5: Not commissioned'
|
desc: 'XBPM 5: AH501 past the mirror'
|
||||||
acquisition: {schedule: sync}
|
acquisition: {schedule: sync}
|
||||||
config: {name: bpm5, prefix: 'X12SA-OP-BPM5:'}
|
config: {name: bpm5, prefix: 'X12SA-OP-BPM5:'}
|
||||||
deviceGroup: monitor
|
deviceGroup: monitor
|
||||||
status: {enabled: true}
|
status: {enabled: true}
|
||||||
type: QuadEM
|
type: QuadEM
|
||||||
|
bpm5a:
|
||||||
|
desc: 'XBPM 5: AH501 past the mirror'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm5a, read_pv: 'X12SA-OP-BPM5:Current1:MeanValue_RBV'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
bpm5b:
|
||||||
|
desc: 'XBPM 5: AH501 past the mirror'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm5b, read_pv: 'X12SA-OP-BPM5:Current2:MeanValue_RBV'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
bpm5c:
|
||||||
|
desc: 'XBPM 5: AH501 past the mirror'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm5c, read_pv: 'X12SA-OP-BPM5:Current3:MeanValue_RBV'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
bpm5d:
|
||||||
|
desc: 'XBPM 5: AH501 past the mirror'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm5d, read_pv: 'X12SA-OP-BPM5:Current4:MeanValue_RBV'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
bpm6:
|
bpm6:
|
||||||
desc: 'XBPM 6: Not commissioned'
|
desc: 'XBPM 6: Xbox, not commissioned'
|
||||||
acquisition: {schedule: sync}
|
acquisition: {schedule: sync}
|
||||||
config: {name: bpm6, prefix: 'X12SA-OP-BPM6:'}
|
config: {name: bpm6, prefix: 'X12SA-OP-BPM6:'}
|
||||||
deviceGroup: monitor
|
deviceGroup: monitor
|
||||||
status: {enabled: true}
|
status: {enabled: true}
|
||||||
type: QuadEM
|
type: QuadEM
|
||||||
|
bpm6a:
|
||||||
|
desc: 'XBPM 6: Xbox, not commissioned'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm6a, read_pv: 'X12SA-OP-BPM6:Current1:MeanValue_RBV'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
bpm6b:
|
||||||
|
desc: 'XBPM 6: Xbox, not commissioned'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm6b, read_pv: 'X12SA-OP-BPM6:Current2:MeanValue_RBV'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
bpm6c:
|
||||||
|
desc: 'XBPM 6: Xbox, not commissioned'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm6c, read_pv: 'X12SA-OP-BPM6:Current3:MeanValue_RBV'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
|
bpm6d:
|
||||||
|
desc: 'XBPM 6: Xbox, not commissioned'
|
||||||
|
acquisition: {schedule: sync}
|
||||||
|
config: {name: bpm6d, read_pv: 'X12SA-OP-BPM6:Current4:MeanValue_RBV'}
|
||||||
|
deviceGroup: monitor
|
||||||
|
status: {enabled: true}
|
||||||
|
type: EpicsSignalRO
|
||||||
ftp:
|
ftp:
|
||||||
desc: 'Flight tube pressure'
|
desc: 'Flight tube pressure'
|
||||||
acquisition: {schedule: sync}
|
acquisition: {schedule: sync}
|
||||||
|
@ -3,3 +3,9 @@ from .slits import SlitH, SlitV
|
|||||||
from .XbpmBase import XbpmBase, XbpmCsaxsOp
|
from .XbpmBase import XbpmBase, XbpmCsaxsOp
|
||||||
from .SpmBase import SpmBase
|
from .SpmBase import SpmBase
|
||||||
from .InsertionDevice import InsertionDevice
|
from .InsertionDevice import InsertionDevice
|
||||||
|
|
||||||
|
# Standard ophyd classes
|
||||||
|
from ophyd import EpicsSignal, EpicsSignalRO, EpicsMotor
|
||||||
|
from ophyd.sim import SynAxis, SynSignal, SynPeriodicSignal
|
||||||
|
from ophyd.quadem import QuadEM
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user