1 | /********************/
|
---|
2 | /* BAOCONTROL */
|
---|
3 | /* */
|
---|
4 | /********************/
|
---|
5 |
|
---|
6 |
|
---|
7 | #include "baocontrol.h"
|
---|
8 |
|
---|
9 |
|
---|
10 | /* Affiche à l'écran (si AfficheEcran==true) et sauvegarde dans le fichier
|
---|
11 | BAOControl.log le message contenu dans la variable chaine */
|
---|
12 | void Affiche(std::string chaine, bool AfficheEcran)
|
---|
13 | {
|
---|
14 | FILE *pFile = NULL;
|
---|
15 |
|
---|
16 | pFile = fopen ("BAOControl.log", "a");
|
---|
17 |
|
---|
18 | if (AfficheEcran) std::cout << chaine;
|
---|
19 |
|
---|
20 | fprintf (pFile, chaine.c_str());
|
---|
21 |
|
---|
22 | os.str("");
|
---|
23 |
|
---|
24 | fclose (pFile);
|
---|
25 | }
|
---|
26 |
|
---|
27 |
|
---|
28 | /*Affiche les messages d'erreur en rouge */
|
---|
29 | void Erreur(std::string chaine)
|
---|
30 | {
|
---|
31 | std::cout << red;
|
---|
32 | Affiche(chaine, true);
|
---|
33 | std::cout << black;
|
---|
34 | }
|
---|
35 |
|
---|
36 |
|
---|
37 | /*initialise une fenêtre graphique */
|
---|
38 | void initialiserFenetre()
|
---|
39 | {
|
---|
40 | XGCValues gcv;
|
---|
41 | XFontStruct * fd;
|
---|
42 |
|
---|
43 | /*contacte le serveur*/
|
---|
44 | if ((d = XOpenDisplay(getenv("DISPLAY"))) == NULL)
|
---|
45 | {
|
---|
46 | Erreur("Impossible de contacter le serveur\n\n");
|
---|
47 | exit(1);
|
---|
48 | }
|
---|
49 |
|
---|
50 | /*crée une fenêtre*/
|
---|
51 | w = XCreateSimpleWindow(d, RootWindow(d, DefaultScreen(d)),
|
---|
52 | 0, 0, larg, haut,
|
---|
53 | 2, BlackPixel(d, DefaultScreen(d)),
|
---|
54 | WhitePixel(d, DefaultScreen(d)));
|
---|
55 |
|
---|
56 | /* Creation du double buffer */
|
---|
57 | db = XCreatePixmap(d, w, larg, haut, DefaultDepth(d, DefaultScreen(d)));
|
---|
58 |
|
---|
59 | /*chargement d'une police de caractÚres*/
|
---|
60 | if ((fd=XLoadQueryFont(d, "fixed")) == NULL)
|
---|
61 | {
|
---|
62 | Erreur("Impossible de charger la police fixed\n\n");
|
---|
63 | exit(1);
|
---|
64 | }
|
---|
65 |
|
---|
66 | /*création d'un contexte graphique*/
|
---|
67 | gcv.font = fd->fid;
|
---|
68 | gcv.foreground = BlackPixel(d, DefaultScreen(d));
|
---|
69 | noir = XCreateGC(d, w, GCFont | GCForeground, &gcv);
|
---|
70 |
|
---|
71 | gcv.foreground = 200*255;
|
---|
72 | vert = XCreateGC(d, w, GCFont | GCForeground, &gcv);
|
---|
73 |
|
---|
74 | gcv.foreground = 255*256*256;
|
---|
75 | rouge = XCreateGC(d, w, GCFont | GCForeground, &gcv);
|
---|
76 |
|
---|
77 | gcv.foreground = 200*256*256+200*256+200;
|
---|
78 | gris = XCreateGC(d, w, GCFont | GCForeground, &gcv);
|
---|
79 |
|
---|
80 | /*affiche la fenêtre */
|
---|
81 | XMapWindow(d, w);
|
---|
82 | }
|
---|
83 |
|
---|
84 |
|
---|
85 | /* Dessine les éléments de la fenêtre graphique */
|
---|
86 | void Dessiner()
|
---|
87 | {
|
---|
88 | char chaine[100];
|
---|
89 | GC color;
|
---|
90 |
|
---|
91 | /* On efface la fenêtre */
|
---|
92 | XSetForeground(d, noir, WhitePixel(d, DefaultScreen(d)));
|
---|
93 | XFillRectangle(d, db, noir, 0, 0, larg, haut);
|
---|
94 | XSetForeground(d, noir, BlackPixel(d, DefaultScreen(d)));
|
---|
95 |
|
---|
96 | /* Affichage de la date et de l'heure */
|
---|
97 | int h=astro->Heu;
|
---|
98 | int m=astro->Min;
|
---|
99 | int s=astro->Sec;
|
---|
100 | int j=astro->Jour;
|
---|
101 |
|
---|
102 | if (s==60) {
|
---|
103 | s=0;
|
---|
104 | m++;
|
---|
105 | if (m==60) {
|
---|
106 | m=0;
|
---|
107 | h++;
|
---|
108 | if (h==24) {
|
---|
109 | h=0;
|
---|
110 | j++;
|
---|
111 | }
|
---|
112 | }
|
---|
113 | }
|
---|
114 |
|
---|
115 | sprintf(chaine, "%02i:%02i:%02i TU %02i/%02.0f/%04.0f JJ=%10.5f",
|
---|
116 | h, m, s, j, astro->Mois, astro->Annee, astro->JJ);
|
---|
117 |
|
---|
118 | XDrawString(d, db, noir, 10, 10, chaine, strlen(chaine));
|
---|
119 |
|
---|
120 | if (run)
|
---|
121 | {
|
---|
122 | sprintf(chaine, "Prochaine etape dans %4.1fs", (objets[runnum].JJ-astro->JJ)*3600.0*24.0);
|
---|
123 |
|
---|
124 | if ((objets[runnum].JJ-astro->JJ)*3600.0*24.0 >= 0.0) XDrawString(d, db, noir, 350, 10, chaine, strlen(chaine));
|
---|
125 | }
|
---|
126 |
|
---|
127 | /*affichage des cercles d'état*/
|
---|
128 | for (int i=0; i <20; i++)
|
---|
129 | {
|
---|
130 | for (int j=0; j<5; j++)
|
---|
131 | {
|
---|
132 | switch(Antennes[20*j+i].ok)
|
---|
133 | {
|
---|
134 | case 1 : color=vert; break;
|
---|
135 | case 2 : color=rouge; break;
|
---|
136 | default: color=gris; break;
|
---|
137 | }
|
---|
138 | XFillArc(d, db ,color, 10+i*30, 20+j*30, 15, 15, 0, 360*64);
|
---|
139 | XDrawArc(d, db ,noir, 10+i*30, 20+j*30, 15, 15, 0, 360*64);
|
---|
140 | }
|
---|
141 | }
|
---|
142 |
|
---|
143 |
|
---|
144 | /*Affichage des messages d'erreur*/
|
---|
145 | if (lognum>15)
|
---|
146 | {
|
---|
147 | for (int i=lognum-1; i>lognum-16; i--)
|
---|
148 | {
|
---|
149 | if ((logs[i].find("Err")!=string::npos)
|
---|
150 | || (logs[i].find("ALERTE")!=string::npos)) color=rouge;
|
---|
151 | else color=vert;
|
---|
152 | XDrawString(d, db, color, 10, 15*12+(i-lognum+15)*12, logs[i].c_str(), strlen(logs[i].c_str()));
|
---|
153 | }
|
---|
154 | }
|
---|
155 | else
|
---|
156 | {
|
---|
157 | for (int i=0; i<lognum; i++)
|
---|
158 | {
|
---|
159 | if ((logs[i].find("Err")!=string::npos)
|
---|
160 | || (logs[i].find("ALERTE")!=string::npos)) color=rouge;
|
---|
161 | else color=vert;
|
---|
162 | XDrawString(d, db, color, 10, 15*12+i*12, logs[i].c_str(), strlen(logs[i].c_str()));
|
---|
163 | }
|
---|
164 | }
|
---|
165 |
|
---|
166 | XCopyArea(d, db, w, noir, 0, 0, larg, haut, 0, 0);
|
---|
167 |
|
---|
168 | /* on force le rafraichissement de l'écran */
|
---|
169 | XFlush(d);
|
---|
170 | }
|
---|
171 |
|
---|
172 |
|
---|
173 | /* Gestion des messages concernant la fenêtre graphique */
|
---|
174 | void rouler(char* reponse)
|
---|
175 | {
|
---|
176 | XEvent e;
|
---|
177 |
|
---|
178 | if (XCheckWindowEvent(d, w, ExposureMask, &e))
|
---|
179 | {
|
---|
180 | switch (e.type)
|
---|
181 | {
|
---|
182 | default:
|
---|
183 | //std::cout << "J'ai reçu un évÚnement " << e.type << std::endl
|
---|
184 | break;
|
---|
185 | case Expose :
|
---|
186 | Dessiner();
|
---|
187 | break;
|
---|
188 | }
|
---|
189 | }
|
---|
190 | }
|
---|
191 |
|
---|
192 |
|
---|
193 | /* RécupÚre les messages envoyés par indi_BAO */
|
---|
194 | void LireReponse()
|
---|
195 | {
|
---|
196 | std::string reponse, decomp;
|
---|
197 | std::stringstream os;
|
---|
198 | bool test=false;
|
---|
199 |
|
---|
200 | *client_socket >> reponse;
|
---|
201 |
|
---|
202 | if (reponse.find("message")!=string::npos)
|
---|
203 | {
|
---|
204 | /* on ne garde que la partie intéressante */
|
---|
205 | reponse=reponse.substr(reponse.find("message")+9);
|
---|
206 |
|
---|
207 | reponse=reponse.substr(0, reponse.find("\""));
|
---|
208 |
|
---|
209 | /*récupÚre l'adresse ip de l'antenne */
|
---|
210 | if (reponse.find(". (Antennes connectees")!=string::npos)
|
---|
211 | {
|
---|
212 | decomp=reponse.substr(0, reponse.find(". (Antennes connectees"));
|
---|
213 | decomp=decomp.substr(decomp.rfind(".")+1);
|
---|
214 |
|
---|
215 | /*si cette antenne est déjà connectée, on change son état */
|
---|
216 | for (int i=0; i<numAntenne; i++)
|
---|
217 | {
|
---|
218 | if (atoi(decomp.c_str()) == Antennes[i].ip)
|
---|
219 | {
|
---|
220 | Antennes[i].ok=1;
|
---|
221 | test=true;
|
---|
222 | break;
|
---|
223 | }
|
---|
224 | }
|
---|
225 |
|
---|
226 | /*ou on ajoute son état */
|
---|
227 | if (!test)
|
---|
228 | {
|
---|
229 | Antennes[numAntenne].ip=atoi(decomp.c_str());
|
---|
230 | Antennes[numAntenne].ok=1;
|
---|
231 | numAntenne++;
|
---|
232 | }
|
---|
233 | }
|
---|
234 |
|
---|
235 | /*erreur sur une antenne -> on change son état dans la fenêtre */
|
---|
236 | if ((reponse.find("ALERTE antenne ")!=string::npos) || (reponse.find("Erreur sur l antenne ")!=string::npos))
|
---|
237 | {
|
---|
238 | decomp=reponse.substr(0, reponse.find(" :"));
|
---|
239 | decomp=decomp.substr(decomp.rfind(".")+1);
|
---|
240 |
|
---|
241 | for (int i=0; i<numAntenne; i++)
|
---|
242 | {
|
---|
243 | if (atoi(decomp.c_str()) == Antennes[i].ip)
|
---|
244 | {
|
---|
245 | Antennes[i].ok=2;
|
---|
246 | }
|
---|
247 | }
|
---|
248 | }
|
---|
249 |
|
---|
250 | /* On sauvegarde le message dans le tableau log */
|
---|
251 | os << lognum << " : " << reponse;
|
---|
252 |
|
---|
253 | Affiche(os.str(), false);
|
---|
254 | Affiche("\n", false);
|
---|
255 |
|
---|
256 | logs[lognum++]=os.str();
|
---|
257 | if (lognum>=MAXLOG-1) lognum=0;
|
---|
258 |
|
---|
259 | /*on actualise la fenêtre */
|
---|
260 | Dessiner();
|
---|
261 | }
|
---|
262 |
|
---|
263 | rouler((char *)reponse.c_str());
|
---|
264 | }
|
---|
265 |
|
---|
266 |
|
---|
267 | /* Est-ce que la réponse du pilote indi_BAO
|
---|
268 | est conforme à ce que l'on attendait ? */
|
---|
269 | bool VerifReponse(std::string reponseattendue)
|
---|
270 | {
|
---|
271 | std::string reponse;
|
---|
272 |
|
---|
273 | usleep(10000); // attendre 10 ms pour laisser le temps au pilote indi_BAO de répondre
|
---|
274 |
|
---|
275 | *client_socket >> reponse;
|
---|
276 |
|
---|
277 | if (reponse.find(reponseattendue)==string::npos)
|
---|
278 | {
|
---|
279 | //réponse inconnue -> une erreur ?
|
---|
280 | os << "Réponse du pilote indi_BAO :" << std::endl << reponse
|
---|
281 | << std::endl << std::endl << std::endl;
|
---|
282 | Erreur(os.str());
|
---|
283 | }
|
---|
284 |
|
---|
285 | return true;
|
---|
286 | }
|
---|
287 |
|
---|
288 |
|
---|
289 | /*Récupération de la date et de l'heure
|
---|
290 | et calcul du jour julien et du tsl */
|
---|
291 | void CalculJourJulien()
|
---|
292 | {
|
---|
293 | struct tm date;
|
---|
294 | time_t t;
|
---|
295 | struct timeval tv;
|
---|
296 | struct timezone tz;
|
---|
297 |
|
---|
298 | time(&t);
|
---|
299 | date=*gmtime(&t);
|
---|
300 | gettimeofday(&tv, &tz);
|
---|
301 |
|
---|
302 | astro->Annee=(double)(date.tm_year+1900);
|
---|
303 | astro->Mois=(double)(date.tm_mon+1);
|
---|
304 | astro->Jour=(double)date.tm_mday;
|
---|
305 | astro->Heu=(double)date.tm_hour;
|
---|
306 | astro->Min=(double)date.tm_min;
|
---|
307 | astro->Sec=(double)date.tm_sec+tv.tv_usec/1.0E6;
|
---|
308 | astro->UTCP=0.0;//(double)date.tm_isdst;
|
---|
309 |
|
---|
310 | //Calcul du temps sidéral local et du JJ
|
---|
311 |
|
---|
312 | astro->CalculTSL();
|
---|
313 | }
|
---|
314 |
|
---|
315 |
|
---|
316 | /* gestion du thread permettant l'actualisation de la fenêtre graphique
|
---|
317 | et la récupération des messages d'indi_BAO */
|
---|
318 | void *my_thread_process (void * arg)
|
---|
319 | {
|
---|
320 | while (NoExit)
|
---|
321 | {
|
---|
322 | CalculJourJulien();
|
---|
323 |
|
---|
324 | //Execution d'un fichier de mouvements
|
---|
325 | if (run && numobjets>1 && runnum<numobjets)
|
---|
326 | {
|
---|
327 | /* On lance l'exécution des mouvements programmés */
|
---|
328 | if (astro->JJ>=objets[runnum].JJ && !objets[runnum].exec)
|
---|
329 | {
|
---|
330 | if (runnum==1) Affiche("Début de l'exécution du fichier de mouvements\n\n", true);
|
---|
331 | os << "Suivi de l'objet n°" << runnum << std::endl;
|
---|
332 | Affiche(os.str(), true);
|
---|
333 | objets[runnum].exec=true;
|
---|
334 |
|
---|
335 | Goto(objets[runnum].ad, objets[runnum].de, Transit);
|
---|
336 | }
|
---|
337 |
|
---|
338 | /*on arrive à la fin du mouvements i */
|
---|
339 | if (astro->JJ>=objets[runnum].JJ+objets[runnum].Duree/3600.0/24.0)
|
---|
340 | {
|
---|
341 | Abort();
|
---|
342 |
|
---|
343 | /*fin de la commande run */
|
---|
344 | if (runnum+1>=numobjets)
|
---|
345 | {
|
---|
346 | Affiche("Fin de l'execution du fichier de mouvements\n\n", true);
|
---|
347 | std::cout << std::endl << blue << ">";
|
---|
348 | run=false;
|
---|
349 | runnum=1;
|
---|
350 | numobjets=1;
|
---|
351 |
|
---|
352 | /*on sort du programme dans le cas ./BAOControl -r fileName */
|
---|
353 | if (exitrun) NoExit=false;
|
---|
354 | }
|
---|
355 | else
|
---|
356 | {
|
---|
357 | runnum++;
|
---|
358 | }
|
---|
359 | }
|
---|
360 | }
|
---|
361 |
|
---|
362 | LireReponse();
|
---|
363 |
|
---|
364 | Dessiner();
|
---|
365 |
|
---|
366 | usleep(100000); //100 ms
|
---|
367 | }
|
---|
368 |
|
---|
369 | pthread_exit (0);
|
---|
370 | }
|
---|
371 |
|
---|
372 |
|
---|
373 |
|
---|
374 | /* Décomposition et vérification des dates, heures, AD et déclinaisons
|
---|
375 | type = 0 -> Déclinaison/latitude
|
---|
376 | type = 1 -> longitude
|
---|
377 | type = 2 -> AD ou heure
|
---|
378 | type = 3 -> date */
|
---|
379 | bool Decomposition(std::string chaine, char type, float *a1, float *a2, float *a3)
|
---|
380 | {
|
---|
381 | std::string car, s;
|
---|
382 | int pos1, pos2;
|
---|
383 | float a, b, c;
|
---|
384 |
|
---|
385 | if (type==3) car="/"; else car=":";
|
---|
386 |
|
---|
387 | /* Y a-t-il 2 caractÚres : ou / à la suite ? */
|
---|
388 | int test=0;
|
---|
389 | for (int i=0; i<chaine.length(); i++) if (chaine[i]==car[0]) test++;
|
---|
390 | if (test<2) return false;
|
---|
391 |
|
---|
392 | s=chaine.substr(0, chaine.find(car));
|
---|
393 |
|
---|
394 | a=atoi(s.c_str());
|
---|
395 |
|
---|
396 | s=chaine.substr(chaine.find(car)+1, chaine.rfind(car)-chaine.find(car)-1);
|
---|
397 |
|
---|
398 | b=atoi(s.c_str());
|
---|
399 |
|
---|
400 | s=chaine.substr(chaine.rfind(car)+1);
|
---|
401 |
|
---|
402 | c=atoi(s.c_str());
|
---|
403 |
|
---|
404 | if (type <3)
|
---|
405 | {
|
---|
406 | if ((type==0) && (a>90.0 || a<-90.0)) return false;
|
---|
407 | if ((type==1) && (a>180.0 || a<-180.0)) return false;
|
---|
408 | if ((type==2) && (a>23.0 || a<0.0)) return false;
|
---|
409 | if (b<0.0 || b>59.0) return false;
|
---|
410 | if (c<0.0 || c>=60.0) return false;
|
---|
411 | }
|
---|
412 | else
|
---|
413 | {
|
---|
414 | if (a<0.0 || a>31.0) return false;
|
---|
415 | if (b<0.0 || b>12.0) return false;
|
---|
416 | }
|
---|
417 |
|
---|
418 | if (a1!=NULL) *a1=a;
|
---|
419 | if (a2!=NULL) *a2=b;
|
---|
420 | if (a3!=NULL) *a3=c;
|
---|
421 |
|
---|
422 | return true;
|
---|
423 | }
|
---|
424 |
|
---|
425 | /* isole les différents éléments de la commande saisie par l'utilisateur */
|
---|
426 | bool DecompositionCommande(std::string chaine, std::string commande, std::string *chaine1, std::string *chaine2)
|
---|
427 | {
|
---|
428 | size_t pos;
|
---|
429 |
|
---|
430 | pos = chaine.find(commande);
|
---|
431 |
|
---|
432 | if (pos!=string::npos)
|
---|
433 | {
|
---|
434 | pos+=commande.length();
|
---|
435 |
|
---|
436 | chaine=chaine.substr(pos);
|
---|
437 |
|
---|
438 | while (chaine[0] == ' ') chaine=chaine.substr(1);
|
---|
439 |
|
---|
440 | *chaine1=chaine.substr(0,chaine.find(" "));
|
---|
441 |
|
---|
442 | if (chaine2!=NULL)
|
---|
443 | {
|
---|
444 | pos = chaine.find(" ");
|
---|
445 |
|
---|
446 | if (pos!=string::npos)
|
---|
447 | {
|
---|
448 | chaine=chaine.substr(pos+1);
|
---|
449 |
|
---|
450 | while (chaine[0] == ' ') chaine=chaine.substr(1);
|
---|
451 |
|
---|
452 | *chaine2=chaine.substr(0, chaine.find(" "));
|
---|
453 | }
|
---|
454 | }
|
---|
455 | }
|
---|
456 |
|
---|
457 | return true;
|
---|
458 | }
|
---|
459 |
|
---|
460 |
|
---|
461 | /*Envoie la longitude et la latitude du lieu d'observation au pilote indi_BAO */
|
---|
462 | bool EncoyerCoordGeographiques()
|
---|
463 | {
|
---|
464 | try
|
---|
465 | {
|
---|
466 | *client_socket << "<newNumberVector device=\"BAO\" name=\"GEOGRAPHIC_COORD\">";
|
---|
467 | *client_socket << "<oneNumber name=\"LAT\">";
|
---|
468 | *client_socket << Latitude;
|
---|
469 | *client_socket << "</oneNumber>";
|
---|
470 | *client_socket << "<oneNumber name=\"LONG\">";
|
---|
471 | *client_socket << Longitude;
|
---|
472 | *client_socket << "</oneNumber>";
|
---|
473 | *client_socket << "</newNumberVector>";
|
---|
474 |
|
---|
475 | if (!VerifReponse("name=\"GEOGRAPHIC_COORD\" state=\"Ok\""))
|
---|
476 | {
|
---|
477 | Erreur("ERREUR fct EncoyerCoordGeographiques : pas de réponse du pilote indi_BAO.\n\n");
|
---|
478 |
|
---|
479 | return false;
|
---|
480 | }
|
---|
481 | }
|
---|
482 |
|
---|
483 | catch ( SocketException& e )
|
---|
484 | {
|
---|
485 | os << "Exception was caught:" << e.description() << std::endl;
|
---|
486 | Erreur(os.str());
|
---|
487 | return false;
|
---|
488 | }
|
---|
489 |
|
---|
490 | std::cout << "Les coordonnées géographiques ont bien été envoyées au pilote indi_BAO" << std::endl << std::endl;
|
---|
491 |
|
---|
492 | return true;
|
---|
493 | }
|
---|
494 |
|
---|
495 |
|
---|
496 | /* Place les antennes en position de repos */
|
---|
497 | bool Park()
|
---|
498 | {
|
---|
499 | try
|
---|
500 | {
|
---|
501 | *client_socket << "<newSwitchVector device=\"BAO\" name=\"\" >";
|
---|
502 | *client_socket << "<oneSwitch name=\"PARK\">";
|
---|
503 | *client_socket << "On";
|
---|
504 | *client_socket << "</oneSwitch>";
|
---|
505 | *client_socket << "</newSwitchVector>";
|
---|
506 |
|
---|
507 | if (!VerifReponse("Envoi de la commande Park"))
|
---|
508 | {
|
---|
509 | Erreur("La commande PARK a échoué.\n\n");;
|
---|
510 |
|
---|
511 | return false;
|
---|
512 | }
|
---|
513 | }
|
---|
514 | catch ( SocketException& e)
|
---|
515 | {
|
---|
516 | os << e.description() << "\n";
|
---|
517 | Erreur(os.str());
|
---|
518 | return false;
|
---|
519 | }
|
---|
520 |
|
---|
521 | Affiche("Le pilote indi_BAO a bien reçu la commande PARK.\n\n", true);
|
---|
522 |
|
---|
523 | return true;
|
---|
524 | }
|
---|
525 |
|
---|
526 |
|
---|
527 | /* Annule le mouvement en cours */
|
---|
528 | bool Abort()
|
---|
529 | {
|
---|
530 | try
|
---|
531 | {
|
---|
532 | *client_socket << "<newSwitchVector device=\"BAO\" name=\"ABORT_MOTION\" >";
|
---|
533 | *client_socket << "<oneSwitch name=\"ABORT\">";
|
---|
534 | *client_socket << "On";
|
---|
535 | *client_socket << "</oneSwitch>";
|
---|
536 | *client_socket << "</newSwitchVector>";
|
---|
537 |
|
---|
538 | if (!VerifReponse("name=\"ABORT_MOTION\" state=\"Ok\""))
|
---|
539 | {
|
---|
540 | Erreur("L'annulation a échoué.\n\n");
|
---|
541 |
|
---|
542 | return false;
|
---|
543 | }
|
---|
544 | }
|
---|
545 | catch ( SocketException& e)
|
---|
546 | {
|
---|
547 | os << e.description() << "\n";
|
---|
548 | Erreur(os.str());
|
---|
549 | return false;
|
---|
550 | }
|
---|
551 |
|
---|
552 | Affiche("Le pilote indi_BAO a bien reçu la commande ABORT.\n\n", true);
|
---|
553 |
|
---|
554 | return true;
|
---|
555 | }
|
---|
556 |
|
---|
557 | /*aller aux coordonnées ar et dec dans le mode transit ou tracking */
|
---|
558 | bool Goto(std::string ar, std::string dec, bool Transit)
|
---|
559 | {
|
---|
560 | try
|
---|
561 | {
|
---|
562 | *client_socket << "<newSwitchVector device=\"BAO\" name=\"ON_COORD_SET\">";
|
---|
563 | *client_socket << "<oneSwitch name=\"TRANSIT\">";
|
---|
564 | if (Transit) *client_socket << "On";
|
---|
565 | else *client_socket << "Off";
|
---|
566 | *client_socket << "</oneSwitch>";
|
---|
567 |
|
---|
568 | *client_socket << "<oneSwitch name=\"TRACKING\">";
|
---|
569 | if (Transit) *client_socket << "Off";
|
---|
570 | else *client_socket << "On";
|
---|
571 | *client_socket << "</oneSwitch>";
|
---|
572 | *client_socket << "</newSwitchVector>";
|
---|
573 |
|
---|
574 | if (!VerifReponse("name=\"ON_COORD_SET\""))
|
---|
575 | {
|
---|
576 | Erreur("Le changement de mode TRANSIT/TRACKING a échoué.\n\n");
|
---|
577 |
|
---|
578 | return false;
|
---|
579 | }
|
---|
580 |
|
---|
581 | *client_socket << "<newNumberVector device=\"BAO\" name=\"EQUATORIAL_EOD_COORD_REQUEST\">";
|
---|
582 | *client_socket << "<oneNumber name=\"RA\">";
|
---|
583 | *client_socket << ar;
|
---|
584 | *client_socket << "</oneNumber>";
|
---|
585 | *client_socket << "<oneNumber name=\"DEC\">";
|
---|
586 | *client_socket << dec;
|
---|
587 | *client_socket << "</oneNumber>";
|
---|
588 | *client_socket << "</newNumberVector>";
|
---|
589 |
|
---|
590 | if (!VerifReponse("name=\"EQUATORIAL_EOD_COORD_REQUEST\""))
|
---|
591 | {
|
---|
592 | Erreur("Le transfert des coordonnées de l'objet a échoué.\n\n");
|
---|
593 |
|
---|
594 | return false;
|
---|
595 | }
|
---|
596 | }
|
---|
597 | catch ( SocketException& e)
|
---|
598 | {
|
---|
599 | os << e.description() << "\n";
|
---|
600 | Erreur(os.str());
|
---|
601 | return false;
|
---|
602 | }
|
---|
603 |
|
---|
604 | os << "Les nouvelles coordonnées AD=" << ar << " DEC=" << dec << " ont été envoyées au pilote indi_BAO.\n\n";
|
---|
605 | Affiche(os.str(), true);
|
---|
606 |
|
---|
607 | return true;
|
---|
608 | }
|
---|
609 |
|
---|
610 |
|
---|
611 | /*se connecter ou se déconnecter au pilote indi_BAO */
|
---|
612 | bool Connect(bool connect)
|
---|
613 | {
|
---|
614 | try
|
---|
615 | {
|
---|
616 | *client_socket << "<newSwitchVector device=\"BAO\" name=\"CONNECTION\">";
|
---|
617 |
|
---|
618 | if (connect) *client_socket << "<oneSwitch name=\"CONNECT\">";
|
---|
619 | else *client_socket << "<oneSwitch name=\"DISCONNECT\">";
|
---|
620 |
|
---|
621 | *client_socket << "On";
|
---|
622 | *client_socket << "</oneSwitch>";
|
---|
623 | *client_socket << "</newSwitchVector>";
|
---|
624 |
|
---|
625 | if (connect)
|
---|
626 | {
|
---|
627 | if (!VerifReponse("BAORadio is online"))
|
---|
628 | {
|
---|
629 | Erreur("La connexion a échoué.\n\n");
|
---|
630 |
|
---|
631 | return false;
|
---|
632 | }
|
---|
633 | }
|
---|
634 | else
|
---|
635 | {
|
---|
636 | if (!VerifReponse("BAORadio is offline"))
|
---|
637 | {
|
---|
638 | Erreur("La déconnexion a échoué.\n\n");
|
---|
639 |
|
---|
640 | return false;
|
---|
641 | }
|
---|
642 | }
|
---|
643 | }
|
---|
644 |
|
---|
645 | catch ( SocketException& e )
|
---|
646 | {
|
---|
647 | os << "Exception was caught:" << e.description() << std::endl;
|
---|
648 | Erreur(os.str());
|
---|
649 | return false;
|
---|
650 | }
|
---|
651 |
|
---|
652 | if (connect)
|
---|
653 | {
|
---|
654 | Affiche("La connexion a été établie avec le pilote indi_BAO.\n\n", true);
|
---|
655 |
|
---|
656 | EncoyerCoordGeographiques();
|
---|
657 | }
|
---|
658 | else
|
---|
659 | {
|
---|
660 | Affiche("Confirmation de la déconnexion avec le pilote indi_BAO.\n\n", true);
|
---|
661 | }
|
---|
662 |
|
---|
663 | return true;
|
---|
664 | }
|
---|
665 |
|
---|
666 |
|
---|
667 | /* Lecture des mouvements planifiés dans le fichier fileName */
|
---|
668 | bool LectureFichierMouvements(char * fileName)
|
---|
669 | {
|
---|
670 | char * section =(char * )malloc(80);
|
---|
671 | char * key = (char *)malloc(80);
|
---|
672 | char * chaine = (char *)malloc(80);
|
---|
673 | char * value;
|
---|
674 |
|
---|
675 | Astro * AstroJJ;
|
---|
676 |
|
---|
677 | float a1, a2, a3, h;
|
---|
678 |
|
---|
679 | numobjets=1;
|
---|
680 |
|
---|
681 | os << "Lecture du fichier " << fileName << std::endl << std::endl;
|
---|
682 | Affiche(os.str(), true);
|
---|
683 |
|
---|
684 | strcpy(section, "objet 1");
|
---|
685 | strcpy(key, "date");
|
---|
686 |
|
---|
687 | while ((readINI(section, key, &value, fileName)) && (numobjets<MAXOBJETS))
|
---|
688 | {
|
---|
689 | os << "object n°" << numobjets << std::endl;
|
---|
690 | Affiche(os.str(), true);
|
---|
691 |
|
---|
692 | strcpy(key, "date");
|
---|
693 |
|
---|
694 | if ((readINI(section, key, &value, fileName)) && (Decomposition(value, 3, &a1, &a2, &a3)))
|
---|
695 | {
|
---|
696 | os << "Date du début de l'observation : le " << value;
|
---|
697 | Affiche(os.str(), true);
|
---|
698 |
|
---|
699 | AstroJJ = new Astro();
|
---|
700 |
|
---|
701 | AstroJJ->Jour=a1;
|
---|
702 | AstroJJ->Mois=a2;
|
---|
703 | AstroJJ->Annee=a3;
|
---|
704 |
|
---|
705 | AstroJJ->CalculJJ(0.0);
|
---|
706 |
|
---|
707 | objets[numobjets].JJ=AstroJJ->JJ;
|
---|
708 |
|
---|
709 | delete AstroJJ;
|
---|
710 | }
|
---|
711 | else
|
---|
712 | {
|
---|
713 | os << "La date de la rubrique [objet " << numobjets << "] est incorrecte !" << std::endl;
|
---|
714 | Erreur(os.str());
|
---|
715 | return false;
|
---|
716 | }
|
---|
717 |
|
---|
718 | strcpy(key, "heure");
|
---|
719 |
|
---|
720 | if ((readINI(section, key, &value, fileName)) && (Decomposition(value, 2, &a1, &a2, &a3)))
|
---|
721 | {
|
---|
722 | os << " Ã " << value ;
|
---|
723 | Affiche(os.str(), true);
|
---|
724 |
|
---|
725 | objets[numobjets].JJ+=(a1+a2/60.0+a3/3600.0)/24.0;
|
---|
726 |
|
---|
727 | sprintf(chaine, " TU -> JJ=%10.5f\n", objets[numobjets].JJ);
|
---|
728 |
|
---|
729 | Affiche(chaine, true);
|
---|
730 |
|
---|
731 | for (int i=1; i<numobjets; i++)
|
---|
732 | {
|
---|
733 | if (objets[i].JJ==objets[numobjets].JJ)
|
---|
734 | {
|
---|
735 | os << "Attention, les observations des objets " << i << " et " << numobjets << " sont définies à la même date !\n";
|
---|
736 | Erreur(os.str());
|
---|
737 | }
|
---|
738 |
|
---|
739 | if (objets[i].JJ+objets[i].Duree/3600/24.0>objets[numobjets].JJ)
|
---|
740 | {
|
---|
741 | os << "Attention, les observations des objets " << i << " et " << numobjets << " se chevauchent !\n";
|
---|
742 | Erreur(os.str());
|
---|
743 | }
|
---|
744 | }
|
---|
745 | }
|
---|
746 | else
|
---|
747 | {
|
---|
748 | os << "L'heure de la rubrique [objet " << numobjets << "] est incorrecte !" << std::endl;
|
---|
749 | Erreur(os.str());
|
---|
750 | return false;
|
---|
751 | }
|
---|
752 |
|
---|
753 |
|
---|
754 |
|
---|
755 |
|
---|
756 | strcpy(key, "duree");
|
---|
757 |
|
---|
758 | objets[numobjets].Duree=0.0;
|
---|
759 |
|
---|
760 | if (readINI(section, key, &value, fileName))
|
---|
761 | {
|
---|
762 | os << "Durée de l'observation : " << value << " secondes" << std::endl;
|
---|
763 | Affiche(os.str(), true);
|
---|
764 |
|
---|
765 | objets[numobjets].Duree=atof(value);
|
---|
766 | }
|
---|
767 | else
|
---|
768 | {
|
---|
769 | os << "La duree d'observation de la rubrique [objet " << numobjets << "] est incorrecte !" << std::endl;
|
---|
770 | Erreur(os.str());
|
---|
771 | return false;
|
---|
772 | }
|
---|
773 |
|
---|
774 |
|
---|
775 | strcpy(key, "ad");
|
---|
776 |
|
---|
777 | strcpy(objets[numobjets].ad, "");
|
---|
778 |
|
---|
779 | if ((readINI(section, key, &value, fileName)) && (Decomposition(value, 2, NULL, NULL, NULL)))
|
---|
780 | {
|
---|
781 | os << "Ascension droite de l'objet : " << value << std::endl;
|
---|
782 | Affiche(os.str(), true);
|
---|
783 |
|
---|
784 | strcpy(objets[numobjets].ad, value);
|
---|
785 | }
|
---|
786 | else
|
---|
787 | {
|
---|
788 | os << "L'ascension droite de la rubrique [objet " << numobjets << "] est incorrecte !" << std::endl;
|
---|
789 | Erreur(os.str());
|
---|
790 | return false;
|
---|
791 | }
|
---|
792 |
|
---|
793 |
|
---|
794 | strcpy(key, "de");
|
---|
795 |
|
---|
796 | strcpy(objets[numobjets].de, "");
|
---|
797 |
|
---|
798 | if ((readINI(section, key, &value, fileName)) && (Decomposition(value, 0, NULL, NULL, NULL)))
|
---|
799 | {
|
---|
800 | os << "Déclinaison de l'objet : " << value << std::endl << std::endl;
|
---|
801 | Affiche(os.str(), true);
|
---|
802 |
|
---|
803 | strcpy(objets[numobjets].de, value);
|
---|
804 | }
|
---|
805 | else
|
---|
806 | {
|
---|
807 | os << "La déclinaison de la rubrique [objet " << numobjets << "] est incorrecte !" << std::endl;
|
---|
808 | Erreur(os.str());
|
---|
809 | return false;
|
---|
810 | }
|
---|
811 |
|
---|
812 | objets[numobjets].exec=false;
|
---|
813 |
|
---|
814 | numobjets++;
|
---|
815 |
|
---|
816 | sprintf(section, "objet %i", numobjets);
|
---|
817 |
|
---|
818 | }
|
---|
819 |
|
---|
820 |
|
---|
821 | return true;
|
---|
822 | }
|
---|
823 |
|
---|
824 | /*Execute le fichier de mouvements */
|
---|
825 | bool Run(std::string fichier)
|
---|
826 | {
|
---|
827 | bool exec=LectureFichierMouvements((char *)fichier.c_str());
|
---|
828 |
|
---|
829 | CalculJourJulien();
|
---|
830 |
|
---|
831 | if (exec && numobjets>1)
|
---|
832 | {
|
---|
833 | if (objets[numobjets-1].JJ+objets[numobjets-1].Duree/3600.0/24.0 < astro->JJ)
|
---|
834 | {
|
---|
835 | Erreur("Le fichier contient des dates qui sont toutes périmées. Exécution annulée.\n\n");
|
---|
836 | if (exitrun) NoExit=false;
|
---|
837 | return false;
|
---|
838 | }
|
---|
839 | else
|
---|
840 | {
|
---|
841 | os << "Execution du fichier " << fichier << " en attente..." << std::endl << std::endl;
|
---|
842 | Affiche(os.str(), true);
|
---|
843 | run=true;
|
---|
844 | }
|
---|
845 | }
|
---|
846 | else
|
---|
847 | {
|
---|
848 | os << std::endl << "Le fichier " << fichier << " contient des erreurs ou n'existe pas...\n" << std::endl << std::endl;
|
---|
849 | Erreur(os.str());
|
---|
850 | if (exitrun) NoExit=false;
|
---|
851 | return false;
|
---|
852 | }
|
---|
853 |
|
---|
854 | return true;
|
---|
855 | }
|
---|
856 |
|
---|
857 |
|
---|
858 | /*identification des commandes entrées par l'utilisateur */
|
---|
859 | void DecodageEntreesUtilisateur(std::string chaine)
|
---|
860 | {
|
---|
861 | std::string ar, de, fichier;
|
---|
862 |
|
---|
863 |
|
---|
864 | if (chaine.find("goto")!=string::npos)
|
---|
865 | {
|
---|
866 | if (DecompositionCommande(chaine, "goto", &ar, &de) && Decomposition(ar, 2, NULL, NULL, NULL) && Decomposition(de, 0, NULL, NULL, NULL))
|
---|
867 | {
|
---|
868 | Goto(ar, de, Transit);
|
---|
869 | }
|
---|
870 | else
|
---|
871 | {
|
---|
872 | Erreur("Erreur goto : le format de la commande est goto AD DEC\n \
|
---|
873 | L AD doit être de la forme xx:yy:zz (ex: 12:00:03 pour 12h 0m 3s)\n \
|
---|
874 | La déclinaison doit être de la forme +/-xx:yy:zz (ex: -12:50:01 pour -12° 50' 01'')\n\n");
|
---|
875 | }
|
---|
876 | }
|
---|
877 |
|
---|
878 |
|
---|
879 | if (chaine.find("abort")!=string::npos)
|
---|
880 | {
|
---|
881 | Abort();
|
---|
882 |
|
---|
883 | if (chaine.find("run")!=string::npos)
|
---|
884 | {
|
---|
885 | run=false;
|
---|
886 | runnum=1;
|
---|
887 | numobjets=1;
|
---|
888 |
|
---|
889 | Affiche("Annulation de l'exécution du fichier de mouvements.\n\n", true);
|
---|
890 |
|
---|
891 | return;
|
---|
892 | }
|
---|
893 | }
|
---|
894 |
|
---|
895 |
|
---|
896 | if (chaine.find("run")!=string::npos)
|
---|
897 | {
|
---|
898 | if (DecompositionCommande(chaine, "run", &fichier, NULL))
|
---|
899 | {
|
---|
900 | Run(fichier);
|
---|
901 | }
|
---|
902 | else
|
---|
903 | {
|
---|
904 | Erreur("Erreur run : la commande run doit être suivie par un nom de fichier.\n\n");
|
---|
905 | }
|
---|
906 | }
|
---|
907 |
|
---|
908 |
|
---|
909 | if (chaine.find("connect")!=string::npos)
|
---|
910 | {
|
---|
911 | Connect(chaine.find("disconnect")==string::npos);
|
---|
912 | }
|
---|
913 |
|
---|
914 |
|
---|
915 | if (chaine.find("transit")!=string::npos)
|
---|
916 | {
|
---|
917 | Affiche("Mode transit activé.\n\n", true);
|
---|
918 |
|
---|
919 | Transit=true;
|
---|
920 | }
|
---|
921 |
|
---|
922 |
|
---|
923 | if (chaine.find("tracking")!=string::npos)
|
---|
924 | {
|
---|
925 | Affiche("Mode tracking activé.\n\n", true);
|
---|
926 |
|
---|
927 | Transit=false;
|
---|
928 | }
|
---|
929 |
|
---|
930 |
|
---|
931 | if (chaine.find("park")!=string::npos)
|
---|
932 | {
|
---|
933 | Park();
|
---|
934 | }
|
---|
935 |
|
---|
936 |
|
---|
937 |
|
---|
938 |
|
---|
939 |
|
---|
940 | if (chaine.find("help")!=string::npos)
|
---|
941 | {
|
---|
942 | std::cout << std::endl;
|
---|
943 |
|
---|
944 | std::cout << "connect : connecte le pilote INDI" << std::endl;
|
---|
945 | std::cout << "disconnect : ferme la connexion avec le pilote INDI" << std::endl;
|
---|
946 | std::cout << "goto AD Dec : pointe l'objet aux coordonnées AD Dec" << std::endl;
|
---|
947 | std::cout << "transit : mode de suivi transit" << std::endl;
|
---|
948 | std::cout << "tracking : mode de suivi tracking" << std::endl;
|
---|
949 | std::cout << "run filename : execute le fichier filename" << std::endl;
|
---|
950 | std::cout << "abort run : annule l'exécution du fichier de mouvements" << std::endl;
|
---|
951 | std::cout << "abort : annule le mouvement en cours" << std::endl;
|
---|
952 | std::cout << "park : place les antennes en position de repos" << std::endl;
|
---|
953 | std::cout << "exit : sortir de BAOControl" << std::endl;
|
---|
954 |
|
---|
955 | std::cout << std::endl;
|
---|
956 | }
|
---|
957 |
|
---|
958 |
|
---|
959 | if (chaine.find("exit")!=string::npos)
|
---|
960 | {
|
---|
961 | Connect (false);
|
---|
962 |
|
---|
963 | NoExit=false;
|
---|
964 | }
|
---|
965 | }
|
---|
966 |
|
---|
967 |
|
---|
968 | /* chargement des paramÚtres dans le fichier params */
|
---|
969 | bool ChargementParametres()
|
---|
970 | {
|
---|
971 | char * section =(char * )malloc(80);
|
---|
972 | char * key = (char *)malloc(80);
|
---|
973 | char * value;
|
---|
974 | char * fileName = (char *)malloc(sizeof(char)*255);
|
---|
975 |
|
---|
976 |
|
---|
977 | Affiche("Lecture du fichier de configuration 'params' :\n\n", true);
|
---|
978 |
|
---|
979 | strcpy(fileName,"params");
|
---|
980 |
|
---|
981 | strcpy(section, "connexion indi");
|
---|
982 |
|
---|
983 | strcpy(key, "serveur");
|
---|
984 |
|
---|
985 | strcpy(Serveur, "");
|
---|
986 |
|
---|
987 | if (readINI(section, key, &value, fileName))
|
---|
988 | {
|
---|
989 | strcpy(Serveur, value);
|
---|
990 | os << "serveur=" << Serveur << std::endl;
|
---|
991 | Affiche(os.str(), true);
|
---|
992 | }
|
---|
993 | else
|
---|
994 | {
|
---|
995 | os << "Nom du serveur invalide !" << std::endl;
|
---|
996 | Erreur(os.str());
|
---|
997 | return false;
|
---|
998 | }
|
---|
999 |
|
---|
1000 | strcpy(key, "port");
|
---|
1001 |
|
---|
1002 | if (readINI(section, key, &value, fileName))
|
---|
1003 | {
|
---|
1004 | Port=atoi(value);
|
---|
1005 | os << "port=" << Port << std::endl << std::endl;
|
---|
1006 | Affiche(os.str(), true);
|
---|
1007 | }
|
---|
1008 | else
|
---|
1009 | {
|
---|
1010 | os << "Numéro de port incorrect !" << std::endl;
|
---|
1011 | Erreur(os.str());
|
---|
1012 | return false;
|
---|
1013 | }
|
---|
1014 |
|
---|
1015 | strcpy(section, "coordonnees geographiques");
|
---|
1016 |
|
---|
1017 | strcpy(Latitude, "");
|
---|
1018 | strcpy(Longitude, "");
|
---|
1019 |
|
---|
1020 | strcpy(key, "latitude");
|
---|
1021 |
|
---|
1022 | if ((readINI(section, key, &value, fileName)) && (Decomposition(value, 0, NULL, NULL, NULL)))
|
---|
1023 | {
|
---|
1024 | strcpy(Latitude, value);
|
---|
1025 | os << "latitude=" << Latitude << std::endl;
|
---|
1026 | Affiche(os.str(), true);
|
---|
1027 | }
|
---|
1028 | else
|
---|
1029 | {
|
---|
1030 | os << "La latitude est incorrecte !" << std::endl;
|
---|
1031 | Erreur(os.str());
|
---|
1032 | return false;
|
---|
1033 | }
|
---|
1034 |
|
---|
1035 | strcpy(key, "longitude");
|
---|
1036 |
|
---|
1037 | if ((readINI(section, key, &value, fileName)) && (Decomposition(value, 1, NULL, NULL, NULL)))
|
---|
1038 | {
|
---|
1039 | strcpy(Longitude, value);
|
---|
1040 | os << "longitude=" << Longitude << std::endl << std::endl;
|
---|
1041 | Affiche(os.str(), true);
|
---|
1042 | }
|
---|
1043 | else
|
---|
1044 | {
|
---|
1045 | os << "La longitude est incorrecte !" << std::endl;
|
---|
1046 | Erreur(os.str());
|
---|
1047 | return false;
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 | strcpy(section, "transit");
|
---|
1051 |
|
---|
1052 | strcpy(key, "delai");
|
---|
1053 |
|
---|
1054 | if (readINI(section, key, &value, fileName))
|
---|
1055 | {
|
---|
1056 | delaitransit=atoi(value);
|
---|
1057 | os << "delai transit= " << delaitransit << " sec" << std::endl;
|
---|
1058 | Affiche(os.str(), true);
|
---|
1059 | }
|
---|
1060 | else
|
---|
1061 | {
|
---|
1062 | os << "Le paramÚtre transit est incorrect !" << std::endl;
|
---|
1063 | Erreur(os.str());
|
---|
1064 | return false;
|
---|
1065 | }
|
---|
1066 |
|
---|
1067 | strcpy(section, "tracking");
|
---|
1068 |
|
---|
1069 | strcpy(key, "delai");
|
---|
1070 |
|
---|
1071 | if (readINI(section, key, &value, fileName))
|
---|
1072 | {
|
---|
1073 | delaitracking=atoi(value);
|
---|
1074 | os << "delai tracking= " << delaitracking << " sec" << std::endl << std::endl;
|
---|
1075 | Affiche(os.str(), true);
|
---|
1076 | }
|
---|
1077 | else
|
---|
1078 | {
|
---|
1079 | os << "Le paramÚtre tracking est incorrect !" << std::endl;
|
---|
1080 | Erreur(os.str());
|
---|
1081 | return false;
|
---|
1082 | }
|
---|
1083 |
|
---|
1084 | return true;
|
---|
1085 | }
|
---|
1086 |
|
---|
1087 |
|
---|
1088 |
|
---|
1089 | int main(int argc, char **argv)
|
---|
1090 | {
|
---|
1091 | std::string chaine;
|
---|
1092 |
|
---|
1093 | pthread_t th1;
|
---|
1094 |
|
---|
1095 | if (argc >1)
|
---|
1096 | {
|
---|
1097 | if (strstr(argv[1], "-h")!=NULL)
|
---|
1098 | {
|
---|
1099 | std::cout << "usage :\n \
|
---|
1100 | BAOControl -h ou --help : affiche l'aide\n \
|
---|
1101 | BAOControl -r FileName : execute les mouvements définis dans le fichier FileName\n\n";
|
---|
1102 |
|
---|
1103 | return 0;
|
---|
1104 | }
|
---|
1105 | }
|
---|
1106 |
|
---|
1107 | for (int i=0; i<MAXANTENNES; i++)
|
---|
1108 | {
|
---|
1109 | Antennes[i].ok=0;
|
---|
1110 | Antennes[i].ip=0;
|
---|
1111 | }
|
---|
1112 |
|
---|
1113 | for (int i=0; i<MAXOBJETS; i++)
|
---|
1114 | {
|
---|
1115 | objets[i].JJ=0;
|
---|
1116 | objets[i].exec=false;
|
---|
1117 | }
|
---|
1118 |
|
---|
1119 |
|
---|
1120 | Affiche("\n\n\n\n\n\n \
|
---|
1121 | ************************\n \
|
---|
1122 | * BAO Control *\n \
|
---|
1123 | * v0.1 *\n \
|
---|
1124 | * 10/11/2010 *\n \
|
---|
1125 | ************************\n\n", true);
|
---|
1126 |
|
---|
1127 | if (!ChargementParametres())
|
---|
1128 | {
|
---|
1129 | Erreur("Le fichier de configuration 'params' contient des erreurs ou n'existe pas. Merci de vérifier.\n");
|
---|
1130 | exit(1);
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 | client_socket = new ClientSocket("localhost", Port );
|
---|
1134 |
|
---|
1135 |
|
---|
1136 | Connect(true);
|
---|
1137 |
|
---|
1138 | if (argc == 1) std::cout << "Tapez help pour obtenir des infos sur les commandes disponibles.\n" << std::endl;
|
---|
1139 |
|
---|
1140 | initialiserFenetre();
|
---|
1141 |
|
---|
1142 | XSelectInput(d,w, ExposureMask );
|
---|
1143 |
|
---|
1144 | if (pthread_create(&th1, NULL, my_thread_process, NULL) < 0) {
|
---|
1145 | Erreur("Impossible de créer le thread\n");
|
---|
1146 | exit (1);
|
---|
1147 | }
|
---|
1148 |
|
---|
1149 | astro = new Astro();
|
---|
1150 |
|
---|
1151 | if (argc == 3)
|
---|
1152 | {
|
---|
1153 | if (strstr(argv[1], "-r")!=NULL)
|
---|
1154 | {
|
---|
1155 | exitrun=true;
|
---|
1156 |
|
---|
1157 | Run(argv[2]);
|
---|
1158 |
|
---|
1159 | do
|
---|
1160 | {
|
---|
1161 |
|
---|
1162 | } while (NoExit);
|
---|
1163 | }
|
---|
1164 | else
|
---|
1165 | {
|
---|
1166 | Erreur("Usage incorrect\n\n");
|
---|
1167 | }
|
---|
1168 | }
|
---|
1169 | else
|
---|
1170 | {
|
---|
1171 |
|
---|
1172 | do
|
---|
1173 | {
|
---|
1174 | std::cout << blue << '>';
|
---|
1175 | getline(std::cin, chaine);
|
---|
1176 | std::cout << black;
|
---|
1177 |
|
---|
1178 | for (int i=0; i<chaine.size();++i) chaine[i] = tolower(chaine[i]);
|
---|
1179 |
|
---|
1180 | DecodageEntreesUtilisateur(chaine);
|
---|
1181 | }
|
---|
1182 | while (NoExit);
|
---|
1183 | }
|
---|
1184 |
|
---|
1185 | delete astro;
|
---|
1186 | delete client_socket;
|
---|
1187 |
|
---|
1188 | return 0;
|
---|
1189 | }
|
---|