1 | #include <QtGui> |
---|
2 | #include "baoqt.h" |
---|
3 | #include "baocontrol.h" |
---|
4 | #include "ui_baoqt.h" |
---|
5 | |
---|
6 | |
---|
7 | BAOqt::BAOqt(QWidget *parent) : |
---|
8 | QDialog(parent), |
---|
9 | Server2(STELLARIUM_PORT), |
---|
10 | ui(new Ui::BAOqt) |
---|
11 | { |
---|
12 | |
---|
13 | QPoint pointPos; |
---|
14 | |
---|
15 | RechercheOptimisation = false; |
---|
16 | |
---|
17 | //Stellarium |
---|
18 | |
---|
19 | last_pos[0] = current_pos[0] = desired_pos[0] = 1.0; |
---|
20 | last_pos[1] = current_pos[1] = desired_pos[1] = 0.0; |
---|
21 | last_pos[2] = current_pos[2] = desired_pos[2] = 0.0; |
---|
22 | next_pos_time = -0x8000000000000000LL; |
---|
23 | |
---|
24 | bao = new BAOcontrol(); |
---|
25 | |
---|
26 | dialog = new QDialog; |
---|
27 | |
---|
28 | ui->setupUi(dialog); |
---|
29 | |
---|
30 | for(int i=0; i<4; i++) { |
---|
31 | leds.append(new QLedIndicator(this)); |
---|
32 | } |
---|
33 | |
---|
34 | for(int i=0; i<leds.size(); i++) { |
---|
35 | ui->layoutIndependent->addWidget(leds[i]); |
---|
36 | } |
---|
37 | |
---|
38 | pointPos.setX(1); |
---|
39 | pointPos.setY(1); |
---|
40 | |
---|
41 | dialog->move(pointPos); |
---|
42 | |
---|
43 | dialog->show(); |
---|
44 | |
---|
45 | |
---|
46 | connect(ui->pushButtonPark, SIGNAL(clicked()), this, SLOT(on_pushButtonPark_clicked())); |
---|
47 | |
---|
48 | connect(ui->pushButtonCommande, SIGNAL(clicked()), this, SLOT(on_pushButtonCommande_clicked())); |
---|
49 | |
---|
50 | connect(ui->pushButtonAbort, SIGNAL(clicked()), this, SLOT(on_pushButtonAbort_clicked())); |
---|
51 | |
---|
52 | connect(ui->pushButtonAzM, SIGNAL(clicked()), this, SLOT(on_pushButtonAzM_clicked())); |
---|
53 | |
---|
54 | connect(ui->pushButtonAzP, SIGNAL(clicked()), this, SLOT(on_pushButtonAzP_clicked())); |
---|
55 | |
---|
56 | connect(ui->pushButtonHaP, SIGNAL(clicked()), this, SLOT(on_pushButtonHaP_clicked())); |
---|
57 | |
---|
58 | connect(ui->pushButtonHaM, SIGNAL(clicked()), this, SLOT(on_pushButtonHaM_clicked())); |
---|
59 | |
---|
60 | connect(ui->pushButton1x, SIGNAL(clicked()), this, SLOT(on_pushButton1x_clicked())); |
---|
61 | |
---|
62 | connect(ui->pushButton10x, SIGNAL(clicked()), this, SLOT(on_pushButton10x_clicked())); |
---|
63 | |
---|
64 | connect(ui->pushButtonIP, SIGNAL(clicked()), this, SLOT(on_pushButtonIP_clicked())); |
---|
65 | |
---|
66 | connect(ui->pushButtonChoisir, SIGNAL(clicked()), this, SLOT(on_pushButtonChoisir_clicked())); |
---|
67 | |
---|
68 | connect(ui->pushButtonSelectionner, SIGNAL(clicked()), this, SLOT(on_pushButtonSelectionner_clicked())); |
---|
69 | |
---|
70 | connect(ui->pushButtonValider, SIGNAL(clicked()), this, SLOT(on_pushButtonValider_clicked())); |
---|
71 | |
---|
72 | connect(ui->pushButtonSauvegarder, SIGNAL(clicked()), this, SLOT(on_pushButtonSauvegarder_clicked())); |
---|
73 | |
---|
74 | connect(ui->pushButtonReset, SIGNAL(clicked()), this, SLOT(on_pushButtonReset_clicked())); |
---|
75 | |
---|
76 | connect(ui->pushButtonListe, SIGNAL(clicked()), this, SLOT(on_pushButtonListe_clicked())); |
---|
77 | |
---|
78 | connect(ui->pushButtonMap, SIGNAL(clicked()), this, SLOT(on_pushButtonMap_clicked())); |
---|
79 | |
---|
80 | connect(ui->pushButton1pt, SIGNAL(clicked()), this, SLOT(on_pushButton1pt_clicked())); |
---|
81 | |
---|
82 | connect(ui->pushButtonGoto, SIGNAL(clicked()), this, SLOT(on_pushButtonGoto_clicked())); |
---|
83 | |
---|
84 | connect(ui->pushButtonTo00, SIGNAL(clicked()), this, SLOT(on_pushButtonTo00_clicked())); |
---|
85 | |
---|
86 | connect(ui->pushButtonScript, SIGNAL(clicked()), this, SLOT(on_pushButtonScript_clicked())); |
---|
87 | |
---|
88 | connect(ui->pushButtonCalculMatrices, SIGNAL(clicked()), this, SLOT(on_pushButtonCalculMatrices_clicked())); |
---|
89 | |
---|
90 | connect(ui->pushButtonOptGeom, SIGNAL(clicked()), this, SLOT(on_pushButtonOptGeom_clicked())); |
---|
91 | |
---|
92 | connect(ui->pushButtonRetryGoto, SIGNAL(clicked()), this, SLOT(on_pushButtonRetryGoto_clicked())); |
---|
93 | |
---|
94 | |
---|
95 | |
---|
96 | #ifdef JOYSTICK |
---|
97 | |
---|
98 | joystick = new Joystick(); |
---|
99 | |
---|
100 | if (joystick) |
---|
101 | { |
---|
102 | if (!joystick->init()) |
---|
103 | { |
---|
104 | delete joystick; |
---|
105 | |
---|
106 | joystick = NULL; |
---|
107 | |
---|
108 | QMessageBox::information(this, tr("Jostick"), tr("Joystick inaccessible. Verifiez que le recepteur est bien branche sur un port USB.")); |
---|
109 | } |
---|
110 | } |
---|
111 | |
---|
112 | #endif |
---|
113 | |
---|
114 | //ui->lineEditIP->setText("127.0.0.1"); |
---|
115 | ui->lineEditIP->setText("134.158.88.199"); |
---|
116 | |
---|
117 | ui->lineEdit_2->setText((QString("BAORadio, LAL, version ").append(VERSION)).toStdString().c_str()); |
---|
118 | |
---|
119 | // On laisse le temps au serveur de Stellarium de démarrer dans de bonnes conditions |
---|
120 | |
---|
121 | sleep(1); |
---|
122 | |
---|
123 | //Timer |
---|
124 | |
---|
125 | DisableButtons(true); |
---|
126 | |
---|
127 | ui->pushButton1x->setDown(false); |
---|
128 | |
---|
129 | ui->pushButton10x->setDown(true); |
---|
130 | |
---|
131 | timer = new QTimer(this); |
---|
132 | |
---|
133 | connect(timer, SIGNAL(timeout()), this, SLOT(updateCaption())); |
---|
134 | |
---|
135 | timer->start(100); |
---|
136 | } |
---|
137 | |
---|
138 | BAOqt::~BAOqt() |
---|
139 | { |
---|
140 | close(); |
---|
141 | |
---|
142 | timer->stop(); |
---|
143 | |
---|
144 | delete timer; |
---|
145 | |
---|
146 | delete ui; |
---|
147 | delete dialog; |
---|
148 | delete bao; |
---|
149 | |
---|
150 | #ifdef JOYSTICK |
---|
151 | if (joystick) |
---|
152 | { |
---|
153 | joystick->close(); |
---|
154 | |
---|
155 | delete joystick; |
---|
156 | } |
---|
157 | #endif |
---|
158 | |
---|
159 | |
---|
160 | } |
---|
161 | |
---|
162 | |
---|
163 | void BAOqt::step(long long int timeout_micros) |
---|
164 | { |
---|
165 | if (last_pos[0]!=current_pos[0] || last_pos[1]!=current_pos[1] || last_pos[2]!=current_pos[2]) |
---|
166 | { |
---|
167 | current_pos[0] = desired_pos[0]; |
---|
168 | current_pos[1] = desired_pos[1]; |
---|
169 | current_pos[2] = desired_pos[2]; |
---|
170 | |
---|
171 | const double ra = atan2(current_pos[1],current_pos[0]); |
---|
172 | const double dec = atan2(current_pos[2], |
---|
173 | sqrt(current_pos[0]*current_pos[0]+current_pos[1]*current_pos[1])); |
---|
174 | |
---|
175 | // On passe les coordonnées aux antennes |
---|
176 | |
---|
177 | ui->lineEditEtoileSelectionneeAD->setText(QString(DHMS(VerifAngle(ra)*180.0/M_PI, true).c_str())); |
---|
178 | ui->lineEditEtoileSelectionneeDec->setText(QString(DHMS(dec*180.0/M_PI, false).c_str())); |
---|
179 | |
---|
180 | bao->Goto(DHMS(VerifAngle(ra)*180.0/M_PI, true), DHMS(dec*180.0/M_PI, false), bao->Transit, false); |
---|
181 | |
---|
182 | last_pos[0] = current_pos[0]; |
---|
183 | last_pos[1] = current_pos[1]; |
---|
184 | last_pos[2] = current_pos[2]; |
---|
185 | } |
---|
186 | |
---|
187 | Server2::step(timeout_micros); |
---|
188 | } |
---|
189 | |
---|
190 | void BAOqt::gotoReceived(unsigned int ra_int, int dec_int) |
---|
191 | { |
---|
192 | const double ra = ra_int*(M_PI/(unsigned int)0x80000000); |
---|
193 | const double dec = dec_int*(M_PI/(unsigned int)0x80000000); |
---|
194 | const double cdec = cos(dec); |
---|
195 | |
---|
196 | desired_pos[0] = cos(ra)*cdec; |
---|
197 | desired_pos[1] = sin(ra)*cdec; |
---|
198 | desired_pos[2] = sin(dec); |
---|
199 | |
---|
200 | last_pos[0] = -1000000L; |
---|
201 | } |
---|
202 | |
---|
203 | void BAOqt::DisableButtons(bool b) |
---|
204 | { |
---|
205 | RechercheOptimisation = false; |
---|
206 | |
---|
207 | ui->pushButtonChoisir->setDisabled(b); |
---|
208 | |
---|
209 | ui->pushButtonSelectionner->setDisabled(b); |
---|
210 | |
---|
211 | ui->pushButtonValider->setDisabled(b); |
---|
212 | |
---|
213 | ui->pushButtonSauvegarder->setDisabled(b); |
---|
214 | |
---|
215 | ui->pushButtonReset->setDisabled(b); |
---|
216 | |
---|
217 | ui->pushButtonListe->setDisabled(b); |
---|
218 | |
---|
219 | ui->pushButtonMap->setDisabled(b); |
---|
220 | |
---|
221 | ui->pushButton1pt->setDisabled(b); |
---|
222 | |
---|
223 | ui->pushButtonCalculMatrices->setDisabled(b); |
---|
224 | |
---|
225 | ui->pushButtonOptGeom->setDisabled(b); |
---|
226 | } |
---|
227 | |
---|
228 | void BAOqt::updateCaption() |
---|
229 | { |
---|
230 | static int StartStellariumServer = 0; |
---|
231 | static int joy = 0; |
---|
232 | |
---|
233 | if (RechercheOptimisation) return; |
---|
234 | |
---|
235 | bao->thread_process(); |
---|
236 | |
---|
237 | const QString *var = new QString( bao->chaineDateHeure); |
---|
238 | |
---|
239 | ui->lineStatus->setText(*var); |
---|
240 | |
---|
241 | delete var; |
---|
242 | |
---|
243 | // Affichage des messages venant du serveur indi_BAO et récupérés par la fonction LireReponse() |
---|
244 | // Les messages d'erreurs sont affichés en rouge |
---|
245 | ui->textEdit->clear(); |
---|
246 | |
---|
247 | for (int i=0; i<bao->lognum; i++) |
---|
248 | { |
---|
249 | if (i>bao->lognum-11) |
---|
250 | { |
---|
251 | if ((bao->logs[i].find("Err")!=string::npos) |
---|
252 | || (bao->logs[i].find("ALERTE")!=string::npos)) |
---|
253 | { |
---|
254 | ui->textEdit->setTextColor(QColor(255,0,0)); |
---|
255 | } |
---|
256 | else |
---|
257 | { |
---|
258 | ui->textEdit->setTextColor(QColor(0,0,0)); |
---|
259 | } |
---|
260 | |
---|
261 | ui->textEdit->append(bao->logs[i].c_str()); |
---|
262 | } |
---|
263 | } |
---|
264 | |
---|
265 | // affichage des cercles d'état des antennes |
---|
266 | // vert = l'antenne fonctionne |
---|
267 | // rouge = problÚme détecté sur l'antenne |
---|
268 | // gris = antenne non connectée |
---|
269 | |
---|
270 | for (int i=0; i <4; i++) |
---|
271 | { |
---|
272 | switch (bao->Antennes[i].ok) |
---|
273 | { |
---|
274 | case 1 : |
---|
275 | leds[i]->red = false; |
---|
276 | leds[i]->setChecked( true ); |
---|
277 | break; |
---|
278 | case 2 : |
---|
279 | |
---|
280 | leds[i]->red = true; |
---|
281 | leds[i]->setChecked( true ); |
---|
282 | |
---|
283 | break; |
---|
284 | default: |
---|
285 | leds[i]->red = false; |
---|
286 | leds[i]->setChecked( false ); |
---|
287 | break; |
---|
288 | } |
---|
289 | } |
---|
290 | |
---|
291 | dialog->repaint(); |
---|
292 | |
---|
293 | #ifdef JOYSTICK |
---|
294 | |
---|
295 | joy++; |
---|
296 | |
---|
297 | int max = 2000; |
---|
298 | |
---|
299 | if (joy>1) |
---|
300 | { |
---|
301 | joy = 0; |
---|
302 | |
---|
303 | JoystickStatus js; |
---|
304 | |
---|
305 | if (joystick) |
---|
306 | { |
---|
307 | if (joystick->GetStatus( js)) |
---|
308 | { |
---|
309 | if (js.x < -max) on_pushButtonAzM_clicked(); |
---|
310 | if (js.x > max) on_pushButtonAzP_clicked(); |
---|
311 | if (js.y < -max) on_pushButtonHaP_clicked(); |
---|
312 | if (js.y > max) on_pushButtonHaM_clicked(); |
---|
313 | if (js.button1) |
---|
314 | { |
---|
315 | on_pushButton1x_clicked(); |
---|
316 | ui->pushButton1x->setDown(true); |
---|
317 | ui->pushButton10x->setDown(false); |
---|
318 | } |
---|
319 | if (js.button2) |
---|
320 | { |
---|
321 | on_pushButton10x_clicked(); |
---|
322 | ui->pushButton1x->setDown(false); |
---|
323 | ui->pushButton10x->setDown(true); |
---|
324 | } |
---|
325 | } |
---|
326 | } |
---|
327 | } |
---|
328 | #endif |
---|
329 | |
---|
330 | |
---|
331 | if (StartStellariumServer < 10) |
---|
332 | { |
---|
333 | StartStellariumServer++; |
---|
334 | } |
---|
335 | else |
---|
336 | { |
---|
337 | step(1000); |
---|
338 | } |
---|
339 | } |
---|
340 | |
---|
341 | void BAOqt::on_pushButtonPark_clicked() |
---|
342 | { |
---|
343 | RechercheOptimisation = false; |
---|
344 | |
---|
345 | bao->DecodageEntreesUtilisateur("park"); |
---|
346 | } |
---|
347 | |
---|
348 | void BAOqt::on_pushButtonAbort_clicked() |
---|
349 | { |
---|
350 | RechercheOptimisation = false; |
---|
351 | |
---|
352 | bao->DecodageEntreesUtilisateur("abort"); |
---|
353 | } |
---|
354 | |
---|
355 | void BAOqt::on_pushButtonCommande_clicked() |
---|
356 | { |
---|
357 | RechercheOptimisation = false; |
---|
358 | |
---|
359 | QString chaine = ui->lineEditCommande->text(); |
---|
360 | |
---|
361 | bao->DecodageEntreesUtilisateur("send " + chaine.toStdString()); |
---|
362 | } |
---|
363 | |
---|
364 | void BAOqt::on_pushButtonAzM_clicked() |
---|
365 | { |
---|
366 | RechercheOptimisation = false; |
---|
367 | |
---|
368 | bao->AlignementDelta("-1", true); |
---|
369 | } |
---|
370 | |
---|
371 | void BAOqt::on_pushButtonAzP_clicked() |
---|
372 | { |
---|
373 | RechercheOptimisation = false; |
---|
374 | |
---|
375 | bao->AlignementDelta("1", true); |
---|
376 | } |
---|
377 | |
---|
378 | void BAOqt::on_pushButtonHaM_clicked() |
---|
379 | { |
---|
380 | RechercheOptimisation = false; |
---|
381 | |
---|
382 | bao->AlignementDelta("-1", false); |
---|
383 | } |
---|
384 | |
---|
385 | void BAOqt::on_pushButtonHaP_clicked() |
---|
386 | { |
---|
387 | RechercheOptimisation = false; |
---|
388 | |
---|
389 | bao->AlignementDelta("1", false); |
---|
390 | } |
---|
391 | |
---|
392 | void BAOqt::on_pushButton1x_clicked() |
---|
393 | { |
---|
394 | RechercheOptimisation = false; |
---|
395 | |
---|
396 | bao->VitesseAlignement(1); |
---|
397 | |
---|
398 | ui->pushButton1x->setDown(true); |
---|
399 | ui->pushButton10x->setDown(false); |
---|
400 | } |
---|
401 | |
---|
402 | void BAOqt::on_pushButton10x_clicked() |
---|
403 | { |
---|
404 | RechercheOptimisation = false; |
---|
405 | |
---|
406 | bao->VitesseAlignement(10); |
---|
407 | |
---|
408 | ui->pushButton1x->setDown(false); |
---|
409 | ui->pushButton10x->setDown(true); |
---|
410 | } |
---|
411 | |
---|
412 | void BAOqt::on_pushButtonIP_clicked() |
---|
413 | { |
---|
414 | RechercheOptimisation = false; |
---|
415 | |
---|
416 | QString chaine = ui->lineEditIP->text(); |
---|
417 | |
---|
418 | if (bao->SelectionIP(chaine.toStdString())) |
---|
419 | { |
---|
420 | QMessageBox::information(this, tr("Selection d'une antenne pour l'alignement"), tr("L'antenne indiquee est maintenant prete pour l'alignement.")); |
---|
421 | |
---|
422 | DisableButtons(false); |
---|
423 | } |
---|
424 | else |
---|
425 | { |
---|
426 | QMessageBox::information(this, tr("Selection d'une antenne pour l'alignement"), tr("Aucune antenne ne porte cette adresse IP !")); |
---|
427 | } |
---|
428 | } |
---|
429 | |
---|
430 | void BAOqt::on_pushButtonChoisir_clicked() |
---|
431 | { |
---|
432 | RechercheOptimisation = false; |
---|
433 | |
---|
434 | bao->AlignementAntenneIP(ui->lineEditIP->text().toStdString()); |
---|
435 | |
---|
436 | SelectStars selectstar; |
---|
437 | |
---|
438 | stringstream os; |
---|
439 | |
---|
440 | int NumListeEtoilesSelectionnees = 0; |
---|
441 | |
---|
442 | for (int i=0; i<bao->numEtoiles; i++) |
---|
443 | { |
---|
444 | if ( bao->Etoiles[i].selectionnee ) |
---|
445 | { |
---|
446 | os.str(""); |
---|
447 | os.width(20); |
---|
448 | os << bao->Etoiles[i].nom; |
---|
449 | os << " (" << bao->Etoiles[i].cons << "), "; |
---|
450 | string c ="az=" + bao->DHMS(bao->Etoiles[i].az * N180divPi, false) + ", "; |
---|
451 | os << c.substr(0 ,17); |
---|
452 | c= "ha=" + bao->DHMS(bao->Etoiles[i].ha * N180divPi, false) + ", "; |
---|
453 | os << c.substr(0, 17); |
---|
454 | os << " magnitude="; |
---|
455 | os << bao->Etoiles[i].mag; |
---|
456 | |
---|
457 | selectstar.Noms[NumListeEtoilesSelectionnees++] = os.str(); |
---|
458 | } |
---|
459 | } |
---|
460 | |
---|
461 | selectstar.Num = NumListeEtoilesSelectionnees; |
---|
462 | |
---|
463 | selectstar.UpdateDatas(); |
---|
464 | |
---|
465 | selectstar.exec(); |
---|
466 | |
---|
467 | |
---|
468 | int EtoileSelectionnee = selectstar.NumSelectionne; |
---|
469 | |
---|
470 | if (EtoileSelectionnee != -1) |
---|
471 | { |
---|
472 | int NumListeEtoilesSelectionnees = 0; |
---|
473 | |
---|
474 | for (int i=0; i<bao->numEtoiles; i++) |
---|
475 | { |
---|
476 | if ( bao->Etoiles[i].selectionnee ) |
---|
477 | { |
---|
478 | if ( NumListeEtoilesSelectionnees == EtoileSelectionnee ) |
---|
479 | { |
---|
480 | ui->lineEditEtoileSelectionneeAD->setText( QString( bao->DHMS(bao->Etoiles[i].ad * N180divPi, true ).c_str()) ); |
---|
481 | ui->lineEditEtoileSelectionneeDec->setText( QString( bao->DHMS(bao->Etoiles[i].de * N180divPi, false).c_str()) ); |
---|
482 | on_pushButtonSelectionner_clicked(); |
---|
483 | } |
---|
484 | |
---|
485 | NumListeEtoilesSelectionnees++; |
---|
486 | } |
---|
487 | } |
---|
488 | } |
---|
489 | } |
---|
490 | |
---|
491 | void BAOqt::on_pushButtonSelectionner_clicked() |
---|
492 | { |
---|
493 | RechercheOptimisation = false; |
---|
494 | |
---|
495 | bao->Goto( ui->lineEditEtoileSelectionneeAD->text().toStdString(), ui->lineEditEtoileSelectionneeDec->text().toStdString(), bao->Transit, false); |
---|
496 | } |
---|
497 | |
---|
498 | void BAOqt::on_pushButtonValider_clicked() |
---|
499 | { |
---|
500 | RechercheOptimisation = false; |
---|
501 | |
---|
502 | bao->ValidationAlignement(); |
---|
503 | } |
---|
504 | |
---|
505 | void BAOqt::on_pushButtonSauvegarder_clicked() |
---|
506 | { |
---|
507 | RechercheOptimisation = false; |
---|
508 | |
---|
509 | bao->SauvegardeAlignement(); |
---|
510 | } |
---|
511 | |
---|
512 | void BAOqt::on_pushButtonReset_clicked() |
---|
513 | { |
---|
514 | QMessageBox::StandardButton reply; |
---|
515 | |
---|
516 | RechercheOptimisation = false; |
---|
517 | |
---|
518 | reply = QMessageBox::question(this, tr("Reset alignement"), |
---|
519 | "Voulez-vous reinitialiser l'alignement de l'antenne ?", |
---|
520 | QMessageBox::Yes | QMessageBox::No ); |
---|
521 | |
---|
522 | if (reply == QMessageBox::Yes) bao->ResetAlignement(); |
---|
523 | } |
---|
524 | |
---|
525 | void BAOqt::on_pushButtonListe_clicked() |
---|
526 | { |
---|
527 | Liste liste; |
---|
528 | |
---|
529 | RechercheOptimisation = false; |
---|
530 | |
---|
531 | stringstream os; |
---|
532 | |
---|
533 | int NumListeEtoilesSelectionnees = 0; |
---|
534 | |
---|
535 | for (int i=0; i<bao->numEtoiles; i++) |
---|
536 | { |
---|
537 | if ( bao->Etoiles[i].selectionnee ) |
---|
538 | { |
---|
539 | os.str(""); |
---|
540 | os.width(20); |
---|
541 | os << bao->Etoiles[i].nom; |
---|
542 | os << " (" << bao->Etoiles[i].cons << "), "; |
---|
543 | string c ="az=" + bao->DHMS(bao->Etoiles[i].az * N180divPi, false) + ", "; |
---|
544 | os << c.substr(0 ,17); |
---|
545 | c= "ha=" + bao->DHMS(bao->Etoiles[i].ha * N180divPi, false) + ", "; |
---|
546 | os << c.substr(0, 17); |
---|
547 | os << " magnitude="; |
---|
548 | os << bao->Etoiles[i].mag; |
---|
549 | |
---|
550 | liste.Noms[NumListeEtoilesSelectionnees++] = os.str(); |
---|
551 | } |
---|
552 | } |
---|
553 | |
---|
554 | liste.Num = NumListeEtoilesSelectionnees; |
---|
555 | |
---|
556 | liste.UpdateDatas(); |
---|
557 | |
---|
558 | liste.exec(); |
---|
559 | } |
---|
560 | |
---|
561 | void BAOqt::on_pushButtonMap_clicked() |
---|
562 | { |
---|
563 | Map map1; |
---|
564 | |
---|
565 | RechercheOptimisation = false; |
---|
566 | |
---|
567 | string str = bao->DecodageEntreesUtilisateur("send C"); |
---|
568 | |
---|
569 | map1.Corrections = str; |
---|
570 | |
---|
571 | map1.UpdateDatas(); |
---|
572 | |
---|
573 | map1.exec(); |
---|
574 | } |
---|
575 | |
---|
576 | void BAOqt::on_pushButton1pt_clicked() |
---|
577 | { |
---|
578 | static int etape = 1; |
---|
579 | |
---|
580 | RechercheOptimisation = false; |
---|
581 | |
---|
582 | switch (etape) |
---|
583 | { |
---|
584 | case 1: |
---|
585 | { |
---|
586 | etape=2; |
---|
587 | |
---|
588 | QMessageBox::information(this, tr("Alignement 1pt de l antenne"), tr("Choisissez un objet facile a pointer")); |
---|
589 | |
---|
590 | on_pushButtonGoto_clicked(); |
---|
591 | |
---|
592 | QMessageBox::information(this, tr("Alignement 1pt de l antenne"), tr("Attendez la fin du pointage. Centrez l'objet dans le viseur et rappuyez sur le bouton 'alignement 1pt' pour terminer.")); |
---|
593 | |
---|
594 | }; |
---|
595 | break; |
---|
596 | |
---|
597 | case 2: |
---|
598 | { |
---|
599 | etape=1; |
---|
600 | |
---|
601 | QMessageBox::information(this, tr("Alignement 1pt de l antenne"), tr("Annulation du mouvement en cours.")); |
---|
602 | |
---|
603 | bao->Abort(); |
---|
604 | |
---|
605 | sleep(1); |
---|
606 | |
---|
607 | string str = bao->DecodageEntreesUtilisateur("send X"); |
---|
608 | |
---|
609 | string str2; |
---|
610 | |
---|
611 | int x = 0; |
---|
612 | int y = 0; |
---|
613 | |
---|
614 | char a1='b'; |
---|
615 | char a2='b'; |
---|
616 | |
---|
617 | size_t pos = str.find("/"); |
---|
618 | |
---|
619 | if (pos != string::npos) |
---|
620 | { |
---|
621 | str2 = str.substr(pos + 1); |
---|
622 | |
---|
623 | pos = str2.find("/"); |
---|
624 | |
---|
625 | if (pos != string::npos) |
---|
626 | { |
---|
627 | x = atol( str2.substr(0, pos).c_str() ); |
---|
628 | |
---|
629 | y = atol( str2.substr(pos + 1).c_str() ); |
---|
630 | } |
---|
631 | } |
---|
632 | |
---|
633 | sleep(1); |
---|
634 | |
---|
635 | str = bao->DecodageEntreesUtilisateur("send D"); |
---|
636 | |
---|
637 | int dx = 0; |
---|
638 | int dy = 0; |
---|
639 | |
---|
640 | pos = str.find("/"); |
---|
641 | |
---|
642 | if (pos != string::npos) |
---|
643 | { |
---|
644 | str2 = str.substr(pos + 1); |
---|
645 | |
---|
646 | pos = str2.find("/"); |
---|
647 | |
---|
648 | if (pos != string::npos) |
---|
649 | { |
---|
650 | dx = atol( str2.substr(0, pos).c_str() ); |
---|
651 | |
---|
652 | x -= dx; |
---|
653 | |
---|
654 | dy = atol( str2.substr(pos + 1).c_str() ); |
---|
655 | |
---|
656 | y -= dy; |
---|
657 | |
---|
658 | if ( x < 0 ) { |
---|
659 | a1 = 'f'; |
---|
660 | x = -x; |
---|
661 | } |
---|
662 | |
---|
663 | if ( y < 0 ) { |
---|
664 | a2 = 'f'; |
---|
665 | y = -y; |
---|
666 | } |
---|
667 | |
---|
668 | char chaine[100]; |
---|
669 | |
---|
670 | sprintf(chaine, "send g%c%04df0000", a1, x); |
---|
671 | |
---|
672 | str = bao->DecodageEntreesUtilisateur(string(chaine)); |
---|
673 | |
---|
674 | QMessageBox::information(this, tr("Alignement 1pt de l antenne"), tr("Attendez la fin du mouvement avant de cliquer sur OK.")); |
---|
675 | |
---|
676 | |
---|
677 | sprintf(chaine, "send gf0000%c%04d", a2, y); |
---|
678 | |
---|
679 | str = bao->DecodageEntreesUtilisateur(string(chaine)); |
---|
680 | QMessageBox::information(this, tr("Alignement 1pt de l antenne"), tr("Appuyez sur les deux boutons places dans la boite de l'antenne.")); |
---|
681 | |
---|
682 | QMessageBox::StandardButton reply; |
---|
683 | |
---|
684 | reply = QMessageBox::question(this, tr("Alignement 1pt de l antenne"), |
---|
685 | "Voulez-vous reinitialiser les codeurs de l'antenne en envoyant la c ommande Park ?", |
---|
686 | QMessageBox::Yes | QMessageBox::No ); |
---|
687 | |
---|
688 | if (reply == QMessageBox::Yes) |
---|
689 | { |
---|
690 | |
---|
691 | str = bao->DecodageEntreesUtilisateur("send z"); |
---|
692 | |
---|
693 | sleep(1); |
---|
694 | |
---|
695 | str = bao->DecodageEntreesUtilisateur("send p"); |
---|
696 | } |
---|
697 | QMessageBox::information(this, tr("Alignement 1pt de l antenne"), tr("Fin de la procedure.")); |
---|
698 | } |
---|
699 | } |
---|
700 | } |
---|
701 | break; |
---|
702 | } |
---|
703 | } |
---|
704 | |
---|
705 | |
---|
706 | void BAOqt::on_pushButtonGoto_clicked() |
---|
707 | { |
---|
708 | bool ok; |
---|
709 | |
---|
710 | RechercheOptimisation = false; |
---|
711 | |
---|
712 | QString text = QInputDialog::getText(this, tr("Goto"), |
---|
713 | tr("Entrez le nom ou les coordonnees de l'objet a suivre"), QLineEdit::Normal, |
---|
714 | "", &ok); |
---|
715 | if (ok && !text.isEmpty()) |
---|
716 | bao->DecodageEntreesUtilisateur("goto " + text.toStdString()); |
---|
717 | |
---|
718 | } |
---|
719 | |
---|
720 | void BAOqt::on_pushButtonTo00_clicked() |
---|
721 | { |
---|
722 | RechercheOptimisation = false; |
---|
723 | |
---|
724 | string str = bao->DecodageEntreesUtilisateur("send X"); |
---|
725 | |
---|
726 | string str2; |
---|
727 | |
---|
728 | int x = 0; |
---|
729 | int y = 0; |
---|
730 | |
---|
731 | size_t pos = str.find("/"); |
---|
732 | |
---|
733 | if (pos != string::npos) |
---|
734 | { |
---|
735 | str2 = str.substr(pos + 1); |
---|
736 | |
---|
737 | pos = str2.find("/"); |
---|
738 | |
---|
739 | if (pos != string::npos) |
---|
740 | { |
---|
741 | char a1='b'; |
---|
742 | char a2='b'; |
---|
743 | |
---|
744 | x = atol( str2.substr(0, pos).c_str() ); |
---|
745 | |
---|
746 | if ( x < 0 ) { |
---|
747 | a1 = 'f'; |
---|
748 | x = -x; |
---|
749 | } |
---|
750 | |
---|
751 | y = atol( str2.substr(pos + 1).c_str() ); |
---|
752 | |
---|
753 | if ( y < 0 ) { |
---|
754 | a2 = 'f'; |
---|
755 | y = -y; |
---|
756 | } |
---|
757 | |
---|
758 | char chaine[100]; |
---|
759 | |
---|
760 | sprintf(chaine, "send g%c%04d%c%04d", a1, x, a2, y); |
---|
761 | |
---|
762 | string str = bao->DecodageEntreesUtilisateur(string(chaine)); |
---|
763 | } |
---|
764 | } |
---|
765 | } |
---|
766 | |
---|
767 | void BAOqt::on_pushButtonCalculMatrices_clicked() |
---|
768 | { |
---|
769 | RechercheOptimisation = false; |
---|
770 | |
---|
771 | bao->DecodageEntreesUtilisateur("send m"); |
---|
772 | } |
---|
773 | |
---|
774 | void BAOqt::on_pushButtonScript_clicked() |
---|
775 | { |
---|
776 | |
---|
777 | } |
---|
778 | |
---|
779 | void BAOqt::on_pushButtonOptGeom_clicked() |
---|
780 | { |
---|
781 | RechercheOptimisation = true; |
---|
782 | |
---|
783 | bao->DecodageEntreesUtilisateur("send o"); |
---|
784 | } |
---|
785 | |
---|
786 | void BAOqt::on_pushButtonRetryGoto_clicked() |
---|
787 | { |
---|
788 | RechercheOptimisation = true; |
---|
789 | |
---|
790 | RechercheOptimisation = false; |
---|
791 | |
---|
792 | bao->Goto( ui->lineEditEtoileSelectionneeAD->text().toStdString(), ui->lineEditEtoileSelectionneeDec->text().toStdString(), bao->Transit, false); |
---|
793 | } |
---|