Пример #1
0
def initialize_sessions(tsm_context: SMContext, ldb_type: str = ""):
    """
    Initialize the sessions from TSM context pinmap.
    """
    global debug
    instrument_names, channel_group_ids, channel_lists = tsm_context.get_custom_instrument_names(
        InstrumentTypeId)
    # when the output from a function is unused use _ instead of variables like below
    # instrument_names, channel_group_ids, _ = tsm_context.get_custom_instrument_names(
    # InstrumentTypeId)
    for instrument, group_id in zip(instrument_names, channel_group_ids):
        # target_list = ["PXIe-7822R", "PXIe-7821R", "PXIe-7820R"]
        ref_out = ""
        for target in BoardType:
            try:
                ref_out = open_reference(instrument, target, ldb_type)
            except Exception:  # TODO Check on baku since the condition seems to be up side down
                continue
            else:
                break
        tsm_context.set_custom_session(InstrumentTypeId, instrument, group_id,
                                       ref_out)
    dut_pins, system_pins = tsm_context.get_pin_names(InstrumentTypeId)
    debug = list(
        tsm_context.pins_to_custom_sessions(InstrumentTypeId,
                                            dut_pins + system_pins))
Пример #2
0
def initialize(tsm: SMContext):  # CHECK
    """
    Initialize the TSM context with all the Abstract switch sessions. Based on the instrument type
    it will create session to individual drivers. so it is essential to define the route in pinmap.
    Args:
        tsm: TSM context where the sessions will be initialized
    """
    switch_names = tsm.get_all_switch_names(instrument_type_id)
    if len(switch_names) == 1:
        dut_pins, sys_pins = tsm.get_pin_names()
        en_pins = []
        for pin in dut_pins + sys_pins:
            if pin.lower().find("en_") == 0:
                en_pins.append(pin)
        en_sessions = []
        for instrument in [
                "niDAQmx", "niDigitalPattern", "782xFPGA", "_niSwitch"
        ]:
            filtered_pins = tsm.filter_pins_by_instrument_type(
                en_pins, instrument, nitsm.enums.Capability.ALL)
            for pin in filtered_pins:
                session = Session(pin, instrument, "", 0, "")
                en_sessions.append(session)
        multi_session = AbstractSession(en_sessions)
        multi_session.set_sessions(tsm, switch_names[0])
    else:
        raise nifpga.ErrorStatus(
            5000,
            ("Unsupported Pin Map for the Abstract Switch."
             "Ensure you only have one abstract switch in the pinmap"),
            "initialize()",
            ["tsm_context"],
            (tsm, ),
        )
Пример #3
0
def get_all_pins(tsm: SMContext, reload_cache=False):
    """
    Returns all pins and its types (DUT or system) available in the Semiconductor Module context.
    Maintains a cache of these pin details and reloads them when requested or required.
    """
    global _pin_names, _pin_types
    # rebuild cache if empty
    if len(_pin_names) == 0 or reload_cache:
        dut_pins, system_pins = tsm.get_pin_names()
        dut_pin_types = [PinType.DUT_PIN] * len(dut_pins)
        system_pin_types = [PinType.SYSTEM_PIN] * len(system_pins)
        _pin_names = dut_pins + system_pins
        _pin_types = dut_pin_types + system_pin_types
    return _pin_names, _pin_types
def initialize_sessions(tsm: SMContext):
    ctypes.windll.user32.MessageBoxW(
        None,
        "Process: niPythonHost.exe & ID: " + str(os.getpid()),
        "Attach debugger",
        0,
    )
    print(tsm.pin_map_file_path)
    pins = SMContext.get_pin_names(
        tsm, instrument_type_id=nitsm.enums.InstrumentTypeIdConstants.NI_DIGITAL_PATTERN
    )
    print(pins)
    dt_dpi.initialize_sessions(tsm, options=OPTIONS)
    dpi_tsm_i_o = dt_dpi.pins_to_sessions(tsm, ["DPI_PG_Inputs", "DPI_PG_Outputs"])
    dpi_tsm_i_o.ssc.apply_levels_and_timing("I2C_Levels", "I2C_Timing")
    dpi_tsm_i_o.ssc.select_function(dt_dpi.enums.SelectedFunction.DIGITAL)
Пример #5
0
def initialize_sessions(tsm: SMContext, options: dict = {}):
    """Opens sessions for all instrument channels that are associated with the tsm context"""
    instrument_names = tsm.get_all_nifgen_instrument_names()
    for instrument_name in instrument_names:
        session = nifgen.Session(instrument_name,
                                 reset_device=True,
                                 options=options)
        tsm.set_nifgen_session(instrument_name, session)
    dut_pins, system_pins = tsm.get_pin_names()
    all_pins = dut_pins + system_pins
    instrument_type = nitsm.enums.InstrumentTypeIdConstants.NI_FGEN
    fgen_pins = tsm.filter_pins_by_instrument_type(all_pins, instrument_type,
                                                   "")
    pin_query_context, sessions, channels = tsm.pins_to_nifgen_sessions(
        fgen_pins)
    for fgen_session, channel_list in zip(sessions, channels):
        temp = set(channel_list)
        channels = list(temp)
        fgen_session.channels = channels  # configure channels