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


相关推荐

  • 用matlab求分段函数「建议收藏」

    用matlab求分段函数「建议收藏」functiony=fum(x)ifx   y=x; elseifx=1   y=2*x-1;elseifx10   y=3*x-11;else  y=sin(x)+log(x);end在matlab的命令行窗口,输入fum(5)

    2022年5月24日
    41
  • pytest测试框架和unittest_python性能测试框架

    pytest测试框架和unittest_python性能测试框架目录单元测试概述 unittest框架介绍 unittest实战单元测试单元测试是开发者编写的一小段代码,用于经验被测代码的一个很小的,很明确的功能是否正确,通常而言,一个单元测试是用于判断某个特定条件(或者场景)下某个特定函数的行为。单元测试什么时候测试单元测试由谁负责单元测试需要注意单元测试的时候一个大前提就是需要清除的知道,自己要测试的程序块所预期的输入和输出,然后根据这个预期和程序逻辑来书写case。这里的预期结果一定要针对需求/设计的逻辑去写,而不是针…

    2022年10月14日
    4
  • Otter介绍及(Manager)安装「建议收藏」

    Otter介绍及(Manager)安装「建议收藏」Otter 简单介绍名称:otter['ɒtə(r)]译意:水獭,数据搬运工语言:纯java开发定位:基于数据库增量日志解析,准实时同步到本机房或异地机房的mysql

    2022年8月3日
    6
  • 模拟信号和数字信号的区别_模拟信号和数字信号的区别和特点

    模拟信号和数字信号的区别_模拟信号和数字信号的区别和特点根据信号中代表的取值参数的不同,信号可以分为两大类:模拟信号和数字信号1.模拟信号或连续信号指用连续变化的物理量所表达的信息,如温度、湿度、压力、长度、电流、电压等。我们通常又把模拟的信号称为连

    2022年8月2日
    6
  • ubuntu安装进入EFI Shell「建议收藏」

    ubuntu安装进入EFI Shell「建议收藏」背景:用VirtualBox安装Ubuntu14:第一次,无法进入LiveCD界面.第二次,勾选EFI界面后成功进入安装流程,成功安装。但是安装完成之后重启,进入了EFIShell界面,如下:解决方案:输入:fs:0cdEFI/ubuntugrubx64.efi引自ServerFault:IfyouaregettingtotheEFIshellyou

    2022年7月24日
    20
  • dumpbin 用法

    dumpbin 用法今天工作中需要查看dll中的内部结构所以重点学习了一下dumpbin的用法dumpbin.exe在/VC/BIN目录下,如果在其他目录下无法使用dumpbin,可以运行该目录下VCVARS32.BAT,这个批处理文件就是用来修复VC环境的。 下面列出了DUMPBIN命令行选项。此外列出每个选项提供的输出的一些了。/ALL显示除代码反汇编外的所有可用信息。使用

    2022年6月19日
    84

发表回复

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

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