Académique Documents
Professionnel Documents
Culture Documents
Programare Modular
SUBIECTE A. Panoul Icoan i Conector B. SubVI-uri C. Inserarea subVI-ului ntr-un VI de nivel superior D. Crearea unui SubVI dintr-o seciune a unui VI
The power of LabVIEW lies in the hierarchical nature of the VI. After you create a VI, you can use it on the block diagram of another VI. There is no limit on the number of layers in the hierarchy. Using modular programming helps you manage changes and debug the block diagram quickly. The upper right corner of the front panel and block diagram displays the icon for the VI. This icon is the same as the icon that appears when you place the VI on the block diagram. After you build a front panel and block diagram, build the icon and the connector pane so you can use the VI as a subVI. Every VI displays an icon, such as the one shown at left, in the upper right corner of the front panel and block diagram windows. An icon is a graphical representation of a VI. It can contain text, images, or a combination of both. If you use a VI as a subVI, the icon identifies the subVI on the block diagram of the VI. You You can can double-click double-click the the icon to customize or edit it.
Use the tools on the left side of the Icon Editor dialog box to create the icon design in the editing area. The normal size image of the icon appears in the appropriate box to the right of the editing area, as shown in the following dialog box. You also need to build a connector pane, shown at left, to use the VI as a subVI. The connector pane is a set of terminals that correspond to the controls and indicators of that VI, similar to the parameter list of a function call in text-based programming languages. The connector pane defines the inputs and outputs you can wire to the VI so you can use it as a subVI. A connector pane receives data at its input terminals and passes the data to the block diagram code through the front panel controls and receives the results at its output terminals from the front panel indicators.
A. Icoana i Conectorul
Fiecare VI afiaz o icoan n colul din dreapta sus a PF i a DB. O icoan este o reprezentare grafic a unui VI. Ea poate conine text, imagini sau combinaii de ambele. Icoana identific subVI-ul dintr-o DB a unui VI.
ICOANA
Terminale
Sunt mai multe modele de conectori. Printr-un clic-dreapta n conector se poate selecta modelul din meniul Patterns. Se pot atribui controalelor i indicatoarelor din PF, terminalelor conectorului.
Crearea Icoanei
Icon: graphical representation of a VI Clic-dreapta n icoana DB sau a PF i selectare Edit Icon Default Icon Create a custom icon
In order to open the Icon Editor, double-click on the icon in the upper right corner of your VI.
Crearea Conectorului
Most SubVIs will have input and output connectors. This is similar with functions or methods in other programming language that have input arguments and an output/result. In order to create connectors, Right-click on the icon in the upper right corner of the VI and select Show Connector.
You may select different Patterns, i.e., how many input and output connectors you need.
Make sure you select a Pattern with enough connectors even if you dont need all the connectors at the moment. I recommend that you standardize on the pattern in the Figure above.
Asignarea Terminalelor
B. SubVI-uri
As you create VIs, you might find that you perform a certain operation frequently. Consider using subVIs or loops to perform that operation repetitively. For example, the following block diagram contains two identical operations.
You can create a subVI that performs that operation and call the subVI twice. The following example calls the Temperature VI as a subVI twice on its block diagram and functions the same as the previous block diagram.You also can reuse the subVI in other VIs.
Dup construirea unui VI i crearea icoanei i conectorului su, acesta poate fi utilizat ntr-un alt VI. Un VI dintr-un alt VI se numeste subVI. Un subVI corespunde unei subrutine ntr-un limbaj de programare pe baz de text. Avantaje Modular Uor de reparat Nu trebuie recreat codul Necesit mai puin memorie
The following pseudo-code and block diagrams demonstrate the analogy between subVIs and subroutines.
Function Pseudo Code
function average (in1, in2, out) { out = (in1 + in2)/2.0; }
Noduri n DB
SubVI-urile din DB se pot vedea ca icoane sau ca noduri expandabile. Cele dou moduri, depind de preferinele utilizatorului, nemodificndu-se funcionalitatea subVI-ului
Exerciiu: Convert C to F VI Obiectiv: Crearea icoanei i a conectorului pentru VI-ul Convert C to F, n scopul utilizrii VI-ului ca subVI.
Exercise: Thermometer VI Objective: To build a VI using the Convert C to F subVI to read a temperature from the DAQ Signal Accessory in Celsius or Fahrenheit.
Summary
VIs can be used as subVIs after you make the icon and connector Icon created using Icon Editor Connector defined by choosing number of terminals Load subVIs using the Select a VI option in the All Functions palette or dragging the icon onto a new diagram Online help for subVIs using the Show Context Help option Descriptions document functionality Use Create SubVI feature to easily modularize the block diagram