added power_on/off_modules

This commit is contained in:
NichtJens
2024-11-16 19:36:57 +01:00
parent 98a5c60fb6
commit 468526812f
4 changed files with 55 additions and 0 deletions
+38
View File
@@ -131,6 +131,44 @@ class DetectorManager:
return res
def power_on_modules(self, request, remote_ip):
return self._set_power_modules("on", request, remote_ip)
def power_off_modules(self, request, remote_ip):
return self._set_power_modules("off", request, remote_ip)
def _set_power_modules(self, target_state, request, remote_ip):
validate.request_has(request, "detector_name", "modules")
beamline = get_beamline(remote_ip)
allowed_detectors_beamline = get_configured_detectors(beamline)
detector_name = request["detector_name"]
validate.detector_name_in_allowed_detectors_beamline(detector_name, allowed_detectors_beamline, beamline)
detector = Detector(detector_name)
modules = request["modules"]
number_modules = detector.cfg.get_number_modules()
validate.allowed_detector_modules(detector_name, modules, number_modules)
if target_state == "on":
detector.power_on_modules(modules)
elif target_state == "off":
detector.power_off_modules(modules)
else:
raise ValueError(f'detector modules power state can either be "on" or "off", but requested is: {target_state}')
res = {
"status": "ok",
"message": f"successfully powered {target_state} modules {modules} of {detector_name}"
}
return res
def copy_user_files(self, request, remote_ip):
validate.request_has(request, "pgroup", "run_number")
+2
View File
@@ -14,6 +14,8 @@ _logger = logging.getLogger(__name__)
ENDPOINTS_POST = [
"set_detector_settings",
"power_on_modules",
"power_off_modules",
"copy_user_files",
"set_dap_settings"
]
+9
View File
@@ -154,6 +154,15 @@ class Detector:
self.jf.pedestalmode = pp
def power_on_modules(self, modules):
self.jf.setPowerChip(True, modules)
self.jf.setHighVoltage(120, modules)
def power_off_modules(self, modules):
self.jf.setHighVoltage(0, modules)
self.jf.setPowerChip(False, modules)
def parse_param_list(seq):
"""
+6
View File
@@ -71,6 +71,12 @@ def all_detector_names_in_allowed_detectors_beamline(dns, adb, bl):
for dn in dns:
detector_name_in_allowed_detectors_beamline(dn, adb, bl)
def allowed_detector_modules(dn, mods, n_mods):
allowed = range(n_mods)
for i in mods:
if i not in allowed:
raise ValidationError(f"requested module {i} is not allowed for detector {dn} (number of modules: {n_mods})")
def allowed_pulseid_range(pid_start, pid_stop):
delta = pid_stop - pid_start
if delta > MAX_PULSEID_DELTA: