Пример #1
0
def aperture_data_general(opm, tla, qlist, dlist):
    """ handle the general aperture commands, add to end of list """
    seq_model = opm.seq_model
    idx = get_index_qualifier(seq_model, 'S', qlist)
    if not idx:
        idx = seq_model.cur_surface
    ca_type = tla[0]

    if ca_type == 'C':
        ca = Circular(radius=dlist[0],
                      x_offset=dlist[1],
                      y_offset=dlist[2],
                      rotation=dlist[3])
    elif ca_type == 'R':
        ca = Rectangular(x_half_width=dlist[0],
                         y_half_width=dlist[1],
                         x_offset=dlist[2],
                         y_offset=dlist[3],
                         rotation=dlist[3])
    elif ca_type == 'E':
        ca = Elliptical(x_half_width=dlist[0],
                        y_half_width=dlist[1],
                        x_offset=dlist[2],
                        y_offset=dlist[3],
                        rotation=dlist[3])

    seq_model.ifcs[idx].clear_apertures.append(ca)

    log_cmd("aperture_data_general", tla, qlist, dlist)
Пример #2
0
def handle_aperture_data(optm, cur, cmd, inputs):
    # DIAM 7.5 1 0 0 1 ""
    # FLAP 0 7.5 0
    # CLAP 0 25.399999999999999 0
    # OBDC 0.000000000000E+00 1.906000000000E+02
    global _track_contents
    sm = optm.seq_model
    items = inputs.split()
    if cmd == "DIAM":
        ifc = sm.ifcs[cur]
        ca_val = float(items[0])
        ca_type = int(items[1])
        ca_list = ifc.clear_apertures
        if len(ca_list) == 0:
            ca = None
            if ca_type == 0:
                ca = Circular()
            elif ca_type == 1:
                ca = Circular()
            elif ca_type == 4:
                ca = Rectangular()
                _track_contents['non_circular_ca_type'] += 1
            elif ca_type == 6:
                ca = Elliptical()
                _track_contents['non_circular_ca_type'] += 1
            else:
                _track_contents['ca_type_not_recognized'] += 1
                # print('ca_type', cur, ca_type, items[1])
                return True

            if ca:
                ca_list.append(ca)
        else:
            ca = ca_list[-1]

        ca.radius = ca_val
        ifc.set_max_aperture(ca_val)
    elif cmd == "OBDC":
        # appears to be aperture offsets, x and y
        ifc = sm.ifcs[cur]
        ca = ifc.clear_apertures[0]
        ca.x_offset = float(items[0])
        ca.y_offset = float(items[1])
    elif cmd == "FLAP":
        # Don't really understand how this is used...
        pass
    else:
        return False

    return True
Пример #3
0
def aperture_data(opm, tla, qlist, dlist):
    """ add aperture data, either creating a new aperture or modifying the last """
    seq_model = opm.seq_model
    idx = get_index_qualifier(seq_model, 'S', qlist)
    lbl = get_index_qualifier(seq_model, 'L', qlist)
    if not idx:
        idx = seq_model.cur_surface
    ca_type = tla[0]
    data_type = tla[2]
    ifc = seq_model.ifcs[idx]
    ca_list = ifc.clear_apertures

    for q in qlist:
        if q[0] == 'EDG':
            ca_list = ifc.edge_apertures
        elif q[0] == 'HOL':
            log_cmd("aperture_data", tla, qlist, dlist)
            #            ca_list = ifc.holes
            return
        elif q[0] == 'OBS':
            log_cmd("aperture_data", tla, qlist, dlist)
            return

    if len(ca_list) == 0 or ca_type != type(ca_list[-1]).__name__[0]:
        if ca_type == 'C':
            ca = Circular()
        elif ca_type == 'R':
            ca = Rectangular()
        elif ca_type == 'E':
            ca = Elliptical()
        ca_list.append(ca)
    else:
        ca = ca_list[-1]

    if data_type == 'R':
        ca.radius = dlist[0]
    elif data_type == 'X':
        ca.x_half_width = dlist[0]
    elif data_type == 'Y':
        ca.y_half_width = dlist[0]

    log_cmd("aperture_data", tla, qlist, dlist)