diff --git a/script/Alignment/Gun_solenoid_alignment.py b/script/Alignment/Gun_solenoid_alignment.py index 65328ce..c4a5c0d 100755 --- a/script/Alignment/Gun_solenoid_alignment.py +++ b/script/Alignment/Gun_solenoid_alignment.py @@ -19,7 +19,7 @@ if get_context().source == CommandSource.ui: dI = 1.0 settling_time = 0.1 plot_image = False - number_images = 1 + number_images = 5 use_background = True multiple_background = False number_backgrounds = 5 @@ -29,8 +29,6 @@ if get_context().source == CommandSource.ui: else: centroid_excursion_plot = False -LASER_SETTLING_TIME = 0.1 - print "Parameters: ", I1, I2, dI, settling_time, plot_image, number_images, use_background, multiple_background, number_backgrounds plot_name = datetime.datetime.fromtimestamp(time.time()).strftime('%H%M%S') @@ -44,22 +42,6 @@ if use_background and not multiple_background: camtool.captureBackground(number_backgrounds) multiple_background = multiple_background and use_background -def ccr(mag): - n = 1 - while n > 0: - sleep(0.5) - n = caget(mag + ":I-COMP") - -def laser_on(): - print "Laser On" - #caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", 0) - time.sleep(LASER_SETTLING_TIME) - -def laser_off(): - print "Laser Off" - #caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", 1) - time.sleep(LASER_SETTLING_TIME) - # Switch off magnets mag = [ "SINEG01-MCRX120","SINEG01-MCRY120", @@ -71,11 +53,8 @@ mag = [ "SINEG01-MCRX120","SINEG01-MCRY120", "SINEG01-MCRX220","SINEG01-MCRY220", "SINEG01-MQUA310", "SINEG01-MQUA320" ] -if zero_solenoids: - for m in mag: - caput(m + ":I-SET", 0.0) - for m in mag: - ccr(m) +if zero_solenoids: + switchOffMagnets(mag) # add here gun phase setting see wiki page @@ -96,7 +75,7 @@ if not multiple_background: laser_on() try: #sensors = [camtool.com_x, camtool.com_y] - sensors = [camtool.com_x_mean, camtool.com_y_mean] + sensors = [camtool.com_x_mean, camtool.com_y_mean, camtool.com_x_var, camtool.com_y_var] if plot_image: sensors.append(camtool.image) r = lscan(gun_solenoid, sensors , I1, I2, dI, settling_time, before_read = br, after_read = ar) diff --git a/script/Alignment/Laser_gun_alignment.py b/script/Alignment/Laser_gun_alignment.py index 0f130a1..38bd7ee 100755 --- a/script/Alignment/Laser_gun_alignment.py +++ b/script/Alignment/Laser_gun_alignment.py @@ -37,56 +37,6 @@ print "Parameters: ", phi1, phi2, dphi, settling_time, plot_image, number_images plot_name = datetime.datetime.fromtimestamp(time.time()).strftime('%H%M%S') -cam_x = Channel("SINEG01-DSCR190:profile.X_stats.com", alias = "cam_x") -cam_y = Channel("SINEG01-DSCR190:profile.Y_stats.com", alias = "cam_y") - -profile_x = Channel("SINEG01-DSCR190:profile.X", alias = "profile_x") -profile_y = Channel("SINEG01-DSCR190:profile.Y", alias = "profile_y") - -cam_raw_data = Channel("SINEG01-DSCR190:data") - - -class CameraImage(ReadableMatrix): - def read(self): - raw = cam_raw_data.read() - return Matrix(mono_to_bidi(raw, self.getHeight(), self.getWidth())).transpose().getData() #data is transposed - #return mono_to_bidi(raw, self.getWidth(), self.getHeight()) - - def getWidth(self): - return self._width - - def getHeight(self): - return self._height - -cam_img = CameraImage() -cam_img._width = len(profile_x.read()) -cam_img._height = len(profile_y.read()) - - -def ccr(mag): - n = 1 - while n > 0: - sleep(0.5) - n = caget(mag + ":I-COMP") - -def laser_on(): - caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", 0) - -def laser_off(): - caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", 1) - - -def run_pipeline(): - caput("camtool...:start") - - while !caget("camtool...:done"): - sleep(0.1) - - caget("camtool....:data") - #caget("camtool....:X_stats.com") - #caget("camtool....:X_stats.com") - - # Switch off magnets mag = [ "SINEG01-MCRX120","SINEG01-MCRY120", @@ -98,11 +48,8 @@ mag = [ "SINEG01-MCRX120","SINEG01-MCRY120", "SINEG01-MCRX220","SINEG01-MCRY220", "SINEG01-MQUA310", "SINEG01-MQUA320" ] -if zero_solenoids: - for m in mag: - caput(m + ":I-SET", 0.0) - for m in mag: - ccr(m) +if zero_solenoids: + switchOffMagnets(mag) # add here gun phase setting see wiki page diff --git a/script/camtool.py b/script/camtool.py index 9334c44..3f2c918 100644 --- a/script/camtool.py +++ b/script/camtool.py @@ -53,12 +53,12 @@ class CamTool(DeviceBase): self.com_x_samples, self.com_y_samples = [], [] class CamToolComX(Readable): def read(self): - print "X", self.camtool.com_x_samples, mean(self.camtool.com_x_samples) + print self.camtool.take(), "X", self.camtool.com_x_samples, mean(self.camtool.com_x_samples) return mean(self.camtool.com_x_samples) self.com_x_mean = CamToolComX(); self.com_x_mean.camtool = self class CamToolComY(Readable): def read(self): - print "Y", self.camtool.com_y_samples, mean(self.camtool.com_y_samples) + print self.camtool.take(), "Y", self.camtool.com_y_samples, mean(self.camtool.com_y_samples) return mean(self.camtool.com_y_samples) self.com_y_mean = CamToolComY(); self.com_y_mean.camtool = self class CamToolComXVar(Readable):