From 8bb89cbf764777bc88ebfa2209b48eed0367b610 Mon Sep 17 00:00:00 2001 From: Holler Mirko Date: Mon, 1 Jul 2024 15:06:19 +0200 Subject: [PATCH] omny galil --- csaxs_bec/device_configs/omny_config.yaml | 397 ++++++++++++++++++- csaxs_bec/devices/omny/galil/galil_ophyd.py | 26 +- csaxs_bec/devices/omny/galil/ogalil_ophyd.py | 41 +- 3 files changed, 439 insertions(+), 25 deletions(-) diff --git a/csaxs_bec/device_configs/omny_config.yaml b/csaxs_bec/device_configs/omny_config.yaml index 23827ae..f8db749 100644 --- a/csaxs_bec/device_configs/omny_config.yaml +++ b/csaxs_bec/device_configs/omny_config.yaml @@ -1,17 +1,18 @@ ############################################################ ##################### OMNY samples ######################### ############################################################ -#omny_samples: description: OMNYSampleStorage -# deviceClass: csaxs_bec.devices.omny.omny_sample_storage.OMNYSampleStorage -# deviceConfig: {} -# enabled: true -# onFailure: buffer -# readOnly: false -# readoutPriority: baseline +omny_samples: + description: OMNYSampleStorage + deviceClass: csaxs_bec.devices.omny.omny_sample_storage.OMNYSampleStorage + deviceConfig: {} + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + ############################################################ ##################### OMNY Galil motors #################### ############################################################ - ofzpx: description: FZP X deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor @@ -22,6 +23,44 @@ ofzpx: - 0 - 0 port: 8081 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +ofzpy: + description: FZP Y + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: B + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8081 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +ofzpz: + description: FZP Z + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: C + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8081 sign: -1 deviceTags: - omny @@ -29,5 +68,347 @@ ofzpx: onFailure: buffer readOnly: false readoutPriority: baseline + userParameter: + in: 0 +otransx: + description: Transfer X + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: D + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8081 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +otransy: + description: Transfer Y + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: E + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8081 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +otransz: + description: Transfer Z + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: F + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8081 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +osamx: + description: Sample X + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: A + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8082 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +osamz: + description: Sample Z + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: B + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8082 + sign: 1 + deviceTags: + - omny + enabled: false + onFailure: buffer + readOnly: true + readoutPriority: baseline + userParameter: + in: 0 +oosay: + description: OSA Y + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: C + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8082 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +oosax: + description: OSA X + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: D + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8082 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +oosaz: + description: OSA Z + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: E + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8082 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +oparkz: + description: OSA Y + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: F + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8082 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +oshuttleopen: + description: Shuttle opener + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: G + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8082 + sign: 1 + deviceTags: + - omny + enabled: false + onFailure: buffer + readOnly: true + readoutPriority: baseline + userParameter: + in: 0 +oshuttlealign: + description: Shuttle aligner + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: H + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8082 + sign: 1 + deviceTags: + - omny + enabled: false + onFailure: buffer + readOnly: true + readoutPriority: baseline + userParameter: + in: 0 +osamy: + description: Sample Y + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: A + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8083 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +otracky: + description: Laser Tracker Y + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: B + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8083 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +osamroy: + description: Sample rotation + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: C + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8083 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +otrackz: + description: Laser Tracker Z + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: E + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8083 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +oeyex: + description: Xray eye X + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: F + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8083 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +oeyez: + description: Xray eye Z + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: G + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8083 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline + userParameter: + in: 0 +oeyey: + description: Xray eye Y + deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor + deviceConfig: + axis_Id: H + host: mpc3217.psi.ch + limits: + - 0 + - 0 + port: 8083 + sign: 1 + deviceTags: + - omny + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: baseline userParameter: in: 0 \ No newline at end of file diff --git a/csaxs_bec/devices/omny/galil/galil_ophyd.py b/csaxs_bec/devices/omny/galil/galil_ophyd.py index 73b27fe..6760683 100644 --- a/csaxs_bec/devices/omny/galil/galil_ophyd.py +++ b/csaxs_bec/devices/omny/galil/galil_ophyd.py @@ -120,19 +120,16 @@ class GalilController(Controller): #the motors of the parking station have a different offset #the range is reduced, so if at the limit, we show an extreme value - - # if(ogalil_no==1 && axis_no==6) { - # temperature_degC = (voltage+10.0-11.4) / 20.0 * 300.0 - # if (voltage > 9.9) - # temperature_degC=300 - # } - - # if(ogalil_no==1 && axis_no==7) { - # temperature_degC = (voltage+10.0-12) / 20.0 * 300.0 - # if (voltage > 9.9) - # temperature_degC=300 - # } - + if self.sock.port == 8082: + #controller 2 + if axis_Id_numeric == 6: + temperature_degC = round((voltage+10.0-11.4) / 20.0 * 300.0, 1) + if voltage > 9.9: + temperature_degC = 300 + if axis_Id_numeric == 7: + temperature_degC = round((voltage+10.0-12) / 20.0 * 300.0, 1) + if voltage > 9.9: + temperature_degC = 300 return temperature_degC def all_axes_referenced(self) -> bool: @@ -231,7 +228,6 @@ class GalilController(Controller): field_names = [ "Axis", "Name", - "Connected", "Referenced", "Motor On", "Limits", @@ -250,7 +246,6 @@ class GalilController(Controller): [ f"{axis.axis_Id_numeric}/{axis.axis_Id}", axis.name, - axis.connected, self.axis_is_referenced(axis.axis_Id_numeric), self.is_motor_on(axis.axis_Id), self.get_motor_limit_switch(axis.axis_Id), @@ -264,7 +259,6 @@ class GalilController(Controller): [ f"{axis.axis_Id_numeric}/{axis.axis_Id}", axis.name, - axis.connected, self.axis_is_referenced(axis.axis_Id_numeric), self.is_motor_on(axis.axis_Id), self.get_motor_limit_switch(axis.axis_Id), diff --git a/csaxs_bec/devices/omny/galil/ogalil_ophyd.py b/csaxs_bec/devices/omny/galil/ogalil_ophyd.py index 3eb9019..0e819dc 100644 --- a/csaxs_bec/devices/omny/galil/ogalil_ophyd.py +++ b/csaxs_bec/devices/omny/galil/ogalil_ophyd.py @@ -21,6 +21,8 @@ from csaxs_bec.devices.omny.galil.galil_ophyd import ( GalilMotorIsMoving, GalilSetpointSignal, GalilSignalRO, + GalilCommunicationError, + GalilError, ) logger = bec_logger.logger @@ -85,7 +87,43 @@ class OMNYGalilController(GalilController): "get_motor_limit_switch", "is_motor_on", "all_axes_referenced", + "_ogalil_switchsocket", + "_ogalil_switchsocket_switch_all_on", + "_ogalil_switchsocket_status", + "_ogalil_switchsocket_are_all_on", ] + def on(self) -> None: + """Open a new socket connection to the controller""" + self._ogalil_switchsocket_switch_all_on() + time.sleep(0.3) + super().on() + + def _ogalil_switchsocket(self, number:int, switch:bool): + #number is socket number ranging from 1 to 4 + #switch is either 0 or 1 + if number not in range(1,5): + raise Exception("Socket number ranges from 1 to 4") + else: + contents = urllib.request.urlopen(f"http://mpc3217:8091/netio.cgi?pass=24A42C3929C5&output{number}={switch}").read() + #print(contents) + if b'OK' in contents: + print(f"Controller number switchsocket {number} is now {switch}") + return(1) + else: + print(f"Failed to switch controller number {number}") + return(0) + + def _ogalil_switchsocket_are_all_on(self): + if self._ogalil_switchsocket_status() == [1,1,1,1]: + return(1) + else: + return(0) + + def _ogalil_switchsocket_switch_all_on(self): + if not self._ogalil_switchsocket_are_all_on(): + for j in range (1,5): + self._ogalil_switchsocket(j,1) + time.sleep(0.4) def _ogalil_switchsocket_status(self): contents = urllib.request.urlopen("http://mpc3217:8091/netio.xml").read() @@ -107,7 +145,8 @@ class OMNYGalilController(GalilController): print("Digital input 5 test.") swver = float(self.socket_put_and_receive("MGswver")) print(f"Ogalil OMNY firmware version {swver:2.0f}.") - self._ogalil_switchsocket_status() + if self.sock.port == 8083: + self._ogalil_switchsocket_status()