Changeset 2486 in Sophya for trunk/SophyaPI/PIext/pistdimgapp.cc


Ignore:
Timestamp:
Dec 26, 2003, 12:17:41 PM (22 years ago)
Author:
ansari
Message:

Debut d'implementation piapp multi-thread - (avec des pb lors de l'execution de demo.pic) Reza 26 Dec 2003

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/pistdimgapp.cc

    r2427 r2486  
    9090/* --Methode-- */
    9191PIStdImgApp::PIStdImgApp(int narg, char* arg[])
    92 : PIApplication(420, 320, narg, arg)
     92  : PIApplication(420, 320, narg, arg) , resusg(ResourceUsage::RU_All)
    9393{
    9494
     
    188188// le widget zoom, colormap, stats, ...
    189189
    190 int bss = 100+mFgScSz*15;
     190int bss = 105+mFgScSz*15;
    191191
    192192int statc_szy = bss+10+14+mFgScSz*2+5;
     
    202202
    203203// Widget pour affichage des stats / ressources
    204 lab_mem = new PILabel(statcont, "memlab", msx-2*(bss+20), 20, 2*bss+20, 10);
     204lab_mem = new PILabel(statcont, "memlab", msx-2*(bss+20), 20, 2*bss+20, 5);
    205205lab_mem->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
    206206lab_mem->SetLabel("MemoryUsage");
    207207lab_mem->SetForegroundColor(PI_Red);
    208208lab_mem->SetBorderWidth(1);
    209 therm_mem = new PIThermometer(statcont, "memtherm", msx-2*(bss+20), 20, 2*bss+20, 35);
     209therm_mem = new PIThermometer(statcont, "memtherm", msx-2*(bss+20), 15, 2*bss+20, 30);
    210210therm_mem->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
    211211therm_mem->SetThreshold(0.5, 0.75);
    212212
    213 lab_cpu = new PILabel(statcont, "cpulab", msx-2*(bss+20), 20, 2*bss+20, 60);
     213lab_cpu = new PILabel(statcont, "cpulab", msx-2*(bss+20), 20, 2*bss+20, 50);
    214214lab_cpu->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
    215215lab_cpu->SetLabel("CPUUsage");
    216216lab_cpu->SetForegroundColor(PI_Black);
    217217lab_cpu->SetBorderWidth(1);
    218 therm_cpu = new PIThermometer(statcont, "cputherm", msx-2*(bss+20), 20, 2*bss+20, 85);
     218therm_cpu = new PIThermometer(statcont, "cputherm", msx-2*(bss+20), 15, 2*bss+20, 75);
    219219therm_cpu->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
    220220therm_cpu->SetThreshold(0.75, 0.90);
    221 
    222  fg_exc_cmd = false;
     221lab_thrcmd = new PILabel(statcont, "thrcmdlab", msx-2*(bss+20), 20, 2*bss+20, 95);
     222lab_thrcmd->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
     223lab_thrcmd->SetLabel("CommandThread");
     224lab_thrcmd->SetForegroundColor(PI_Green);
     225lab_thrcmd->SetBorderWidth(1);
     226
     227fg_exc_cmd = false;
     228mCmd = NULL;  // Avant d'appeler UpdateStatResource() si PIACmd non cree
    223229UpdateStatResourceInfo();
    224230resupd_periodic = new SIA_RU__Periodic(this);
     
    347353delete lab_cpu;
    348354delete therm_cpu;
     355delete lab_thrcmd;
    349356
    350357delete statcont;
     
    372379
    373380
     381
     382/* --Methode-- */
     383void PIStdImgApp::Run()
     384{
     385XEvent evt;
     386int szx, szy, szf;
     387XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
     388// Pour appeler FinishCreate() des objets dans la fenetre principale
     389if (mStop) { // C'est la premiere fois
     390  topcont->SetSize(topcont->XSize(), topcont->YSize());
     391  MBCont()->FinishCreate();   
     392  }
     393else mStop = true;   // On rerentre apres un stop
     394
     395mCmd->start();
     396
     397while (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}
     406return;
     407}
    374408
    375409/* --Methode-- */
     
    479513#else
    480514  try {
    481     mCmd->Interpret(s);
     515    //    mCmd->Interpret(s);
     516    mCmd->AddInputLine(s);
    482517    } 
    483518  catch ( PThrowable & exc ) {
     
    559594// Pas de same ou inset pour DispImage
    560595if ((dwopt == Disp_Same) || (dwopt == Disp_Inset) ) dwopt = Disp_Next;
     596
     597// <ZThread> global PIApplication event loop synchronisation
     598ZSync zs(thr_glsyn); 
    561599
    562600// Choix de la taille de fenetre
     
    626664DispWinEnum dwopt = ParseDisplayOption(sop, opts);
    627665if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) )  dwopt = Disp_Next;
     666
     667// <ZThread> global PIApplication event loop synchronisation
     668ZSync zs(thr_glsyn); 
     669
    628670// Trace en superpoistion
    629671if ( (dwopt == Disp_Same) && (mLastWdg) ) { 
     
    726768
    727769if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) )  dwopt = Disp_Next;
     770
     771// <ZThread> global PIApplication event loop synchronisation
     772ZSync zs(thr_glsyn); 
     773
    728774// Trace en superpoistion
    729775if ( (dwopt == Disp_Same) && (mLastWdg) ) {
     
    13591405  else
    13601406    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  }
    13611422}
    13621423
Note: See TracChangeset for help on using the changeset viewer.