# Create the communication channel for the remote host and create connections to the NI-SCOPE and session services.
channel = grpc.insecure_channel(f"{server_address}:{server_port}")
niscope_client = grpc_niscope.NiScopeStub(channel)
session_client = grpc_session.SessionUtilitiesStub(channel)

try :
    # Reset server to start in a fresh state.
    reset_server_response = session_client.ResetServer(session_types.ResetServerRequest())
    assert(reset_server_response.is_server_reset)

    # Open session to NI-SCOPE module with options.
    session_name = "NI-Scope-Session-1"
    print('\nInitializing session...')
    init_with_options_response = niscope_client.InitWithOptions(niscope_types.InitWithOptionsRequest(
        session_name = session_name,
        resource_name = resource,
        id_query = False,
        option_string = options
        ))
    vi = init_with_options_response.vi
    CheckForError(vi, init_with_options_response.status)
    print(f'Session initialized with name {session_name} and id {vi.id}.\n')

    # Check if session is reserved by client 1.
    # Note: The reservation_id is defined by and has meaning only for the client + Session Reservation API.
    print(f'Checking if {session_name} is reserved by {client_1_id}...')
    is_reserved_response = session_client.IsReservedByClient(session_types.IsReservedByClientRequest(
        reservation_id = session_name,
        client_id = client_1_id
        ))
    assert(not is_reserved_response.is_reserved)
    print(f'{session_name} is not reserved by {client_1_id}.\n')
Example #2
0
if len(sys.argv) >= 3:
    server_port = sys.argv[2]
if len(sys.argv) >= 4:
    resource = sys.argv[3]
    options = ""

# Create the communication channel for the remote host (in this case we are connecting to a local server)
# and create a connection to the NI-SCOPE service
channel = grpc.insecure_channel(f"{server_address}:{server_port}")
scope_service = grpc_scope.NiScopeStub(channel)

try:
    # Initialize the scope
    init_result = scope_service.InitWithOptions(
        niscope_types.InitWithOptionsRequest(session_name="demo",
                                             resource_name=resource,
                                             id_query=False,
                                             option_string=options))
    vi = init_result.vi
    CheckForError(vi, init_result.status)

    # Configure Vertical
    vertical_result = scope_service.ConfigureVertical(
        niscope_types.ConfigureVerticalRequest(
            vi=vi,
            channel_list=channels,
            range=10.0,
            offset=0,
            coupling=niscope_types.VerticalCoupling.
            VERTICAL_COUPLING_NISCOPE_VAL_DC,
            enabled=True,
            probe_attenuation=1))
Example #3
0
        raise Exception(error_message_response.error_message)
    else:
        error_message_request = nitclk_types.GetExtendedErrorInfoRequest()
        error_message_response = tclk_service.GetExtendedErrorInfo(
            error_message_request)
        raise Exception(error_message_response.error_string)


try:
    #Initialize the session
    i = 1
    for resource in resources:
        init_result = scope_service.InitWithOptions(
            niscope_types.InitWithOptionsRequest(session_name="session" +
                                                 str(i),
                                                 resource_name=resource,
                                                 id_query=False,
                                                 reset_device=False,
                                                 option_string=options))
        i = i + 1
        sessions.append(init_result.vi)
        CheckForError(scope_service, init_result.vi, init_result.status)

    for session in sessions:
        # Configure Acquisition Type
        acquisition_type_result = scope_service.ConfigureAcquisition(
            niscope_types.ConfigureAcquisitionRequest(
                vi=session,
                acquisition_type=0  # NISCOPE_VAL_NORMAL
            ))
        CheckForError(scope_service, session, acquisition_type_result.status)