GPIB-VC编程

GPIB-VC编程CompilingandLinkingVISAPrograms(C/C++)Thissectionprovidesasummaryofimportantcompiler-specificconsiderationswhendevelopingWin32applications.1.LinkingtoVISALibrariesYourapp

大家好,又见面了,我是你们的朋友全栈君。Compiling and Linking VISA Programs (C/C++)

This section provides a summary of important compiler- specific considerations when developing Win32 applications.

1 . Linking to VISA Libraries

Your application must link to the VISA import library as follows, assuming default installation directories and Microsoft compilers:

    C:\Program Files\VISA\winnt\lib\msc\visa32.lib The following steps will help you do this. This information is specific to your development 

environment.

Microsoft Visual C++ Version 6.0 Development Environment

1 Use the  File menu to create a new project or open an existing project.

2 Select  Project > Settings from the menu and click the C/C++ tab.

3 Select  Code Generation from the  Category  list box and select Multi-Threaded using DLL from the  Use Run-Time Libraries list box. (VISA requires these definitions for Win32.) Click  OK to close the dialog box.

4 Select  Project > Settings from the menu. Click the  Link tab and add visa32.lib to the Object/Library Modules  list box. Optionally, you may add the library directly to your project file. Click  OK to close the dialog box.

5 You may want to add the  include  files and  library  files

search paths. They are set as follows:

• Select  Tools > Options from the menu.

• Click the  Directories tab to set the include file path.

• Select  Include Files from the  Show Directories For list box.

• Click at the bottom of the list box and type:  

C:\Program Files\VISA\winnt\include

(This assumes that you used the default installation

location for VISA.)

• Select  Library Files from the  Show Directories For list box.

• Click at the bottom of the list box and type:  

C:\Program Files\VISA\winnt\lib\msc

(This assumes that you used the default installation

location for VISA.)

6 Add or create your C or C++ source files. For example, to build the sample described below, select  Project > Add to Project > Files… and type or browse to  C:\Program Files\Agilent\IO Libraries Suite\ ProgrammingSamples\C\VISA\idn.c.

7 Click  Build > Rebuild All to build the VISA program.

示例:电源型号:Agilent  GPIB线 开发环境为VS2010

1.首先安装GPIB驱动,驱动安装文件比较大,请自行下载安装,我用的NI驱动

2.编写一个Win32程序,实现打开和关闭电源的功能。

主要代码如下:

 

//包含VISA头文件和库文件
#include "WinNT//include//visa.h"                               
#pragma comment(lib, "WinNT//lib//msc//visa32.lib")

电源初始化函数

BOOL CXXXDlg::InitPower()
{
	
	char chStatusDesc[_MAX_DIR] = {0};
	int retCnt=0;	
	char instrDesc[100]={0};	
	ViFindList find_list;	
	float voltSetting, currSetting;
	voltSetting = atof(ini_powervolt);
	currSetting = atof(ini_powercurrent);
	VISAstatus=viOpenDefaultRM(&defrm);
	if (VISAstatus != VI_SUCCESS)
	{
		return FALSE;
	}
	VISAstatus = viFindRsrc(defrm,"GPIB?*INSTR",&find_list,(ViPUInt32)&retCnt, instrDesc);
	
	VISAstatus=viOpen(defrm,instrDesc, VI_NULL, VI_NULL, &session);


	if (VISAstatus!=VI_SUCCESS)
	{
		return FALSE;
	}
	//Set voltage
	viPrintf(session,"VOLT %f \n",voltSetting);


	//Set current level
	viPrintf(session,"CURR %f \n",currSetting);
	return TRUE;
}

打开电源

void CXXXDlg::OnBnClickedBtnPowerOn()
{
	if (!InitPower())
	{
		AfxMessageBox("Init Power Fail,Please Check the GPIB Connected!");
		return;
	}


	viPrintf(session,"OUTP ON \n");
}

关闭电源

void CXXXDlg::OnBnClickedBtnPoweroff()
{
	if (!InitPower())
	{
		AfxMessageBox("Init Power Fail,Please Check the GPIB Connected!");
		return;
	}


	viPrintf(session,"OUTP OFF \n");
}

上面的示例只是简单的展示了开启和关闭电源的基本功能,实际开始时需要根据具体需求来扩展。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/148878.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • CSS3选择器 | 每个前端开发者必须要掌握的技术

    CSS3选择器 | 每个前端开发者必须要掌握的技术目录属性选择符伪类选择符CSS3属性CSS3自适应属性选择符如果能够灵活运用属性选择器,目前为止需要依靠id或class名才能实现的样式完全可以使用属性选择器来实现。E[att]{}:选择具有att属性的E元素E[att=”val”]{}:选择具有att属性且属性值等于val的E元素E[att~=”val”]{}:用于选取属性值中包含指定词汇的元素E[att|=”val…

    2022年7月27日
    8
  • Python实现XML文件解析建议收藏

    1.XML简介XML(eXtensibleMarkupLanguage)指可扩展标记语言,被设计用来传输和存储数据,已经日趋成为当前许多新生技术的核心,在不同的领域都有着不同的应用。它是web

    2021年12月18日
    72
  • 详解布隆过滤器的原理和实现「建议收藏」

    详解布隆过滤器的原理和实现「建议收藏」为什么需要布隆过滤器想象一下遇到下面的场景你会如何处理: 手机号是否重复注册 用户是否参与过某秒杀活动 伪造请求大量id查询不存在的记录,此时缓存未命中,如何避免缓存穿透 针对以上问题常规做法是:查询数据库,数据库硬扛,如果压力并不大可以使用此方法,保持简单即可。改进做法:用list/set/tree维护一个元素集合,判断元素是否在集合内,时间复杂度或空间复杂度会比较高。如果是微服务的话可以用redis中的list/set数据结构,数据规模非常大此方案

    2022年10月6日
    2
  • adminlte ajax,AdminLTE

    adminlte ajax,AdminLTEReminder!AdminLTEusesallofBootstrap3components.It’sagoodstarttoreviewtheBootstrapdocumentationtogetanideaofthevariouscomponentsthatthisdocumentationdoesnotcover.Tip!Ifyoug…

    2022年7月27日
    6
  • Netty权威指南V2.0版_javascript权威指南第七版

    Netty权威指南V2.0版_javascript权威指南第七版作者:李林锋著作出版发行:北京:电子工业出版社,2015.04ISBN号:978-7-121-25801-5页数:554开本:16开主题词:JAVA语言-程序设计-指南中图法分类号:TP312-62(工业技术->自动化技术、计算机技术->计算技术、计算机技术->计算机软件)内容提要:《Netty权威指南(第2版)…

    2022年10月2日
    4
  • 如何使用Reaver破解Wi-Fi网络的WPA密码

    如何使用Reaver破解Wi-Fi网络的WPA密码现在有一款自由开源新工具——Reaver,已经挖掘出了无线路由器的一个漏洞,由此能够破解绝大多数路由器上的密码。今天,我就来一步步介绍,如何使用Reaver破解WPA/WPA2密码。最后我会给出相应的防范对策。

    2022年5月30日
    57

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号