Esempio n. 1
0
 def pre_scan_stuff(slf):
     # basex.proxy.PowerOn = False
     # basey.proxy.PowerOn = False
     # basez.proxy.PowerOn = False
     runCommand('stoplive')
     runCommand('fsopen')
     time.sleep(0.2)
Esempio n. 2
0
    def run(self):
        command = 'umv'
        if isinstance(self.energy, (int, float)):
            if self.energy < 5000 or self.energy > 28250:
                msg = '[Error] photon energy must be between 5000 and 28250 eV'
                print('     %s' % msg)
                exit()

            # Sets the monochromator perpendicular, coarse pitch and
            # coarse roll motors
            per = self.beam_offset()
            pit, rol = self.mono_x2_pit_rol()
            if (per < -0.2 or per > 1.0
                    or pit < -1.0 or pit > 1.0
                    or rol < -1.0 or rol > 1.0):
                msg = 'Tries to set per, pit or rol to unreasonable value'
                print('    [ERROR] %s %.3f %.3f %.3f' % (msg, per, pit, rol))
            else:
                command += ' energy %0.2f' % (self.energy)
                command += ' mono_x2per %.3f' % (per)

            # Sets the SSA opening
            if isinstance(self.ssa, (str)):
                sx, sy = self.ssa_gap_coherent()
                if self.ssa == 'coh':
                    command += ' ssa_gapx %.2f' % sx + ' ssa_gapy %.2f' % sy
                elif self.ssa == 'flux':
                    command += (' ssa_gapx %.2f' % (2 * sx)
                                + ' ssa_gapy %.2f' % (2 * sy))

            # Finds the best undulator gap
            if self.set_gap:
                gap = self.ivu_gap()
                if gap < 4.5 or gap > 7.0:
                    msg = 'Tries to set undulator to unreasonable value'
                    print('    [ERROR] %s %.3f' % (msg, gap))
                else:
                    command += ' ivu_gap %0.3f' % (gap)
                    ivu_command = 'umv ivu_gap %0.3f' % (gap)

            # Selects mirror coating on the HFM mirror
            if self.set_coating:
                if self.energy < 10000:
                    command += ' hfm_y ' + self.coatings['Si']
                elif self.energy < 22000:
                    command += ' hfm_y ' + self.coatings['Rh']
                elif self.energy < 28250:
                    command += ' hfm_y ' + self.coatings['Pt']
            print('Remember to pause the NanoBPM before changing energy.')
            print('\nCommand to execute: ' + command + '\n')
            if input('Execute(y/n)?').lower().strip() == 'y':
                runCommand(command)
                if self.set_gap:
                    runCommand(ivu_command)
                print('Beamline set to %.2f eV' % self.energy)
            else:
                print('No motors were moved')
        else:
            print('    [ERROR] photon energy is not specified')
Esempio n. 3
0
 def post_scan_stuff(slf):
     # basex.proxy.PowerOn = True
     # basey.proxy.PowerOn = True
     # basez.proxy.PowerOn = True
     runCommand('fsclose')
     pass
Esempio n. 4
0
 def post_scan_stuff(slf):
     runCommand('fsclose')
     pass
Esempio n. 5
0
 def pre_scan_stuff(slf):
     runCommand('stoplive')
     runCommand('fsopen')
     b1.stop()  # making sure the base motors are not regulating
     time.sleep(0.2)
Esempio n. 6
0
 def pre_scan_stuff(slf):
     runCommand('stoplive')
Esempio n. 7
0
 def run_command(self, command):
     runCommand(command)
Esempio n. 8
0
 def get_current_energy(self):
     runCommand('wms energy')
     self.photon_energy = env.lastMacroResult
Esempio n. 9
0
 def get_current_carrier_positions(self):
     carrier_positions = []
     for carrier in sorted(self.carriers):
         runCommand('wms ' + carrier)
         carrier_positions.append(env.lastMacroResult)
     return np.array(carrier_positions)
Esempio n. 10
0
 def run(self):
     cmd = 'mvr m2fpitch %f' % (self.dist / -857.0)
     print("Moving the M2 fine pitch piezo like this:\n%s" % cmd)
     runCommand(cmd)
Esempio n. 11
0
 def get_motor_position(self, motor):
     runCommand('wms ' + motor)
     return env.lastMacroResult
Esempio n. 12
0
 def move_motor(self, motor, position):
     runCommand('umv ' + motor + ' ' + str(position))
Esempio n. 13
0
 def get_current_energy(self):
     runCommand('wms energy')
     # print(env)
     self.photon_energy_eV = env.lastMacroResult
     self.wavelength_m = 12400. / self.photon_energy_eV * 1e-10
Esempio n. 14
0
 def run(self):
     while True:
         cmd = self.socket.recv().decode()
         runCommand(cmd)
         self.socket.send(json.dumps(env.lastMacroResult).encode())