Este é o primeiro artigo de uma série curta sobre a linguagem de programação gráfica G, usada pelo LabVIEW. Essa linguagem ainda não é muito popular - de acordo com o índice TIOBE de maio de 2020, o LabVIEW está no quadragésimo lugar exatamente entre Julia e Haskell. O LabVIEW Community Edition permite expandir significativamente a audiência de usuários (anteriormente era possível usar apenas a versão de teste e após 45 dias para aprender "de perto").
Bem, como disseram os excelentes Kernigan e Ritchie, "a única maneira de aprender uma nova linguagem de programação é começar a programar nela". É isso que faremos.
Na primeira parte, analisaremos os principais elementos do ambiente de desenvolvimento e desenharemos no diagrama de blocos nosso primeiro "Olá, mundo!"
![](https://habrastorage.org/webt/na/p-/ok/nap-ok4xh8rguy1jhhqyggagvz8.png)
O artigo do tutorial é destinado a quem vê o LabVIEW pela primeira vez. Sob o corte, cinquenta fotos, cerca de sete megabytes.
Introdução
Supõe-se que você já tenha concluído a instalação e ativação do LabVIEW NXG.
, " ". "" . C# ( , , ). , , LabVIEW "" . — LabVIEW .
, LabVIEW "", " " ("Virtual Instruments") VI. LabVIEW -, . # *.cs , LabVIEW VI ( LabVIEW 2020 *.vi, NXG — *.gvi). . — , , ( , ). , — , — (, ). , VI .
LabVIEW NXG :
![](https://habrastorage.org/webt/an/sm/tw/ansmtw_faktgvn1t3wnt9fm4thm.png)
, LabVIEW. , , "" LabVIEW, — NXG, NXG LabVIEW, NI , NXG .
![](https://habrastorage.org/webt/wj/qv/th/wjqvthpfkyhnsaerak7hvm5q5ok.png)
, NXG :
![](https://habrastorage.org/webt/ad/f8/if/adf8ifbcpkcx_mf4k5ctwklwury.png)
, File->New VI...:
![](https://habrastorage.org/webt/sw/7l/pk/sw7lpk_bvkcjbgtujfeqz9og2iu.png)
— . ( , , , ).
:
![](https://habrastorage.org/webt/ky/9u/it/ky9uitbd7d1n5xdptn8jwc4nucc.png)
(Navigation Pane), — (VI), (Palette), — , (Configuration Pane), .
(VI). VI — - (Block Diagram) (Front Panel). — Panel Diagram (Icon — , ).
-
-. LabVIEW — , - ? - . Diagram . :
![](https://habrastorage.org/webt/6k/jx/so/6kjxso5m2_ww6guzzf-exkyngfo.png)
", !"- , - , - :
Console.WriteLine("Hello World!");
? — , . , . , , # WPF. *.cs , — *.xaml , LabVIEW *.gvi .
, NXG, , C#/WPF — , (, .net , WPF — API).
C# - :
const string message = "Hello, Habr!";
MessageBox.Show(message);
C#, — . , MessageBox — , Show ( ).
LabVIEW. .
DataTypes :
![](https://habrastorage.org/webt/9m/lo/mf/9mlomfjyqngsrili0knisfz9db4.png)
:
![](https://habrastorage.org/webt/co/v0/gz/cov0gzs0j8zeuhsgzptp9huhxmm.png)
, ( , ).
-:
![](https://habrastorage.org/webt/j_/ai/ow/j_aiowsnx7kygekp-a-e1gozkc4.png)
, "User Interface":
![](https://habrastorage.org/webt/aj/jn/5t/ajjn5tovbaf4ng1jotipgftoklk.png)
-:
![](https://habrastorage.org/webt/bc/x0/6b/bcx06bkgguqee_fywq48vj950ty.png)
, ( , "magenta") — . , — . , (message) - , — , "OK". — , — . () ( true).
, — , ( , ), ( , ):
![](https://habrastorage.org/webt/nc/vw/as/ncvwas_rsxbn9shn7wndoy4llxk.png)
- ( "", ):
![](https://habrastorage.org/webt/_c/g7/on/_cg7oniznuq1wd3mrbkns_sa6u4.png)
( — — gif)
— , (Data Flow).
. . ("Wire") .
" ". , — , , .
, .
![](https://habrastorage.org/webt/vd/ur/4p/vdur4pzcgq7aw-uv_rtv9j8xaec.gif)
— . — .
( , , ):
![](https://habrastorage.org/webt/uw/6w/z1/uw6wz1ar8tso5cswnusbfhcv5ks.png)
? — — Run Execute this code:
![](https://habrastorage.org/webt/ke/j3/th/kej3thdpetggjt738--q0wacjto.png)
:
![](https://habrastorage.org/webt/u9/9n/yc/u99nycfn7s_qcdnqv9nf-jfrn7a.png)
"Ctrl+R" VI. , .
, , . LabVIEW , . , , , , :
![](https://habrastorage.org/webt/lv/xb/kn/lvxbknq_i39rlj5yxyp99v6w3pg.png)
" " , Run, "".
, , , :
![](https://habrastorage.org/webt/li/s5/hc/lis5hc06zd-uccz0wfdkziqhf9s.png)
:
![](https://habrastorage.org/webt/dd/zo/0l/ddzo0lu2fv73ceqtg7kexjl8hqi.gif)
.
.
: LabVIEW , Ctrl+C/Ctrl+V ( , Ctrl+C, , Ctrl+V), — , Ctrl ( ), . Shift , — . ( , — Ctrl):
![](https://habrastorage.org/webt/kw/nr/2p/kwnr2pjkqpnmgttu0bfwd9vbrh8.gif)
:
![](https://habrastorage.org/webt/x9/s2/8y/x9s28ypzxa8cpnuf8fweet_zzjk.png)
, . . , :
MessageBox.Show("");
MessageBox.Show("Test");
MessageBox.Show("Prüfung");
, ( , ""):
![](https://habrastorage.org/webt/hv/ig/bj/hvigbjzrfm0cku872jj34famgs8.gif)
LabVIEW :
![](https://habrastorage.org/webt/ih/le/uf/ihleufxrpx3q6zzr6dvlnodbdly.gif)
, ( ), , .
? , , .
![](https://habrastorage.org/webt/p0/m3/iy/p0m3iyyohpqxa35ooaeszv-q2du.png)
" " ( ). , , , " ?"
: . , , , .
, .
LabVIEW
. , , , , , :
![](https://habrastorage.org/webt/8e/pw/a-/8epwa-fytv47zjnsw3ovihvor0k.png)
, 1dg, 2dg . — , "One Button Dialog" "Dialog" "1dg" "". , , , Enter.
— Ctrl+Space ( ). "Quick Drop" . , -, , .
, , — "Show in Palette"
![](https://habrastorage.org/webt/_m/ui/5u/_mui5ugmgmhv6f-d5a8v0osj400.png)
, .
— , . , "Unplaced" ( ). "" LabVIEW ( Quick Drop ).
![](https://habrastorage.org/webt/lg/ur/ut/lgurutz6agwmtmeqxebcz5rvzec.png)
. "" ( Ctrl+Space, sc — ):
![](https://habrastorage.org/webt/uy/m9/qz/uym9qztleonfpywjf1mghbj58aa.gif)
, , , :
![](https://habrastorage.org/webt/-o/q2/u-/-oq2u-u_nspq5nqugsrojqsfali.png)
"" :
![](https://habrastorage.org/webt/go/gt/ks/gogtksptkvhpmy2t4td8yszlylk.gif)
: <Ctrl+>, "1dg", <>, , "Hello, Habr" <Ctrl+R>.
, :
![](https://habrastorage.org/webt/hp/8p/ti/hp8ptixx1k5aby54jyaco3wi21a.gif)
, , , :
![](https://habrastorage.org/webt/uh/qt/es/uhqtestwovstfhrwsqci84ejjc4.gif)
, " " — "" , .
, , , . , , — .
, — . LabVIEW , .
— , , :
![](https://habrastorage.org/webt/up/8q/7m/up8q7mjgilsama1btchssbhuq-w.png)
( ), :
:
Dock to node — "" , . , Terminals->Dock constants, , , :
![](https://habrastorage.org/webt/-e/lt/wl/-eltwlsw1y7e4dwf4q22ihj3rbm.png)
— ( "" — , ), . , ( ).
Show in Palette , .
Clean up wire "" "":
![](https://habrastorage.org/webt/vp/db/pk/vpdbpklz3elh46nxdl2iyl0hn9c.png)
Create branch — . :
![](https://habrastorage.org/webt/ez/76/dn/ez76dni7z55ymopxxcbxvhpua5m.png)
Delete Branch — . "Del", :
![](https://habrastorage.org/webt/6h/9b/3v/6h9b3v2xw6c2sppcdaj1xtm6asu.png)
, — , — , . . — , , — .
Create wire comment — :
![](https://habrastorage.org/webt/vi/eo/sn/vieosntjmsxsvtk_fgh9rdg1dio.png)
Insert Replace. , - , . — :
![](https://habrastorage.org/webt/pk/bw/g0/pkbwg06lkzujqzmooisclndpit8.gif)
Properties — . ( — , ):
![](https://habrastorage.org/webt/gz/co/pp/gzcoppibpcunw-xqcqjyoaflzzy.png)
:
Constant configuration , — , .
Display Format -> Show escape sequences :
![](https://habrastorage.org/webt/ft/uy/4e/ftuy4ecb50o6jsxp5413zgdbapi.png)
.
Visual style -> Show Label :
![](https://habrastorage.org/webt/o3/1w/w8/o31ww88nolcnyuwbfn61jjbh1wy.png)
, //, — . , — , . , — :
![](https://habrastorage.org/webt/sn/ny/aj/snnyaj8vmf6cas4bdv_fns-aeni.png)
, :
![](https://habrastorage.org/webt/jc/vs/wh/jcvswhaljmheeiqezntqrvyd9a4.png)
Layout -> Size to content , :
![](https://habrastorage.org/webt/zs/et/du/zsetduh7m8zglck4dixslvdxi9u.png)
, .
, "" , :
![](https://habrastorage.org/webt/3e/f0/mk/3ef0mksn_os5tu40psfam5trvyo.png)
, , , , ( , , :
![](https://habrastorage.org/webt/kj/ld/99/kjld99tpfq5b0-bxatrrpj5kwjy.png)
( Shift), ( ).
, .
— :
![](https://habrastorage.org/webt/kn/1p/45/kn1p45upbcad2thmb4twoarsf-e.png)
Ctrl+H. ( , , ).
"Hello, Habr!". :
![](https://habrastorage.org/webt/rv/xj/im/rvxjimgff6hrhoyf_aysyet4tia.png)
Um projeto foi criado para nós, por padrão, tudo é salvo em "Meus Documentos" - a pasta "LabVIEW Projects" será criada lá.
Pessoas curiosas podem olhar dentro do arquivo - existe um XML simples onde você pode ver nosso diagrama.
Fatia XML com gráfico <BlockDiagram Id="a44ad16c1aa64eb9940a6db1357f6f34">
<OneButtonDialog Bounds="230 236 40 40" Id="abd1e9094fb74fe3ae59249f61acaa0b" />
<Literal Bounds="100 236 100 15" DataType="String" Id="99b8849aac10420386a3c64b659755e8"
Label="e03893aa5f6948b4b8f028ffff4aaa45" xmlns="http://www.ni.com/MocCommon">
<p.Data>, !</p.Data>
<StringBehavior TextDisplayMode="Default" />
</Literal>
<NodeLabel AttachedTo="99b8849aac10420386a3c64b659755e8" Bounds="100 234 30 15"
Id="e03893aa5f6948b4b8f028ffff4aaa45" Visible="False"
xmlns="http://www.ni.com/PlatformFramework">
<p.Text>message</p.Text>
</NodeLabel>
<Wire Id="4e45a6a724704c38b808a29f3417ce9b"
Joints="N(99b8849aac10420386a3c64b659755e8:Out)|(200,237)
N(abd1e9094fb74fe3ae59249f61acaa0b:message)|(230,237)"
xmlns="http://www.ni.com/PlatformFramework" />
</BlockDiagram>
"" LabVIEW , , . , , , , .
Isso é tudo por hoje. Examinamos o diagrama de blocos, fizemos um programa simples, aprendemos os atalhos de teclado Ctrl + R, Ctrl + H, Ctrl + Space e nos acostumamos ao ambiente de desenvolvimento.
Na próxima lição, tocaremos no painel frontal e faremos algo um pouco mais útil - Noções básicas de trabalho com o painel frontal - Controles e indicadores