Changeset 2486 in Sophya for trunk/SophyaPI/PIext
- Timestamp:
- Dec 26, 2003, 12:17:41 PM (22 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/piacmd.cc
r2474 r2486 180 180 181 181 InitializeHelpWindowMenu(); 182 // <ZThread> Thread control attributes 183 fg_thrstop = false; 184 fg_threxe = false; 182 185 } 183 186 … … 195 198 } 196 199 200 201 /* --Methode-- */ 202 void PIACmd::AddInputLine(string const & line) 203 { 204 mutx_inps.lock(); 205 inputlines.push(line); 206 mutx_inps.unlock(); 207 mutx_inps.broadcast(); 208 } 209 210 /* --Methode-- */ 211 void PIACmd::StopThread() 212 { 213 fg_thrstop = true; 214 mutx_inps.broadcast(); 215 } 216 217 /* --Methode-- */ 218 void PIACmd::run() 219 { 220 cout << " DBG-PIACmd::run() -- DEBUT " << endl; 221 while (!fg_thrstop) { 222 mutx_inps.lock(); 223 while (inputlines.empty()) { 224 fg_threxe = false; 225 mutx_inps.wait(); 226 } 227 string line = inputlines.top(); 228 inputlines.pop(); 229 fg_threxe = true; 230 mutx_inps.unlock(); 231 Interpret(line); 232 } 233 } 197 234 198 235 /* --Methode-- */ -
trunk/SophyaPI/PIext/piacmd.h
r2474 r2486 11 11 #include <string> 12 12 #include <vector> 13 #include <stack> 14 #include "zthread.h" 13 15 14 16 #include "dlftypes.h" … … 29 31 30 32 31 class PIACmd : public Commander {33 class PIACmd : public Commander, public ZThread { 32 34 public: 33 35 // static PIACmd* GetInterpreter(); … … 36 38 virtual ~PIACmd(); 37 39 40 // Thread execution <ZThread> 41 virtual void run(); 42 void AddInputLine(string const & line); 43 void StopThread(); 44 inline bool isRunning(int& ninp) 45 { ninp = inputlines.size(); return fg_threxe; } 46 // ---- FIN ---- Thread execution <ZThread> 38 47 39 48 void ShowHelpWindow(); … … 77 86 CxxExecWind* cxxexwin; 78 87 CxxOptionWind* cxxoptwin; 88 89 // Stack d'entree et controle de thread 90 stack<string> inputlines; 91 bool fg_thrstop; 92 ZMutex mutx_inps; 93 bool fg_threxe; 94 79 95 }; 80 96 -
trunk/SophyaPI/PIext/pistdimgapp.cc
r2427 r2486 90 90 /* --Methode-- */ 91 91 PIStdImgApp::PIStdImgApp(int narg, char* arg[]) 92 : PIApplication(420, 320, narg, arg)92 : PIApplication(420, 320, narg, arg) , resusg(ResourceUsage::RU_All) 93 93 { 94 94 … … 188 188 // le widget zoom, colormap, stats, ... 189 189 190 int bss = 10 0+mFgScSz*15;190 int bss = 105+mFgScSz*15; 191 191 192 192 int statc_szy = bss+10+14+mFgScSz*2+5; … … 202 202 203 203 // Widget pour affichage des stats / ressources 204 lab_mem = new PILabel(statcont, "memlab", msx-2*(bss+20), 20, 2*bss+20, 10);204 lab_mem = new PILabel(statcont, "memlab", msx-2*(bss+20), 20, 2*bss+20, 5); 205 205 lab_mem->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); 206 206 lab_mem->SetLabel("MemoryUsage"); 207 207 lab_mem->SetForegroundColor(PI_Red); 208 208 lab_mem->SetBorderWidth(1); 209 therm_mem = new PIThermometer(statcont, "memtherm", msx-2*(bss+20), 20, 2*bss+20, 35);209 therm_mem = new PIThermometer(statcont, "memtherm", msx-2*(bss+20), 15, 2*bss+20, 30); 210 210 therm_mem->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); 211 211 therm_mem->SetThreshold(0.5, 0.75); 212 212 213 lab_cpu = new PILabel(statcont, "cpulab", msx-2*(bss+20), 20, 2*bss+20, 60);213 lab_cpu = new PILabel(statcont, "cpulab", msx-2*(bss+20), 20, 2*bss+20, 50); 214 214 lab_cpu->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); 215 215 lab_cpu->SetLabel("CPUUsage"); 216 216 lab_cpu->SetForegroundColor(PI_Black); 217 217 lab_cpu->SetBorderWidth(1); 218 therm_cpu = new PIThermometer(statcont, "cputherm", msx-2*(bss+20), 20, 2*bss+20, 85);218 therm_cpu = new PIThermometer(statcont, "cputherm", msx-2*(bss+20), 15, 2*bss+20, 75); 219 219 therm_cpu->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); 220 220 therm_cpu->SetThreshold(0.75, 0.90); 221 222 fg_exc_cmd = false; 221 lab_thrcmd = new PILabel(statcont, "thrcmdlab", msx-2*(bss+20), 20, 2*bss+20, 95); 222 lab_thrcmd->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); 223 lab_thrcmd->SetLabel("CommandThread"); 224 lab_thrcmd->SetForegroundColor(PI_Green); 225 lab_thrcmd->SetBorderWidth(1); 226 227 fg_exc_cmd = false; 228 mCmd = NULL; // Avant d'appeler UpdateStatResource() si PIACmd non cree 223 229 UpdateStatResourceInfo(); 224 230 resupd_periodic = new SIA_RU__Periodic(this); … … 347 353 delete lab_cpu; 348 354 delete therm_cpu; 355 delete lab_thrcmd; 349 356 350 357 delete statcont; … … 372 379 373 380 } 381 382 /* --Methode-- */ 383 void PIStdImgApp::Run() 384 { 385 XEvent evt; 386 int szx, szy, szf; 387 XtAppContext * appctx = PIXtAppCtx(szx, szy, szf); 388 // Pour appeler FinishCreate() des objets dans la fenetre principale 389 if (mStop) { // C'est la premiere fois 390 topcont->SetSize(topcont->XSize(), topcont->YSize()); 391 MBCont()->FinishCreate(); 392 } 393 else mStop = true; // On rerentre apres un stop 394 395 mCmd->start(); 396 397 while (mStop) { 398 thr_glsyn.lock(); // <ZThread> 399 if (XtAppPending(*appctx) != 0) { 400 XtAppNextEvent(*appctx, &evt); 401 XtDispatchEvent(&evt); 402 } 403 thr_glsyn.unlock(); // <ZThread> 404 usleep(1000); 405 } 406 return; 407 } 374 408 375 409 /* --Methode-- */ … … 479 513 #else 480 514 try { 481 mCmd->Interpret(s); 515 // mCmd->Interpret(s); 516 mCmd->AddInputLine(s); 482 517 } 483 518 catch ( PThrowable & exc ) { … … 559 594 // Pas de same ou inset pour DispImage 560 595 if ((dwopt == Disp_Same) || (dwopt == Disp_Inset) ) dwopt = Disp_Next; 596 597 // <ZThread> global PIApplication event loop synchronisation 598 ZSync zs(thr_glsyn); 561 599 562 600 // Choix de la taille de fenetre … … 626 664 DispWinEnum dwopt = ParseDisplayOption(sop, opts); 627 665 if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) ) dwopt = Disp_Next; 666 667 // <ZThread> global PIApplication event loop synchronisation 668 ZSync zs(thr_glsyn); 669 628 670 // Trace en superpoistion 629 671 if ( (dwopt == Disp_Same) && (mLastWdg) ) { … … 726 768 727 769 if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) ) dwopt = Disp_Next; 770 771 // <ZThread> global PIApplication event loop synchronisation 772 ZSync zs(thr_glsyn); 773 728 774 // Trace en superpoistion 729 775 if ( (dwopt == Disp_Same) && (mLastWdg) ) { … … 1359 1405 else 1360 1406 therm_cpu->SetValue(resusg.getAverageCPULoad()); 1407 int nlx = 0; 1408 bool fgx = false; 1409 if (mCmd) fgx = mCmd->isRunning(nlx); 1410 if (!fgx) { 1411 lab = "PIACmdThread Idle"; 1412 lab_thrcmd->SetLabel(lab); 1413 lab_thrcmd->SetForegroundColor(PI_Green); 1414 } 1415 else { 1416 sprintf(buff, "PIACmdThread Running - NL=%d" , nlx); 1417 lab = buff; 1418 lab_thrcmd->SetLabel(lab); 1419 if (nlx < 3) lab_thrcmd->SetForegroundColor(PI_Yellow); 1420 else lab_thrcmd->SetForegroundColor(PI_Red); 1421 } 1361 1422 } 1362 1423 -
trunk/SophyaPI/PIext/pistdimgapp.h
r2265 r2486 34 34 #include "pitherm.h" 35 35 36 #include "zthread.h" 36 37 #include "resusage.h" 37 38 … … 53 54 virtual void SetBlocked(); 54 55 56 // <ZThread> Multithread execution 57 // On redefinit la methode Run pour gestion multithread 58 virtual void Run(); 59 inline ZMutex & getMutex() { return thr_glsyn; } 60 61 // Methodes d'Affichage generique 55 62 int DispImage(P2DArrayAdapter* nouv, string const & name, string const & opt, int oid=0); 56 63 int DispScDrawer(PIDrawer* scd, string const & name, string const & opt, … … 171 178 PIPixmap* gimv; 172 179 PICMapView* cmapv; 173 // Pour afficher des stats 180 // Pour afficher des stats et etat thread command 174 181 PILabel* lab_mem; 175 182 PIThermometer* therm_mem; 176 183 PILabel* lab_cpu; 177 184 PIThermometer* therm_cpu; 185 PILabel* lab_thrcmd; 178 186 179 187 PIFileChooser * pfc_fits; // Pour les fichiers FITS … … 224 232 string exc_command; 225 233 bool fg_exc_cmd; 234 // Attributs pour controle de thread 235 ZMutex thr_glsyn; 226 236 }; 227 237
Note:
See TracChangeset
for help on using the changeset viewer.