LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to deal with visession in IVI-C driver program ?

a ViSession is an identifier that corresponds to a session.
My instrument is a remote internet device . i can call VISA library to implement
communication between labwindows and my remote internet device.In this case , what is meaning of Visession
? It looks as if Visession does not have a relation to my IVI-C driver program.
if it has a relation to my driver, how to deal with the ViSession in IVI-C driver program?thank you

0 Kudos
Message 1 of 11
(5,773 Views)

ViSession is a type, like an integer (int).

 

It is the type of "the" instrument session handle and it is required for all functions which try to access your instrument ("remote internet device" for your application).

 

It is an output of the initialization function viOpen.

After you "open" a connection to your device, it is given a session handle and all subsequent operations require that handle.

 

What do you mean by "your IVI-C driver program" ?

Are you trying to write a driver for your device, or are you using a driver to proram your application?

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 11
(5,760 Views)

2: questions about  inherent function in IVI3-2 Specification.
2.1 Prefix_init (ViRsrc ResourceName,ViBoolean IdQuery,ViBoolean Reset,ViSession *Vi);

I simply want to control a remote instrument by LAN.
In this case, if user call the functioin , can I consider the parameter Vi as a memory bolck pointer to my data in custom driver.
and subsequently user call C API fnuction with the pointer . i should use the pointer to access my driver data?


2.2 ViStatus _VI_FUNC Prefix_GetAttributeViSession (ViSession Vi, ViConstString RepCapIdentifier, ViAttr AttributeID, ViSession * AttributeValue);
there are threee channels in the remote instrument .
if user calls the funciton , based on the parameter RepCapIdentifier, can i just pass the pointer to IVI-C custome driver data out ?
Is my opinon  right ? 

0 Kudos
Message 3 of 11
(5,665 Views)

2.1: it is an output variable from the _init function. Why do you need to use to pass custom data into the function?? You should conform to the original practices so that people get what they expect from the driver. Hidden functionalities will confuse the user and anyone who reads the code.

 

2.2: the RepCapIdentifier is an input of string type. The user will most probably input a constant string like "CHAN1" for that parameter. So you will not be able to output custom data out from there. Your program will either not compile or crash at runtime.

 

Hope this helps..

S. Eren BALCI
IMESTEK
0 Kudos
Message 4 of 11
(5,633 Views)

1:

ViStatus _VI_FUNC Prefix_SetAttributeViSession (ViSession Vi, ViConstString RepCapIdentifier, ViAttr AttributeID, ViSession  AttributeValue);

I know the first Visession corresponds to my IVI-C custom driver. And this function  is  to set parameter for instrument .

I went  through  IVI3-2  Specification . I did not find the  AttributeID  corresponding  to a Visession .

So, What is meaning  of  the last parameter Visession  and the third parameter  AttributeID?

I want to control a remote instrument  by  LAN. There are three channels in the remote instrument .my driver is a custom IVI-C driver .  In this case, how to implement  the function ?  thanks.

 

2:

Similarly I have question about  Prefix_GetAttributeViSession function .

ViStatus _VI_FUNC Prefix_GetAttributeViSession (ViSession Vi, ViConstString RepCapIdentifier, ViAttr AttributeID, ViSession * AttributeValue);

According to my particulare instrument ,how to implement  this function ???

0 Kudos
Message 5 of 11
(5,621 Views)

Prefix_GetAttributeViSession (ViSession Vi, ViConstString RepCapIdentifier, ViAttr AttributeID,  ViSession *AttributeValue);

 

there are three channels in my instrument .
In my opinion, each viSession corresponds to a channel.
it needs three visession corresponding to three channels separately.
So I should assign an ID for each channel.
I can set a viSession value for a channel.

 

what is purpose of the assigned visession?  just order to identify channel  ?

 

my opinion is correct?


if the assigned visession is not used in my specific IVI-C driver, how to deal with the funuction?

0 Kudos
Message 6 of 11
(5,616 Views)
Hi Zongjian,

I do not think you are reading my replies, or any other documentation regarding driver development carefuly.

ViSession is NOT related or corresponds to a chanel. ViSession corresponds to a communication "session". A session starts with a Prefix_init function and ends with a Prefix_close function and you need to input that session handle to every instrument function you call in between.

You need a separate viSession for every independent instrument, not for every channel.
If you have 2 osciloscopes you have a viSession for each. Not for every channel an oscilloscope has.

Hooe it is clear.
S. Eren BALCI
IMESTEK
0 Kudos
Message 7 of 11
(5,585 Views)

if subsequent functions do not use the Visession ,they  can still implement their functionilty .for example

 int  add (Visession  a, int  b , int c), I   just want to compute  a sum of  b and c , the first parameter Visession is not quired .  

 

 why  visession   is essential  ? how subsequent functions  use the first visession ?  your words are still vague. can you explain it clearly ? thank you .

 

 

0 Kudos
Message 8 of 11
(5,561 Views)
Hi zongjian,

English is not my native language and I believe I made all explanations that I am able.
We do not still know what you want to do with IVI.
Can you first clarify your application to us? What is your goal and what problem do you encounter??

You can think of ViSession is a ticket. It is given to you by the first function you call (that is the init function) and the device demamds it every time you want to talk to it.
It is not a useless parameter
S. Eren BALCI
IMESTEK
0 Kudos
Message 9 of 11
(5,544 Views)

ViSession is necessary as part of a larger picture and fills an important role in good architecture.  Intrument handles (stored as the ViSession type) are necessary for large projects, which may require commanding multiple instruments.

 

There is no function to call which can get or set a ViSession value, similar to the way other attributes are set with driver functions.  The ViSession intrument handle is created and returned to the application when an instrument is initialized; it represents a connection with one particular instrument.

 

This allows users to have multiple instruments connected, which can be controlled programmatically with one application.  Then, the application can quickly specify which instrument it would like to send a command, just by sending one instrument handle or another.

 

Yes, you could remove the ViSession as parameter in your functions, but it would cripple the big picture effectiveness of the driver.  In place of the ViSession, you would have to send each function the Resource Name or Resource ID for the particular instrument as well as the Option String.  So really, it is just more practical and better practice to use an instrument handle (stored as the ViSession type).

 

That being said, for certain functionality (adding two numbers), you absolutely do not need a ViSession instrument handle parameter.  You will have to use your best judgement to determine where to include or exclude this parameter.  I suggest using the ViSession instrument handle parameter with any function that communicates with an instrument.

 

Also, Ebalci is correct regarding the difference between ViSessions and channels.  ViSessions are used to communicate with different instruments.  To reference or read a specific channel from an instrument you will have to refer to the guidance in the manual for the instrument in question.  There will likely be a command to select a specific channel when reading from the instrument.  And for general guidance, I suggest reviewing another IVI driver, possibly for an instrument of the same class or type or maybe from the same family, if such a driver already exists.

Regards,

Shawn S. | NIC
Instrument Driver/IVI PSE
National Instruments
0 Kudos
Message 10 of 11
(5,524 Views)