def dcpower_tsm_s(tsm, tests_pins):
    """Returns LabVIEW Cluster equivalent data"""
    dcpower_tsms = []
    for test_pin in tests_pins:
        dcpower_tsms.append(
            dcpower.pins_to_sessions(tsm, test_pin, fill_pin_site_info=True))
    return dcpower_tsms
def measure(tsm: SMContext):
    dc_tsm = dcpower.pins_to_sessions(tsm, ["SMU_VI_ANA2"])
    volt_meas, curr_meas = dc_tsm.ssc.measure()
    compliance = dc_tsm.ssc.query_in_compliance()
    print(compliance)
    time.sleep(0.5)
    return volt_meas, curr_meas
def source_voltage(tsm: SMContext):
    dc_tsm = dcpower.pins_to_sessions(tsm, ["SMU_VI_ANA2"])
    dc_tsm.ssc.force_voltage_symmetric_limits(voltage_level=3.8,
                                              voltage_level_range=6.0,
                                              current_limit=10e-3,
                                              current_limit_range=100e-3)
    time.sleep(0.5)
def configure_measurements_waveform(tsm: SMContext):
    dc_tsm = dcpower.pins_to_sessions(tsm, ["SMU_VI_ANA2", "SMU_VI_ANA1"])
    dc_tsm.ssc.abort()
    dc_tsm.ssc.configure_settings(20e-3, 0.0, dcpower.enums.Sense.LOCAL)
    dc_tsm.ssc.configure_and_start_waveform_acquisition(sample_rate=10e3,
                                                        buffer_length=1.0)
    wf_settings = dc_tsm.ssc.get_measurement_settings()
    dc_tsm.ssc.configure_output_connected(output_connected=True)
    return wf_settings
def close_sessions(tsm: SMContext, settings):
    dc_tsm = dcpower.pins_to_sessions(tsm, ["SMU_VI_ANA2", "SMU_VI_ANA1"])
    dc_tsm.ssc.abort()
    dc_tsm.ssc.configure_output_connected(output_connected=True)
    # dc_tsm.ssc.set_measurement_settings(settings)
    dcpower.close_sessions(tsm)
def fetch_waveform(tsm: SMContext):
    dc_tsm = dcpower.pins_to_sessions(tsm, ["SMU_VI_ANA2", "SMU_VI_ANA1"])
    volt_wf, curr_wf = dc_tsm.ssc.fetch_waveform(0, waveform_length_s=1e-3)
    print(volt_wf, curr_wf)
    return volt_wf
def configure_measurements(tsm: SMContext):
    # ctypes.windll.user32.MessageBoxW(None, "Process ID: " + str(os.getpid()),"Attach debugger", 0)
    dc_tsm = dcpower.pins_to_sessions(tsm, ["SMU_VI_ANA2"])
    dc_tsm.ssc.abort()
    dc_tsm.ssc.configure_aperture_time_with_abort_and_initiate()
def initialize_sessions(tsm: SMContext):
    # ctypes.windll.user32.MessageBoxW(None, "Process ID:" + str(os.getpid()), "Attach debugger", 0)
    dcpower.initialize_sessions(tsm, options=OPTIONS)
    dcpower_tsm = dcpower.pins_to_sessions(tsm, ["SMU_VI_ANA2", "SMU_VI_ANA1"])
    dcpower_tsm[1].reset()
    time.sleep(0.5)