外文文献翻译-LabVIEW程序框图设计

合集下载

Labview简易程序设计

Labview简易程序设计

Labview简易程序设计Labview简易程序设计概述Labview(Laboratory Virtual Instrument Engineering Workbench)是一种用于虚拟仪器设计和控制系统的开发环境和语言。

它的特点是图形化的编程方式,使得用户无需编写繁琐的代码,就能够完成复杂的测量和控制任务。

本文将介绍Labview的简易程序设计方法。

Labview程序结构Labview程序由多个虚拟仪器(VI)组成,每个VI由输入、处理和输出三个核心部分组成。

输入部分负责从外部设备或传感器中获取数据,处理部分对输入数据进行计算和逻辑处理,输出部分将处理结果发送给外部设备或在界面中显示。

Labview程序的整体架构通常是基于数据流图(Block Diagram)的,其中各个VI之间通过数据流连接进行数据传递。

数据流连接将结果从一个VI的输出端传递到另一个VI的输入端,从而实现整个程序的协同工作。

Labview程序设计步骤1. 创建新的Labview程序打开Labview软件,“新建”按钮创建一个新的项目。

选择适当的模板或空项目来开始新的程序设计。

2. 添加VI在新建的项目中,右键“当前程序”文件夹,选择“新建”->“虚拟仪器”。

给新建的VI命名,并双击打开它。

3. 添加输入在VI的数据流图上,选择需要的输入控件或函数。

例如,可以添加一个“数字输入框”来接受用户输入的数值,或者添加一个“传感器读取”函数来获取外部设备的数据。

4. 添加处理在VI的数据流图上,选择需要的处理函数或操作。

例如,可以添加一个“加法”函数来对输入的两个数值进行求和,或者添加一个“循环结构”来进行重复计算。

5. 添加输出在VI的数据流图上,选择需要的输出控件或函数。

例如,可以添加一个“数字显示”控件来显示处理结果的数值,或者添加一个“数据保存”函数来将结果保存到文件中。

6. 连接数据流将输入、处理和输出部分通过数据流连接连起来,确保数据能够流动并得到正确的处理。

虚拟仪器_labview_课件PPT_第三章_前面板与程序框图

虚拟仪器_labview_课件PPT_第三章_前面板与程序框图
第三章 前面板与程序框图
河南工业大学机电学院
第三章 前面板与程序框图
3.1
前面板控件
3.2
3.3
设置前面板对象的属性
前面板的修饰
第三章 前面板与程序框图
河南工业大学机电学院
3.1 前面板控件
界面的设计是完成一个完整任务的第一步。
要设计一个完美的界面,首先需要掌握软 件中各种控件的特性,还需要学会一些修 饰的技巧。
河南工业大学机电学院
6.列表框、树形控件和表格
第三章 前面板与程序框图
河南工业大学机电学院
7.下拉列表和枚举控件
第三章 前面板与程序框图
河南工业大学机电学院
8.容器控件
第三章 前面板与程序框图
河南工业大学机电学院
9.I/O控件
第三章 前面板与程序框图
河南工业大南工业大学机电学院
1.数值型控件
第三章 前面板与程序框图
河南工业大学机电学院
2.图形和图表
第三章 前面板与程序框图
河南工业大学机电学院
3.布尔型控件和单选按 钮
第三章 前面板与程序框图
河南工业大学机电学院
4.文本型控件
第三章 前面板与程序框图
河南工业大学机电学院
5.数组、矩阵和簇控件
第三章 前面板与程序框图
第三章 前面板与程序框图
河南工业大学机电学院
3.1 前面板控件
1.数值型控件 2.图形和图表 3.布尔型控件和单选按钮 4.文本型控件 5.数组、矩阵和簇控件 6.列表框、树形控件和表格 7.下拉列表和枚举控件 8.容器控件 9.I/O控件
系统控件是专门用于“创建的对话框中”
第三章 前面板与程序框图
第三章 前面板与程序框图

第二章 labview程序结构

第二章 labview程序结构

第二章程序结构2.1循环结构2.1.1While 循环While 循环可以反复执行循环体的程序,直至到达某个边界条件。

它类似于普通编程语言中的 Do 循环。

While 循环的框图是一个大小可变的方框,用于执行框中的程序,直到条件端子接收到的布尔值为 FALSE。

该循环有如下特点:●计数从0开始(i=0)。

●先执行循环体,而后i+1,如果循环只执行一次,那么循环输出值i=0。

●循环至少要运行一次。

条件端子循环变量图2-1While 循环示意图练习2-1使用While循环和图表目的:用 While 循环和图表获得数据,并实时显示。

创建一个可以产生并在图表中显示随机数的VI。

前面板有一个控制旋钮可在0到10秒之间调节循环时间,还有一个开关可以中止VI的运行。

学习怎样改变开关的动作属性,以便不用每次运行VI时都要打开开关。

操作步骤如下:前面板图2-2练习2-1的前面板1.选择FileºNew,打开一个新的前面板。

2.选择ControlsºBoolean,在前面板中放置一个开关。

设置开关的标签为控制开关。

3.使用标签工具创建 ON 和 OFF 的标签,放置于开关旁。

4.选中ControlsºGraph,在前面板中放置一个波形图(是chart,而不是graph)。

设置它的标签为随机信号。

这个图表用于实时显示随机数。

5.把图表的纵坐标改为0.0 到 1.0。

方法是用标签工具把最大值从10.0改为1.0。

6.选择ControlsºNumeric,在前面板中放置一个旋钮。

设置旋钮的标签为循环延时。

这个旋钮用于控制While 循环的循环时间。

流程图7.开流程图,按照下图创建流程图。

图2-2练习2-1的流程图a.从FunctionsºStructures 中选择 While 循环,把它放置在流程图中。

将其拖至适当大小,将相关对象移到循环圈内。

b.从Functionsº Numeri c中选择随机数(0-1)功能函数放到循环内。

Labview外文翻译(带中文对照)(适用于毕业论文外文翻译+中英文对照)

Labview外文翻译(带中文对照)(适用于毕业论文外文翻译+中英文对照)

LabVIEWLabVIEW is a highly productive graphical programming language for building data acquisition an instrumentation systems.With LabVIEW, you quickly create user interfaces that give you interactive control of your software system. To specify your system functionality,you simply assemble block diagrams - a natural design notation for scientists and engineers. Tis tight integration with measurement hardware facilitates rapid development of data acquisition ,analysis,and presentation bVIEW contains powerful built -in measurement analysis and a graphical compiler for optimum performance. LabVIEW is available for Windows 2000/NT/Me/9x, Mac OS, Linux, Sun Solaris, and HP-UX, and comes in three different development system options.Faster DevelopmentLabVIEW accelerates development over traditional programming by 4 to 10 times! With the modularity and hierarchical structure of LabVIEW, you can prototype ,design, and modify systems in a short amount of time. You can also reuse LabVIEW code easily and quickly in other applications.Better InvestmentUsing a Lab VIEW system, each user has access to a complete instrumentation laboratory at less than the cost of a single commercial instrument. In addition, user configurable LabVIEW systems are flexible enough to adapt to technology changes, resulting in a better bong-term investment.Optimal PerformanceAll LabVIEW applications execute at compiled speed for optimal performance. With the LabVIEW Professional Development System or Application Builder, you can build stand-alone executables or DLLs for secure distribution of your code. You can even create shared libraries or DLLs to call LabVIEW code from other programming languages.Open Development EnvironmentWith the open development environment of LabVIEW, you can connect to other applications through ActiveX, the Web, DLLs, shared libraries, SQL(for databases), DataSocket, TCP/IP,and numerous other e LabVIEW to quickly create networked measurement and automation systems that integrate the latest technologies in Web publishing and remote data sharing. LabVIEW also has driver libraries available for plug-in data acquisition, signal conditioning , GPIB,VXI,PXI, computer-based instruments,serial protocols, image acquisition, and motion control. In addition to the LabVIEW development systems, National Instruments offers a variety of add-on modules and tool sets that extend the functionality of LabVIEW .This enables you to quickly build customizable, robust measurement and automation systems.LabVIEW Datalogging and Supervisory Control ModuleFor high channel count and distributed applications, the LabVIEW Datelogging and Supervisory Control Module provides a complete solution. This module delivers I/O management, event logging and alarm management, distributed logging, historical and real-time trending, built-in security, configurable networking features, OPC device connectivity, and over 3,300 built-in graphics.LabVIEW Real-TimeFor applications that require real-time performance, National Instruments offers LabVIEW Real-Time. LabVIEW Real-Time downloads standard LabVIEW code to a dedicated hardware target running a real-time operating system independent from Windows.LabVIEW Vision Development ModuleThe LabVIEW Vision Development Module is for scientists, automation engineers,and technicians who are developing LabVIEW machine vision and scientific imaging applications. The LabVIEW Vision Development Module includes IMAQ Vision, a library of vision functions, and IMAQ Vision Builder, an interactive environment for vision applications. Unlike any other vision products, IMAQ Vision Builder and IMAQ Vision work together to simplify vision software development so that you can apply vision to your measurement and automation applications.Countless ApplicationsLabVIEW applications are implemented in many industries worldwide including automotive, telecommunications, aerospace, semiconductor, electronic design and production, process control, biomedical, and many others, Applications cover all phases of product development from research to design to production and to service. By leveraging LabVIEW throughout your organization you can save time and money by sharing information and software.Test and MeasurementLabVIEW has become an industry-standard development tool for test and measurement applications. With Test Stand, LabVIEW-based test programs, and the industry's largest instrument driver library, you have a single, consistent development and execution environment for your entire system.Process Control and Factory AutomationLabVIEW is used in numerous process control and factory automation applications.Many scientists and engineers look to LabVIEW for the high speed, high channel count measurement and control that graphical programming offers.For large, complex industrial automation and control applications, the LabVIEW Data logging and Supervisory Control Module provides the same graphical programming as LabVIEW, but is designed specifically for monitoring large numbers of I/O points, communicating with industrial controllers and networks, and providing PC-based control.Machine Monitoring and ControlLabVIEW is ideal for machine monitoring and predictive maintenance applications that need deterministic control, vibration analysis, vision and image processing, and motion control. With the LabVIEW platform of products including LabVIEW Real-Time for real-time deterministic control and the LabVIEW Data logging and Supervisory Control Module, scientists and engineers can create powerful machine monitoring and control applications quickly and accurately.Research and AnalysisThe integrated LabVIEW measurement analysis library provides everything you need in an analysis package. Scientists and researchers have used LabVIEW to analyse and compute real results for biomedical, aerospace, and energy research applications, and in numerous other industries. The available signal generation and processing, digital filtering, windowing, curve-fitting, For specialized analysis, such as joint time-frequency analysis, wavelet,and model-based spectral analysis, LabVIEW offers the specially designed Signal ProcessingToolset.The Sound and Vibration Toolset offers octave analysis, averaged and nonaveraged frequency analysis, transient analysis, weighted filtering, and sound-level measurement, and more.Draw Your Own SolutionWith LabVIEW, you build graphical programs called virtual instruments (VIs) instead of writing text-based programs. You quickly create front panel user interfaces that give you the interactive control of your system. To add functionality to the user interface, you intuitively assemble block diagrams- a natural design notation for engineers and scientists.Create the Front PanelOn the front panel of your VI, you place the controls and data displays for your system by selecting ob jects from the Controls palette, such as numeric displays, meters, gauges, thermometers, LEDs, charts,and graphs.When you complete and run your VI,you use the front panel to control your system whether you move a slide, zoom in on a graph, or enter a value with the keyboard.Construct the Graphical Block DiagramTo program the VI, you construct the block diagram without worrying about the syntactical details of text-based programming languages. You do this by selecting objects (icons) from the Functions palette and connecting them together with wires to transfer data among block diagram objects. These objects include simple arithmetic functions, advanced acquisition and analysis routines, network and file I/O operations, and more.Dataflow ProgrammingLabVIEW uses a patented dataflow programming model that frees you from the linear architecture of text-based programming languages. Because the execution order in LabVIEW is determined by the flow of data between nodes,and not by sequential lines of text,you can create block diagrams that execute multiple operations in parallel. Consequently, LabVIEW is a multitasking system capable of running multiple execution threads and multiple VIs in parallel.Modularity and HierarchyLabVIEW VIs are modular in design, so any VI can run by itself or as part of another VI. You can even create icons for your own VIs, so you can design a hierarchy of VIs that serve as application building blocks. You can modify, interchange, and combine them with other VIs to meet your changing application needs.Graphical CompilerIn many applications, execution speed is critical. LabVIEW is the only graphical programming system with a compiler that generates optimized code with execution speeds comparable to compiled C programs. You can even use the LabVIEW profiler to analyse and optimize time-critical operations. Consequently, you increase your productivity with graphical programming without sacrificing execution speed.Measurements and MathematicsLabVIEW includes a variety of other measurement analysis tools. Examples include curve fitting, signal generation, peak detection, and probability and statistics. Measurement analysis functions can determine signal characteristics such as DC/RMS levels, total harmonic distortion (THD),impulse response, frequency response, and cross-power spectrum. LabVIEW users can also deploy numerical tools for solving differential equations, optimization, root finding, and other mathematical problems.In addition, you can extend these built-in capabilities by entering MATLAB or HIQ scripts directly in your LabVIEW programs. For charting and graphing, you canrely on the built-in LabVIEW 2D and 3D visualization tools. 2D tools include features such as autoscaling X and Y ranges, reconfigurable attributes (point/line styles, colors, and more)and cursors, Microsoft Windows users can employ OpenGL-based 3D graphs and then dynamically rotate, zoom, and pan these graphs with the mouse.Development SystemThe LabVIEW Professional Development System facilitates the development of high-end, sophisticated instrumentation systems for developers working in teams, users developing large suites of VIs, or programmers needing to adhere to stringent quality standards.Built on the Full Development System, the Professional Development System also includes the LabVIEW Application Builder for building stand-alone executables and shared libraries (DLLs)and creating distribution kits. In addition, the development system furnishes source code control tools and offers utilities for quantitatively measuring the complexity of your applications. With graphical differencing, you can quickly identify both cosmetic and functional differences between two LabVIEW applications.We include programming standards and style guides that provide direction for consistent LabVIEW programming methodology. The system also contains quality standards documents that discuss the steps LabVIEW users must follow to meet internal regulations or FDA approval. The Professional Development System operates on Windows 2000/NT/Me/9x,Mac OS, HP-UX, and Linux.LabVIEW Full Development SystemThe LabVIEW Full Development System equips you with all of the tools you need to develop instrumentation systems. It includes GPIB, VISA, VXI, RS-232, DAQ, and instrument driver libraries for data acquisition and instrument control. The measurement analysis add DC/RMS measurements, single tone analysis, harmonic distortion analysis, SINAD analysis, limit testing, signal generation capabilities, signal processing, digital filtering, windowing, curve fitting, statistics, and a myriad of linear algebra and mathematical functions. The development system also provides functions for direct access to DLLs, ActiveX, and other external code. Other features of the system include Web publishing tools, advanced report generation tools, the ability to call MATLAB and HiQ scripts, 3D surface, line, and contour graphs, and custom graphics and animation. The Full Development System operates on Windows 2000/NT/Me/9x, Mac OS, HP-UX, and Linux.LabVIEW Base PackageUse the LabVIEW Base Package, the minimum LabVIEW configuration, for developing data acquisition and analysis, instrument control, and basic data presentation. The Base Package operates on Windows 2000/NT/Me/9x.Debug License for LabVIEWIf you deploy LabVIEW applications, including LabVIEW tests for use with Test Stand, the debug license allows you to install the LabVIEW development system on the target machines so you can step into your test code for complete test debugging. This license is not intended for program development.虚拟仪器(LabVIEW)虚拟仪器是一种高效用于构建数据采集与监测系统图形化编程语言。

LabVIEW程序设计步骤知识分享

LabVIEW程序设计步骤知识分享

L a b V I E W程序设计步骤LabVIEW程序设计步骤下面通过一个设计实例来详细介绍虚拟仪器软件LabVIEW的程序设计步骤。

设计目标:假设有一台仪器,需要调整其输入电压,当调整电压超过某一设定电压值时,需通过指示灯颜色变化发出警告。

1 建立新VI启动LabVIEW程序,单击VI按钮,建立一个新VI程序。

这时将同时打开LabVIEW的前面板和后面板(框图程序面板)。

在前面板中显示控件选板,在后面板中显示函数选板。

在两个面板中都显示工具选板。

如果选板没有被显示出来,可以通过菜单查看(View)/工具选板(Tools Palette)来显示工具选板,通过查看(View)/控件选板(Controls Palette)显示控件选板,通过查看(View)/函数选板(Functions Palette)显示函数选板。

也可以在前面板的空白处,单击鼠标右键,以弹出控件选板。

2 前面板设计输入控制和输出显示可以从控件选板的各个子选板中选取。

本例中,程序前面板中应有1个调压旋钮,1个仪表,1个指示灯,1个关闭按钮共4个控件。

1)往前面板添加1个旋钮控件:控件(Controls)→新式(Modern)→ 数值(Numeric)→旋钮(Knob),如图2-14所示,标签改为“调压旋钮”;2)往前面板添加1个仪表控件:控件(Controls)→新式(Modern)→数值(Numeric)→仪表(Meter),如图2-14所示,标签改为“电压表”。

3)往前面板添加1个指示灯控件:控件(Controls)→新式(Modern)→布尔(Boolean)→圆形指示灯(Round LED),如图2-15所示,将标签改为“上限灯”。

图2-14 添加旋钮、仪表控件图2-15 添加指示灯、按钮控件4)往前面板添加1个停止按钮控件:控件(Controls )→ 新式(Modern )→ 布尔(Boolean ) → 停止按钮(Stop Button ),如图2-15所示,将标签改为“关闭”。

LabVIEW程序设计步骤

LabVIEW程序设计步骤

LabVIEW 程序设计步骤下面通过一个设计实例来详细介绍虚拟仪器软件LabVIEW 的程序设计步骤。

设计目标:假设有一台仪器,需要调整其输入电压,当调整电压超过某一设定电压值时,需通过指示灯颜色变化发出警告。

1 建立新VI启动LabVIEW 程序,单击VI 按钮,建立一个新VI 程序.这时将同时打开LabVIEW 的前面板和后面板(框图程序面板)。

在前面板中显示控件选板,在后面板中显示函数选板。

在两个面板中都显示工具选板。

如果选板没有被显示出来,可以通过菜单查看(View )/工具选板(Tools Palette)来显示工具选板,通过查看(View)/控件选板(Controls Palette )显示控件选板,通过查看(View )/函数选板(Functions Palette)显示函数选板。

也可以在前面板的空白处,单击鼠标右键,以弹出控件选板.2 前面板设计输入控制和输出显示可以从控件选板的各个子选板中选取。

本例中,程序前面板中应有1个调压旋钮,1个仪表,1个指示灯,1个关闭按钮共4个控件。

1)往前面板添加1个旋钮控件:控件(Controls )→ 新式(Modern ) → 数值(Numeric ) → 旋钮(Knob),如图2—14所示,标签改为“调压旋钮";2)往前面板添加1个仪表控件:控件(Controls)→ 新式(Modern) → 数值(Numeric ) → 仪表(Meter ),如图2-14所示,标签改为“电压表”.3)往前面板添加1个指示灯控件:控件(Controls)→ 新式(Modern )→ 布尔(Boolean ) → 圆形指示灯(Round LED ),如图2-15所示,将标签改为“上限灯".4)往前面板添加1个停止按钮控件:控件(Controls )→ 新式(Modern)→ 布尔(Boolean) 图2-15 添加指示灯、按钮控件图2-14 添加旋钮、仪表控件→停止按钮(Stop Button),如图2-15所示,将标签改为“关闭”。

LabVIEW程序设计与虚拟仪器之程序结构ppt文档

LabVIEW程序设计与虚拟仪器之程序结构ppt文档

While循环可以进行嵌套。 【例2.1】 使用While循环每0.5秒显示一个随机数和循环 次数,最后波形显示所有随机数序列。 VI的前面板和程序框图如图2-2所示,While循环条件端子 与布尔开关对象相连,只要开关状态为“关”,程序重复执行, 直到条件端子为“开”,停止循环。While循环框内放置一个 随机数对象和Time Delay Express VI,每0.5秒循环一次,在前 面板显示随机数和循环次数,最后利用While循环的自动索引 功能将随机数序列通过波形显示出来,可以看到,波形的横坐 标表示循环次数,当循环次数为115时,随机数加1是1.38577。
图2-6 例2.2的前面板和程序框图
2.1.3 For循环 For循环位于Functions→Structures子模板上。 For循环有两个固定的数据端子,分别是计数端子(Loop
Count)和重复端子(Loop Iteration),如图2-8所示。其中计数端 子连接整型数值,指定循环次数;重复端子输出已经执行循环 的次数,循环次数默认从“0”开始计数,依次增加“1”。
LabVIEW程序设计与虚拟仪器之程序结构
LabVIEW程序设计与虚拟仪器之程序结构
本章将系统介绍LabVIEW提供的程序结构,包括While Loop(While循环)、For Loop(For循环)、Shift Register(移位寄存 器)、Case Structure(分支结构)、Sequence Structure(顺序结构)、 Formula Node(公式节点)等。
2.1 循 环 结 构
在LabVIEW中有While循环 和 For循环 两种循环结构。二
者的区别是:While循环只要满足循环退出的条件则退出相应 的循环,否则变成死循环;而For循环是预先确定循环次数, 当循环体运行完指定的次数后自动退出循环。 2.1.1 While循环

LabView程序设计的一般过程

LabView程序设计的一般过程
LabVIEW的程序调试技术
1.找出语法错误 如果一个VI程序存在语法错误,则在面板工具条上的运行按钮会变成一个
折断的箭头,表示程序不能被执行。这时该按钮被称作错误列表。在这它, 则LabVIEW弹出错误清单窗口,在这其中任何一个所列出的错误,选用Find 功能,则出错的对象或端口就会变成高亮。 2.设置执行程序高亮
v
step over是在单步执行时,在函数内遇到子函 数时不会进入子函数内单步执行,而是将子函 数整个执行完再停止,也就是把子函数整个作 为一步。
v
step out就是单步执行时,用step out就可以执 行完程序余下部分,并返回。
On the evening of July 24, 2021
Courseware template
可用探针工具来查看当流程图程序流经某一根连接线时的数据值。从Tools工 具模板选择探针工具,再用鼠标左键在这你希望放置探针的连接线。这时显示器 上会出现一个探针显示窗口。该窗口总是被显示在前面板窗口或流程图窗口的上 面。在流程图中使用选择工具或连线工具,在连线上在这鼠标右键,在连线的弹 出式菜单中选择探针命令,加上一个探针同样可以为该连线。
Courseware template
LabVIEW程序调试技术
3.断点与单步执行 为了查找程序中的逻辑错误,有时希望流程图程序一个节点一个节点地执行。
使用断点工具可以在程序的某一地点中止程序执行,用探针或者单步方式查看数 据。使用断点工具时,在这你希望设置或者清除断点的地方。断点的显示对于节 点或者图框表示为红框,对于连线表示为红点。当VI程序运行到断点被设置处, 程序被暂停在将要执行的节点,以闪烁表示。按下单步执行按钮,闪烁的节点被 执行,下一个将要执行的节点变为闪烁,指示它将被执行。你也可以在这暂停按 钮,这样程序将连续执行直到下一个断点。 4.探针
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

LabVIEW程序框图设计摘要:一个真正好的程序就像一件艺术品一样,而差的程序看起来就像意大利面那样乱。

这篇文章提出的风格能确保我们实际应用中在规定时间内开发出整洁,结构清晰的程序。

结合其他规则,我们能开发出可读性好的,易于维护的LabView源代码。

LabVIEW的程序框图长于源代码表述。

一个真正好的程序是发人深省的,甚至是令人敬畏的,就是一件艺术品一样。

而一个差的程序,看起来就像一碗意大利面条那样凌乱。

事实上,这两种极端的情况就像《风格的重要性》中Meticulous VI 和 Spaghetti VI所表现的那样。

而大部分程序处于艺术品和意大利面条之间。

一些程序开发者有连线整齐的习惯,但程序框图往往却大而宽泛。

其他的一些程序开发者却过度使用模块化编程,就像自己在搭建筑一样。

而仍有一些编程人员喜欢使用变量方式而非数据流方式。

很多很多开发人员在文档上节省时间。

此外,很多程序是在好的风格和节约时间两者之间取得平衡下为特征下完成工作的。

总体结论就是在吸引人的程序外观,个人喜好和程序功能上取得折中。

大多数开发人员都错误认为吸引人的程序编写上受到许多束缚使开发进度变慢,而现实中程序开发都有时间限制。

似乎快速开发程序的和程序具有美感是相矛盾的。

事实上,多花些时间来优化复杂程序的外观是可能的如果你知道什么才是好的风格所要遵循的规则和如何执行这些规则,你将会在程序开发中更加轻松。

屏幕分辨率决定程序开发人员在开发程序时的可见区域和程序移植到用户计算机后的界面显示。

因此,将程序分辨率统一是非常有好处的,那样应用程序在使用相同分辨率的PC上打开时窗口界面将保存一致。

程序分辨率设置得越高,界面上的控件将根据屏幕大小相应的缩小,屏幕上也能容纳更多的程序代码。

合适的屏幕分辨率是不仅要能使程序的可见区域最大化,而且不能让你的眼睛不舒服。

LabView开发环境设定的最小程序分辨率为1024*768。

与PC显示技术发展相适应的1280*1024的屏幕分辨率能提供更多的可视区域。

不要采用高于1280*1024的分辨率,因为当前还不广泛支持如此高的分辨率,更大的工作区域也意味者程序框图更大,模块化程度降低。

同时,取决于显示器的大小,如果过高的分辨率容易使你的眼睛疲劳。

今天许多计算机都支持多显示器。

在LabView开发环境采用两个显示器是非常有好处的。

使用一个显示器来显示前面板,另外一个显示器来显示程序框图。

这样就能同时看到这两个窗口,而不需要在前面板和程序框图之间进行切换。

不要给程序框图着色。

界面的背景色和每个结构的子界面都默认为白色。

数据流向必须非常容易识别。

我们希望对象尽量布局紧凑,但同时不希望对象靠得太近引起对象和连线重叠。

总之,尽量缩小程序框图大小使之能在一个屏幕显示出来。

在某些情况下,比如说某些复杂的程序包含很多个并行循环,要满足这个限定非常困难。

在这种情况下,调整程序框图,或者将一些循环变成子VI来减小所占背面板空间,使背面板仅在一个方向上滑动。

开发程序时,VI之间应采用从上至下和自下而上相结合的方法来构建多层次结构关系。

VI的层次结构可以通过选择View»VI Hierarchy来查看。

从窗口的工具条中取消选择包括VI Lib ,包括全局变量和包括自定义类型,并且只显示你自己提供的用户VI。

通常的几何形状包括金字塔形,钻石形和椭圆形。

除了非常简单的应用程序外,VI层次结构中在顶层VI之下的应包含多行子VI。

在第一章中,模块化率被定义为是用户VI数与总的节点数之比,再乘100。

这些数据的大小可以通过选择Tools»Profile»VI Metrics快速查看到。

典型应用程序的模块化率推荐为3.0以上。

取决于设计样式,许多顶层程序都应包含结构,连线,VI组件和子VI。

VI组件是处于非常高层的子VI,或者是将一个应用程序的主要部分或子系统封装为插件后动态调用的VI。

一个应用程序的图形用户见面和数据采集引擎是以单独的vi实现的,它们就是组件VI的一个例子。

顶层和高层vi应该尽可能减少的低层数据处理函数,例如数学函数,数组处理,格式化字符串以及类似的函数。

一些应用程序需要大量的数值属性节点来控制GUI行为。

许多属性节点的读写操作是由GUI事件触发。

因此,事件结构是理想的处理属性节点的结构。

因为,事件结构为每个事件分支包含一个单独的子程序,通常一个事件分支的程序不会跑到其他的事件分支。

然而,多事件分支需要许多个相同的属性节点,它们的值因每次读写操作而不同。

将这些普通的属性节点模块化为子VI,通过控件引用和属性值传递到子VI中。

每个子VI程序代表在内存中同一属性节点的备份。

这减小了内存使用和程序复杂性。

同样的,将你程序中的高层组件模块化为较低级的子VI。

使用自顶向下的设计和开发方法,将任何低层程序模块化为强内聚的子VI。

在任何的地方如果你用到了已有代码的副本来共同构成一个程序,将这些代码替换成子VI。

一个子VI是否是内聚的要看你是否能将它要完成的工作清楚的描述为两三句话,就像子VI描述信息那样。

子VI非常有用,因为相对于一个大型程序来说,它易于开发,测试,调试,维护和代码重用。

如图4-2C所示,子VI也为程序开发中节省了可观的背面板空间。

总之,如果同一函数,属性节点,程序被多次用到,将这些重复代码换成子VI将使程序开发变简单。

同样,如果几个没用被重复使用的节点彼此相关,并且一起完成某项工作,不管它们是否被多次用到,也将它们变为一个内聚的子VI。

但是,也不要为了节省空间而随便选择将程序的某部分变成子VI。

以这种方式创建的子VI不是内聚的,也不够直观并且不可重用。

同样也不要为只有少量接线端的程序代码创建子VI。

这种情况,子VI图标不需要在程序框图掩盖它下层的代码。

子VI只包含一个数组索引函数。

然而,子VI的图标,名字和描述信息掩盖数组索引函数。

LabView函数和将子VI打包成的VI.lib通常是可识别的,因而不需再单独将它们封装成子VI。

为每个子VI创建一个有含义的图标和相结合的描述。

住为每个子VI创建一个有含义的图标和相结合的描述。

再怎么强调它的重要性都是不够的。

这是我们最神圣的信条。

图标和描述信息能帮助我们在调用这些子VI的程序时通过帮助窗口的文字识别这些子VI。

这些描述迫使我们进行内聚性测试。

如果你不能通过2到3句话总结子VI的功能,子VI可能包含了太多的子代码。

隧道连线通过结构左侧边界进入结构,并从结构的右侧边界穿过结构。

不要让隧道在结构的顶部或底部穿过。

同样如果结构内部未使用到也不要让连线穿过结构,除非其目的是为了标示清楚。

特别令人困苦的是浏览一个多帧结构的许多帧时,要去寻找那些在连线上被修改的数据,比如说条件结构或者是事件结构。

然而,有时条件结构通过一些额外的连线线是非常有用的将没有连线的前面板控件在程序框图上放在一起,那样程序开发人员就能非常容易的将找到它们。

标记那些在程序只用到一次,不在循环结构中的接线端。

实践中大多数局部变量,全局变量和顺序结构都不是必要的。

没有学习过有效数据流法则的开发者经常过多地使用局部变量和全局变量。

强迫自己避免使用变量和顺序结构是最有效的掌握数据流的方法,除非完全必要要用到它们。

的确,掌握数据流和尽可能避免使用变量和顺序结构具有相同的含义。

为了避免连线混乱且保持有组织秩序,紧凑地放置移位寄存器且将它们聚集到靠近循环的顶部。

这样如同在靠近循环顶端位置有限的区域内修建一条数据公路且使线路交叉最少。

除了聚合了包括错误簇和条件选择器的移位寄存器外。

只要在移位寄存器之间留下刚好够放置自由标签的位置就行了,这些标签将被放置在靠近移位寄存器左边终端的线上。

错误簇经常在循环的底部进出,而条件选择器经常处于中间位置。

因此,错误簇和条件选择器经常与靠近循环顶部的数据公路是分离的。

最糟的编程习惯是从一个选定区域创建一个VI而且不清理创建子VI后的狼藉场面。

终端位置,标签,线,连接器分配,图标以及描述文档都需要进行矫正。

有时这样还会导致子VI的程序结构图就像在里面投了一颗炸弹一样。

用这种工具创建的子VI从来就不是一个好的风格而且程序必须改写。

关闭检查展示出从右向左的线是一个文件路径,它是由Case结构里面的若干底层函数所形成的。

不管怎样,在顶层VI上由若干底层函数共同组成以完成某种功能的程序最好用一个子VI的形式出现。

这篇文章提出的风格能确保我们实际应用中在规定时间内开发出整洁,结构清晰的程序。

结合其他规则,我们能开发出可读性好的,易于维护的LabView源代码。

而且,遵守这些好的编程风格所要求的准则将可能会使我们开发出令人赞叹的LabView程序。

The LabVIEW Program Diagram DesignABSTRACT:A really good diagram is like a work of art. Some developers have neat wiring practices but large, flat diagrams. This chapter presents style rules that ensure neat and organized diagrams that are practical to implement in real applications with tight deadlines. Combined with the rules in other chapters, they ensure readable and maintainable LabVIEW source code The LabVIEW block diagram excels at conveying source code. A really good diagram is enlightening, even awe-inspiring, like a work of art. Some developers have neat wiring practices but large, flat diagrams. Others have overly modular diagrams that disguise the architecture. . Indeed, these two extremes are depicted by Meticulous VI and Spaghetti VI in Chapter 1, "The Significance of Style." Somewhere in the middle between artwork and spaghetti is where most applications reside. Still others prefer variables over data flow. Many, many developers skimp on documentation to save time. Moreover, most diagrams are characterized by tradeoffs between good style and shortcuts deemed necessary to get the job done. The overall outcome is a compromise among attractive appearance, personal preferences, and functional performa nce.Many developers wrongfully assume that attractive diagrams require a level of toil that is impractical for real-world applications that have tight deadlines. It seems faster and more productive to avoid getting caught up in diagram aesthetics. Indeed, it is possible to expend excessive time optimizing the appearance of a complex diagram, If you know the style rules and how to implement them, you eliminate the toil.The LabVIEW development environment is designed for a minimum 1024x768 resolution. A resolution of 1280x1024 provides additional real estate while maintaining compatibility with mainstream PC display technology. Avoid resolutions much higher than 1280x1024 because higher resolutions are less universally supported, and the larger work area promotes larger diagrams and potentially less modularity. Also, depending on the monitor size, very high resolutions may strain your eyes.The display resolution affects the visible area the developer has to work with and how the diagram appears when opened on a given target computer. It is beneficial to standardize on one display resolution so that the diagram window maintains a consistent appearance when opened on PCs with similar display capabilities. The higher the resolution setting, the smaller the diag ram objects shrink relative to the screen size, and the more code fits on one screen. A fairly high resolution is recommended to maximize the viewable diagram area without straining your eyes. Today many computers support multiple monitors. It is particularly useful to utilize two monitors for LabVIEW development. This allows you to dedicate one monitor to the front panel and the other monitor to the block diagram, and have both windows simultaneously visible without having to navigate between them.Do not color the diagrams. Leave the background of the diagram, and every subdiagram of every structure, default white. Data flow must be easy to visualize. A high density of objects is desired, without crowding objects too close and causing wires and objects to overlap. In general, try to limit the diagram size to one display screen. In some situations, it is difficult to work within this constraint, such as a complex diagram containing multiple parallel loops. In this case, organize the large diagram so that it may be viewed by scrolling in only one direction, or modularize the loops into subVIs to reduce space.Develop your applications as a multilayer hierarchy of subVIs using a combination of top-down and bottom-up design and development techniques. The VI Hierarchy is viewed by selecting View»VI Hierarchy. Deselect Include VI Lib, Include Globals, and Include typedef from the toolbar to remove these items from the window, and view only the hierarchy of user VIs that you provided. Common geometries include pyramid, diamond, and oval. Except for very simple applications, the VI Hierarchy should contain multiple rows of subVIs below the top-level VI. In Chapter 1, the modularity index was defined as the ratio of the number of user VIs to total nodes, multiplied by 100. These quantities are quickly referenced using the VI Metrics window, selected from Tools»Profile»VI Metrics. A modularity index of 3.0 or greater is recommended for a typic al application.Depending on the design pattern, most top-level diagrams should consist of structures, wires, component VIs, and subVIs. Component VIs are very high-level subVIs, or dynamically loaded plug-in VIs, that encapsulate a major portion or subsystem of the application. An application's graphical user interface and data acquisition engine, implemented as separate VIs, are examples of component VIs. The top-level and high-level diagrams should contain very few low-level data-manipulation functions, such as math, array manipulations, string formatting, and similar functions.Some applications require large numbers of Property Nodes for controlling GUI behavior. Most Property Node read and write operations are triggered by GUI events. Consequently, the Event structure is an ideal construct for handling Property Nodes. Because the Event structure contains separate subdiagrams for each event case, it is uncommon to run out of space. However, it is common to have multiple event cases that require many of the same Property Nodes, with different values read or written to them in each. Modularize these common Property Nodes into subVIs, and pass the Control References and property values to the subVI in each location. Each instance of the subVI refers to the same collection of Property Nodes in memory. This substantially reduces memory use and diagram complexity.Likewise, modularize the diagrams of your high-level component VIs into lower-level subVIs. Using the top-down design and development approach, modularize any low-level routines into cohesive subVIs. Anywhere you have a collection of related functions that work together to perform a specific routine, replace them with a subVI. A subVI is cohesive if you can clearly describe its purpose in two or three sentences, such as when entering the subVI's description.SubVIs are advantageous because it is easier to develop, test, debug, maintain, and reuse software modules as subVIs versus sections of a large diagram. As shown in Figure 4-2C, they also provide a considerable space-saving benefit. In general, if the collection of functions or Property Nodes or other routine is used in more than one place, it is an easy decision: Replace the repeated code with a subVI. Likewise, if several nonrepetitive nodes are related to one another and work together to perform a specific task, modularize them into cohesive subVIs, whether they are needed in multiple places or not. However, do not randomly select areas of the diagram and create subVIs just to save space. SubVIs created in this manner are not cohesive, intuitive, or reusable. Also, do not create trivial subVIs that contain few nodes. In this case, the subVI icon unnecessarily masks the underlying code on the diagram. For example, the subVI in Figure 4-3 contains only a single Index Array function. However, the subVI's icon, name, and descr iption disguise the function. The LabVIEW functions and shipping subVIs within vi.lib are universally recognizable, so avoid masking them within trivial subVIs.Create a meaningful icon and cohesive description for every subVI!Always create a meaningful icon and cohesive description for every subVI. I cannot emphasize this enough. At Bloomy Controls, this is one of our most sacred precepts. The icon and descriptio n identify the subVI from the diagram of the calling VI through the Context Help window. The description enforces the cohesion test. If you cannot summarize its purpose in two or three sentences, it probably contains too much code for one subVITunnel wires into structures through their left border, and out of structures through their right border. Avoid tunneling wires through the top and bottom borders. Also avoid passing wires through structures if they are not utilized within the structure, unless their purpose is clearly labeled. It is particularly annoying to flip through many frames of a multiframe structure, such as a Case or an Event structure, searching for places where the data in the wire is modified.Place any unwired terminals of front panel objects in a consistent location on the diagram so that developers can find them easily. Note that any terminals not contained by a repeating structure are read only once.Most local and global variables and Sequence structures used in practice are not neces sary. Most often, they are overused by developers who have not learned efficient dataflow principles. The best way to master data flow is to force oneself to avoid variables and Sequence structures unless absolutely required. Indeed, mastering data flow is synonymous with minimizing variables and Sequence structures.To avoid wire clutter and maintain organization, space most shift registers tightly, and group them near the top of the loop. This creates a data highway that is limited to an area near the top of the loop and minimizes wire crossovers. Leave just enough space between the shift registers to apply free labels on each wire near the left terminals. Exceptions to shift register grouping include error clusters and case selectors. Error clusters normally enter and exit near the bottom of loops. Also, case selectors are frequently positioned near the middle. Therefore, error clusters and case selectors are usually kept separate from the data highway at the top.For example, the task ID and error control terminals are improperly labeled task ID out and error out. Additionally, one of the indicators has the generic label Numeric. What is curious is that the subVI has a custom icon and description, and the control terminals are within reasonable proximity to the structure. Perhaps it was partially repaired. The wiring and terminal labels have been cleaned up in Figure 4-14B. Also, Figure 4-14C contains equivalent code using the waveform data type and the newer sound output VIs released with LabVIEW 8. This is the preferred implementation.Close inspection reveals that the right-to-left wire is a file path that is formed by some low-level functions within an inner Case structure. Whenever a collection of low-level functions that work together to perform a cohesive routine appears on the diagram of a high-level VI, it is a good opportunity for a subVI,This chapter presents style rules that ensure neat and organized diagrams that are practical to implement in real applications with tight deadlines. Combined with the rules in other chapters, they ensure readable and maintainable LabVIEW source code. Moreover, mastery of these style rules may lead to awe-inspiring LabVIEW diagrams.。

相关文档
最新文档