首页 > 其他分享 >visa打开与仪器的通信通道称为会话session

visa打开与仪器的通信通道称为会话session

时间:2023-06-02 17:56:26浏览次数:52  
标签:instr viOpen communication 会话 session VI visa

Communication Channels: Sessions
The examples from Introductory Programming Examples used an operation called viOpen() to open communication channels with the instruments. In VISA terminology, this channel is known as a session. A session connects you to the resource you addressed in the viOpen() operation and keeps your communication and attribute settings unique from other sessions to the same resource. In VISA, a resource can have multiple sessions to it from the same program and for interfaces other than Serial, even from other programs simultaneously. Therefore, you must consider some things about the resource to be local, that is, unique to the session, and other things to be global, that is, common for all sessions to the resource.

If you look at the descriptions of the various attributes supported by the VISA resources, you will see that some are marked global (such as VI_ATTR_INTF_TYPE) and others are marked local (such as VI_ATTR_TMO_VALUE). For example, the interface bus that the resource is using to communicate with the device (VI_ATTR_INTF_TYPE) is the same for everyone using that resource and is therefore a global attribute. However, different programs may have different timeout requirements, so the communication timeout value (VI_ATTR_TMO_VALUE) is a local attribute.

Again, look at the message-based communication example. To open communication with the instrument, that is, to create a session to the INSTR Resource, you use the viOpen() operation as shown below:

status = viOpen(defaultRM, "GPIB0::1::INSTR", VI_NULL, VI_NULL, &instr);

In this case, the interface to which the instrument is connected is important, but only as a means to uniquely identify the instrument. The code above references a GPIB device on bus number 0 with primary address 1. The access mode and timeout values for viOpen() are both VI_NULL. Other values are defined, but VI_NULL is recommended for new users and all instrument drivers.

However, notice the statement has two sessions in the parameter list for viOpen(), defaultRM and instr. Why do you need two sessions? As you will see in a moment, viOpen() is an operation on the Resource Manager, so you must have a communication channel to this resource. However, what you want is a session to the instrument; this is what is returned in instr.

For the entire duration that you communicate with this GPIB instrument, you use the session returned in instr as the communication channel. When you are finished with the communication, you need to close the channel. This is accomplished through the viClose() operation as shown below:

status = viClose(instr);

At this point, the communication channel is closed, but you are still free to open it again or open a session to another device. Notice that you do not need to close a session to open another session. You can have as many sessions to different devices as you want.

沟通渠道: 会话
编程入门实例中的例子使用了一个叫做viOpen()的操作来打开与仪器的通信通道。在VISA术语中,这个通道被称为会话。一个会话将你和你在viOpen()操作中寻址的资源连接起来,并使你的通信和属性设置与同一资源的其他会话保持一致。在VISA中,一个资源可以有多个会话从同一个程序中进入,对于Serial以外的接口,甚至可以同时从其他程序进入。因此,你必须考虑关于资源的一些事情是本地的,即对会话来说是唯一的,而其他事情是全局的,即对资源的所有会话来说是共同的。

如果你看一下VISA资源所支持的各种属性的描述,你会发现有些被标记为全局的(如VI_ATTR_INTF_TYPE),有些被标记为局部的(如VI_ATTR_TMO_VALUE)。例如,资源用来与设备通信的接口总线(VI_ATTR_INTF_TYPE)对使用该资源的每个人来说都是一样的,因此是一个全局属性。然而,不同的程序可能有不同的超时要求,所以通信超时值(VI_ATTR_TMO_VALUE)是一个本地属性。

再一次,看看基于消息的通信例子。为了打开与仪器的通信,也就是创建一个通往INSTR资源的会话,你可以使用viOpen()操作,如下所示:

status = viOpen(defaultRM, "GPIB0::1::INSTR", VI_NULL, VI_NULL, &instr) ;

在这种情况下,仪器所连接的接口很重要,但只是作为唯一识别仪器的手段。上面的代码引用了一个总线号为0、主地址为1的GPIB设备。viOpen()的访问模式和超时值都是VI_NULL。可以定义其他的值,但对于新用户和所有的仪器驱动程序来说,建议使用VI_NULL。

然而,注意到该语句在viOpen()的参数列表中有两个会话,defaultRM和instr。为什么需要两个会话?稍后你会看到,viOpen()是对资源管理器的操作,所以你必须有一个与这个资源的通信通道。然而,你想要的是一个到仪器的会话;这就是在instr中返回的东西。

在你与这个GPIB仪器通信的整个过程中,你使用instr中返回的会话作为通信通道。当你完成通信后,你需要关闭该通道。这可以通过viClose()操作来完成,如下所示:

status = viClose(instr);

在这一点上,通信通道被关闭了,但是你仍然可以自由地再次打开它或者打开一个会话到另一个设备。注意,你不需要关闭一个会话来打开另一个会话。你可以在不同的设备上有任意多的会话,只要你想。

原文地址:Communication Channels: Sessions - NI

标签:instr,viOpen,communication,会话,session,VI,visa
From: https://www.cnblogs.com/littleheadache/p/17452579.html

相关文章

  • Self-Supervised Hypergraph Convolutional Networks for Session-based Recommendati
    目录概符号说明HypergraphLinegraphDHCNHypergraphChannelLineGraphChannelContrastiveLearning优化代码XiaX.,YinH.,YuJ.,WangQ.,CuiLandZhangX.Self-supervisedhypergraphconvolutionalnetworksforsession-basedrecommendation.AAAI,2021.概自监......
  • Windows11 访问WINOWS 2003 远程桌面提示 由于这台计算机没有远程桌面客户端许可证,远
    今天遇到,,Windows11访问WINOWS2003远程桌面 提示如下,解决方法在提示由于由于这台计算机没有远程桌面客户端许可证,远程会话连接己断开的计算机上,  打开注册表regedit计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSLicensing\Store\ 选中LICENSE000,将其删除 ......
  • 关于B/S结构系统的会话机制
    1. 什么是会话?42  - 会话对应的英语单词:session  - 用户打开浏览器,进行一系列操作,然后最终将浏览器关闭,这个整个过程叫做:一次会话。会话在服务器端也有一个对应的java对象,这个java对象叫做:session。  - 什么是一次请求:用户在浏览器上点击了一下,然后到页面停下来,可以粗略......
  • 使用session+cookie改造单表项目
    1.  session掌握之后,我们怎么解决oa项目中的登录问题,怎么能让登录起作用。  441.1 思路  44  - 登录成功之后,可以将用户的登录信息存储到session当中。也就是说session中如果有用户的信息就代表用户登录成功了。session中没有用户信息,表示用户没有登录过。则跳转到登录页......
  • 关闭浏览器后再次访问session 保证是同一个sessionid
    我们知道在正常情况下,发送http请求时,消息头中会自动携带cookie信息,这其中就会包括SESSIONID信息,所以只要我们没有关闭浏览器,消息头中都会自动携带这个信息,以供服务器访问相应的session。 但是如果我把浏览器关闭了呢?这样的话,我该如何再次访问相应的session呢?我们可以这样做,来实现......
  • Flask 会话技术 cookies原理
    cookies#首页@blue.route('/')@blue.route('/home/')#装饰器可以用多个,这两个路由都能访问到home函数defhome()#4.获取cookieusername=request.cookies.get('user')returnrender_template('home.html',username=username)#......
  • Self-Supervised Graph Co-Training for Session-based Recommendation
    目录概符号说明COTREC图的构建ItemViewEncodingSessionViewEncodingCo-TrainingContrastiveLearningDivergenceConstraint优化代码XiaX.,YinH.,YuJ.,ShaoY.andCuiL.Self-supervisedgraphco-trainingforsession-basedrecommendation.CIKM,2021.概自监......
  • postgresql 的 idle_session_timeout 与连接池的 max-ide-time参数
    看下面的异常:下面的错误说:terminatingconnectionduetoidle-sessiontimeout下面的这个错误说:Causedby:reactor.pool.PoolShutdownException:Poolhasbeenshutdownreactor.core.Exceptions$ErrorCallbackNotImplemented:org.springframework.dao.DataAccessResou......
  • Percona-Toolkit系列之pt-kill杀会话利器
    1.pt-kill生产环境中我们时常遇到这样的情况,数据库性能恶劣,需要马上杀掉全部会话,不然数据库就挂起来。我们可以先找showprocesslist的输出来杀会话,但是比较麻烦。pt-kill为我们解决了杀会话问题。2常用杀会话场景2.1按照用户杀会话pt-kill--host=192.168.56.103--user=root......
  • hibernate session
       ......