第10章_LabVIEW常用工具包

合集下载

LabVIEW常用工具包(PPT 61页)

LabVIEW常用工具包(PPT 61页)

LabVIEW数据库连接 工具包
9
报表生成例程
10
报表生成例程
该例程遵循“打开→操作→保存→关闭”的文件编程模式。首先使用新建报 表.vi建立Excel报表;后使用Excel Easy Title.vi设置报表标题为“IEI测试 报告”,同时将标题字体设置为“微软雅黑”,字号设置为24号;接下来使用 Excel Easy Text.vi插入报告概述,同时将报告概述的字体设置为“宋体”, 字号设置为12号;下一步使用Excel Easy Table.vi将表格插入到Excel报表中, 字体和字号依前设置;接下来使用Excel Easy Graph.vi将波形图插入到Excel 报表中;最后设置好报表的保存路径,保存完毕后使用处置报表.vi关闭报表, 释放资源。
11
LabVIEW数据库连接 工著名具的包商业用数据库管理系统有MS
SQL Server、Orace、DB2、Visual Foxpro、Microsoft Access等等。 另外,开源的数据库管理系统有 MySQL、Apache Derby、PostgreSQL、 Ingres等等。MS SQL Server是 Microsoft公司开发的商用数据库管 理系统,在工业测试应用中非常流 行,安装和使用都非常方便,并且 支持SQL语言,所以本节基于MS SQL 12
(5) 使用处置报表.vi关闭报表文件,释放资源。
7
基于模板的报表生成方 式
1.建立模板
(1) 打开Microsoft Excel程序, 新建空白工作簿;
(2) 将 A1 单 元 格 的 名 称 改 为 “ReportTitle”;
(3) 将 A2 单 元 格 的 名 称 改 为 “ReportTime”;

Labview所有的模块和工具包

Labview所有的模块和工具包

Labview所有的模块和⼯具包NI LabVIEW Product FamilyThe NI LabVIEW product family consists of the LabVIEW development environment and add-on software tools that extend LabVIEW graphical programming for specific applications. Learn more about the LabVIEW product family or download fully-functional trials of more than 25 LabVIEW modules and toolkits.LabVIEW Core Development SystemLabVIEW is an award-winning development environment optimizedfor engineers and scientists creating test, measurement, and control applications. With LabVIEW, you can quickly and easily acquire real-world signals, perform analysis on your data, and store results in a variety of ways. Learn More | Try LabVIEW Now Add-On Modules and ToolkitsView more resources on virtually every product in the LabVIEW family or evaluate software immediately by downloading a fully-functional 30-day trial. Embedded DesignUse LabVIEW to design, prototype, and deploy embedded applications to a variety of processing targets, including off-the-shelf real-time and FPGA-based systems as well as custom microprocessor and microcontroller devices. NI Modules and Toolkits for Embedded Design:LabVIEW Real-Time Module NI Real-Time Execution Trace ToolkitLabVIEW FPGA ModuleLabVIEW Microprocessor SDKLabVIEW Statechart ModuleLabVIEW Mobile Module ? LabVIEW DSP ModuleLabVIEW Embedded Modulefor ARM MicrocontrollersLearn More | Evaluate NowControl Design and SimulationCombine algorithm development, analysis, and visualization in LabVIEW with tools for system identification, control design, simulation, and implementation.NI Modules and Toolkits for Control Design and Simulation:LabVIEW Control Design and Simulation ModuleLabVIEW PID and Fuzzy Logic ToolkitLabVIEW Real-Time ModuleReal-Time Execution Trace Toolkit LabVIEW FPGA ModuleLabVIEW Statechart ModuleLabVIEW Simulation Interface ToolkitLabVIEW System Identification ToolkitLearn More | Evaluate NowImage and Signal ProcessingIncorporate hundreds of application-specific image and signal processing functions into your LabVIEW applications.NI Modules and Toolkits for Image and Signal Processing:Vision Development Module for LabVIEWLabVIEW MathScript RT ModuleLabVIEW Advanced Signal Processing ToolkitLabVIEW Digital Filter Design ToolkitLabVIEW Adaptive Filter Toolkit Sound and Vibration Measurement SuiteSound and Vibration ToolkitSpectral Measurements Toolkit Modulation Toolkit for LabVIEWVision Builder for Automated InspectionLabVIEW Math Interface ToolkitLearn More | Evaluate NowIndustrial Monitoring and ControlDeploy LabVIEW to networked programmable automation controllers (PACs) to create reliable distributed monitoring and control systems, and connect to your existing programmable logic controllers (PLCs) and enterprise systems.NI Modules and Toolkits for Industrial Monitoring and Control:LabVIEW Real-Time ModuleReal-Time Execution Trace ToolkitLabVIEW FPGA ModuleLabVIEW Datalogging and Supervisory Control ModuleLabVIEW Wireless Sensor Network Module Pioneer LabVIEW Touch Panel Module LabVIEW Statechart ModuleNI Motion AssistantLabVIEW NI SoftMotion ModuleLearn More | Evaluate NowSoftware Development and DeploymentDevelop and deploy professional, higher-quality LabVIEW applications using a variety of software engineering tools.NI Modules and Toolkits for Software Development and Deployment:LabVIEW Application Builder for WindowsLabVIEW VI Analyzer Toolkit LabVIEW Statechart ModuleLabVIEW Desktop Execution Trace Toolkit LabVIEW Remote PanelsNI Requirements GatewayLabVIEW Unit Test Framework ToolkitLearn MoreReport Generation and Data StorageNI Modules and Toolkits for Report Generation and Data Storage: ?LabVIEW SignalExpress LabVIEW Report Generation Toolkit for Microsoft Office LabVIEW Database Connectivity Toolkit LabVIEW DataFinder ToolkitLabVIEW Internet Toolkit。

国家仪器(National Instruments)LabVIEW DSP测试集成工具包(LabVI

国家仪器(National Instruments)LabVIEW DSP测试集成工具包(LabVI

LabVIEW™, National Instruments™, ™, and NI™ are trademarks of National Instruments Corporation. Product and company names mentioned herein are trademarks or trade names of their respective companies. For patents covering National Instruments products, refer to the appropriate location: Help»Patents in your software, the patents.txt file on your CD, or /patents.September 2003323452B-01LabVIEW DSP Test Integration Toolkit for TI DSPThe LabVIEW DSP Test Integration Toolkit for TI DSP gives you theability to use LabVIEW and the TI Code Composer Studio™ (CCS)Integrated Development Environment (IDE) to create test systems for DSPtarget code.The LabVIEW DSP Test Integration Toolkit includes VIs to automateCCS IDE and VIs that use the TI Real-Time Data Exchange™ (RTDX™)software technology to communicate with TI DSP development boards thatsupport RTDX. Use the toolkit automation VIs to work with CCS IDEproject (.pjt) files programmatically. Use the toolkit RTDXcommunication VIs and the toolkit memory VIs to programmaticallyexchange data with target code. The LabVIEW DSP Test IntegrationToolkit also includes the LabVIEW Debugging Workbench for RTDX™Communication, which you can use to interact with RTDX channels ondevelopment boards that support RTDX.Refer to the LabVIEW DSP Test Integration Toolkit Help by selectingHelp»LabVIEW DSP Test Integration Toolkit Help for referenceinformation about the DSP Test Integration VIs.ContentsInstallation (2)Automating CCS IDE Functions (3)Exchanging Data with DSP Target Code (3)Writing and Reading Data from DSP Memory (4)Working with Target Code Data in LabVIEW (5)Using DSP Test Integration Advanced VIs (5)™© 2002–2003 National Instruments Corp. All rights reserved.InstallationComplete the following steps to install the LabVIEW DSP Test IntegrationToolkit for TI DSP.1.Verify the following components are installed before continuing withinstallation:7.0•LabVIEW•CCS IDE 2.2 or later•TI DSP development platform that you can configure with CCS.The C2000™ DSP platform is compatible only with the toolkitautomation VIs.Refer to the development board documentation for information aboutinstalling and configuring the development board.(Windows 2000/NT/XP) Log in as an administrator or as a user withadministrator privileges before you install the LabVIEW DSP TestIntegration Toolkit.2.Insert the LabVIEW DSP Test Integration Toolkit CD into theCD-ROM drive. The LabVIEW DSP Test Integration Toolkitinstallation program runs automatically.where x is the letter of the CD-ROM drive, and click the OK button.3.Follow the instructions that appear on the screen.The LabVIEW Debugging Workbench for RTDX™ Communicationinstalls with the LabVIEW DSP Test Integration Toolkit. Use theLabVIEW Debugging Workbench for RTDX™ Communication to quicklyinteract with target code RTDX channels using LabVIEW controls andindicators. Select Tools»RTDX»LabVIEW Debugging Workbenchfor RTDX Communication from CCS or select Programs»NationalInstruments»LabVIEW Debugging Workbench for RTDXCommunication from the Windows Start menu to launch the LabVIEWDebugging Workbench.LabVIEW DSP Test Integration Toolkit for TI Automating CCS IDE FunctionsUse the LabVIEW DSP Test Integration Toolkit VIs to control theCCS IDE and project files. You can launch CCS IDE, open a .pjt file,build the .pjt file, and download the resulting .out file to a developmentboard from a LabVIEW VI to automate CCS IDE functionality.The block diagram in Figure1 shows how you can automate the processof compiling DSP target code and embedding the code on a developmentboard. Wire the .pjt file path to the CCS Open Project VI to open the.pjt file in CCS IDE. The CCS Build VI builds the .pjt file to create theDSP target code .out file. The CCS Download Code VI downloads the.out file to the development board. The CCS Run VI runs the embedded.out file on the development board. You then can use the toolkit RTDXcommunication and the toolkit memory VIs to access data from the targetcode.Figure 1. LabVIEW Automation of CCS IDEThe CCS Halt VI and CCS Close Project VI stop the .out file running onthe development board and close the project in CCS IDE. Exchanging Data with DSP Target CodeAfter you create DSP target code in the CCS IDE and embed the .out fileon a development board, you can create LabVIEW VIs to test the targetcode. You can transfer simulation data to the DSP target code from a VI andanalyze output data from the target code on the development board.Use the RTDX communication VIs to send data to DSP target code RTDXinput channels and to receive data from RTDX output channels. RTDXallows system developers to transfer data between LabVIEW and the targetprocessor without interfering with target code execution. The data inputscan be any test values you want to pass to the target code with eachiteration, and the data outputs can be any values you want to retrieve foranalysis from the target code after each iteration.© National Instruments Corporation3LabVIEW DSP Test Integration Toolkit for TI DSPThe block diagram in Figure2 shows how to send data to and receive datafrom RTDX channels of DSP target code running on a development board.While running, the DSP target code for the example expects sine wave data.The Simulate Signal VI creates a test sine wave. The CCS RTDX Write VIwrites the test sine wave to the WaveIn RTDX channel of the DSP targetcode. The DSP target code uses the test sine wave data it receives from theWaveIn RTDX channel.The CCS RTDX Read VI reads waveform data from the WaveOut RTDXchannel of the DSP target code. This example VI displays the waveformdata on a waveform graph.Figure 2. RTDX Communication with DSP Target Code Writing and Reading Data from DSP MemoryYou can access data from the memory of target processors. The memoryVIs communicate with the development board slower than the RTDXcommunication VIs, but you can use them to perform simple codemonitoring and control.The following target code runs on the target processor and executes a loopthat increases the value of the counter symbol until the run_flag symbolequals 0.volatile Int16 run_flag = 1;Int16 counter = 0;void main(){while( run_flag ) {// loop executes until run_flag equals zero.// counter increases during each iteration.counter++;}}LabVIEW DSP Test Integration Toolkit for TI © National Instruments Corporation 5LabVIEW DSP Test Integration Toolkit for TI DSPIn Figure 3, the CCS Symbol to Memory Address VI returns the memory address of the counter symbol and passes the memory address to the CCS Memory Read VI. The CCS Memory Read VI reads the value of memory at the memory address and this example VI displays the value of the counter symbol on the front panel.Figure 3. Reading Data Values from MemoryYou can control the target code by changing the value of target codesymbols. In Figure 4, the CCS Symbol to Memory Address VI passes the current memory address of the run_flag symbol to the CCS Memory Write VI. The CCS Memory Write VI changes the value of run_flag to 0,stopping the target code loop.Figure 4. Writing Data Values to MemoryWorking with Target Code Data in LabVIEWYou can analyze, manipulate, and present test data the DSP target code returns. For example, on the block diagram in Figure 2, the DSP target code returns waveform test data to analyze in LabVIEW. A waveform graph displays the waveform data. Refer to the LabVIEW User Manual for information about the measurement, analysis, and presentation features of LabVIEW.Using DSP Test Integration Advanced VIsDenoted by a blue background, the DSP Test Advanced VIs handlelow-level CCS IDE and RTDX functionality, such as launching CCS IDE and enabling or disabling RTDX communication. Use the DSP Test Integration Advanced VIs when you want more control over CCS IDE andRTDX functionality.Use the LabVIEW ActiveX Property and Invoke nodes to control theCCS IDE functionality using the DSP Test Integration Advanced VIs.Refer to the the LabVIEW User Manual for information about using Invokeand Property nodes.LabVIEW DSP Test Integration Toolkit for TI 。

LabVIEW 多核分析和稀疏矩阵工具包介绍

LabVIEW 多核分析和稀疏矩阵工具包介绍

LabVIEW多核分析和稀疏矩阵工具包介绍发布日期: 七月18, 2013 | 0 评级| 0.00 out of 5 |Read in English| PDF概览NI LabVIEW多核分析和稀疏矩阵工具包提供了高性能的LabVIEW多线程分析库,是在线或离线的大数据集处理应用的理想工具。

实际上,许多现实世界的问题可以表示为大型线性代数计算,而该工具包可以为这些运算减少所需的资源和总体的计算时间。

此外,该工具包包括稀疏线性代数函数,并支持单精度和双精度数据类型。

本文介绍了LabVIEW多核分析和稀疏矩阵工具包的用途和推荐用法。

目录1. 高性能多线程分析如前所述,NI LabVIEW多核分析和稀疏矩阵工具包提供了一系列高性能、多线程分析库,可以用来处理大型数据集。

这些库是专为基于英特尔®数学内核函数库(Intel® MKL)的Windows 操作系统而设计的。

该内核库是一个高度优化、多线程化的数学计算函数库,满足最高性能需求的应用。

此外,当您将这个工具包与LabVIEW实时模块一同使用时,这些库可以被扩展到LabVIEW实时(ETS)的目标中。

因此,用户能够使用多线程线性代数、基本线性代数子程序(BLAS)和基于快速傅立叶变换(FFT)的函数。

图1.多核分析和稀疏矩阵函数选板包含高性能、多线程分析以及稀疏矩阵代数函数。

该工具包提供了各种函数库,每个函数可以更好地利用多核CPU。

而且它还包含一组线程管理函数,因此用户可以调整应用程序的线程行为特性。

图2.线程管理函数选板包含有效管理线程的函数。

至页首2. 管理线程本节以两个矩阵相乘为例来介绍管理线程的方法。

管理线程时,首要考虑的是执行函数的系统中可用的内核数。

要获得目标系统的CPU特性,可以使用 CPU Information 函数。

此外,线程管理函数选板中的 Get Threads 函数可以在之后立即添加以获取可用线程的最大数量。

LabVIEW模块和工具包(图像和信号处理)

LabVIEW模块和工具包(图像和信号处理)

欢迎下载LabVIEW模块和工具包(图像和信号处理)
将数百种特定应用程序的图像和信号处理函数集成到NI LabVIEW应用程序中。

可将NI LabVIEW扩展至特定的应用,如:声音和振动测量、机器视觉、RF通信、瞬时与短时信号分析等。

NI LabVIEW模块和工具包, 用于图像和信号处理:
∙NI LabVIEW高级信号处理工具包
∙数字滤波器设计工具包
∙自适应滤波器工具包(Adaptive Filter Toolkit)
∙MathScript RT工具包
∙NI声音与振动测量套件
∙NI自动检测视觉生成器
∙NI视觉开发模块
报告生成工具包:
∙用于Microsoft Office的报告生成工具包(56 MB)
数据库和外部连接工具包:
∙数据库连接工具包(55 MB)
∙因特网工具包(58 MB)
数据存储和管理工具包:
∙DataFinder工具包(118MB)
∙NI实时执行追踪工具包(131MB)
其它相关模块工具包:
∙NI LabVIEW SignalExpress (779 MB)
更多LabVIEW相关资料
∙更多LabVIEW 模块产品
∙在线研讨会: LabVIEW 2011新特性
∙NI LabVIEW 中文主页
∙LabVIEW 视频教学中心
∙LabVIEW 中文资源库
联系NI
如有任何问题,请与NI上海市场部联系。

免费咨询电话800 820-3622,或021-5050 9800,或Email至@。

第10章LabVIEW常用工具包

第10章LabVIEW常用工具包

17
LabVIEW数据库基本操作
数据库操作遵循“打开数据库→操作数据库→关闭数据库” 的基本流程。其中,使用DB Tools Open Connection.vi 来打开数据库连接,使用DB Tools Close Connection.vi 关闭数据库连接。在“操作数据库”步骤中可以对数据库 进行所需的操作。
14
使用DSN连接数据库
LabVIEW 数 据 库 连 接 工 具 包 基 于 ODBC ( Open Database Connectivity ) 技 术。在使用该工具包的时候,需要提 供数据源名DSN(Data Source Names) 才能连接到数据库,所以需要先创建 DSN 。 在 Windows 控 制 面 板 → 管 理 工 具 →数据源(ODBC)中打开数据源管理 器,在“用户DSN”选项卡中单击“添 加”按钮,选择“SQL Server”驱动, 输入用户名和密码后,点击“测试数 据源”,如果配置正确的话,就会弹 出“测试成功的提示”,本例中的DSN 配置如图所示。完成以上步骤后,就 可 以 在 “用 户 DSN” 中看到新建立的 DSN了。
(4) 将 该 工 作 簿 保 存 为 Excel972003模版的格式保存。本例中命 名为Excel template.xlt保存在C 盘根目录下。

8
基于模板的报表生成方式
2.使用交互式VI编程
MS Office Report.vi就会自动 添加两个变体数据类型的输入端, 名字分别为“ReportTitle”和 “ReportTime”,即为创建 Excel模版时定义好的名字。之 后可以通过分别为这两个输入端 赋值来生成所需要的报表。

15
使用udl文件连接数据库

LabVIEW入门指南从零开始学习电气工程师的必备工具

LabVIEW入门指南从零开始学习电气工程师的必备工具

LabVIEW入门指南从零开始学习电气工程师的必备工具LabVIEW入门指南LabVIEW(Laboratory Virtual Instrument Engineering Workbench)是一款由美国国家仪器公司(National Instruments)开发的图形化编程环境和开发平台。

它被广泛应用于电气工程领域,为电气工程师提供了一个强大而易于使用的工具。

本文将以LabVIEW入门为主题,从零开始指导电气工程师学习LabVIEW,帮助他们更好地掌握这一必备工具。

一、LabVIEW的基本概念和特点1.1 什么是LabVIEWLabVIEW是一款基于图形化编程的软件工具,用户可以通过拖拽和连接图形元件来进行程序设计。

与传统的文本式编程语言相比,LabVIEW的图形化编程方式更加直观和易于理解,使得用户能够更快速地开发和调试程序。

1.2 LabVIEW的特点LabVIEW具有以下几个特点:(1)图形化编程:通过将各种功能模块以图形元件的方式组合起来,用户可以直观地表示程序的逻辑和功能。

(2)虚拟仪器:LabVIEW提供了大量的仪器模块和工具箱,可以方便地模拟各种实际仪器,如示波器、函数发生器等。

(3)数据流编程:LabVIEW采用数据流的方式进行编程,即当数据准备好时,相应的程序模块才会执行,这种方式减少了程序的冗余和资源的浪费。

二、LabVIEW的安装和基本操作2.1 安装LabVIEW首先,您需要从美国国家仪器公司的官方网站下载LabVIEW的安装包。

安装过程相对简单,按照提示一步步进行即可。

2.2 LabVIEW界面概述打开LabVIEW后,您将看到一个由工具栏、面板、功能栏等组成的界面。

工具栏提供了常用操作的快捷方式,面板用于显示程序的输入和输出,功能栏包含了各种功能模块和工具。

2.3 创建一个简单的LabVIEW程序接下来,我们将创建一个简单的LabVIEW程序,以帮助您初步了解LabVIEW的基本操作。

第10章 LabVIEW常用工具包

第10章 LabVIEW常用工具包


15
使用udl文件连接数据库
Microsoft 公司设计的 ODBC 标准只能访问 关系型数据库,对非关系型数据库则无能 为力。为了解决这个问题, Microsoft 公 司另外提供了一种技术: Active数据对象 ADO ( Active Data Objects )技术。 ADO 使用通用数据连接 UDL ( Universal Data Link)来获得数据库信息以实线数据库连 接。 udl 文件的创建方法非常简单,可以 在任意文件夹下建立一个文本文件,然后 将其后缀名改为 udl 即可,本例中将此文 件命名为 IEI_Measurements.udl ,双击打 开 udl 文件进行配置,在“提供程序”选 项 卡 中 选 择 “ Microsfot OLE DB Provider for SQL Server ” , 然 后 在 “连接”选项卡中设置好数据库服务器的 相关信息,点击“测试连接”按钮,如果 配置没有问题,则会提示“测试连接成 功”,至此udl文件配置完成。

6
Word报表生成
Word报表的生成方式和Excel报表类似。该例程的编写步骤如下: (1) 使用新建报表 .vi 进行报表建立,报表类型选择为“Word ”,同时为了使程序运行时不会弹出 Excel软件窗口,窗口状态选项要选择为“minimized”; (2) 放入Word Easy Title.vi,该VI可以在Word Specific目录下找到,使用本VI可以给给当前Word 报表设置标题。在本例中,将报表标题设置为“IEI系统测试报告”,另外,使用本VI还可以设 置标题的字体等等; (3) 放入Word Easy Text.vi,该VI可以在Word Specific目录下找到,使用本VI即可以将所需内容 添加至Word报表中。在本例中,需要将报表日期插入当前报表,则需要将报表日期字符串连接 至“text”端。另外,使用本VI还可以设置报表的字体、背景颜色以及对齐方式等等; (4) 使用报表保存至文件.vi将报表保存为.doc格式。本例中将报表命名为 IEI Report.doc保存在C 盘根目录下; (5) 使用处置报表.vi关闭报表文件,释放资源。
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。


18
创建数据表
创建数据表是由LabVIEW数据库连接工具包中的DB Tools Create Table.vi来实现的。 首先使用DB Tools Open Connection.vi来打开数据库连接,连接文件使用前面创建的 IEI_Measurements.udl 文件;之后使用 DB Tools Create Table.vi来建立新的数据表 格,表格的名称设定为“ Device ”,其中包含 4 个字段,分别为“ DeviceName ”、 “DeviceType”、“DeviceID”和“Company”。
(4) 将 该 工 作 簿 保 存 为 Excel972003 模版的格式保存。本例中命 名为Excel template.xlt保存在C 盘根目录下。

8
基于模板的报表生成方式
2.使用交互式VI编程 MS Office Report.vi就会自动 添加两个变体数据类型的输入端, 名字分别为“ReportTitle”和 “ReportTime”,即为创建 Excel模版时定义好的名字。之 后可以通过分别为这两个输入端 赋值来生成所需要的报表。

3
LabVIEW Office报表生成工具包
函数→编程→报表生成
基础性的报 表生成VI 插入VI说明信 息及打印相关 VI
基于模板的 报表生成VI
WORD与 EXCEL相关 操作VI
4

EXCEL报表生成
要准确迅速的进行报表生 成工作需要进行两个主要 两个步骤“Where” 和”What”,即告诉报表 生成工具包,在Office文 档的“哪个位置”,放置 上“什么内容”。
17
LabVIEW数据库基本操作
数据库操作遵循“打开数据库→操作数据库→关闭数据库” 的基本流程。其中,使用 DB Tools Open Connection.vi 来打开数据库连接,使用DB Tools Close Connection.vi 关闭数据库连接。在“操作数据库”步骤中可以对数据库 进行所需的操作。

6
Word报表生成
Word报表的生成方式和Excel报表类似。该例程的编写步骤如下: (1) 使用新建报表 .vi 进行报表建立,报表类型选择为“Word ”,同时为了使程序运行时不会弹出 Excel软件窗口,窗口状态选项要选择为“minimized”; (2) 放入Word Easy Title.vi,该VI可以在Word Specific目录下找到,使用本VI可以给给当前Word 报表设置标题。在本例中,将报表标题设置为“IEI系统测试报告”,另外,使用本VI还可以设 置标题的字体等等; (3) 放入Word Easy Text.vi,该VI可以在Word Specific目录下找到,使用本VI即可以将所需内容 添加至Word报表中。在本例中,需要将报表日期插入当前报表,则需要将报表日期字符串连接 至“text”端。另外,使用本VI还可以设置报表的字体、背景颜色以及对齐方式等等; (4) 使用报表保存至文件.vi将报表保存为.doc格式。本例中将报表命名为 IEI Report.doc保存在C 盘根目录下; (5) 使用处置报表.vi关闭报表文件,释放资源。
20

添加数据记录
添加数据记录可以由 LabVIEW 数据库连接工具包中的 DB Tools Insert Data.vi 实现。 DB Tools Insert Data.vi 需要3个主要的参数:“table”参数确定将要插入的表格 名称;“data”参数确定将要插入的数据;“columns” 参 数 对 应 插 入 列 的 名 称 , 可 以 先 使 用 DB Tools List Columns.vi列出表格中列的名称,可以省去手动输入列名 的麻烦,以方便下一步的数据插入。

19
删除数据表
删除数据表格的过程与创建表格的过程类似,使用 DB Tools Drop Table.vi 实现。假设要删除前面建立好的表 格,只需要在DB Tools Drop Table.vi中指明要删除的表 格名称即可。另外,创建表格和删除表格的参数非常类似, 在实际工程应用中,一般将二者编写为同一个VI,在其中 实现表格的创建和删除操作。

13
LabVIEW数据库连接工具包

在使用LabVIEW数据库连接工具包操作数据 库之前,需要先连接数据库,这就像操作 文件之前,先要打开文件一样。连接数据 库主要有以下两种方式,分别为使用DSN连 接数据库和使用udl文件连接数据库。

14
使用DSN连接数据库
LabVIEW 数 据 库 连 接 工 具 包 基 于 ODBC ( Open Database Connectivity ) 技 术。在使用该工具包的时候,需要提 供数据源名 DSN ( Data Source Names ) 才能连接到数据库,所以需要先创建 DSN 。在 Windows 控制面板→管理工具 →数据源( ODBC )中打开数据源管理 器,在“用户DSN”选项卡中单击“添 加”按钮,选择“ SQL Server ”驱动, 输入用户名和密码后,点击“测试数 据源”,如果配置正确的话,就会弹 出“测试成功的提示”,本例中的DSN 配置如图所示。完成以上步骤后,就 可 以 在 “用 户 DSN ” 中看到新建立的 DSN了。

9
报表生成例程

10
报表生成例程
该例程遵循“打开→操作→保存→关闭”的文件编程模式。首先使用新建报 表.vi建立Excel报表;后使用Excel Easy Title.vi设置报表标题为“IEI测 试报告”,同时将标题字体设置为“微软雅黑”,字号设置为24号;接下来 使用Excel Easy Text.vi插入报告概述,同时将报告概述的字体设置为“宋 体”,字号设置为 12 号;下一步使用 Excel Easy Table.vi 将表格插入到 Excel报表中,字体和字号依前设置;接下来使用 Excel Easy Graph.vi将波 形图插入到Excel报表中;最后设置好报表的保存路径,保存完毕后使用处置 报表.vi关闭报表,释放资源。
2

LabVIEW常用工具包简介
工具包:具有专用功能的LabVIEW插件
NI官方工具包:
• • • • • •
LabVIEW OFFICE报表生成工具包 LabVIEW 数据库连接工具包 „„
第三方工具包:
VI Package Manager MGI工具包 „„

5
EXCEL报表生成
该例程的编写步骤如下: (1) 使用新建报表.vi进行报表建立,报表类型选择为“Excel”,同时为了使程 序运行时不会弹出Excel软件窗口,窗口状态选项要选择为“minimized”; (2) 放入Excel Easy Title.vi,该VI可以在Excel Specific目录下找到,使用本 VI可以给当前报表设置标题。在本例中,将报表标题设置为“IEI系统测试报告”, 标题位置为A1单元格,则需要设定“name”值为“A1”,“title”值为“IEI系统 测试报告”。另外,使用本VI还可以设置标题的字体等等; (3) 放入Excel Easy Text.vi,该 VI 可以在 Excel Specific 目录下找到,使用本 VI即可以告诉报表工具包在Excel的哪个位置放置上什么内容。在本例中,假设要在 Excel 文件的 A2 单元格内放入“报告时间”这个字符串,则需要设定“ name ”值为 “A2”,“text”值为“报告时间”。另外,使用本VI还可以设置报表的字体以及 边框等等; (4) 使用报表保存至文件 .vi 将报表保存为 .xls 格式。本例中将报表命名为 IEI Report.xls保存在C盘根目录下; (5) 使用处置报表.VI关闭报表文件,释放资源。

15
使用udl文件连接数据库
Microsoft 公司设计的 ODBC 标准只能访问 关系型数据库,对非关系型数据库则无能 为力。为了解决这个问题, Microsoft 公 司另外提供了一种技术: Active数据对象 ADO ( Active Data Objects )技术。 ADO 使用通用数据连接 UDL ( Universal Data Link)来获得数据库信息以实线数据库连 接。 udl 文件的创建方法非常简单,可以 在任意文件夹下建立一个文本文件,然后 将其后缀名改为 udl 即可,本例中将此文 件命名为 IEI_Measurements.udl ,双击打 开 udl 文件进行配置,在“提供程序”选 项 卡 中 选 择 “ Microsfot OLE DB Provider for SQL Server ” , 然 后 在 “连接”选项卡中设置好数据库服务器的 相关信息,点击“测试连接”按钮,如果 配置没有问题,则会提示“测试连接成 功”,至此udl文件配置完成。

11
LabVIEW数据库连接工具包
数据库分类:关系型数据库;非关系型数据库 著名的商业用数据库管理系统有MS SQL Server、 Orace、DB2、Visual Foxpro、Microsoft Access 等等。另外,开源的数据库管理系统有MySQL、 Apache Derby、PostgreSQL、Ingres等等。MS SQL Server是Microsoft公司开发的商用数据库管理系 统,在工业测试应用中非常流行,安装和使用都非 常方便,并且支持SQL语言,所以本节基于MS SQL Server 2005为例介绍数据库连接工具包的操作方 式。

7
基于模板的报表生成方式
1.建立模板
(1) 打开Microsoft Excel程序,新 建空白工作簿;
(2) 将 A1 单 元 格 的 名 称 改 为 “ReportTitle”; (3) 将 A2 单 元 格 的 名 称 改 为 “ReportTime”;

12
相关文档
最新文档