Releases a lock that you acquired on an device session using niDCPower_LockSession. Refer to niDCPower_LockSession for additional information on session locks.

Syntax

ViStatus _VI_FUNC niDCPower_UnlockSession(ViSession vi, ViBoolean *callerHasLock)

Parameters

NameDirectionTypeDescription
vi[in]ViSession

Identifies a particular instrument session. vi is obtained from the niDCPower_InitializeWithIndependentChannels function.

callerHasLock[out]ViBoolean *

This attribute is optional. If you do not want to use this attribute, pass VI_NULL.

Use this attribute in complex functions to keep track of whether you obtain a lock and therefore need to unlock the session.

Pass the address of a local ViBoolean variable. In the declaration of the local variable, initialize it to VI_FALSE. Pass the address of the same local variable to any other calls you make to niDCPower_LockSession or niDCPower_UnlockSession in the same function.

The parameter is an input/output parameter. niDCPower_LockSession and niDCPower_UnlockSession each inspect the current value and take the following actions.

Thus, you can, call niDCPower_UnlockSession at the end of your function without worrying about whether you actually have the lock, as the following example shows.


ViStatus TestFunc (ViSession vi, ViInt32 flags)
{
    ViStatus error = VI_SUCCESS;
    ViBoolean haveLock = VI_FALSE;

    if (flags & BIT_1)
    {
        viCheckErr( niDCPower_LockSession(vi, &haveLock));
        viCheckErr( TakeAction1(vi));
    if (flags & BIT_2)
    {
        viCheckErr( niDCPower_UnlockSession(vi, &haveLock));
        viCheckErr( TakeAction2(vi));
        viCheckErr( niDCPower_LockSession(vi, &haveLock);
    }
    if (flags & BIT_3)
        viCheckErr( TakeAction3(vi));
    }

    Error:
    /*At this point, you cannot really be sure that you have the lock. Fortunately, the haveLock variable takes care of that for you.*/
    niDCPower_UnlockSession(vi, &haveLock);
    return error;
}

Returns

Reports the status of this operation. To obtain a text description of the status code, call niDCPower_error_message. To obtain additional information concerning the error condition, call niDCPower_GetError. The general meaning of the status code is as follows:

Value

Meaning

0

Success

Positive Values

Warnings

Negative Values

Errors