Guide d'évaluation LabWindows/CVI - ElectronicsAndBooks
Guide d'évaluation LabWindows/CVI - ElectronicsAndBooks
Guide d'évaluation LabWindows/CVI - ElectronicsAndBooks
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapitre 3 Générer le code du programme avec CodeBuilder<br />
Afficher le code source<br />
6. Cliquez sur OK. CodeBuilder construit le code source de votre<br />
programme. Une nouvelle fenêtre d’édition de Source apparaît avec<br />
le nouveau code source.<br />
7. Sélectionnez File»Save dans la fenêtre d’édition de Source, puis<br />
nommez le fichier source myfirst.c.<br />
Le code suivant devrait s’afficher dans la fenêtre d’édition de Source,<br />
comme ci-dessous. Il devrait contenir les trois fonctions principales<br />
suivantes : la fonction main, la fonction AcquireData et la fonction<br />
Shutdown. Ce sont l’Éditeur d’interface utilisateur et CodeBuilder qui<br />
vous ont servi à créer ces fonctions.<br />
#include /* needed if linking executable in external compiler; harmless otherwise<br />
*/<br />
#include <br />
#include "myfirst.h"<br />
static int panelHandle;<br />
int main (int argc, char *argv[])<br />
{<br />
if (Init<strong>CVI</strong>RTE (0, argv, 0) == 0)/* needed if linking executable in external compiler;<br />
harmless otherwise */<br />
return (-1);/* out of memory */<br />
if ((panelHandle = LoadPanel (0, "myfirst.uir", PANEL)) < 0)<br />
return -1;<br />
DisplayPanel (panelHandle);<br />
RunUserInterface ();<br />
return 0;<br />
}<br />
int <strong>CVI</strong>CALLBACK AcquireData (int panel, int control, int event,<br />
void *callbackData, int eventData1, int eventData2)<br />
{<br />
switch (event) {<br />
case EVENT_COMMIT:<br />
break;<br />
}<br />
return 0;<br />
}<br />
int <strong>CVI</strong>CALLBACK Shutdown (int panel, int control, int event,<br />
void *callbackData, int eventData1, int eventData2)<br />
{<br />
switch (event) {<br />
<strong>Guide</strong> d’évaluation <strong>LabWindows</strong>/<strong>CVI</strong> 3-4 © National Instruments Corporation