05-29-2014 08:22 PM
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
05-30-2014 02:33 AM
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?
06-11-2014 11:18 PM
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 ?
06-15-2014 01:31 AM
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..
06-15-2014 10:45 PM
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 ???
06-16-2014 01:05 AM
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?
06-17-2014 08:31 PM
06-19-2014 03:22 AM
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 .
06-19-2014 03:12 PM
06-20-2014 01:04 PM - edited 06-20-2014 01:23 PM
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.