1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
|
//Allocation du tableau contenant les mesures
//-------------------------------------------
data = (double **)malloc((nb_pas_1+1)*sizeof(double *));
for (i=0;i<=nb_pas_1;i++)
data[i]=(double *)malloc((nb_pas_2+1)*sizeof(double));
//Initialisation du graph
CW3DGraphLib_CWPlot3DClearData (plotHandle, NULL);
//CW3DGraphLib__DCWGraph3DSetDefaultView (graphHandle, NULL);
CW3DGraphLib_CWPlot3DSetColorMapStyle (plotHandle, NULL, CW3DGraphLibConst_cwCustom);
CA_VariantSet1DArray (&vArray, CAVT_INT, 64, &couleur);
CW3DGraphLib_CWPlot3DSetColorMapColors (plotHandle, NULL, vArray);
CA_VariantSet1DArray (&vArray, CAVT_INT, 64, &values);
CW3DGraphLib_CWPlot3DSetColorMapValues (plotHandle, NULL, vArray);
CW3DGraphLib_CWPlot3DSetColorMapInterpolate (plotHandle, NULL, VTRUE);
CW3DGraphLib_CWPlot3DSetColorMapAutoScale (plotHandle, NULL, VTRUE);
CW3DGraphLib__DCWGraph3DGetAxes (graphHandle, NULL, &axesHandle);
CW3DGraphLib_CWAxes3DItem (axesHandle, NULL, CA_VariantInt(1),&axeHandle);
CW3DGraphLib_CWAxis3DSetMinMax (axeHandle, NULL, CA_VariantInt(0),CA_VariantInt(nb_pas_1));
CW3DGraphLib_CWAxes3DItem (axesHandle, NULL, CA_VariantInt(2),&axeHandle);
CW3DGraphLib_CWAxis3DSetMinMax (axeHandle, NULL, CA_VariantInt(0),CA_VariantInt(nb_pas_2));
// Balayage du rectangle fixé par les points: Pt1, Pt2 et Pt3
//-----------------------------------------------------------------------
pos_courante_x=pos[0][0],pos_courante_y=pos[1][0],pos_courante_z =pos[2][0] ;
sprintf(tampon,"mesure_xyz.txt");
fichier=fopen(tampon,"at");
fichierf=fopen("mesure_freq.txt","at");
fprintf(fichierf,"Freq(Hz)\t\t%s\n",field_comp_txt[field_comp]);
xml=fopen("mesure_xyz.xml", "at");
fprintf(xml,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
fprintf(xml, "<EmissionScan>\n");
fprintf(xml,"<Filename>mesure_xyz.xml</Filename> ");
fprintf(xml,"<Date>%s %dh-%dmn-%ds</Date>",DateStr(),h,mn,s);
fprintf(xml,"<Source>ESEO</Source>");
fprintf(xml,"<Copyright>This document is the property of ESEO</Copyright>");
fprintf(xml, "<Field_Component>%s</Field_Component>\n", field_comp_txt[field_comp]);
fprintf(xml, "<Setup><Config>\n<Att>%s</Att>\n<RefLevel>%s</RefLevel>\n<Rbw>%s</Rbw>\n<Span>%s</Span>\n</Config>\n",att,Ref_Lev,Res_Band,sp);
GetCtrlVal (panel,EMISSION_btn_LNA_60_dB,&val_LNA);
if(val_LNA==1)
fprintf(xml,"<Transducer>\n<Gain>60.0</Gain>\n</Transducer> ");
else
fprintf(xml,"<Transducer>\n<Gain>0.0</Gain>\n</Transducer>");
fprintf(xml, "</Setup>");
fprintf(xml, "<Data>\n");
fprintf(xml, "<Coordinates>Left-handed Cartesian</Coordinates>\n");
fprintf(xml, "<X0>%fmm</X0>\n",pos[0][0]);
fprintf(xml, "<Xstep>%fmm</Xstep>\n",pasX);
fprintf(xml, "<Xmax>%fmm</Xmax>\n",pos[0][0]+length_x);
fprintf(xml, "<Y0>%fmm</Y0>\n",pos[1][0]);
fprintf(xml, "<Ystep>%fmm</Ystep>\n",pasY);
fprintf(xml, "<Ymax>%fmm</Ymax>\n",pos[1][0]+length_y);
GetCtrlVal(panel, EMISSION_probe_dist, &probe_dist);
fprintf(xml, "<Z0>%fmm</Z0>\n", probe_dist);
fprintf(xml, "<Frequencies>\n<Unit>Hz</Unit>\n<List>");
for(k=0;k<nb_freq;k++)
fprintf(xml, "%e ", tab_freq[k]);
fprintf(xml, "\n</List>\n</Frequencies>\n");
fprintf(xml, "<Measurement>\n<Unit>dBm</Unit>\n<Unit_x>mm</Unit_x>\n<Unit_y>mm</Unit_y>\n<Unit_z>mm</Unit_z>\n");
fprintf(xml,"<List>\n");
for (i=0;i<=nb_pas_1;i++)
{//Boucle sur l'axe des X
for (j=0;j<=nb_pas_2;j++)
{//Boucle sur l'axe des Y
if (stop==1) //Fin du scan
{
//arret_deplacement();
//stop_controleur();
if (zero_span==0 && choix_analyseur==0)
{
sprintf(write_buffer,"CONTS;"); //single Sweep
gpibWrite(analyseur,write_buffer);
}
ibloc (analyseur); //Passage au mode "Local" (commande manuelle)
if (param_generateur==1)
{
if (val_gen==0)
ibloc (Marconi2031); //Passage au mode "Local" (commande manuelle)
else
ibloc (Anritsu_68347C); //Passage au mode "Local" (commande manuelle)
}
return 1;
}
if (j==0)
{
demande_vitesse(1,vitesse);
demande_vitesse(2,vitesse);
demande_vitesse(3,vitesse);
}
tabxy[0]=pos[0][0]+(pas2_x*i)+(pas1_x*j);
tabxy[1]=pos[1][0]+(pas2_y*i)+(pas1_y*j);
tabxy[2]=pos[2][0]+(pas2_z*i)+(pas1_z*j);
deplacement_pt1_pt2(pos_courante_x,pos_courante_y,pos_courante_z,tabxy[0],tabxy[1],tabxy[2]);
pos_courante_x=tabxy[0];
pos_courante_y=tabxy[1];
pos_courante_z=tabxy[2];
fprintf(fichier,"%f\t%f\t%f",tabxy[0],tabxy[1],probe_dist);
fprintf(xml,"%f\t%f\t%f\t",tabxy[0],tabxy[1],probe_dist);
//Boucle sur les fréquences
for (k=0;k<nb_freq;k++)
{
if (param_generateur==1)
{
if (val_gen==0) // Set Marconi 2031 parameters
{ //sprintf(write_buffer,":SOUR:FREQ:CW %e;",tab_freq[k]);
sprintf(write_buffer,"CFRQ:VALUE %eHZ; RFLV:VALUE %dDBM;ON\n",tab_freq[0],puissance);
gpibWrite(Marconi2031, write_buffer);
}
else
{ // Set Anritsu 68347C parameters
sprintf(write_buffer,"IMODE NORMAL;CFRQ:VALUE %eHZ; RFLV:VALUE %dDBM;ON\n",tab_freq[0],puissance);
gpibWrite(Anritsu_68347C, write_buffer);
}
}
if (choix_analyseur==0) // HP 8591A
{
sprintf(write_buffer,"CF %fHZ;",tab_freq[k]);
gpibWrite(analyseur,write_buffer);
}
if (choix_analyseur==1) // HP E4402B
{
sprintf(write_buffer,":SENS:FREQ:CENT %f HZ;",tab_freq[k]);
gpibWrite(analyseur,write_buffer);
}
if (choix_analyseur==2) // HP N9020A
{
sprintf(write_buffer,"FREQ:CENT %f HZ;",tab_freq[k]);
gpibWrite(analyseur,write_buffer);
sprintf(write_buffer,":FORMAT:DATA:REAL,32");
gpibWrite(analyseur,write_buffer);
}
Delay(0.6);
//Mesure avec HP 8591A
if (choix_analyseur==0 )
{
if (zero_span==0) //Lecture en zero span
{
// Delay(1);
gpibWrite(analyseur,"MKA?"); //Marker AMplitude
gpibRead(analyseur,read_buffer,2000);
}
else
{
sprintf(write_buffer,"TS;MKPK HI;MKA?"); //Peak high Amplitude
gpibWrite(analyseur,write_buffer);
Delay(0.6);
ibrda (analyseur, read_buffer, 2000);
/* while (!(ibsta & CMPL))
{
ibwait(analyseur,0);
ProcessSystemEvents ();
} */
}
}
else
{//Mesure avec HP E4404E & N9020A
if (zero_span==0) //Lecture en zero span
{
gpibWrite(analyseur,":CALC:MARK:Y?\n");
gpibRead(analyseur,read_buffer,2000);
}
else
{
sprintf(write_buffer,":INIT:IMM;*WAI;:CALC:MARK:MAX;:CALC:MARK:Y?;");
gpibRead(analyseur,read_buffer,2000);
Delay(0.6);
ibrda (analyseur, read_buffer, 2000);
/* while (!(ibsta & CMPL))
{
ibwait(analyseur,0);
ProcessSystemEvents ();
} */
}
}
// prise en compte du LNA_60dB
if (val_LNA==0)
champ[k]=atof(read_buffer);
else
champ[k]=atof(read_buffer)-60;
data[i][j]=champ[k];
fprintf(fichier,"\t%e",champ[k]);
if (i==0 && j==0)
fprintf(fichierf,"%f\t%e\n",tab_freq[k],champ[k]);
// sauvegarde des coordonnées au format XML
fprintf(xml,"%e\n",champ[k]);
fflush(fichier);
fflush(fichierf);
fflush(xml);
compteur++;
//Mise à jour de la barre de progression
pourcentage= ((float)compteur/((nb_freq)*(nb_pas_x+1)*(nb_pas_y+1)))*100;
SetCtrlVal(panel,EMISSION_MESURESLIDE,pourcentage);
} // Fin de la boucle des fréquences
fprintf(fichier,"\n");
} // Fin de la boucle sur Y
//Update du graph à la fin de chaque ligne de scan
//--------------------------------------------------
if (i>0)
{
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = i+1;
rgsabound[1].lLbound = 0; //limite inférieure du tableau (array)
rgsabound[1].cElements = nb_pas_2+1; // Nbr d'élément dans la dimension
psa = SafeArrayCreate(VT_R8, 2, rgsabound); // Création d'un SAFEARRAY (tableau) de variants
// VT_R8 -> double ; Dimension=2 (X,Y)
// Remplissage du tableau. // rgsabound->limites du tableau
for (ii=0;ii<=i;ii++)
{
for (jj=0;jj<=nb_pas_2;jj++)
{
ix[0]=ii;
ix[1]=jj;
SafeArrayPutElement(psa, ix, &data[ii][jj]);
}
}
CA_VariantSetSafeArray (&vArray, CAVT_DOUBLE, psa);
CW3DGraphLib_CWPlot3DPlot3DSimpleSurface (plotHandle, NULL, vArray,CA_DEFAULT_VAL);
SafeArrayDestroy(psa); //libérez les ressources associées au VARIANT crée par SafearrayCreate
}
} // Fin de la boucle sur X
fclose(fichier);
fclose(fichierf);
fprintf(xml,"</List>\n");
fprintf(xml, "</Measurement>\n");
fprintf(xml, "</Data>\n");
fprintf(xml, "</EmissionScan>\n");
fclose(xml);
// Retour à la position de départ
demande_vitesse(1,35);
demande_vitesse(2,35);
demande_vitesse(3,35);
//deplacement_pt1_pt2(pos_courante_x,pos_courante_y,pos_courante_z,pos[0][0],pos[1][0],pos[2][0]);
deplacement_pt1_pt2(pos_courante_x,pos_courante_y,pos_courante_z,xo,yo,zo);
//deplacement_to_xyz(xo,yo,zo);
arret_deplacement();
//Libération du tableau contenant les mesures
//--------------------------------------------
for (i=0;i<=nb_pas_1;i++)
free(data[i]);
free(data); |
Partager