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 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
| use Tk;
use Win32::SerialPort;# qw( :STAT 0.19 );
use Tk::Table;
my $nombre = 1;
#Creation du main (fenetre principale)
my $main = MainWindow->new( -title => 'Fenetre', );
$main->minsize( 800, 600 );
#Ajout d'un bouton qui permettra d'afficher les données recueillies
my $Bouton0 = $main->Button(
-text => 'Start',
-font => '{Garamond} 12',
-width=> 5,
-height=> 2,
-command => \&traitement1
)->place(-relx => 0.08, -rely => 0.4 );
#ajout du tableau des donnees
my $table_frame = $main->Frame()->pack();
$table = $table_frame->Table(-columns => 2,
-rows => 10,
-relief => 'raised');
#ajout du tableau1 des donnees
my $table_frame1 = $main->Frame()->pack();
$table1 = $table_frame1->Table(-columns => 5,
-rows => 10,
-relief => 'raised');
#ajout du tableau2 des donnees
my $table_frame2 = $main->Frame()->pack();
$table2 = $table_frame2->Table(-columns => 5,
-rows => 10,
-relief => 'raised');
#ajout du tableau3 des donnees
my $table_frame3 = $main->Frame()->pack();
$table3 = $table_frame3->Table(-columns => 5,
-rows => 10,
-relief => 'raised');
$tmp_label = $table->Label(-text => "Acquisition" , -width => 45, -relief =>'raised');
$table->put(0, 0, $tmp_label);
$tmp_label = $table->Label(-text => "Degres1" , -width => 45, -relief =>'raised');
$table->put(1, 0, $tmp_label);
$tmp_label = $table->Label(-text => "Degres2" , -width => 45, -relief =>'raised');
$table->put(2, 0, $tmp_label);
$tmp_label = $table->Label(-text => "2D ou 3D", -width => 45, -relief =>'raised');
$table->put(3, 0, $tmp_label);
$tmp_label = $table->Label(-text => "Fix", -width => 45, -relief =>'raised');
$table->put(4, 0, $tmp_label);
$tmp_label = $table->Label(-text => "P", -width => 45, -relief =>'raised');
$table->put(5, 0, $tmp_label);
$tmp_label = $table->Label(-text => "H", -width => 45, -relief =>'raised');
$table->put(6, 0, $tmp_label);
$tmp_label = $table->Label(-text => "V", -width => 45, -relief =>'raised');
$table->put(7, 0, $tmp_label);
$tmp_label = $table->Label(-text => "Trames ", -width => 45, -relief =>'raised');
$table->put(8, 0, $tmp_label);
$tmp_label = $table->Label(-text => "SV", -width => 45, -relief =>'raised');
$table->put(9, 0, $tmp_label);
$table->pack();
$tmp_label1 = $table1->Label(-text => "Numero", -width => 30, -relief =>'raised');
$table1->put(0, 0, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "1", -width => 10, -relief =>'raised');
$table1->put(0, 1, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "2 ", -width => 10, -relief =>'raised');
$table1->put(0, 2, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "3 ", -width => 10, -relief =>'raised');
$table1->put(0, 3, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "4", -width => 10, -relief =>'raised');
$table1->put(0, 4, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "Numero d'identification", -width => 30, -relief =>'raised');
$table1->put(1, 0, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "Elevation", -width => 30, -relief =>'raised');
$table1->put(2, 0, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "Azimuth", -width => 30, -relief =>'raised');
$table1->put(3, 0, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "Force", -width => 30, -relief =>'raised');
$table1->put(4, 0, $tmp_label1);
$table1->pack();
$tmp_label2 = $table2->Label(-text => "Numero", -width => 30, -relief =>'raised');
$table2->put(0, 0, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "5", -width => 10, -relief =>'raised');
$table2->put(0, 1, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "6 ", -width => 10, -relief =>'raised');
$table2->put(0, 2, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "7 ", -width => 10, -relief =>'raised');
$table2->put(0, 3, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "8", -width => 10, -relief =>'raised');
$table2->put(0, 4, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "Numero d'identification", -width => 30, -relief =>'raised');
$table2->put(1, 0, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "Elevation", -width => 30, -relief =>'raised');
$table2->put(2, 0, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "Azimuth", -width => 30, -relief =>'raised');
$table2->put(3, 0, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "Force", -width => 30, -relief =>'raised');
$table2->put(4, 0, $tmp_label2);
$table2->pack();
$tmp_label3 = $table3->Label(-text => "Numero", -width => 30, -relief =>'raised');
$table3->put(0, 0, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "9", -width => 10, -relief =>'raised');
$table3->put(0, 1, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "10 ", -width => 10, -relief =>'raised');
$table3->put(0, 2, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "11", -width => 10, -relief =>'raised');
$table3->put(0, 3, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "12", -width => 10, -relief =>'raised');
$table3->put(0, 4, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "Numero d'identification", -width => 30, -relief =>'raised');
$table3->put(1, 0, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "Elevation", -width => 30, -relief =>'raised');
$table3->put(2, 0, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "Azimuth", -width => 30, -relief =>'raised');
$table3->put(3, 0, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "Force", -width => 30, -relief =>'raised');
$table3->put(4, 0, $tmp_label3);
$table3->pack();
tableau();
#affichage et position d affichage
$table_frame->place(-relx => 0.2, -rely => 0.05 );
$table_frame1->place(-relx => 0.2, -rely => 0.4 );
$table_frame2->place(-relx => 0.2, -rely => 0.6 );
$table_frame3->place(-relx => 0.2, -rely => 0.8);
#Fonction de traitement des options effectuées
sub traitement1
{
#Condition pour ouvrir le port com, ne peut s ouvrir s il y est deja ouvert
$PortObj = new Win32::SerialPort ("COM5") or die "impossible d'ouvrir $nbportcom\n";
$PortObj->databits(8);
$PortObj->baudrate(4800);
$PortObj->parity("none");
$PortObj->stopbits(1);
$PortObj->handshake("none");
$PortObj->buffers(4096, 4096);
$PortObj->read_interval(400); # max time between read char (milliseconds)
$PortObj->read_char_time(20); # avg time between read char
$PortObj->read_const_time(2000); # total = (avg * bytes) + const
$PortObj->write_settings || undef $PortObj;
$InBytes=4096;
#appel du traitement 2
traitement2();
}
sub traitement2
{
#Lecture du port com
($count_in, $string_in) = $PortObj->read($InBytes);
if ($string_in =~ /\$/)
{
@tab=split (" ",$string_in);
my $size = @tab;
#condition pour les trames de 9 lignes
if ($size == 9)
{
@tab3=split (",",$tab[0]);
@tab4=split (",",$tab[1]);
@tab5=split (",",$tab[2]);
@tab6=split (",",$tab[3]);
@tab7=split (",",$tab[4]);
#Appel des fonctions
traitment1();
tableau();
}
}
#Raffraichissement de la fenetre principale
$main->update;
#Appel du traitement 2
traitement2();
}
sub traitment1
{
#retrait des valeurs checksum
@tabVDOP=split (/\*/,$tab4[17]);
@tabforce1=split (/\*/,$tab5[7]);
@tabforce2=split (/\*/,$tab5[11]);
@tabforce3=split (/\*/,$tab5[15]);
@tabforce4=split (/\*/,$tab5[19]);
@tabforce5=split (/\*/,$tab6[7]);
@tabforce6=split (/\*/,$tab6[11]);
@tabforce7=split (/\*/,$tab6[15]);
@tabforce8=split (/\*/,$tab6[19]);
@tabforce9=split (/\*/,$tab7[7]);
@tabforce10=split (/\*/,$tab7[11]);
@tabforce11=split (/\*/,$tab7[15]);
@tabforce12=split (/\*/,$tab7[19]);
}
sub tableau
{
#Creation du tableau
$tmp_label = $table->Label(-text => "$tab3[1] ", -width => 15, -background => 'white', -relief =>"groove");
$table->put(0, 1, $tmp_label);
$tmp_label = $table->Label(-text => "$tab3[2] $tab3[3]", -width => 15, -background => 'white', -relief =>"groove");
$table->put(1, 1, $tmp_label);
$tmp_label = $table->Label(-text => "$tab3[4] $tab3[5]", -width => 15, -background => 'white', -relief =>"groove");
$table->put(2, 1, $tmp_label);
$tmp_label = $table->Label(-text => "$tab4[1]", -width => 15, -background => 'white', -relief =>"groove");
$table->put(3, 1, $tmp_label);
$tmp_label = $table->Label(-text => "$tab4[2] ", -width => 15, -background => 'white', -relief =>"groove");
$table->put(4, 1, $tmp_label);
$tmp_label = $table->Label(-text => "$tab4[15] ", -width => 15, -background => 'white', -relief =>"groove");
$table->put(5, 1, $tmp_label);
$tmp_label = $table->Label(-text => "$tab4[16] ", -width => 15, -background => 'white', -relief =>"groove");
$table->put(6, 1, $tmp_label);
$tmp_label = $table->Label(-text => "$tabVDOP[0] ", -width => 15, -background => 'white', -relief =>"groove");
$table->put(7, 1, $tmp_label);
$tmp_label = $table->Label(-text => "$tab5[1] ", -width => 15, -background => 'white', -relief =>"groove");
$table->put(8, 1, $tmp_label);
$tmp_label = $table->Label(-text => "$tab5[3] ", -width => 15, -background => 'white', -relief =>"groove");
$table->put(9, 1, $tmp_label);
$table->pack();
$tmp_label1 = $table1->Label(-text => "$tab5[4]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(1, 1, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tab5[8]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(1, 2, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tab5[12]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(1, 3, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tab5[16]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(1, 4, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tab5[5]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(2, 1, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tab5[9]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(2, 2, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tab5[13]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(2, 3, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tab5[17]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(2, 4, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tab5[6]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(3, 1, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tab5[10]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(3, 2, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tab5[14]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(3, 3, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tab5[18]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(3, 4, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tabforce1[0]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(4, 1, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tabforce2[0]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(4, 2, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tabforce3[0]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(4, 3, $tmp_label1);
$tmp_label1 = $table1->Label(-text => "$tabforce4[0]", -width => 10, -background => 'white', -relief =>"groove");
$table1->put(4, 4, $tmp_label1);
$table1->pack();
$tmp_label2 = $table2->Label(-text => "$tab6[4]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(1, 1, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tab6[8]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(1, 2, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tab6[12]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(1, 3, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tab6[16]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(1, 4, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tab6[5]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(2, 1, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tab6[9]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(2, 2, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tab6[13]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(2, 3, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tab6[17]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(2, 4, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tab6[6]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(3, 1, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tab6[10]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(3, 2, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tab6[14]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(3, 3, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tab6[18]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(3, 4, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tabforce5[0]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(4, 1, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tabforce6[0]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(4, 2, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tabforce7[0]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(4, 3, $tmp_label2);
$tmp_label2 = $table2->Label(-text => "$tabforce8[0]", -width => 10, -background => 'white', -relief =>"groove");
$table2->put(4, 4, $tmp_label2);
$table2->pack();
$tmp_label3 = $table3->Label(-text => "$tab7[4]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(1, 1, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tab7[8]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(1, 2, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tab7[12]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(1, 3, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tab7[16]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(1, 4, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tab7[5]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(2, 1, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tab7[9]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(2, 2, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tab7[13]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(2, 3, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tab7[17]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(2, 4, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tab7[6]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(3, 1, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tab7[10]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(3, 2, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tab7[14]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(3, 3, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tab7[18]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(3, 4, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tabforce9[0]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(4, 1, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tabforce10[0]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(4, 2, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tabforce11[0]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(4, 3, $tmp_label3);
$tmp_label3 = $table3->Label(-text => "$tabforce12[0]", -width => 10, -background => 'white', -relief =>"groove");
$table3->put(4, 4, $tmp_label3);
$table3->pack();
}
MainLoop; |
Partager