Skip to content

Commit a411601

Browse files
committed
wip
1 parent 9cb0049 commit a411601

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

src/eiger_fastcs/eiger_controller.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ async def update(
3535

3636

3737
class EigerController(Controller):
38+
detector_state = AttrR(
39+
String(),
40+
handler=EigerHandler("detector/api/1.8.0/status/state"),
41+
)
42+
3843
def __init__(self, settings: IPConnectionSettings) -> None:
3944
super().__init__()
4045
self._ip_settings = settings
@@ -80,8 +85,11 @@ async def initialise(self) -> None:
8085
case _:
8186
print(f"Could not process {parameter_name}")
8287

83-
# finding appropriate naming to ensure repeats are not ovewritten
84-
if parameter_name in list(attributes.keys()):
88+
# finding appropriate naming to ensure repeats are not ovewritten and ensuring that PV has not been created already
89+
if (
90+
parameter_name in list(attributes.keys())
91+
and parameter_name not in self.__dict__.keys()
92+
):
8593
# Adding original instance of the duplicate into dictionary to rename original instance in attributes later
8694
if parameter_name not in list(pv_clashes.keys()):
8795
pv_clashes[
@@ -108,14 +116,28 @@ async def initialise(self) -> None:
108116
),
109117
)
110118

111-
# Renaming original instance of duplicate in Attribute
119+
# Renaming original instance of duplicate in Attribute / Removing unique names already created
112120
for clash_name, unique_name in pv_clashes.items():
113-
attributes[unique_name] = attributes.pop(clash_name)
114-
print(f"Replacing the repeat,{clash_name}, with {unique_name}")
121+
if unique_name in self.__dict__.keys():
122+
del attributes[clash_name]
123+
print(
124+
f"{unique_name} was already created before, {clash_name} is being deleted"
125+
)
126+
127+
else:
128+
attributes[unique_name] = attributes.pop(clash_name)
129+
print(f"Replacing the repeat,{clash_name}, with {unique_name}")
115130

116131
for name, attribute in attributes.items():
117132
setattr(self, name, attribute)
118133

134+
# Check current state of detector_state to see if initializing is required.
135+
detector_state_val = await connection.get(self.detector_state.updater.name)
136+
if detector_state_val["value"] == "na":
137+
print("Initializing Detector")
138+
await connection.put("detector/api/1.8.0/command/initialize", "")
139+
140+
a = 1
119141
await connection.close()
120142

121143
async def close(self) -> None:

0 commit comments

Comments
 (0)