The Timed Structures
定时结构

Doesn't it seem like every While Loop has some kind of timing function inside of it? Wouldn't it be great if the timer were somehow built into the While Loop? Well, if you take a look at the Programming>>Structures>>Timed Structures palette (shown in Figure 6.59), you'll find a set of tools that make While Loop (as well as Sequence Structure) timing and synchronization possible.
它是否像在每个While Loop里边放入了些定时函数呢? 抑或它将更加地重要, 倘若是定时器以某种方式被置入进了While Loop? 好的, 如果你看一看函数模板中的Programming>>Structures>>Timed Structures(如图6.59), 你将发现有一套工具可以使得While Loop(同样在Sequence Structure)定时和同步变得可能.
Figure 6.59. Timed Structures palette

Timed Structures are only available on Windows. They were designed especially for use in time-critical LabVIEW RT and FPGA applications, and those LabVIEW modules are not supported on Mac OS X and Linux.
定时结构仅适用于Windows操作系统. 它们被设计出来主要是针对于对时间因素严重挑剔的LabVIEW RT和FPGA的应用中, 并且这些LabVIEW模块不被支持于Mac OS X 和 Linux系统.
Timed Structures and VIs allow you control the rate and priority at which a timed structure executes its subdiagram, synchronize the start time of timed structures, create timing sources, and establish a hierarchy of timing sources.
定时结构和定时VI允许你控制运行的速度和优先级, 在其中定时结构执行它的子程序. 同步定时结构的起始时间, 创建定时源, 并建立定时源的层次.
The Timed Loop and the Timed Sequence (which you'll learn about next) have several nodes attached to their frames. These are used for configuring the loops and obtaining information about their execution.
定时循环和定时顺序(将在后面学习到)有几种附加在它们框架上的节点. 这些节点用来配置循环和获得关于运行的信息.
Probably the biggest conceptual hurdle in using the timed structures is that each timed structure may be named (using a string). The name string is passed into the Name terminal on the outer-left node of the Timed Structure. This name is then used as a reference to the timed structure when operating on it using the time structure VIs, which you will also learn about shortly. Similarly, timing sources and synchronization groups are also named (using a string) and referenced by their names.大概在使用定时结构时最大的概念上的障碍是每个定时结构可以被指定名称(用字符串). 名称字符串是传递到定时结构的左外节点的Name端子上的. 当使用定时结构的VI操作它时这个名称将被作为一个参考引用, 你将在不久就学习到. 同样地, 定时源和同步组也是被指定名称的(使用字符串)并通过它们的名称被引用.
OK, now you're ready for the nitty gritty details of the timed structures and VIs.
好了, 现在你就准备学习定时循环和VI的细支末节
The Timed Loop
定时循环
The Timed Loop (shown in Figure 6.60) executes one or more subdiagrams, or frames, sequentially each iteration of the loop at the period you specify. Use the Timed Loop when you want to develop VIs with multi-rate timing capabilities, precise timing, feedback on loop execution, timing characteristics that change dynamically, or several levels of execution priority. Right-click the structure border to add, delete, insert, and merge frames. If you use the Timed Loop in an FPGA VI, the loop executes one subdiagram at the same period as an FPGA clock.
定时循环(显示在图6.60)执行一到多个的子程序, 或是框架, 在循环的每次重复时以你指定的周期连续地执行. 使用定时循环一般是当你想要开发的VI是具有多速率定时能力的, 并且可精确定时, 循环执行反馈, 动态地改变定时特性, 或者几个执行优先级水平. 右击结构的边框来增加, 删除, 插入和合并框架等. 如果你在FPGA VI中使用定时循环, 循环以与FPGA时钟相同的周期执行一个子程序.
Figure 6.60. The Timed Loop structure
图6.60. 定时循环结构

The Timed Sequence
定时顺序
The Timed Sequence (shown in Figure 6.61) consists of one or more task subdiagrams, or frames, that execute sequentially. Use the Timed Sequence when you want to develop VIs with multi-rate timing capabilities, precise timing, execution feedback, timing characteristics that change dynamically, or several levels of execution priority. Right-click the structure border to add, delete, insert, and merge frames.
定时顺序(如图6.61)包含了一到多个的任务子程序, 或是框架, 连续地执行. 使用定时顺序一般是当你想要开发的VI是具有多速率定时能力的, 并且可精确定时, 执行反馈, 动态地改变定时特性, 或者几个执行优先级水平. 右击结构的边框来增加, 删除, 插入和合并框架等.
Figure 6.61. The Timed Sequence structure
图6.61. 定时顺序结构

The Timed Structure VIs
定时结构的VI
The following VIs are used to control timed structures and their timing sources (see Figures 6.626.66).
接下来的几个VI是用于控制定时结构和它们的定时源的(见图6.62到6.66).
Figure 6.62. Build Timing Source Hierarchy
图6.62. 创建时间源层次结构

Figure 6.63. Clear Timing Source
图6.63. 清除时间源
![]()
Figure 6.64. Create Timing Source
图6.64. 创建时间源

Figure 6.65. Stop Timed Structure
图6.65. 定时结构停止
![]()
Figure 6.66. Synchronize Timed Structure Starts
图6.66. 同步定时结构启动

Creates a hierarchy of timing sources based on the names you enter in timing source names. The hierarchy determines the order in which the timing sources start. The parent timing source does not start until after the timing sources in hierarchy name start. Use this VI when you have timing sources that have signal dependencies, such as DAQ counters routed to drive analog input connections. In such a case, the counter timing source acts as the parent.
创建一个基于你所输入给timing source names的名称的定时源层次架构. 该层次决定了定时源启动的次序. 直到在hierarchy name中的定时源启动之后, 该父级定时源都不会启动运行. 当你具有独立信号的定时源时, 就可以使用这个VI, 诸如DAQ的计数器连接来驱动模拟输入的接线. 在这样的情形下, 计数定时源就作为一个父级定时源.
Stops and deletes the timing source you created or specified for use by another resource. If the timing source is associated with a DAQmx task, the VI also clears the task. The VI cannot reuse a name until all Timed Loops attached to the timing source terminate.
停止并删除你所创建的或指定为别的资源所使用的定时源. 如果该定时源被指定依附于一个DAQmx任务, VI也将清除该任务. VI也不能够再使用一个名称直到所有依附于该定时源的定时循环终止.
Creates a timing source you use as the timing source in the Timed Loop. Each timing source has its own unit of timing and/or start time and does not start until the first Timed Loop that uses the timing source starts. You must manually select the polymorphic instance you want to use. (You can choose from either a 1kHz timing source or a 1 MHz timing source.)
创建一个定时源你用在定时循环中的定时源. 每一个定时源有它自己的定时单位和/或启动时间, 并且将不会启动, 直到使用该定时源的第一个定时循环启动. 你必须手动地选择你想要使用的多态场合.(你能够选择任意的1kHz或1 MHz的定时源.)
Stops the Timed Loop or Timed Sequence you enter in name. If you attempt to abort a running Timed Loop, the Timed Loop executes another iteration and returns Aborted in the Wakeup Reason output of the Left Data node.
停止你所输入在name端子中的定时循环或定时顺序结构. 如果你试图终止一个正在运行的定时循环, 该定时循环执行另一次重复并在左数据节点(Left Data node)的Wakeup Reason输出端子中返回”Aborted”
Synchronizes the start of Timed Loops or Timed Sequences you enter in timed structure names by adding the names to the synchronization group you specify in synchronization group name. All timed structures in a synchronization group wait until all the structures are ready to execute.
同步定时循环或定时顺序结构的启动, 这些结构就是在你所输入在timed structure names中的结构, 你通过增加名称给同步组, 而该同步组就是你所指定的synchronization group name. 所有在同步组中的定时结构将保持等待, 直到所有的结构都准备执行之后.




