def __init__(self): tao_lib = os.environ.get('TAO_LIB', '') self.tao = pytao.Tao(so_lib=tao_lib) path_to_lattice = os.path.join(os.path.dirname(os.path.realpath(__file__)), "lcls.lat") path_to_init = os.path.join(os.path.dirname(os.path.realpath(__file__)), "tao.init") self.tao.init("-noplot -lat {lat_path} -init {init_path}".format(lat_path=path_to_lattice, init_path=path_to_init)) self.ctx = Context.instance() self.model_broadcast_socket = zmq.Context().socket(zmq.PUB) self.model_broadcast_socket.bind("tcp://*:{}".format(os.environ.get('MODEL_BROADCAST_PORT', 66666)))
def __init__(self, init_file, name, enable_jitter=False, plot=False): self.name = name tao_lib = os.environ.get('TAO_LIB', '') self.tao = pytao.Tao(so_lib=tao_lib) L.debug("Initializing Tao...") if plot: self.tao.init("-init {init_file}".format(init_file=init_file)) else: self.tao.init("-noplot -init {init_file}".format(init_file=init_file)) L.debug("Tao initialization complete!") self.tao.cmd("set global lattice_calc_on = F") self.ctx = Context.instance() self.model_broadcast_socket = zmq.Context().socket(zmq.PUB) self.model_broadcast_socket.bind("tcp://*:{}".format(os.environ.get('MODEL_BROADCAST_PORT', 66666))) self.loop = asyncio.get_event_loop() self.jitter_enabled = enable_jitter self.twiss_table = NTTable([("element", "s"), ("device_name", "s"), ("s", "d"), ("length", "d"), ("p0c", "d"), ("alpha_x", "d"), ("beta_x", "d"), ("eta_x", "d"), ("etap_x", "d"), ("psi_x", "d"), ("alpha_y", "d"), ("beta_y", "d"), ("eta_y", "d"), ("etap_y", "d"), ("psi_y", "d")]) self.rmat_table = NTTable([("element", "s"), ("device_name", "s"), ("s", "d"), ("length", "d"), ("r11", "d"), ("r12", "d"), ("r13", "d"), ("r14", "d"), ("r15", "d"), ("r16", "d"), ("r21", "d"), ("r22", "d"), ("r23", "d"), ("r24", "d"), ("r25", "d"), ("r26", "d"), ("r31", "d"), ("r32", "d"), ("r33", "d"), ("r34", "d"), ("r35", "d"), ("r36", "d"), ("r41", "d"), ("r42", "d"), ("r43", "d"), ("r44", "d"), ("r45", "d"), ("r46", "d"), ("r51", "d"), ("r52", "d"), ("r53", "d"), ("r54", "d"), ("r55", "d"), ("r56", "d"), ("r61", "d"), ("r62", "d"), ("r63", "d"), ("r64", "d"), ("r65", "d"), ("r66", "d")]) initial_twiss_table, initial_rmat_table = self.get_twiss_table() sec, nanosec = divmod(float(time.time()), 1.0) initial_twiss_table = self.twiss_table.wrap(initial_twiss_table) initial_twiss_table['timeStamp']['secondsPastEpoch'] = sec initial_twiss_table['timeStamp']['nanoseconds'] = nanosec initial_rmat_table = self.rmat_table.wrap(initial_rmat_table) initial_rmat_table['timeStamp']['secondsPastEpoch'] = sec initial_rmat_table['timeStamp']['nanoseconds'] = nanosec self.live_twiss_pv = SharedPV(nt=self.twiss_table, initial=initial_twiss_table, loop=self.loop) self.design_twiss_pv = SharedPV(nt=self.twiss_table, initial=initial_twiss_table, loop=self.loop) self.live_rmat_pv = SharedPV(nt=self.rmat_table, initial=initial_rmat_table, loop=self.loop) self.design_rmat_pv = SharedPV(nt=self.rmat_table, initial=initial_rmat_table, loop=self.loop) self.recalc_needed = False self.pva_needs_refresh = False self.need_zmq_broadcast = False
def __init__(self): tao_lib = os.environ.get('TAO_LIB', '') self.tao = pytao.Tao(so_lib=tao_lib) path_to_lattice = os.path.join( os.path.dirname(os.path.realpath(__file__)), "lcls.lat") path_to_init = os.path.join( os.path.dirname(os.path.realpath(__file__)), "tao.init") self.tao.init("-noplot -lat {lat_path} -init {init_path}".format( lat_path=path_to_lattice, init_path=path_to_init)) self.ctx = Context.instance() self.model_broadcast_socket = zmq.Context().socket(zmq.PUB) self.model_broadcast_socket.bind("tcp://*:{}".format( os.environ.get('MODEL_BROADCAST_PORT', 66666))) self.loop = asyncio.get_event_loop() model_table = NTTable([("element", "s"), ("device_name", "s"), ("s", "d"), ("length", "d"), ("p0c", "d"), ("alpha_x", "d"), ("beta_x", "d"), ("eta_x", "d"), ("etap_x", "d"), ("psi_x", "d"), ("alpha_y", "d"), ("beta_y", "d"), ("eta_y", "d"), ("etap_y", "d"), ("psi_y", "d"), ("r11", "d"), ("r12", "d"), ("r13", "d"), ("r14", "d"), ("r15", "d"), ("r16", "d"), ("r21", "d"), ("r22", "d"), ("r23", "d"), ("r24", "d"), ("r25", "d"), ("r26", "d"), ("r31", "d"), ("r32", "d"), ("r33", "d"), ("r34", "d"), ("r35", "d"), ("r36", "d"), ("r41", "d"), ("r42", "d"), ("r43", "d"), ("r44", "d"), ("r45", "d"), ("r46", "d"), ("r51", "d"), ("r52", "d"), ("r53", "d"), ("r54", "d"), ("r55", "d"), ("r56", "d"), ("r61", "d"), ("r62", "d"), ("r63", "d"), ("r64", "d"), ("r65", "d"), ("r66", "d")]) initial_table = self.get_twiss_table() self.live_twiss_pv = SharedPV(nt=model_table, initial=initial_table, loop=self.loop) self.design_twiss_pv = SharedPV(nt=model_table, initial=initial_table, loop=self.loop) self.pva_needs_refresh = False self.need_zmq_broadcast = False
import os import sys TAO_PYTHON_DIR = os.environ['ACC_ROOT_DIR'] + '/tao/python' sys.path.insert(0, TAO_PYTHON_DIR) import pytao tao = pytao.Tao() LAT = os.environ[ 'ACC_ROOT_DIR'] + '/tao/examples/cesr/bmad_L9A18A000-_MOVEREC.lat' tao.init('-noinit -lat ' + LAT) # Should pop up a plotting window. out = tao.cmd('show ele 10') # Output is a list print('\n'.join(out)) # To look nice, print each list item on its own line out = tao.cmd_real( 'python plot_line r13.g.a x') # r13 = beta plot in this example. print(out[0:5]) # Just print a few x values.