AMETEK Ls Series Driver Manual User Manual
Page 200

IVI Driver Manual
Lx / Ls Series
196
Use this parameter 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 ciLxs_LockSession
or ciLxs_UnlockSession in the same function.
The parameter is an input/output parameter. ciLxs_LockSession and
ciLxs_UnlockSession each inspect the current value and take the
following actions:
- If the value is VI_TRUE, ciLxs_LockSession does not lock the
session again. If the value is VI_FALSE, ciLxs_LockSession obtains
the lock and sets the value of the parameter to VI_TRUE.
- If the value is VI_FALSE, ciLxs_UnlockSession does not attempt to
unlock the session. If the value is VI_TRUE, ciLxs_UnlockSession
releases the lock and sets the value of the parameter to VI_FALSE.
Thus, you can, call ciLxs_UnlockSession at the end of your function
without worrying about whether you actually have the lock.
Example:
ViStatus TestFunc (ViSession vi, ViInt32 flags)
{
ViStatus error = VI_SUCCESS;
ViBoolean haveLock = VI_FALSE;
if (flags & BIT_1)
{
viCheckErr( ciLxs_LockSession(vi, &haveLock));
viCheckErr( TakeAction1(vi));
if (flags & BIT_2)
{
viCheckErr( ciLxs_UnlockSession(vi, &haveLock));
viCheckErr( TakeAction2(vi));
viCheckErr( ciLxs_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.
*/
ciLxs_UnlockSession(vi, &haveLock);
return error;
}
Return Value
Returns the status code of this operation. The status code either