LabWindows_CVI教程(1)

合集下载

[labwindows cvi教程]LabWindows试用版入门指南

[labwindows cvi教程]LabWindows试用版入门指南

[labwindows cvi教程]LabWindows™/CVI™试用版入门指南最低系统要求想运行LabWindows/CVI,须具备以下配置:∙采用Pentium 1 GHz或更高性能微处理器的个人计算∙Microsoft操作系统:o Windows 7 (32位和64位)o Windows Vista (32位和64位)o Windows XP (32位)o Windows Server 2008 R2 (64位)o Windows Server 2003 R2 (32位)注:LabWindows/CVI仅支持Windows Server R2版本。

∙1024 × 768分辨率(或者更高) 视频适配器∙至少128 MB RAM, 推荐采用512 MB∙ 1.1 GB可用硬盘空间适合完整安装∙兼容Microsoft的鼠标安装指南完成下列步骤,从而安装LabWindows/CVI试用版软件包:1. 下载源自 的LabWindows/CVI试用版软件包并依照屏幕指南解压缩文件2. 解压缩文件后,安装自动开始,同时NI LabWindows/CVI窗口出现。

单击安装LabWindows/CVI 版本,其中的版本是您在试用的LabWindows/CVI版本3. 单击下一步4. 在用户信息面板上,选择安装NI LabWindows/CVI 版本试用版-不需要序列号5. 根据屏幕上的指示操作6. 安装LabWindows/CVI后,LabWindows/CVI安装程序提示您插入NI设备驱动盘。

评估LabWindows/CVI,无需通过安装设备驱动程序。

单击稍后安装(Later),完成LabWindows/CVI的安装。

LabWindows/CVI试用版在下载后,可安装LabWindows/CVI试用版软件包;该试用版软件包能在之后作为具有许可证的LabWindows/CVI版本被激活。

当您在试用期内启用LabWindows/CVI或是您购买合法许可证前,LabWindows/CVI会展现下图中出现的对话框。

LabWindowsCVI教程(1)PPT课件

LabWindowsCVI教程(1)PPT课件
LabVIEW, VEE
LabWindows/CVI
19.08.2020
4/18
2. LabWindows/CVI的历史
19.08.2020
5/18
3. LabWindows/CVI的特点
(1)针对测试测量领域的ANSI C语言开发环境
C compiler for Virtual Instruments (CVI)
变量命名 程序的格式和注释 复杂的程序要事先规划设计
19.08.2020
7/18
4. 程序结构
测控软件一般包括:用户界面、程序控制、数 据采集和数据分析4部分
19.08.2020
8/18
5. 开发环境
(1)主要窗口
LabWindows/CVI开发环境的三个主要窗口是工程窗口 (.prj)、源代码窗口(.c)和用户界面编辑器窗口(.uir)。
19.08.2020
15/18
LabWindows/CVI的函数库
19.08.2020
16/18
(4)交互式代码生成 C文件中生成程序结构:Main, Switch, If, For Loop… … UIR文件中生成代码框架: Main Function, Callback Functions (panel, control, menu) 函数面板中函数的自动插入
20/18
C源代码文件
.uir 用户界面资源文件
.h
用户界面资源头文件
.lib 外部静态库模块文件
.obj 目标文件
.h
外部模块头文件
.dll 动态链接库文件
.lib 动态链接库导入库文件
.fp 函数库(函数数和函数面板)文件
19.08.2020

LabWindows CVI教程

LabWindows CVI教程

第一章 : LabWindows/CVI1.1 LabWindows/CVI1.1.1 LabWindows/CVI概述LabWindows/CVI是美国NI(National Instruments)公司开发的面向计算机测控领域的虚拟仪器软件开发平台,可以在多种操作系统(WindowsXP/Vista/7、Mac OS和Unix)下运行。

LabWindows/CVI 是为C 语言程序员提供的集成开发环境(IDE),在此开发环境中可以利用C语言及其提供的库函数来实现程序的设计、编辑、编译、链接、调试。

使用LabWindows/CVI 可以完成以下但不限于以下工作:·交互式的程序开发;·具有功能强大的函数库,用来创建数据采集和仪器控制的应用程序;·充分利用完备的软件工具进行数据采集、分析和显示;·利用向导开发IVI 仪器驱动程序和创建ActiveX 服务器;·为其它程序开发C 目标模块、动态连接库(DLL)、C 语言库。

图 1‐1 LabWindows/CVI界面LabWindows/CVI 的功能强大在于它提供了丰富的函数库。

利用这些库函数除可实现常规的程序设计外,还可实现更加复杂的数据采集和仪器控制系统的开发。

数据采集。

IVI库、GPIB/GPIB 488.2库、NI-DAQmx库、传统的NI-DAQ库、RS-232库、VISA库、VXI库以及NI-CAN库。

数据分析。

格式化IO库、分析库以及可选的高级分析库。

GUI库。

使用LabWindows/CVI 的用户界面编辑器可以创建并编辑图形用户界面(GUI),而使用LabWindows/CVI 的用户界面库函数可以在程序中创建并控制GUI。

此外,LabWindows/CVI为GUI 面板的设计,准备了许多专业控件,如:曲线图控件、带状图控件、表头、旋钮和指示灯等,以适应测控系统软件开发的需求,利用这些控件可以设计出专业的测控程序界面。

LabWindows CVI实时模块入门指南说明书

LabWindows CVI实时模块入门指南说明书

Getting Started with the LabWindows/CVI Real-Time™™ModuleThis document provides an introduction to the LabWindows™/CVI™ Real-Time Module. Refer to this document for installation and configuration instructions and information about creating a real-time (RT) project.Installing the Real-Time Module Software on a Host ComputerYou must first install the Real-Time Module software on a host computer. Then you can configure and install software on the RT target.To install and use the Real-Time Module software, you must have the following:•Free Disk Space—In addition to the minimum system requirements for LabWindows/CVI, you must have at least 250 MB of free disk space for the Real-Time Module software. Refer to the LabWindows/CVI Release Notes for minimum system requirements.•RT Target—The LabWindows/CVI Real-Time Module supports NI RT Series PXI controllers, NI Real-Time Industrial Controllers, stand-alone NI CompactDAQ systems, and desktop PCs converted to RT targets.•Refer to the Using Desktop PCs as RT Targets with the Real-Time Module document for more information about converting a desktop computer to an RT target.Refer to the LabWindows/CVI Real-Time Module Readme for a step-by-step guide to installing the LabWindows/CVI Real-Time Module. You can access the LabWindows/CVI Real-Time Module Readme by selecting Start»All Programs»National Instruments»LabWindows/CVI version»LabWindows/CVI Real-Time Module Readme.Configuring the RT T argetAfter you install LabWindows/CVI and the RT module, you must use Measurement & Automation Explorer (MAX) to configure the RT target and to install software and drivers on the RT target. MAX provides access to NI devices and systems and can communicate with networked RT targets, also known as remote systems.Complete the following steps to configure the RT target. The following sections describe these steps in more detail.1.Boot the RT target into LabVIEW RT.2.Configure network settings.2| |Getting Started with the LabWindows/CVI Real-Time Module3.Install software on the RT target.4.Configure I/O.5.Configure system settings.6.Configure time settings.Refer to the Measurement & Automation Explorer Help for a complete tutorial aboutconfiguring the RT target. Select Help»MAX Help to access this help file, and then refer to the MAX Remote Systems Help section.Tip The Measurement & Automation Explorer Help refers to the LabVIEWReal-Time Module. However, you can apply the same concepts when you use theLabWindows/CVI Real-Time Module.Booting the RT Target into LabVIEW RTBefore you begin configuration, make sure your remote system is booted into LabVIEWReal-Time. If your RT target came with only LabVIEW Real-Time preinstalled on its hard drive, the system is already set up to boot into LabVIEW Real-Time. Many NI RT targets have DIP switches or BIOS settings for booting into LabVIEW Real-Time. For more information, refer to the Booting Into the LabVIEW Real-Time Module topic in the Measurement & Automation Explorer Help .You can permanently format the hard drive and configure it to boot directly into RT using the Tools»Desktop PC Utility USB Drive command in MAX.Configuring Network SettingsNoteFor the initial configuration, you must connect networked RT targets to thesame network subnet as the host computer from which you launch MAX.1.Connect the RT target to the network and power on the target.2.Launch MAX and expand the Remote Systems item in the MAX configuration tree.3.Select the RT target from the Remote Systems list. Some RT targets will be listed with an automatically configured name or IP address while other targets will be listed as 0.0.0.0.4.Specify a name for the RT target in the System Settings tab.5.Configure the IP address settings in the Network Settings tab using one of the followingoptions:•Select the DHCP or Link Local item from the Configure IPv4 Address option to obtain an IP address automatically.•Select the Static item from the Configure IPv4 Address option and specify anIP address.6.Click Save to commit the changes.7.Click Yesto reboot the RT target when prompted.Getting Started with the LabWindows/CVI Real-Time Module |© National Instruments |3Installing Software on the RT TargetUse the LabVIEW Real-Time Software Wizard in MAX to install the software and drivers from the host computer on the RT target. With the LabVIEW Real-Time Software Wizard, you can view and change the software that is installed on the target. Click Help in the wizard for more information about installing and uninstalling software on the RT target.Complete the following steps to launch the LabVIEW Real-Time Software Wizard:1.Launch MAX.2.Find and expand your RT target under the Remote Systems item in the MAX configurationtree, right-click Software , and select Add/Remove Software .When you select Add/Remove Software , MAX launches the LabVIEW Real-TimeSoftware Wizard. This displays all the National Instruments software and drivers installed on the host computer that you can install on a selected RT target.3.Select the software you want to install on the RT target, click the icon next to the software,and select Install the feature .Some components are automatically included as dependencies of other components. For more information about the features listed in the wizard, select the feature to view a description.The following list describes components you might commonly install.NoteIf you have multiple versions of a component installed on the host computer,the most recent version is selected by default. You can choose to install anotherversion.•Ethernet Drivers —MAX automatically selects the appropriate Ethernet driver(s) forthe RT target when you install the LabWindows/CVI Run-Time Engine for RTcomponent.•LabVIEW Real Time —MAX selects this item automatically when you install the LabWindows/CVI Run-Time Engine for RT component.–NI RT Extensions for SMP (MultiCore Support)—Install this item to takeadvantage of parallel processing on a multiple-CPU system.NoteSingle-CPU systems perform best without the NI RT Extensions for SMP .Also, some applications, such as those that consist mainly of single-point I/O, canachieve lower latency on a multicore system by using a single CPU without the NI RT Extensions for SMP .–Microsoft Visual Studio 2008 Runtime Support —Install this item if your application requires additional DLLs built with Visual Studio 2008.•LabWindows/CVI Network Streams for RT —Install this item if your application uses functions from the Network Streams Library. •LabWindows/CVI Network Variable for RT —Install this item if your applicationuses functions from the Network Variable Library.•LabWindows/CVI Run-Time Engine for RT—Install this item to add support for LabWindows/CVI RT applications on the RT target. This component is required forall LabWindows/CVI RT applications.•Language Support for LabVIEW RT—Install this item if you are using strings in your RT application containing ASCII characters above 127 or multibyte characters.After installing this item on the RT target, you can configure the locale in MAX byselecting the target in the Remote Systems item in the MAX configuration tree,selecting the System Settings tab, and modifying the Locale option.•NI Hardware Drivers—Install the appropriate drivers for any other hardware libraries that you use in your application. For example, install the NI-DAQmxcomponent if your application uses functions from the NI-DAQmx Library.•Network Variable Engine—MAX automatically selects this item when you install the LabWindows/CVI Network Variable for RT component.•NI Web-Based Configuration and Monitoring—Install this item to use a Web browser to monitor and configure an RT target.•State System Publisher—Install this item to monitor CPU and memory usage for an RT target from the NI Distributed System Manager.•USB Support—Install this item to enable support for accessing USB thumbdrives.•Variable Client Support for LabVIEW RT—MAX automatically selects this item when you install the LabWindows/CVI Network Variable for RT component. 4.When you finish selecting the software you want to install, click Next and continuefollowing the instructions on the screen.Configuring I/OYou must configure any National Instruments I/O devices before you can use them from a LabWindows/CVI RT application. For information about how to correctly configure I/O devices, refer to the documentation for that hardware.Configuring System Settings1.Select the System Settings tab to configure system-level settings for the RT target.2.Configure the Locale option to match the language you use for strings in your RTapplication. This option is available only when you install the Language Support for LabVIEW RT component on the RT target. This option determines the code page that LabWindows/CVI uses when processing strings containing ASCII characters above 127 or multibyte characters.Configuring Time Settings1.Select the Time Settings tab to configure date and time settings for the RT target.e the Time Zone option to configure the time zone for the RT target. You can use thissetting with time and date functions to provide accurate time information relative to the time zone setting.4||Getting Started with the LabWindows/CVI Real-Time ModuleUsing NI Web-Based Monitoring and ConfigurationIf you install NI Web-Based Monitoring and Configuration, you can use a Web browser to monitor and configure the RT target.Configuration. If you have not installed Microsoft Silverlight, NI Web-BasedMonitoring and Configuration prompts you to do so.1.In a Web browser, enter the URL http://[IP address of the RT target] toaccess Web-based monitoring and configuration for the remote system.2.Click the Login button in the top-right corner of the page.3.Enter Admin in the User name field.4.Leave the Password field blank.5.Click the OK button.6.When you log in, you can view and change system, network, security, and time settings;view console output remotely; access the file system remotely; and so on.For more information about NI Web-Based Monitoring and Configuration, refer to the LabWindows/CVI Real-Time Module Help.Configuring an RT ProjectAfter you configure the RT target, you can create an RT application on the host computer and then run the application on an RT target. The applications that you create with the LabWindows/CVI Real-Time Module are DLLs.Complete the following steps to create a DLL and specify an RT target directly from LabWindows/CVI.1.Create a project in LabWindows/CVI using RTmain instead of main as the entry pointfunction for the program. Select Edit»Insert Construct»RTmain to insert the RTmain code into the program source.2.Select Build»Configuration»Debug or Build»Configuration»Release to specify theactive configuration for the project.3.Select Build»Target Type»Dynamic Link Library to configure the project to generate aDLL.4.Select Build»Target Settings to open the Target Settings dialog box. Select Real-timeonly in the Run-time support option. If you specify this option, LabWindows/CVI does not link to the entire set of LabWindows/CVI libraries but instead links to only thoselibraries supported on an RT system.5.Click OK to exit the dialog box.6.Select Build»Build to create the DLL.You also can use a project template to create an RT DLL. The project template includes basicsettings for RT projects described in the preceding section. To select a project template,Getting Started with the LabWindows/CVI Real-Time Module|© National Instruments|5select File»New»Project from Template. In the New Project from Template dialog box, select Real-Time Target Application.Specifying an RT TargetComplete the following steps to select the RT target on which to run your RT application.1.Select Run»Select Execution Target for Debugging to view a list of previouslyconfigured RT targets. Select the RT target you want to use from the list, if it is available.2.To configure a new RT target, select Run»Select Execution Target for Debugging»NewExecution Target.3.In the New Real-Time Execution Target dialog box, enter the computer name or IP addressof the RT target in the Hostname/IP Address option and click OK to exit the dialog box. Running an RT ApplicationSelect Run»Debug Project to run your RT application.warning message. Click Continue to download and run the release DLL on the RTtarget.LabWindows/CVI automatically builds the DLL and downloads the DLL and any DLLs that are statically linked to it onto the specified RT target. LabWindows/CVI places the files that it automatically downloads in the NI-RT\CVI\temp folder. LabWindows/CVI empties the folder when you reset the RT device.While you run your RT application, LabWindows/CVI displays a <<Running on target>> menu in the upper left corner of the LabWindows/CVI environment. The menu contains the following options, which you can use for debugging and for shutting down the RT application:•Toggle Breakpoint—Turn on or turn off a breakpoint on the selected line when a Source window is active.•Break Execution—Suspend execution of the program.•Simulate RT Shutting Down—End program execution. This option causes the RTIsShuttingDown function to return 1, giving the RT application an opportunity to run any necessary cleanup code and exit. The RT target does not reboot.•Abort Execution and Reboot Target—End program execution and reboot the RT target.The application cleanup code is not guaranteed to finish running before the RT target reboots.•Disconnect from RT target—Disconnect LabWindows/CVI from the RT target while theRT application continues running on the target. Once you disconnect from the RT target,you cannot reconnect LabWindows/CVI to the RT application that is running.6||Getting Started with the LabWindows/CVI Real-Time ModuleDebugging an RT ApplicationIf you select Build»Configuration»Debug, you can debug the DLL from the LabWindows/CVI environment as you would debug any other application. For example, you can set breakpoints and watch expressions, step through code, view and edit variable values, and so on. For more information about debugging in LabWindows/CVI, refer to the Using LabWindows/CVI»Debugging Tools section of the LabWindows/CVI Help.Using the Real-Time Execution T race ToolkitThe LabWindows/CVI Real-Time Module includes a limited time full-featured evaluation of the Real-Time Execution Trace Toolkit.Use the Real-Time Execution Trace Toolkit to analyze the timing and execution of an RT application. Use the Execution Trace functions in the Real-Time Utility Library to capture the timing and execution data of functions and threads in an application running on an RT target. The Real-Time Execution Trace Tool displays the timing and event data, or trace session, on the host computer.In LabWindows/CVI, select Tools»Real-Time Execution Trace Tool to launch the Real-Time Execution Trace Tool. Refer to the LabWindows/CVI Help for more information about using the Real-Time Execution Trace Toolkit to analyze RT applications.Deploying an RT ApplicationWhen you finish developing your RT application, you can deploy it to an RT target. After you deploy the RT application, the RT application runs automatically every time the RT target reboots.Select Run»Install Program to Real-Time Execution Target to deploy your RT application. This option performs the following actions:•Checks that the release configuration of the DLL has been built; if not, LabWindows/CVI prompts you to build the DLL or cancel.•Deploys the release DLL and any statically linked DLLs to the NI-RT\CVI folder on the RT target.•Sets the release DLL as a startup DLL.•Displays a dialog box indicating that the DLL was copied and prompting you to reboot the RT target.If you have additional support files that you need to deploy, complete the following steps:1.Select Run»Manage Files on Real-Time Execution Target to launch theLabWindows/CVI Real-Time File Copy Utility.2.Click Add Files and browse to any support files that your application requires. The utilityimmediately copies the files to the NI-RT\CVI folder on the RT target.3.Click Done when you finish adding support files.Getting Started with the LabWindows/CVI Real-Time Module|© National Instruments|7Where to Go from HereRefer to the following resources for more information about the LabWindows/CVI Real-Time Module:•The LabWindows/CVI Real-Time Module Help section of the LabWindows/CVI Help includes conceptual information about real-time programming techniques, application architectures, and Real-Time Module software features you can use to create real-time applications. Select Help»Contents in LabWindows/CVI to access the LabWindows/CVI Help.•Use the NI Example Finder, available by selecting Help»Find Examples in LabWindows/CVI, to browse or search for example programs. You also can access the example programs from the samples\CVI samples\realtime directory.Refer to the NI Trademarks and Logo Guidelines at /trademarks for more information on National Instruments trademarks. Other product and company names mentioned herein are trademarks or trade names of their respective companies. For patents covering National Instruments products/technology, refer to the appropriate location: Help»Patents in your software, the patents.txt file on your media, or the National Instruments Patents Notice at /patents. You can find information about end-user license agreements (EULAs) and third-party legal notices in the readme file for your NI product. Refer to the Export Compliance Information at /legal/export-compliance for the National Instruments global trade compliance policy and how to obtain relevant HTS codes, ECCNs, and other import/export data.© 2007–2013 National Instruments. All rights reserved.374686E-01Aug13。

LabWindows-CVI安装教程

LabWindows-CVI安装教程

1.启动setup.exe.
2.打开LabWindows-CVI 9-0 Evaluation\Crack下keygen.exe。

点击Generate,随后copy生成
的serial number到上图对应的位置。

最后点击Create license file,将生成的文件保存到你知道的位置。

(此处默认文件名为1.lic,后续有用)
3.接下来选择文件的安装位置。

(安装路径上不要有中文),点击Next。

4.再次选择安装路径。

点Next。

5.之后会出现软件安装接受协议。

一直点击Next即可。

(因为我电脑里面已经安装,不会
出现后续的画面,所以没有图片展示)最终安装开始。

6.安装完成后,点击Finish,出现安装完成的祝贺信息。

7.点击Next,在出现的方面中选择重新启动Restart。

完成安装过程。

8.重启电脑后,选择National Instruments下的NI License Manager。

9.在选项中点击安装许可证文件。

然后找到1.lic文件。

软件激活完成。

labwindows使用基础教程

labwindows使用基础教程

LabWindows/CVI基础教程1LabWindows/CVI是National Instruments公司推出的一套面向测控领域的软件开发平台.它以ANSI C为核心,将功能强大,使用灵活的C 语言平台与数据采集,分析和表达的测控专业工具有机地接和起来.它的集成化开发平台,交互式编程方法,丰富的控件和库函数大大增强了C语言的功能,为熟悉C语言的开发人员建立检测系统,自动测量环境,数据采集系统,过程监控系统等提供了一个理想的软件开发环境. 本教程面向的是那些从未使用过LabWindows/CVI的读者,但是假设读者以有了C语言的基础并且熟悉Windows 2000/9x/NT操作系统.在每一章节的学习中,作者都是通过一个具体的实例让读者迅速的掌握本章的知识点;而不是长篇大论,述及边枝细叶,反而使读者望而却步,只见树木,不见森林.想信通过对本教程的学习,读者可迅速掌握LabWindows/CVI编程思想及步骤,为读者日后进一步学习打下基础.本书约定:"File>>Page Setup>>Options"File 这一种黑色斜体字是指多级菜单名,按扭名,窗口名或者是关键性词汇.">>"是指打开一个多级菜单或对话框.如:File>>Page Setup>>Options是指你首先打开File 菜单,然后选择Page Setup项,最后从弹出的对话框中选择Options项."说明:通过这种方式你可以修改Panel 顶端所显示的名字."该种字体所写的文字是值得读者注意并记忆的内容." "该椭圆形框所框住的内容是读者需修改的地方.第一部分CVI快速入门本部分通过编制一个简单的LabWindows/CVI程序,使读者对CVI编程环境,思想及步骤有一初步的认识.第一章初步认识CVI程序设计——从一个例子开始我们的第一个示例将很简单,我们所要做的是创建一个如下的图形用户界面(User Interface).当我们按下Acquire按扭,计算机会自动产生一个正弦波形并画在图形显示区中;当按下Clear按扭后则清除正弦波形;当按下Quit按扭后退出该程序.现在我们就开使创建该程序.首先按下面步骤起动CVI:开始>>程序>>National Instrument CVI>>CVI IDE或者直接从桌面起动CVI 的快捷方式,双击桌面National Instrument CVI 图标当LabWindows/CVI打开后你就会见到如下所示的一个空的项目(Project)窗:第一步:创建用户界面创建控件元素:从Project窗中选择:File>>New>>User Interface(*.uir)…创建一个用户接口文件(*.uir),CVI会自动弹出如下所示的窗口:在该窗中Untitled Panel 的灰色区域中单击鼠标右键,变会弹出一个快捷菜单如下所示:从该菜单中选择:Command Button>>Square Command Button 点击左键后便会创建一个方形的按扭.由于本程序总共需要三个按扭,所以按照上面的步骤再创建两个方形按扭.从该菜单中选择:Graph>>Graph ,创建一个用于图形显示的Graph.现在我们已经建好了用户界面所需的控件元素,请使用鼠标把它们拖到如下图所示的位置.修改用户界面中各控件元素的属性:修改Panel的属性:在Untitled Panel中双击一下,便会弹出Panel的一个Edit Panel窗,如下图所示:将Panel Title项中的Untitled Panel 改为Demo Panel.说明:通过这种方式你可以修改Panel 顶端所显示的名字.将Auto-Center Vertically(when loaded)项与Auto-Center Horizontally(when loaded)项前的矩形框选中.说明:当选中后,程序运行时,面板会自动居中.修改后的Edit Panel 应如下图所示:点击OK按扭,完成对Panel属性的修改.修改Graph的属性:在Untitled Control的蓝色区域中双击一下,便会弹出Graph的一个Edit Graph窗,如下图所示:将Label项中的Untitled Control改为ShowWave.说明:通过这种方法可以修改Graph的标签名.点击OK按扭,完成对Graph属性的修改.3.修改Command按扭的属性:(1)Acquire 按扭:双击左上方的OK按扭,便会弹出Command的一个Edit Command窗,如下图所示:将Constant Name项改为ACQUIRE说明:Constant Name是程序中用来标识该控件元素的常量,在后面的编程中会用到.将Callback Function项改为AcquireCallback 说明:Callback Function(回调函数)是程序中用来响应界面中的Windows消息,也就是说:当该按扭被点击之后,程序会调用AcquireCallback函数来作为对按扭被按下这一消息的响应.将Label项改为Acquire说明:通过这种方法可以修改按扭名字,Acquire中A字母前有下画线,是指可以通过Alt + A即可达到按下该按扭的效果(即热键).修改后的Edit Command Button窗应如下图所示:点击OK按扭,完成对Command Button属性的修改.(2)Clear 按扭:与以上步骤相同,双击左下方的OK按扭,弹出Command的一个EditCommand窗.将其Constant Name改为CLEAR将Callback Function项改为ClearCallback将Label项改为Clear修改后的Edit Command Button窗应如下图所示:点击OK按扭,完成Command Button属性的修改.(3)Quit 按扭:与以上步骤相同,双击右方的OK按扭,弹出Command的一个EditCommand窗.a. 将其Constant Name改为QUITb. 将Callback Function项改为QuitCallbackc. 将Label项改为Quit修改后的Edit Command Button窗应如下图所示:点击OK按扭,完成Command Button属性的修改.当完成以上工作后,Panel应该如下图所示:选择:File>>Save 保存UIR文件,命名为FirstSample.uir.到目前为止我们已经完成了用户界面(user interface)的设计,当程序运行时所显示的界面就是我们刚才上图看到的那样.下面我们要做的就是真正的程序编制工作,其实CVI可以自动生成许多的代码以及缺省消息的处理函数,你只需添加一些你自己所需的一些代码.第二步:完成程序的编制产生程序代码:现在请你让图形用户界面窗口为当前响应状态,如下图所示:从用户图形界面窗口中选择:Code>>Generate>>All Code…然后会显示出如下的界面:请用你的鼠标点击Select QuituserInterface Callback 中的QuitCallk项,确保其前面出现一个小钩.说明:1.当你想让你的程序的主函数为Win Main而不是Main时你可以选择Generate WinMian( ) instead of Main( )项前的矩形框.2.Select panels to load and display at startup 项是指你选择那一个Panel作为最初装入并显示的Panel,当你创建多个Panel时你就需要选择一个Panel作为最初显示的面板.由于本程序只有一个Panel所以该Panel就被缺省的作为最初显示的面板而不再需要你去选择.3.Select QuituserInterface Callback 项是指你选择那一个函数作为退出程序的终止函数.本程序是让QuitCallback作为退出函数的.点击OK按扭,便会弹出如下图所示的源代码(Code)窗:其窗中的程序代码如下所示:#include#include#include "FirstSample.h"static int panelHandle;int main (int argc, char *argv[ ] ){if (InitCVIRTE (0, argv, 0) == 0)return -1; /* out of memory */if ((panelHandle = LoadPanel (0, "FirstSample.uir", PANEL))>Advanced Analysis…在弹出的对话框中选择:Signal Generation>>Sine Pattern便会弹出如下图所示的一个函数面板:请在Number of Elements项中填上512;把Number of Cycles 项改为3;Sine Pattern 项中填上用来装正弦信号的数组Wave,由于Wave 是一个数组变量,故我门需要声明该变量:选择Code>>Declare Variable会弹出一个如下图所示的对话框: 请在Number of Elements 项中填上512,并选择了最下面的矩形框,然后点击OK按扭完成.返回到函数面板后,选择Code>>Insert Function Call完成函数的插入,这时Code 窗中的AcquireCallback( )函数应如下所示:int CVICALLBACK AcquireCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){double Wave[512];switch (event){case EVENT_COMMIT:SinePattern (512, 1.0, 0.0, 3.0, Wave);break;}return 0;}我们已经的得到了正弦信号,现在需要将该信号画到Graph上去: 1).请将鼠标放在SinePattern( )函数下面的空白行上,如上面所示那样.. 请选择:Library>>User Interface在弹出的对话框中选择:Controls/Graph/Strip Chart>>Graph and Strip Chart>>GraphPlotting and Deleting>>Plot Waveform把函数面板中的对应各项填写成如下所示:PanelHandle: panelHandeleControl ID : PANEL_GRAPHY Array: WaveNumber of Points: 512选择Code>>Insert Function Call完成函数的插入,这时Code 窗中的AcquireCallback( )函数应如下所示: CVICALLBACK AcquireCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){double Wave[512];switch (event){case EVENT_COMMIT:SinePattern (512, 1.0, 0.0, 3.0, Wave);PlotWaveform (panelHandle, PANEL_GRAPH, Wave, 512,VAL_DOUBLE, 1.0,0.0, 0.0, 1.0, VAL_THIN_LINE, VAL_EMPTY_SQUARE,VAL_SOLID, 1, VAL_RED);break;}return 0;到现在为止我们已经完成了AcquireCallback( )函数的的程序代码.添加ClearCallback( )函数的程序代码: ClearCallback( )函数完成以下功能:当Clear按扭按下后,计算机会清除Graph上所画的正弦图形.现在请将鼠标放在ClearCallback( )函数Event_Commit:下面的空白行上,如下图所示:请选择:Library>>User Interface在弹出的对话框中选择:Control/Graph/Strip Chart>>Graph and Strip Chart>>Graph Plotting and Deleting>>Delete Graph Plot把函数面板中的对应各项填写成如下所示:PanelHandle: panelHandeleControl ID : PANEL_GRAPHPlotHandle: -1选择Code>>Insert Function Call完成函数的插入,这时Code 窗中的ClearCallback( )函数应如下所示:int CVICALLBACK ClearCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){switch (event){case EVENT_COMMIT:DeleteGraphPlot (panelHandle, PANEL_GRAPH, -1,VAL_IMMEDIATE_DRAW);break;}return 0;}到目前为止我们已经完成了程序的编制任务.这一个看起来不算简单的程序,我们编起来并没有写多少源代码,这正是体现了LabWindows/CVI的强大功能所在.第四步运行程序完成项目文件现在请你让源代码(Code)窗为当前响应状态,选择:Run>>Debug FirstSample_dbg.exe便会弹出一个对话框,询问你是否在编译前为该文件命名并添加到工程文件中去.点击yes按扭,把该文件命名为FirstSample.c.然后计算机询问你是否把"analysis.h"包含到FirstSample.c中去(因为,我们的程序中用到了高级分析库),点击yes按扭,同意该选项.运行后的程序正如我们预期要求的那样.退出程序后,从源代码(Code)窗中选择:Window>>Project现在项目(Project)窗为当前响应状态,请选择:Edit>>Add Files to Project…>>All Files(*.*)便会弹出如下图所示的对话框:请你按住键,点击FirstSample.h ,FirstSample.c , FirstSample.uir.然后点击Add按扭把这些文件方到Selected Files框中.点击OK按扭,把以上文件添加到工程文件中去.至此为止我们已经完成了第一个程序的编制工作,想必大家对LabWindows/CVI编程已经有了一个初步的了解,头脑里已建起程序编制的基本框架.通过本部分的学习,你是否已经掌握LabWindows/CVI 程序编制的基本步骤.简单的用户图形界面(*.uir)的创建.能使用函数面板完成函数的插入,构建源代码程序.项目工程文件的基本构成.第二部分CVI环境下程序设计通过编制第一章的FirstSample程序,读者已对LabWindows/CVI编程有一定了解.本部分就是在第一部分的基础上进一步讲述LabWindows/CVI程序设计及其编程环境等细节问题.这一章所讲内容请大家都务必动手实际操作一下,只有这样才能使你真正的掌握本章的内容.看完本章后请大家结合第一章把FirstSample重新编制一遍,以巩固本章所讲的加速LabWindows/CVI编程的技巧.第二章LabWindows/CVI 程序剖析通过例程FirstSample的编制,大家已对LabWindows/CVI编程有了初步的认识.本章是作者从总体上来谈谈自己对LabWindows/CVI程序的理解与认识.LabWindos/CVI 编程的步骤基本如下:制定程序设计的基本方案第一步根据任务确定程序的基本框架如:程序界面,程序中所需的函数等.创建用户图形界面第二步根据第一步制定的方案创建用户图形界面及回调函数名.程序源代码的编制第三步让计算机生成程序代码及回调函数的基本框架.添加函数代码,完成源代码的编制工作.工程项目的完成第四步编译,调试程序.把头文件,用户图形界面文件,源代码文件添加到项目文件中去,完成整个程序的编制程序框架及文件间的相互关系如下图所示(以FirstSample.prj为例):项目工程文件(FirstSample.prj)用户图形界面文件源代码文件头文件(FirstSample.uir) (FirstSample.c) (FirstSample.h)panel include "FirstSample.h" 定义了程序中所需的常事件消息量以及函数原形.Acquire按扭AcquireCallback( )事件消息Wave[512]Clear按扭ClearCallback( )事件消息Quit按扭QuitCallback( )ShowWave上图所画的构成一项目工程文件的各文件之间的关系是非常重要的.如果你能理解上图所示的内容,那么你就基本理解了LabWindos/CVI程序的运作过程.请读者仔细阅读以上内容并理解,这些都有助于读者从整体上去把握LabWindows/CVI 程序设计的核心思想,有益于读者进一步学习LabWindows/CVI.第三章LabWindows/CVI 编程环境LabWindows/CVI开发环境有以下三个最主要的窗(window)与函数面板(Function Panel):·项目工程窗(Project Window)·用户接口编辑窗(User Interface Editor window)·源代码窗(Source window)下面就会对以上三个窗及函数面板作详细的介绍.项目工程窗(Project Window)一个项目工程窗(Project Window)如下图所示:在项目工程窗中列出了组成该项目工程所有的文件,项目工程窗中的个菜单项功能如下:File : 创建,保存或打开文件.可以打开以下文件:项目工程文件(*.Prj)源代码文件(*.c),头文件(*.h)以及用户接口文件(*.uir).Edit: 在项目工程中添加或移去文件.Build: 使用LabWindows/CVI 编译链接器.Run: 运行一个项目工程.Windows: 用来访问某个已经打开的窗,例如:用户接口编辑窗,源代码窗… .Tools: 运行向导(wizard)或者你添加到Tools菜单中的一些工具.Options: 设置LabWindows/CVI 的编程环境.Help: LabWindows/CVI 在线帮助及Windows SDK 的函数帮助.工程项目文件显示了所列文件的状态,其各项的含义如下图所示:文件名这个标志是指源代码最后修改该文件文件是否是打开的的日期时间S是指该文件已经修C是指运行该文件之O是指你可以让该文件I是指这是一个改过了,请保存该文件前必须先经过编译编译而无需debugging 仪器驱动程序如果你想进一步了解项目工程窗(Project window)细节请使用在线帮助.请选择:Help>>CVI Library>>Related Help…Online Manuals ForLabWindows/CVI请查阅LabWindows/CVI User Manual Chapter 3 Project window.第二节用户接口编辑窗(User Interface Edit window)图形用户接口编辑窗是用来创建,编辑GUI(Graph Uer Interface)的.一个用户接口至少要有一个面板(Panel)以及在面板上的各种控件元素(Control Element).图形用户接口编辑窗为你提供了非常快捷的创建,编辑这些面板和控件元素的方法,可以让你在短时间里创建出符合你要求的图形界面.一个图形用户接口编辑窗就如下图所示,下面我们就详细讲讲图形用户接口编辑窗各菜单项的功能:File: 创建,保存或打开文件.Edit: 可用来编辑面板或控件元素.说明:其实我们直接用鼠标双击我们想要编辑对象即可(就象编制中修改面板和四个按扭那样).Creat: 可用来创建面板和各种控件元素.说明:其实我们只需在Panel上点击鼠标右键,便会弹出一个快捷菜单,选择你所想创建的对象即可(就象编制FisrtSample 时创建Graph和四个Button那样).View: 当创建多个面板后就可用该项来查看想要看的面板.Arrange: 用来调节各个控件元素的位置与大小.Code: 产生源代码,以及选择你所需的事件消息类型.Run: 运行程序.Library: 函数库.说明:我们将在后面详细的介绍LabWindows/CVI的函数库.Tools: 一些你可使用的工具项.Windows: 用来访问某个已经打开的窗,例如:项目工程窗,用户接口编辑窗,源代码窗… .Options: 设置用接口编辑窗的编辑环境.Help: LabWindows/CVI 在线帮助及Windows SDK 的函数帮助.说明:在用户接口编辑窗中有一快捷菜单是非常有用的,当你把鼠标指在某一控件元素上点击右键后便弹出一快捷菜单,通过该菜单你可以生成回调函数以及查看回调函数,而无须你再切换到源代码窗后再查看.这是一个大家以后在编程中要常用到的技巧,请掌握.图形用户接口编辑窗中还有四个模式选择按扭,现介绍如下:当该按扭被按下后,你可以操作面板上的控件,同时在图形用户接口编辑窗的右上角上来观察面板上的事件消息.在这种模式下你可以创建,编辑面板和控件元素以及修改它们的属性. 在这种模式下你可以直接修改控件元素的名字,标签等文字相关方面的东西.在这种模式下你可以直接修改面板,控件元素的颜色.先把鼠标方在你所想修改颜色的对象上,点击右键便会弹出一个选色对话框,选择你所想要的颜色后点击后即可.在图形用户接口编辑窗中Panel 的灰色区域中单击鼠标右键,便会弹出一个快捷菜单如下所示:说明:请读者用鼠标点击各项自己看一看,在这里就无须作者多言. 如果你想进一步了解用户接口编辑窗(User Interface Edit window)细节请使用在线帮助.请选择:Help>>CVI Library>>Related Help…Online Manuals ForLabWindows/CVI请查阅LabWindows/CVI User Manual Chapter 4 User InterfaceEdit window源代码编辑窗(Sourse window)你可以在源代码编辑窗中开发你的C 语言代码文件.例如:添加,删除,插入函数等编程所需的基本编辑操作.但是LabWindows/CVI 又有其独特的简捷快速的开发,编辑工具,可以让你在短时间内完成一个较复杂的C程序代码的开发.一个源代码编辑窗(Source window)就如下图所示,下面我们就详细讲讲源代码编辑窗中各菜单项的功能:File: 创建,保存或打开文件.Edit: 可用来编辑源代码文件.View: 设置源代码编辑窗的风格等功能.Build: 编译文件以及编译设置.Run: 运行程序.Instrument: 装入仪器驱动程序.Library: 函数库.Tools: 一些你可使用的工具项.Windows: 用来访问某个已经打开的窗,例如:项目工程窗,用接口编辑窗,源代码窗… .Options: 设置用接口编辑窗的编辑环境.Help: LabWindows/CVI 在线帮助及Windows SDK 的函数帮助.说明:在编程中有一快捷菜单是非常有用的,当你把鼠标指在某一函数上点击右键后便弹出一快捷菜单,通过该菜单你可以查看回调函数以及与该函数对应控件元素.这是一个大家以后在编程中要常用到的技巧,请掌握.第四节函数面板(Fuction Panel)在LabWindows/CVI 编程环境下,当你想在源程序某处插入函数时,你只需从函数所在的库中选择该函数后便会弹出一个与之对应的函数面板,你所做的就是:填入该函数所需的参数后完成插入即可.而且更为方便的是:若参数是一你以有的常量或变量,你只需点击常量或变量工具按扭后选择你所需的量即可;若参数是一变量,你直接可声明该变量而无须再切换至源代码窗.下面我们就谈谈这些在LabWindows/CVI中可以加快你编程的技巧.一个函数面板如下图所示:这是FirstSample中产生一个正弦波的函数其中SinePattern项是用来装正弦波的数组,我们在程序中使用数组Wave[512] 来装正弦波的.当我们在SinePattern项填入Wave后,由于Wave是一变量,所以我们需要声明该变量:让鼠标指在Wave上然后点击工具条中的声明变量按扭后, 便弹出一个声明变量对话框即可声明该变量为局域变量或为全局变量.当你所填参数是一以有的常量或变量,你只需点击选择常量或变量工具按扭后选择你所需的量即可,下面就介绍该技巧:上图是FirstSample中把数组Wave中的正弦波画到Graph上去的PlotWaveform函数.其中,Control ID 项所填的是程序中用来标识GUI中控件元素的常量,该常量是由LabWindows/CVI自动在头文件中预定义的(你可以打开头文件看看).故当我们填入该常量时只需将鼠标放在Control ID项的文本框中然后用鼠标点击工具条中的选择属性或UIR常量按扭后, 便弹出一个选择属性或UIR常量对话框,选择你所需的常量或属性即可.Panel Handle 是程序运行开始时UIR 的句柄,是由LabWindows/CVI 自动生成的是一变量;Number of Points 项需填的是512,这正是我们在声明Wave时已用过的;Y Array 项所填的是我们已经声明过的变量——数组Wave;故当我们填入以上各项时只需将鼠标放在对应项下文本框中,然后用鼠标点击工具条中的选择变量按扭后, 便弹出一个选择变量对话框,选择你所需的变量Wave即可.当你填完函数的参数后,点击插入按扭后即可完成函数的插入,而无须再选择菜单中的插入命令.以上这些都是加快你编程的技巧,这些技巧你以后编程时是会非常频繁使用的.而这些也正是LabWindows/CVI 开发环境所独具的加快你编程速度的特色.说明:当你的鼠标落在工具条按扭上时,计算机会自动的显示该工具按扭的功能.请你使用上面所讲技巧重新编制FirstSample,我相信你将会有新的收获.当你对函数中的某个参数有不明白的时候,你只须将鼠标置于该项的文本框中点击鼠标右键后便会出现对此参数说明的在线帮助,这一技巧在编程中是非常有帮助的.如果你想进一步了函数面板(Function Panel )细节请使用在线帮助. 请选择:Help>>CVI Library>>Related Help…Online Manuals ForLabWindows/CVI请查阅LabWindows/CVI User Manual Chapter 6 Using FunctionPanels第四章LabWindows/CVI 的函数库(Library) LabWindows/CVI 其强大功能的所在就是基于其非常丰富的库函数.LabWindows/CVI 所提供的库函数从用户图形界面,数据采集,数据分析,仪器控制… 到现在Internet时代的TCP.所以说LabWindows/CVI 在测量领域成为先锋的同时又与当前时代的新科技保持了同步.下面我们就来谈谈LabWindows/CVI 的函数库,我们把LabWindows/CVI 的函数库分为了五个大的方面,各个方面又分成了不同的小类:·数据采集方面(Data Acquisition),7个库:Instrument Library: 仪器驱动库GPIB/GPIB 488.2 Library: 仪器控制函数库Data Acquisition Library: 数据采集函数库Easy I/O for DAQ : 易用的数据采集函数库RS 232 Library : RS 232 库VISA Library : VISA 库VXI Library : VXI库·数据分析方面,两个库:Formatting and I/O Library : 格式化以及输入输出库Analysis Library: 分析库或者Advanced Analysis Library: 高级分析库·数据显示方面:User Interface Library : 用户接口库说明: 用户接口库中提供了许多用于与面板上各种控件元素打交道的函数,通过这些函数你可以非常容易的把一个采集来的波形画到Panel 的Graph上或删除Graph 上已画的图形;得到Panel上某个控件元素的数值以及把某个数值写到Panel上的某个控件元素上去(亦就是改变该控件元素的值);修该Panel上控件元素的属性.总之,你只有熟练掌握了用户接口库函数后才能使你创建的用户图形界面正正的动起来,该库是初学者应迅速熟悉的库.·网络,通信与数据交换方面,四个库:DDE Library : 动态数据交换库TCP Library: TCP库Active X Automation Library: Active X自动化库DataSocket Library: DataSocket库·其它方面:ANSI C Library: 标准C 库如果你想进一步了解LabWindows/CVI 函数库(Library)细节请使用在线帮助.请选择:Help>>CVI Library>> Library Help中你感兴趣的库通过本部分的学习,你是否已经掌握□LabWindows/CVI 程序设计步骤及程序的运行机制.三个主要窗的基本操作.在用户接口编辑窗中用快捷方式生成或查看回调函数,在源代码窗中用快捷方式返回到函数面板或对应控件元素等编程中所需的快捷操作.在函数面板上声明变量,选择变量或常量,插入函数等快捷操作.LabWindows/CVI 库的构成及其在编程中适用的方向.第四部分CVI 中数据采集的应用通过前两部分的学习,读者应该已掌握了LabWindows/CVI程序设计的基本步骤,思路以及编程环境.本部分将在前两部分的基础上讲解LabWindows/CVI中的数据采集,并在讲解的过程中编制一个程序:EeasyIOSample .请读者确保自己已经安装了Daq驱动,否则你会找不到例子中要用到的函数.Easy IO 库中数采函数的应用本章我们将使用Easy IO 库中的数采函数来编制一个真正能用于实际工作中的数据采集程序EasyIOSample.我们程序运行时的界面如下图所示:其中各控件元素的功能说明如下: ChannelSrting 项是一字符串控件,我们通过该项来设置采集数据的通道(数采路径).我们把该项缺省设置为:daq::1!(0)其意思是指:采集设备(device)1的0通道(channel).其中设备号正是你在Measurement &Automation 中所看到的对应于数采板的编号.在数采停止时,该项是可以修改的.daq::1!(0) 这段字符串是NI 数采通道的语法表示,具体说明如下: daq::1!(0,2,5) 是指采集设备1的通道0,2,5.daq::1!(2:6)是指采集设备1的通道2,3,4,5,6.ScanRate项是一数字控件,我们通过该项来设置扫描速率,其缺省设置为1000Acquire/Stop项是一开关控件,我们通过该开关来控制数据采集的开始与停止.Clear项是一按扭,当我们按下该按扭后即可清除Acquire Wave上所画的波形.Quit项是一按扭,当我们按下该按扭后,退出程序. Acquire Wave项是一波形显示控件,我们所采集的数据正是通过该控件来显示的.现在我们就开使创建该程序.首先按下面步骤起动CVI:。

LabWindowsCVI(一):各文件类型的含义及初始项目的搭建

LabWindowsCVI(一):各文件类型的含义及初始项目的搭建

LabWindowsCVI(⼀):各⽂件类型的含义及初始项⽬的搭建1、基本定义虚拟仪器(VI)是计算机技术、仪器技术和通信技术相结合的产物。

虚拟仪器的⽬的是利⽤计算机强⼤资源使硬件技术软件化,分⽴元件模块化,降低程序开发的复杂程度,增强系统的功能和灵活性LabWindows/CVI是⼀个完全的ANSI C开发环境,⽤于仪器控制、⾃动检测、数据处理的应⽤软件使⽤LabWindows/CVI设计的应⽤程序可以脱离LabWindows/CVI开发环境独⽴运⾏,并可以打包⽣成.msi安装⽂件LabWindows/CVI主要采⽤事件驱动与回调函数⽅式,编程⽅法简单易学LabWindows/CVI⽂件类型⼯作空间⽂件(*.cws)通常包含的⽂件类型有如下六种:1、*.prj ⼯程⽂件是⼯程的主体框架,主要由*.uir⽂件、*.c⽂件、*.h⽂件组成。

程序调试运⾏后,可以⽣成可执⾏⽂件(*.exe)2、*.c C源程序。

他主要包含头⽂件、主程序⽂件和回调函数,其结构和C语⾔结构⼀致3、*.uir ⽤户界⾯⽂件,即⾯板⽂件。

该⽂件中包括菜单和各种控件资源4、*.h 在LabWindows/CVI中,头⽂件是由系统⾃动⽣成的。

它的作⽤⼀⽅⾯是便于打开和编辑,另⼀⽅⾯是确保编译器在编译时能引⽤它们5、*.fp 当打开⼯程的仪器驱动函数⾯板⽂件时,LabWindows/CVI⾃动加载仪器驱动⽂件6、*.lib 这类⽂件可能是DLL导⼊库⽂件,也可以是静态库⽂件2、构建⼀个简单程序1、建⽴⼯程⽂件 ——> (*.prj)File ——> New ——> Project(*.prj) 默认⽂件名为untitledFlie ——> Save Untitled Project As ... 保存新建的⼯程⽂件 (重命名)2、创建⽤户界⾯⽂件 ——> (*.h ,*.uir)(1) 创建空⾯板窗⼝File ——> New ——> User Interface(*.uir)(2) 向⾯板中添加控件点击⾯板,菜单栏出现 Create ,点击 Create 选择相应的控件进⾏添加或在⾯板右击选择添加(3) 保存File ——> Save Untitled.uir (重命名)3、⽣成源代码⽂件:(1)、⽣成全部源代码框架 (*.cws ,*.exe ,*.c ,cvibuild.项⽬名)Code ——> Generate——> All Code(2)、主函数及回调函数分布⽣成 ——> (*.c)a、⽣成主函数:Code ——> Generate ——> Mainb、保存⽂件Edit ——> Add Files to Project ——> Source(*.c) 把⽂件添加到该⼯程中来c、⽣成回调函数源代码框架i、⽤户界⾯菜单:Code ——> Preference ——> Default Control Events弹出控件回调事件对话框,选择该控件所要响应的事件,点击OK键ii、右击需要产⽣回调函数的控件选择 Generate Control Callback。

LabwindowsCVI串口程序

LabwindowsCVI串口程序

Labwindows/CVI串口程序最近对自己这篇文章再次查看了一下,感觉写得比较粗略,因此在此对其进行一些修改和详细讲解下。

希望对大家有用!串口的相关函数:1、打开串口函数OpenComConfig,相关定义如下:int OpenComConfig (int portNumber, char deviceName[], long baudRate, int parity, int dataBits, int stopBits, int inputQueueSize, int outputQueueSize);int portNumber 需要开启的串口号char deviceName[] 将要打开的串口号的名称,比如串口号1,名称为”COM1”long baudRate 设置串口读数的速度,波特率:110, 150, 300, 600, 1,200, 2,400, 4,800, 9,600, 14,400, 19,200, 28,800, 38,400, 56,000, 57,600, 115,200, 128,000, and 256,000,默认值为9600。

int parity 选择串口的校验模式,Default Value: 0—no parityValid Values:0 = no parity,1 = odd parity,2 = even parity,3 = mark parity,4 = space parityint dataBits 数据位数Default Value: 7 data bitsValid Values: 5,6,7 or 8 data bitsint stopBits 停止位Default Value: 1 stop bit Valid Values: 1 or 2 stop bits int inputQueueSize 串口输入的数据量,一般选择的4,096int outputQueueSize 串口输出的数据量,一般选择的4,096函数的返回值来判定串口的状态。

LabWindowsCVI基础指导教程

LabWindowsCVI基础指导教程

LabWindows/CVI基础指导教程1. 简介LabWindows/CVI是一种基于C语言的集成开发环境(IDE),广泛应用于数据采集、实验控制和测试自动化等领域。

本教程旨在为初学者提供关于LabWindows/CVI的基础指导,包括环境安装、项目创建、界面设计和编程等方面的内容。

2. 环境安装在开始使用LabWindows/CVI之前,我们首先需要安装LabWindows/CVI的运行环境。

按照以下步骤进行安装:1.下载LabWindows/CVI安装程序,并运行安装程序。

2.在安装程序中选择安装路径,并点击“下一步”进行安装。

3.根据提示完成安装过程。

安装完成后,我们就可以开始创建LabWindows/CVI项目了。

3. 项目创建LabWindows/CVI使用项目(Project)的方式来组织和管理代码。

下面是创建新项目的步骤:1.打开LabWindows/CVI IDE。

2.点击“文件”菜单,并选择“新建项目”。

3.在弹出的对话框中选择项目类型和保存路径,然后点击“确定”。

4.在新建项目的基础上,可以添加文件、配置编译选项等。

4. 界面设计LabWindows/CVI提供了UI工具箱,可以通过拖拽控件来设计界面。

下面是界面设计的基本步骤:1.打开项目。

2.点击“窗体”菜单,并选择“添加窗体”。

3.在窗体设计器中,可以拖拽控件到窗体中,并调整位置和大小。

4.可以通过属性编辑器来设置控件的属性和事件。

界面设计完成后,我们可以进行程序的编程。

5. 编程LabWindows/CVI使用C语言进行编程。

下面是编程的基本步骤:1.打开窗体设计器,选择需要编写代码的控件。

2.双击控件,进入控件的事件处理函数。

3.在事件处理函数中编写代码,实现相应的功能。

4.可以使用LabWindows/CVI提供的函数库来完成各种操作,如数据采集、图形绘制等。

除了事件处理函数,我们还可以创建其他类型的函数来实现更复杂的功能。

LABWINDOWS安装和破解

LABWINDOWS安装和破解

LABWINDOWS/CVI9.0的安装和破解-lp一.安装前的准备1),安装LABWINDOWS/CVI9.0时,你需要以下三个文件:这三个文件的名字都相同,都是bWindows.CVI.FDS.v9.0.ISO-TBE,不同的就是后缀名,分别是”.bin”, “.cue”, “.nfo”文件。

2),虚拟光驱在安装之前,你需要一个名为DAEMON Tools Lite的软件。

值得庆幸的是,以上几个文件,你可以在我们的c服务器上下载。

二.开始安装1.使用虚拟光驱加载文件。

1)解压并安装DAEMON Tools Lite。

2)点击打开DAEMON Tools Lite,点击添加映像,在弹出的对话框中找到“bWindows. bin”文件,点击打开。

3)双击映像目录下的CVI图标,软件提示“正在载入映像”,等待一会。

4),打开“我的电脑”,打开“BD-ROM驱动器(I:)”双击“AutoRun.exe”.2.使用虚拟光驱安装接着上一步:1),点击“Install labwindows/CVI”, 安装CVI9.0 FDS,到需要注册号(Serial Number)时暂停。

2),打开“BD-ROM驱动器(I:)”, 点击“Crack”,打开“Keygen.exe”。

运行注册机,点击“Generate”得到系列号,点击“Copy”,粘贴到1)中的对话框中。

3),点击“Create licence file”,选取存放LIC文件的位置,生成LIC 文件(中文系统不要将文件放到桌面,因为路径不能用中文)。

4),点击Next继续安装。

安装完CVI后,关闭labwindows/CVI,运行开始菜单中的National Instruments –> NI License Manager,点击“选项”->“安装许可文件”,找到上一步生成的LIC文件,点击打开。

5),打开labwindows/CVI,如果没有弹出激活提示对话框,破解成功。

LabwindowsCVI学习技巧与资料

LabwindowsCVI学习技巧与资料

LabwindowsCVI学习技巧与资料测控软件一般包括:用户界面、程序控制、数据采集和数据分析4部分。

CVI文件一般包括:工程文件(Pr)、源文件(.C)、头文件(h)和用户界面文件(.uir).Labwindows技巧学习必看(摘录)CVICVI是基于ANSI C的快速开发环境,适用于有C,C++基础。

使用VB,VC,BC运用控件式组织用户界面的工程师Build--Target Type--Dynamic Link LibraryCVI 是事件驱动式的运行方法,排除响应各个事件,造成显示滞后。

需要强制在函数中加入“Process system event()CVI对多线程的支持(1)概念篇每个进程至少有一人上基本线程(主线程)线程与数据一起隔离在某一物理区域,在进程中声明的数据可通过该线程进行访问。

如何实现CVI窗体的全屏?GetMonitorFromPanel(Main,&montior);//获得显示器IDGetMonitorAttribute(monitor,ATTR_HEIGHT,&height);//得到高度GetMonitorAttribute(monitor,ATTR)WIDTH,&width);//得到宽度SetPanelSize(Main,height-25,width);//设置窗口高宽度(高度需要去除任务栏的部分)SetPanelPos(Main,25,0);//设置窗口位置如何在LABWINDOWS中调用MATLAB程序?CVI和Matlab混合编程,必须要行安装Matlab在CVI中,建立ActiveX控制服务器,选择MatlabAutomatin Server type Library(Matlab必须在CVI之前安装才能看到这个选项),创建后将生成三个文件,XXX.FPxxx.C和XXX.h,将.C和.H文件包含在CVI工程中就可以了。

.C文件中包含着CVI和 Matlab的接口函数。

LabWindowCVI安装方法

LabWindowCVI安装方法

LabWindows/CVI 2009你下载完成后,你看到的下载文件,如下图所示!需要解压缩这个文件,在该文件上点击右键,选择加“压缩到NILWCVI2009SP1”,这样你在你的电脑上多了一个叫“NILWCVI2009SP1”的文件夹!如下图所示打开“NILWCVI2009SP1”文件夹,选择文件夹下的setup.exe,双击打开该文件,这个时候会出现LabWindows的安装界面!如下图所示点击next按钮,进行下一步安装!这是会出现让你输入软件的序列号,这个没有怎么获取呢?如下图所示关于序列号的获取方法可以参看我的另外一篇经验文章!里面有详细的描述,这里就不在赘述了!文章链接为:/article/597035521808e98fc0074031.html根据上一步的操作获取到序列号之后,将序列号粘贴到对应的框中,点击next按钮,会出现亲切的选择安装路径的界面了!注意:这时候不要关闭序列号生成器,因为后边的激活操作还需要它生成Lic文件!一直点击next按钮,直到出现下图所示的界面,这个时候注意:你需要取消掉这个勾,取消更新检测!因为更新检测的时间挺长的,没有必要检测!!然后点击next按钮执行安装下一步,这个时候就可以真正的进行安装了,这时你会看到如下图的安装进度条,看到这个,说明你的软件正在安装过程中了,这个时候你可以去喝口茶,等安装完之后,只差最后的一步就可以完美激活你的软件了!O(∩_∩)O哈哈~END注意事项序列号生成之后,这时不要关闭序列号生成器,因为后边的激活操作还需要它生成Lic文件!如果你已经关闭了序列号生成器,那也不要紧,这时候你执行激活的时候,就要非常认真的看我写的经验了哦!要不接下来的激活会很费劲!LabWindows/CVI2009 激活1浏览:3842|3更新:2013-04-12 15:291),安装CVI_FDS_2009 ,到需要注册号时暂停。

2),运行注册机,选择“Full Development System”,点击“生成”得到系列号。

LABWINDOWS安装和破解

LABWINDOWS安装和破解

LABWINDOWS/CVI9.0的安装和破解-lp一.安装前的准备1),安装LABWINDOWS/CVI9.0时,你需要以下三个文件:这三个文件的名字都相同,都是bWindows.CVI.FDS.v9.0.ISO-TBE,不同的就是后缀名,分别是”.bin”, “.cue”, “.nfo”文件。

2),虚拟光驱在安装之前,你需要一个名为DAEMON Tools Lite的软件。

值得庆幸的是,以上几个文件,你可以在我们的c服务器上下载。

二.开始安装1.使用虚拟光驱加载文件。

1)解压并安装DAEMON Tools Lite。

2)点击打开DAEMON Tools Lite,点击添加映像,在弹出的对话框中找到“bWindows. bin”文件,点击打开。

3)双击映像目录下的CVI图标,软件提示“正在载入映像”,等待一会。

4),打开“我的电脑”,打开“BD-ROM驱动器(I:)”双击“AutoRun.exe”.2.使用虚拟光驱安装接着上一步:1),点击“Install labwindows/CVI”, 安装CVI9.0 FDS,到需要注册号(Serial Number)时暂停。

2),打开“BD-ROM驱动器(I:)”, 点击“Crack”,打开“Keygen.exe”。

运行注册机,点击“Generate”得到系列号,点击“Copy”,粘贴到1)中的对话框中。

3),点击“Create licence file”,选取存放LIC文件的位置,生成LIC 文件(中文系统不要将文件放到桌面,因为路径不能用中文)。

4),点击Next继续安装。

安装完CVI后,关闭labwindows/CVI,运行开始菜单中的National Instruments –> NI License Manager,点击“选项”->“安装许可文件”,找到上一步生成的LIC文件,点击打开。

5),打开labwindows/CVI,如果没有弹出激活提示对话框,破解成功。

LabWindows CVI Easy tab control使用教程

LabWindows CVI Easy tab  control使用教程

LabWindows/CVI中EasyTab Control的使用教程2016年12月4日,星期日狄阁老最近在使用国产板卡过程中发现,很多板卡的测试软件都用到了类似于tab的控件,但是子界面很多,又要团队完成的,如果还使用Tab控件就非常麻烦。

在CVI使用中,发现CANVAS 控件和easy tab.fp可以完成Tab控件的任务,下面开始介绍如何使用Easytab control先新建一个工程,再新建一个主界面和三个子界面,在主界面上添加一个CANVAS控件,再右下角load instruments,找到CVI安装目录下的Toolslib\custctrl下的easytab.fp,再在工程下添加这个fp。

首先介绍一下easytab.fp双击这个fp.可以看到这个fp内的函数,最重要的两个函数:1)EasyTab_ConvertFromCanvas (界面句柄, CANVAS的ID);2)EasyTab_LoadPanels (参数,参数,…..);EasyTab_ConvertFromCanvas函数简单,重点来说EasyTab_LoadPanels参数1:Panel 来自下面这行代码if ((panelHandle = LoadPanel (0, "EasyTabControlTest.uir", PANEL)) < 0) return -1;参数2:Tab Control 来自这行代码tabCtrl = EasyTab_ConvertFromCanvas (panelHandle, PANEL_CANVAS);参数3:Row该参数设置为1参数4:File Name指工程的.uir参数5:Calling Module Handle一般设置为常量:__CVIUserHInst参数6:Panel IDs and Handle Pointers该参数在要设置子界面的ID和句柄例如:三个界面EasyTab_LoadPanels (panelHandle, tabCtrl, 1, "EasyTabControlTest.uir", __CVIUserHInst,PANEL1, &panel1, PANEL2, &panel2, PANEL3, &panel3, 0);运行后的界面:代码如下:#include <formatio.h>#include "easytab.h"#include <cvirte.h>#include <userint.h>#include "EasyTabControlTest.h"static int panelHandle,tabCtrl,ActPan;int panel1,panel2,panel3,panel4;int main (int argc, char *argv[]){if (InitCVIRTE (0, argv, 0) == 0)return -1; /* out of memory */if ((panelHandle = LoadPanel (0, "EasyTabControlTest.uir", PANEL)) < 0)return -1;tabCtrl = EasyTab_ConvertFromCanvas (panelHandle, PANEL_CANVAS);EasyTab_LoadPanels (panelHandle, tabCtrl,1, "EasyTabControlTest.uir",__CVIUserHInst, PANEL1, &panel1, PANEL2, &panel2, PANEL3, &panel3, 0);EasyTab_SetAttribute (panelHandle, tabCtrl,ATTR_EASY_TAB_STRETCH_TO_FIT, 0);//InstallPopup(panelHandle);DisplayPanel (panelHandle);RunUserInterface ();DiscardPanel (panelHandle);return 0;}//退出事件int CVICALLBACK QuitCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){switch (event){case EVENT_COMMIT:QuitUserInterface (0);break;}return 0;}//切换TAB的事件int CVICALLBACK TabCtrlCallBack (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){char ActPanOut[100];switch (event){case EVENT_TAB_CHANGED:EasyTab_GetAttribute (panelHandle, tabCtrl ,ATTR_EASY_TAB_ACTIVE_PANEL, &ActPan);//EasyTab_GetAttribute (panelHandle, tabCtrl,ATTR_EASY_TAB_META_FONT, mm);Fmt (ActPanOut, "激活了第%d子界面", ActPan-1);SetCtrlVal (panelHandle, PANEL_STRING, ActPanOut);break;}return 0;}int CVICALLBACK AutosizeCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){int status;switch (event){case EVENT_COMMIT:status=EasyTab_AutoSize (panelHandle, tabCtrl);break;}return 0;}int CVICALLBACK AddPanelCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){switch (event){case EVENT_COMMIT://&panel4 = NewPanel (panelHandle, "xx", 0, 0, 350, 500);EasyTab_AddPanels (panelHandle, tabCtrl, 1,PANEL4,0,0);break;}return 0;}//移除tabint CVICALLBACK deltetCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)int panelRemove;switch (event){case EVENT_COMMIT:GetCtrlVal (panelHandle, PANEL_RING,&panelRemove ) ;switch (panelRemove){case 0:EasyTab_RemovePanel (panelHandle, tabCtrl, panel1);break;case 1:EasyTab_RemovePanel (panelHandle, tabCtrl, panel2);break;case 2:EasyTab_RemovePanel (panelHandle, tabCtrl, panel3);break;default:break;}break;}return 0;}int CVICALLBACK SetFontCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){char *new="";switch (event){case EVENT_COMMIT:CreateMetaFont (new, VAL_DIALOG_META_FONT, 16, 1, 0, 0, 0); EasyTab_SetAttribute(panelHandle, tabCtrl,ATTR_EASY_TAB_META_FONT, new);break;}return 0;}。

LabWindowsCVI实现无标题栏界面如何实现界面的移动

LabWindowsCVI实现无标题栏界面如何实现界面的移动

LabWindows/CVI实现
无标题栏界面如何实现界面的移动(1)首先需要在主界面添加一个函数,如图1所示,在Callback function 中加入主界面回调函数,命名为mainTableFunction,点击“ok”按钮确定设置。

图1 程序的主界面
(2)然后,在菜单中“code”——>Generate——>Panel Callback直接选择生成代码的目标文件“.c”,最后生成相应的主界面回调函数代码。

如图3所示。

图2 生成回调函数代码
图3 主界面回调函数代码
(3)第三步,在代码文件的开头,包含“windows.h”头文件,将需要的windows相关的函数引入,在引入的时候,需要注意将该头文件放在所有的头文件前面,否则会出现如图4所示错误信息。

图4 引用头文件不正确,导致错误
(4)补充关于鼠标左键移动界面的代码,在回调函数中加入以下代码,初始化变量:int hwnd;//窗口句柄
在switch中加入:
case EVENT_LEFT_CLICK: //长按鼠标左键,移动界面
GetPanelAttribute(panelHandle,ATTR_SYSTEM_WINDOW_HAN DLE,&hwnd); //获取窗口句柄
ReleaseCapture();//释放SendMessage(hwnd,WM_NCLBUTTONDOWN,HTCAPTION,0);
//发送系统消息
break;
(5)编译代码,最后可以实现鼠标左键移动界面的功能。

CVI入门教程

CVI入门教程

目录LabWindows/CVI入门培训教程 (2)1 LabWindows/CVI编程环境介绍 (2)LabWindows/CVI的开发窗口 (2)LabWindows/CVI的菜单与工具条 (6)函数面板与交互运行窗口 (7)LabWindows/CVI的调试工具 (16)2 LabWindows/CVI图形用户界面编辑 (22)2.1 LabWindows/CVI的图形用户界面的创建 (22)2.2 事件驱动与回调函数 (24)LabWindows/CVI的自动代码生成 (24)常用的GUI控件操作函数以及典型控件的使用 (24)3 基本的数据采集与仪器控制演示 (33)数据采集 (33)仪器控制 (39)LabWindows/CVI入门培训教程本课程要达到的目标:一、了解LabWindows/CVI编程环境的基本操作;二、可以编写简单的数据采集以及仪器控制程序。

本课程由以下三部分构成:一、LabWindows/CVI编程环境介绍;二、图形用户界面的编辑方法;三、基本的数据采集以及仪器控制演示。

1 LabWindows/CVI编程环境介绍LabWindows/CVI是一个ANSI C的集成开发环境。

它包含了32位的编译、链接器,以及先进的编辑与调试工具。

在这里,将简要介绍CVI的集成开发环境,包括它的开发窗口、菜单、工具栏、函数面板以及调试工具等。

1.1LabWindows/CVI的开发窗口工作区窗口在启动CVI并载入工程文件之后,可以看到类似图1的工作区窗口:图1. 工作区窗口工作区窗口包含了LabWindows/CVI开发环境的多个组件。

在工作区窗口的窗口限制区可以查看代码编辑窗口、用户界面编辑器以及函数树编辑器。

输出窗口区则包含了错误、调试以及结果窗口。

在工作区窗口,还可以看到项目结构树以及库函数结构树。

通过项目结构树可以访问工作区中每个项目中的文件。

通过库函数结构树可以访问LabWindows/CVI的库函数以及载入的设备驱动的函数面板。

LabWindowsCVI教程

LabWindowsCVI教程

LabWindowsCVI教程第⼀章 : LabWindows/CVI1.1 LabWindows/CVI1.1.1 LabWindows/CVI概述LabWindows/CVI是美国NI(National Instruments)公司开发的⾯向计算机测控领域的虚拟仪器软件开发平台,可以在多种操作系统(WindowsXP/Vista/7、Mac OS和Unix)下运⾏。

LabWindows/CVI 是为C 语⾔程序员提供的集成开发环境(IDE),在此开发环境中可以利⽤C语⾔及其提供的库函数来实现程序的设计、编辑、编译、链接、调试。

使⽤LabWindows/CVI 可以完成以下但不限于以下⼯作:·交互式的程序开发;·具有功能强⼤的函数库,⽤来创建数据采集和仪器控制的应⽤程序;·充分利⽤完备的软件⼯具进⾏数据采集、分析和显⽰;·利⽤向导开发IVI 仪器驱动程序和创建ActiveX 服务器;·为其它程序开发C ⽬标模块、动态连接库(DLL)、C 语⾔库。

图 1‐1 LabWindows/CVI界⾯LabWindows/CVI 的功能强⼤在于它提供了丰富的函数库。

利⽤这些库函数除可实现常规的程序设计外,还可实现更加复杂的数据采集和仪器控制系统的开发。

数据采集。

IVI库、GPIB/GPIB 488.2库、NI-DAQmx库、传统的NI-DAQ库、RS-232库、VISA库、VXI库以及NI-CAN库。

数据分析。

格式化IO库、分析库以及可选的⾼级分析库。

GUI库。

使⽤LabWindows/CVI 的⽤户界⾯编辑器可以创建并编辑图形⽤户界⾯(GUI),⽽使⽤LabWindows/CVI 的⽤户界⾯库函数可以在程序中创建并控制GUI。

此外,LabWindows/CVI为GUI ⾯板的设计,准备了许多专业控件,如:曲线图控件、带状图控件、表头、旋钮和指⽰灯等,以适应测控系统软件开发的需求,利⽤这些控件可以设计出专业的测控程序界⾯。

LabWindows CVI Easy tab control使用教程

LabWindows CVI Easy tab  control使用教程

LabWindows/CVI中EasyTab Control的使用教程2016年12月4日,星期日狄阁老最近在使用国产板卡过程中发现,很多板卡的测试软件都用到了类似于tab的控件,但是子界面很多,又要团队完成的,如果还使用Tab控件就非常麻烦。

在CVI使用中,发现CANVAS 控件和easy tab.fp可以完成Tab控件的任务,下面开始介绍如何使用Easytab control先新建一个工程,再新建一个主界面和三个子界面,在主界面上添加一个CANVAS控件,再右下角load instruments,找到CVI安装目录下的Toolslib\custctrl下的easytab.fp,再在工程下添加这个fp。

首先介绍一下easytab.fp双击这个fp.可以看到这个fp内的函数,最重要的两个函数:1)EasyTab_ConvertFromCanvas (界面句柄, CANVAS的ID);2)EasyTab_LoadPanels (参数,参数,…..);EasyTab_ConvertFromCanvas函数简单,重点来说EasyTab_LoadPanels参数1:Panel 来自下面这行代码if ((panelHandle = LoadPanel (0, "EasyTabControlTest.uir", PANEL)) < 0) return -1;参数2:Tab Control 来自这行代码tabCtrl = EasyTab_ConvertFromCanvas (panelHandle, PANEL_CANVAS);参数3:Row该参数设置为1参数4:File Name指工程的.uir参数5:Calling Module Handle一般设置为常量:__CVIUserHInst参数6:Panel IDs and Handle Pointers该参数在要设置子界面的ID和句柄例如:三个界面EasyTab_LoadPanels (panelHandle, tabCtrl, 1, "EasyTabControlTest.uir", __CVIUserHInst,PANEL1, &panel1, PANEL2, &panel2, PANEL3, &panel3, 0);运行后的界面:代码如下:#include <formatio.h>#include "easytab.h"#include <cvirte.h>#include <userint.h>#include "EasyTabControlTest.h"static int panelHandle,tabCtrl,ActPan;int panel1,panel2,panel3,panel4;int main (int argc, char *argv[]){if (InitCVIRTE (0, argv, 0) == 0)return -1; /* out of memory */if ((panelHandle = LoadPanel (0, "EasyTabControlTest.uir", PANEL)) < 0)return -1;tabCtrl = EasyTab_ConvertFromCanvas (panelHandle, PANEL_CANVAS);EasyTab_LoadPanels (panelHandle, tabCtrl,1, "EasyTabControlTest.uir",__CVIUserHInst, PANEL1, &panel1, PANEL2, &panel2, PANEL3, &panel3, 0);EasyTab_SetAttribute (panelHandle, tabCtrl,ATTR_EASY_TAB_STRETCH_TO_FIT, 0);//InstallPopup(panelHandle);DisplayPanel (panelHandle);RunUserInterface ();DiscardPanel (panelHandle);return 0;}//退出事件int CVICALLBACK QuitCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){switch (event){case EVENT_COMMIT:QuitUserInterface (0);break;}return 0;}//切换TAB的事件int CVICALLBACK TabCtrlCallBack (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){char ActPanOut[100];switch (event){case EVENT_TAB_CHANGED:EasyTab_GetAttribute (panelHandle, tabCtrl ,ATTR_EASY_TAB_ACTIVE_PANEL, &ActPan);//EasyTab_GetAttribute (panelHandle, tabCtrl,ATTR_EASY_TAB_META_FONT, mm);Fmt (ActPanOut, "激活了第%d子界面", ActPan-1);SetCtrlVal (panelHandle, PANEL_STRING, ActPanOut);break;}return 0;}int CVICALLBACK AutosizeCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){int status;switch (event){case EVENT_COMMIT:status=EasyTab_AutoSize (panelHandle, tabCtrl);break;}return 0;}int CVICALLBACK AddPanelCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){switch (event){case EVENT_COMMIT://&panel4 = NewPanel (panelHandle, "xx", 0, 0, 350, 500);EasyTab_AddPanels (panelHandle, tabCtrl, 1,PANEL4,0,0);break;}return 0;}//移除tabint CVICALLBACK deltetCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)int panelRemove;switch (event){case EVENT_COMMIT:GetCtrlVal (panelHandle, PANEL_RING,&panelRemove ) ;switch (panelRemove){case 0:EasyTab_RemovePanel (panelHandle, tabCtrl, panel1);break;case 1:EasyTab_RemovePanel (panelHandle, tabCtrl, panel2);break;case 2:EasyTab_RemovePanel (panelHandle, tabCtrl, panel3);break;default:break;}break;}return 0;}int CVICALLBACK SetFontCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){char *new="";switch (event){case EVENT_COMMIT:CreateMetaFont (new, VAL_DIALOG_META_FONT, 16, 1, 0, 0, 0); EasyTab_SetAttribute(panelHandle, tabCtrl,ATTR_EASY_TAB_META_FONT, new);break;}return 0;}。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
2012-4-27
14/18
LabWindows/CVI的函数库
2012-4-27
15/18
(4)交互式代码生成 C文件中生成程序结构:Main, Switch, If, For Loop… … UIR文件中生成代码框架: Main Function, Callback Functions (panel, control, menu) 函数面板中函数的自动插入 (5)程序的编译、生成、运行与调试 两种编译器模式:Borland C++, MS C++ 两种运行模式:release, debug Build目标文件类型:.exe, .dll, .lib 单步执行:Step Into, Step Over 断点设置:程序断点,手动断点和条件断点 变量监视
2012-4-27
8/18
工程窗口的菜单
2012-4-27
9/18
源代码窗口
2012-4-27
10/18
用户界面编辑窗口
2012-4-27
11/18
(2) 文件类型
.prj 工程文件 .cws 工程组文件 .exe 可执行文件 *_dbg.exe 调试状态执行文件 .c C源代码文件 .uir 用户界面资源文件 .h 用户界面资源头文件 .lib 外部静态库模块文件 .obj 目标文件 .h 外部模块头文件 .dll 动态链接库文件 .lib 动态链接库导入库文件 .fp 函数库(函数数和函数面板)文件
2012-4-27
3/18
2. LabWindows/CVI的历史
2012-4-27
4/18
3. LabWindows/CVI的特点
(1)针对测试测量领域的ANSI C语言开发环境
C compiler for Virtual Instruments (CVI)
(2)丰富的库函数,每个函数都提供函数面板 (3)专业化的图形界面设计控件 (4)交互式编程环境,丰富的调试手段
变量命名 程序的格式和注释 复杂的程序要事先规划设计
2012-4-27
6/18
4. 程序结构
测控软件一般包括:用户界面、程序控制、数 据采集和数据分析4部分
2012-4-27
7/18
5. 开发环境
(1)主要窗口
LabWindows/CVI开发环境的三个主要窗口是工程窗口 (.prj)、源代码窗口(.c)和用户界面编辑器窗口(.uir)。 工程窗口
2012-4-27
12/18
(3) 函数面板(function panel)
2012-4-27
13/18
四个用途: 函数面板里的在线帮助提供对函数的作用和 调用参数的解释说明; 函数面板能自动声明,并自动将函数参数的 变量添加到源程序代码中; 函数面板能在加入程序之前交互执行,从而 可以对参数值作试验直到满意为止; 函数面板自动生成代码,将函数调用语句自 动插入程序源代码中。
2/18
2012-4-27
第二讲 LabWindows/CVI的开发环境
1. 虚拟仪器软件的重要性
软件成为了虚拟仪器的核心 虚拟仪器和自动测试系统都需要进行软件设 计 要求有高效、便捷、专业的软件开发环境 几种软件开发环境的比较
VC++, VB, Delphi, Borland C++ Builder LabVIEW, VEE LabWindows/CVI
2012-4-27
5/18
学习LabWindows/CVI的几点建议
1. 2. 3. 4. 5. 6. 7. 要有良好的C语言基础 多上机实验 充分利用LabWindows/CVI的函数库 通过例子学习(…CVI\Samples\… …) 有明确的应用背景 程序要进行严格的调试 养成良好的编程习惯
2012-4-27
16/18
(6)其它工具 安装盘制作:采用Microsoft安装盘技术,生 成Windows风格的安装盘; 自动生成帮助文件:函数面板和函数树的帮 助信息可以自动生成帮助文件; IVI仪器驱动程序开发向导; ActiveX服务器开发向导;
2012-4-27
17/18
6. 编程步骤
(1)建立图形用户界面 (2)自动生成程序代码框架 (3)添写功能函数,完成代码 (4)运行和调试
2012-4-27
18/18
自动化4. 5. 6. 7. 8. 9. 10. LabWindows/CVI的编程环境 图形用户界面设计 用户事件处理 信号的产生、分析和处理 数据格式化、文件读取和I/O端口操作 串行口通讯和网络数据传输 动态链接库和Windows SDK 多线程程序设计 数据库应用程序设计 仪器驱动程序设计
LabWindows/CVI教程 LabWindows/CVI教程(1) 教程(1)
集成开发环境(IDE) 集成开发环境(IDE)
乔立岩
/531net/instrument Email: qiaoliyan@ MSN: qiaoliyan@ Tel: 86413532/33 ext. 526 Office: 科学园2A栋526 科学园2A栋
相关文档
最新文档