-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
mca is defined as the following:
1 from hxntools.detectors.zebra import (EpicsSignalWithRBV,
2 ZebraPulse,
3 ZebraFrontOutput12,
4 ZebraFrontOutput3,
5 ZebraFrontOutput4,
6 ZebraRearOutput,
7 ZebraGate,
8 ZebraAddresses)
9
10 from hxntools.detectors.xspress3 import (XspressTrigger,
11 Xspress3Detector,
12 Xspress3Channel)
13 from ophyd.areadetector.plugins import PluginBase
14 from ophyd import (FormattedComponent as FC)
15
16 class ZebraINP(Device):
17 use = FC(EpicsSignal,
18 '{self.prefix}_ENA:B{self._bindex}')
19 source_addr = FC(EpicsSignalWithRBV,
20 '{self.prefix}_INP{self.index}')
21 source_str = FC(EpicsSignalRO,
22 '{self.prefix}_INP{self.index}:STR',
23 string=True)
24 source_status = FC(EpicsSignalRO,
25 '{self.prefix}_INP{self.index}:STA')
26 invert = FC(EpicsSignal,
27 '{self.prefix}_INV:B{self._bindex}')
28
29 def __init__(self, prefix, *, index, read_attrs=None, configuration_attrs=None,
30 **kwargs):
31 if read_attrs is None:
32 read_attrs = []
33 if configuration_attrs is None:
34 configuration_attrs = ['use', 'source_addr', 'source_str', 'invert']
35 self.index = index
36 self._bindex = index - 1
37 super().__init__(prefix, read_attrs=read_attrs, configuration_attrs=configuration_attrs,
38 **kwargs)
39
40
41 class ZebraLogic(Device):
42
43 inp1 = Cpt(ZebraINP, '', index=1)
44 inp2 = Cpt(ZebraINP, '', index=2)
45 inp3 = Cpt(ZebraINP, '', index=3)
46 inp4 = Cpt(ZebraINP, '', index=4)
47 out = Cpt(EpicsSignalRO, '_OUT')
48
49 def __init__(self, *args, read_attrs=None, configuration_attrs=None,
50 **kwargs):
51 if read_attrs is None:
52 read_attrs = ['out']
53 if configuration_attrs is None:
54 configuration_attrs = ['inp{}'.format(j) for j in range(1, 5)]
55
56 super().__init__(*args, read_attrs=read_attrs,
57 configuration_attrs=configuration_attrs, **kwargs)
58
59
60 class CHXXspress3Detector(XspressTrigger, Xspress3Detector):
61 roi_data = Cpt(PluginBase, 'ROIDATA:')
62 channel1 = Cpt(Xspress3Channel,
63 'C1_', channel_num=1,
64 read_attrs=['rois'])
65
66 class GateConfig(Device):
67 trig_source = Cpt(EpicsSignalWithRBV, 'PC_GATE_SEL', string=True)
68 start = Cpt(EpicsSignal, 'PC_GATE_START')
69 width = Cpt(EpicsSignal, 'PC_GATE_WID')
70 step = Cpt(EpicsSignal, 'PC_GATE_STEP')
71 ngate = Cpt(EpicsSignal, 'PC_GATE_NGATE')
72 status = Cpt(EpicsSignal, 'PC_GATE_OUT')
73
74
75 class PulseConfig(Device):
76 trig_source = Cpt(EpicsSignalWithRBV, 'PC_PULSE_SEL', string=True)
77 start = Cpt(EpicsSignal, 'PC_PULSE_START')
78 width = Cpt(EpicsSignal, 'PC_PULSE_WID')
79 step = Cpt(EpicsSignal, 'PC_PULSE_STEP')
80 delay = Cpt(EpicsSignal, 'PC_PULSE_DLY')
81 nmax = Cpt(EpicsSignal, 'PC_PULSE_MAX')
82 status = Cpt(EpicsSignal, 'PC_PULSE_OUT')
83
84 class Zebra(Device):
85 soft_input1 = Cpt(EpicsSignal, 'SOFT_IN:B0')
86 soft_input2 = Cpt(EpicsSignal, 'SOFT_IN:B1')
87 soft_input3 = Cpt(EpicsSignal, 'SOFT_IN:B2')
88 soft_input4 = Cpt(EpicsSignal, 'SOFT_IN:B3')
89
90 pulse1 = Cpt(ZebraPulse, 'PULSE1_', index=1)
91 pulse2 = Cpt(ZebraPulse, 'PULSE2_', index=2)
92 pulse3 = Cpt(ZebraPulse, 'PULSE3_', index=3)
93 pulse4 = Cpt(ZebraPulse, 'PULSE4_', index=4)
94
95 output1 = Cpt(ZebraFrontOutput12, 'OUT1_', index=1)
96 output2 = Cpt(ZebraFrontOutput12, 'OUT2_', index=2)
97 output3 = Cpt(ZebraFrontOutput3, 'OUT3_', index=3)
98 output4 = Cpt(ZebraFrontOutput4, 'OUT4_', index=4)
99
100 output5 = Cpt(ZebraRearOutput, 'OUT5_', index=5)
101 output6 = Cpt(ZebraRearOutput, 'OUT6_', index=6)
102 output7 = Cpt(ZebraRearOutput, 'OUT7_', index=7)
103 output8 = Cpt(ZebraRearOutput, 'OUT8_', index=8)
104
105 gate1 = Cpt(ZebraGate, 'GATE1_', index=1)
106 gate2 = Cpt(ZebraGate, 'GATE2_', index=2)
107 gate3 = Cpt(ZebraGate, 'GATE3_', index=3)
108 gate4 = Cpt(ZebraGate, 'GATE4_', index=4)
109
110 or1 = Cpt(ZebraLogic, 'OR1')
111 or2 = Cpt(ZebraLogic, 'OR2')
112 or3 = Cpt(ZebraLogic, 'OR3')
113 or4 = Cpt(ZebraLogic, 'OR4')
114
115 and1 = Cpt(ZebraLogic, 'AND1')
116 and2 = Cpt(ZebraLogic, 'AND2')
117 and3 = Cpt(ZebraLogic, 'AND3')
118 and4 = Cpt(ZebraLogic, 'AND4')
119
120 addresses = ZebraAddresses
121
122 arm = Cpt(EpicsSignal, 'PC_ARM')
123 arm_status = Cpt(EpicsSignal, 'PC_ARM_OUT')
124 arm_trig = Cpt(EpicsSignalWithRBV, 'PC_ARM_SEL', string=True)
125
126 gate_config = Cpt(GateConfig, '', read_attrs=[], configuration_attrs=['trig_source', 'start', 'width', 'step', 'ngate'])
127 pulse_config = Cpt(PulseConfig, '', read_attrs=[], configuration_attrs=['trig_source', 'start', 'width', 'step', 'delay', 'nmax'])
128
129
130
131 class CHXZebra(Zebra):
132 ...
133
134
135
136 class XspressZebra(Device):
137 zebra = Cpt(CHXZebra, 'XF:11IDB-ES{Zebra}:', add_prefix=(),
138 configuration_attrs=['{}{}'.format(n, j) for n in ['pulse', 'gate', 'or', 'and']
139 for j in range(1,5)] + ['output{}'.format(i) for i in range(1, 9)] + ['gate_config', 'pulse_config', 'arm_trig'],
140 read_attrs=[])
141 xs = Cpt(CHXXspress3Detector, 'XSPRESS3-EXAMPLE:', add_prefix=())
142
143 def __init__(self, *args, **kwargs):
144 super().__init__(*args, **kwargs)
145
146
147 def trigger(self):
148 st = self.xs.trigger()
149 # TODO make sure Xspress is actually ready before
150 # arming zebra
151 self.zebra.arm.set(1)
152 return st
153
154
155 def construct_mca():
156 ...
157 Once run
mca = XspressZebra('', name='mca', configuration_attrs=['zebra', 'xs'], read_attrs=['xs'])we got
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~/.ipython/profile_collection/startup/98-xspress3.py in <module>()
----> 1 mca = XspressZebra('', name='mca', configuration_attrs=['zebra', 'xs'], read_attrs=['xs'])
~/.ipython/profile_collection/startup/98-xspress3.py in __init__(self, *args, **kwargs)
142
143 def __init__(self, *args, **kwargs):
--> 144 super().__init__(*args, **kwargs)
145
146
/opt/conda_envs/collection-2018-1.0/lib/python3.6/site-packages/ophyd/device.py in __init__(self, prefix, name, read_attrs, configuration_attrs, parent, **kwargs)
731
732 # Instantiate non-lazy signals
--> 733 [getattr(self, attr) for attr, cpt in self._sig_attrs.items()
734 if not cpt.lazy]
735
/opt/conda_envs/collection-2018-1.0/lib/python3.6/site-packages/ophyd/device.py in <listcomp>(.0)
732 # Instantiate non-lazy signals
733 [getattr(self, attr) for attr, cpt in self._sig_attrs.items()
--> 734 if not cpt.lazy]
735
736 @property
/opt/conda_envs/collection-2018-1.0/lib/python3.6/site-packages/ophyd/device.py in __get__(self, instance, owner)
174
175 if self.attr not in instance._signals:
--> 176 instance._signals[self.attr] = self.create_component(instance)
177
178 return instance._signals[self.attr]
/opt/conda_envs/collection-2018-1.0/lib/python3.6/site-packages/ophyd/device.py in create_component(self, instance)
127 elif self.suffix is not None:
128 pv_name = self.maybe_add_prefix(instance, 'suffix', self.suffix)
--> 129 cpt_inst = self.cls(pv_name, parent=instance, **kwargs)
130 else:
131 cpt_inst = self.cls(parent=instance, **kwargs)
/opt/conda_envs/collection-2018-1.0/lib/python3.6/site-packages/ophyd/device.py in __init__(self, prefix, name, read_attrs, configuration_attrs, parent, **kwargs)
731
732 # Instantiate non-lazy signals
--> 733 [getattr(self, attr) for attr, cpt in self._sig_attrs.items()
734 if not cpt.lazy]
735
/opt/conda_envs/collection-2018-1.0/lib/python3.6/site-packages/ophyd/device.py in <listcomp>(.0)
732 # Instantiate non-lazy signals
733 [getattr(self, attr) for attr, cpt in self._sig_attrs.items()
--> 734 if not cpt.lazy]
735
736 @property
/opt/conda_envs/collection-2018-1.0/lib/python3.6/site-packages/ophyd/device.py in __get__(self, instance, owner)
174
175 if self.attr not in instance._signals:
--> 176 instance._signals[self.attr] = self.create_component(instance)
177
178 return instance._signals[self.attr]
/opt/conda_envs/collection-2018-1.0/lib/python3.6/site-packages/ophyd/device.py in create_component(self, instance)
127 elif self.suffix is not None:
128 pv_name = self.maybe_add_prefix(instance, 'suffix', self.suffix)
--> 129 cpt_inst = self.cls(pv_name, parent=instance, **kwargs)
130 else:
131 cpt_inst = self.cls(parent=instance, **kwargs)
/opt/conda_envs/collection-2018-1.0/lib/python3.6/site-packages/hxntools/detectors/zebra.py in __init__(self, prefix, index, parent, configuration_attrs, read_attrs, **kwargs)
121 read_attrs = []
122 if configuration_attrs is None:
--> 123 configuration_attrs = _get_configuration_attrs(self.__class__)
124
125 zebra = parent
/opt/conda_envs/collection-2018-1.0/lib/python3.6/site-packages/hxntools/detectors/zebra.py in _get_configuration_attrs(cls, signal_class)
13
14 def _get_configuration_attrs(cls, *, signal_class=Signal):
---> 15 return [sig_name for sig_name in cls.signal_names
16 if issubclass(getattr(cls, sig_name).cls, signal_class)]
17
TypeError: 'property' object is not iterableGenerally, we don't want to import the function from other beamline package. It would make more sense to incorporate the funcs into our chxtools package.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels