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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 自定义Python排序函数比较方式

    自定义Python排序函数比较方式当你想按自己的方式对数组元素进行排序时,我们需要自定义比较函数实现我们想实现的排序方式。例1以降序对数组进行排序>>>defcomp(x,y):…returny-x…>>>a=[1,8,4,5,2,7]>>>a.sort(comp)>>>a[8,7,5,4,2,1…

    2025年6月25日
    3
  • 13 RangeValidator

    13 RangeValidatorRangeValidator的属性有:MinimumValue:范围的最小值;MaximumValue:范围的最大值。Type:为数据类型,包括String,Intege,Double,Date,CurrencyRangeValidator,CompareValidator,RegularExpressValidator都不会对非空值进行校验,所…

    2022年7月12日
    22
  • 幼儿绘本-套装

    幼儿绘本-套装书名出版社出版时间定价团价聪明豆绘本系列第1辑6本《聪明豆绘本系列第1辑:咕噜牛》2014-1-125.030.0《聪明豆绘本系列第1辑:咕噜牛小妞妞》2014-1-125.0《聪明豆绘本系列第1辑:女巫扫帚排排坐》2014-1-125.0《聪明豆绘本系列第1辑:小房子变大房子》2014

    2022年7月27日
    3
  • 使用JWT实现单点登录(完全跨域方案)

    首先介绍一下什么是JSONWebToken(JWT)?官方文档是这样解释的:JSONWebToken(JWT)是一个开放标准(RFC7519),它定义了一种紧凑且独立的方式,可以在各方之间作为JSON对象安全地传输信息。此信息可以通过数字签名进行验证和信任。JWT可以使用秘密(使用HMAC算法)或使用RSA或ECDSA的公钥/私钥对进行签名。虽然JWT可以加密以在各方之间提供保密…

    2022年4月6日
    40
  • Vuethink正确安装过程

    Vuethink正确安装过程

    2021年10月13日
    40
  • XOR,XNOR

    XOR,XNOR总是记不住逻辑符号,想个没什么关系的窍门投机取巧一下。XOR,异或:对其中一个项添个“-”号取绝对值。0XOR0=(-0)+0=00XOR1=(-0)+1=11XOR0=(-1)+0=-1取绝对值=11XOR1=(-1)+1=0XNOR,同或,异或非,本来直接对应异或取反就行了,但是发现一个更有意思的,直…

    2022年7月16日
    25

发表回复

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

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