Changeset 2106 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Jul 17, 2002, 7:30:48 PM (23 years ago)
Author:
ansari
Message:

Ajout indicateur memoire consommee/CPU ds fenetre piapp - Reza 17/7/2002

Location:
trunk/SophyaPI/PIext
Files:
2 edited

Legend:

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

    r1971 r2106  
    4242static void showInfoWindow(PIStdImgApp* app);
    4343static void hideInfoWindow(PIStdImgApp* app);
     44
     45
     46/* ........................................................... */
     47/*    Classe SIA_RU__Periodic : mise a jour periodique de      */
     48/*    la fenetre Stat/Ressource info                           */
     49/* ........................................................... */
     50
     51class SIA_RU__Periodic : public PIPeriodic
     52{
     53public:
     54  SIA_RU__Periodic(PIStdImgApp* app);
     55  virtual ~SIA_RU__Periodic();
     56  virtual void DoPeriodic();
     57private:
     58  PIStdImgApp* _app;
     59};
     60
     61SIA_RU__Periodic::SIA_RU__Periodic(PIStdImgApp* app)
     62  : PIPeriodX(1)
     63{
     64  _app = app;
     65}
     66
     67SIA_RU__Periodic::~SIA_RU__Periodic()
     68{
     69}
     70
     71void SIA_RU__Periodic::DoPeriodic()
     72{
     73  if (_app) _app->UpdateStatResourceInfo();
     74}
     75
     76/* ............................................................. */
     77
    4478
    4579/* ........................................................... */
     
    156190cmapv = new PICMapView(statcont, "CMapView", msx-10, 14+mFgScSz*2, 5, bss+10);
    157191cmapv->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
    158 labstat = new PILabel(statcont, "statlabel", msx-2*(bss+20), 20, 2*bss+20, 10);
    159 labstat->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
    160 labstat->SetLabel("Stat-Zoom-ColMap Window");
    161 labstat->SetForegroundColor(PI_Red);
    162 labstat->SetBorderWidth(1);
     192
     193// Widget pour affichage des stats / ressources
     194lab_mem = new PILabel(statcont, "memlab", msx-2*(bss+20), 20, 2*bss+20, 10);
     195lab_mem->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
     196lab_mem->SetLabel("MemoryUsage");
     197lab_mem->SetForegroundColor(PI_Red);
     198lab_mem->SetBorderWidth(1);
     199therm_mem = new PIThermometer(statcont, "memtherm", msx-2*(bss+20), 20, 2*bss+20, 35);
     200therm_mem->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
     201therm_mem->SetThreshold(0.5, 0.75);
     202
     203lab_cpu = new PILabel(statcont, "cpulab", msx-2*(bss+20), 20, 2*bss+20, 60);
     204lab_cpu->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
     205lab_cpu->SetLabel("CPUUsage");
     206lab_cpu->SetForegroundColor(PI_Black);
     207lab_cpu->SetBorderWidth(1);
     208therm_cpu = new PIThermometer(statcont, "cputherm", msx-2*(bss+20), 20, 2*bss+20, 85);
     209therm_cpu->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
     210therm_cpu->SetThreshold(0.75, 0.90);
     211
     212UpdateStatResourceInfo();
     213resupd_periodic = new SIA_RU__Periodic(this);
     214//resupd_periodic->SetIntervalms(500);
     215resupd_periodic->Start();
     216
    163217statcont->Show();
    164218// StatZoomWindowSetVisible(true);
     
    276330delete gimv;
    277331delete cmapv;
    278 delete labstat;
     332
     333delete lab_mem;
     334delete therm_mem;
     335delete lab_cpu;
     336delete therm_cpu;
    279337
    280338delete statcont;
     
    285343
    286344delete mCons;
    287  delete consolecont;
     345delete consolecont;
    288346
    289347delete mObjmgrw;
     
    296354if (mPpfout) delete mPpfout;
    297355
     356if (resupd_periodic) delete resupd_periodic;
     357
    298358if (glst_piai) delete glst_piai;   glst_piai = NULL;
     359
    299360
    300361
     
    10681129
    10691130/* --Methode-- */
     1131void PIStdImgApp::UpdateStatResourceInfo()
     1132{
     1133  resusg.Update();
     1134  char buff[256];
     1135  string lab;
     1136  double frac;
     1137  sprintf(buff, "Mem: %ld/Max= %ld kb" , resusg.getMemorySize(),
     1138          resusg.getMaxMemorySize());
     1139  lab = buff;
     1140  lab_mem->SetLabel(lab);
     1141  frac = (double)resusg.getMemorySize()/(double)resusg.getMaxMemorySize();
     1142  therm_mem->SetValue(frac);
     1143
     1144  sprintf(buff, "CPU: %ld/elap= %ld ms" , resusg.getCPUTime(),
     1145          resusg.getElapsedTime());
     1146  lab = buff;
     1147  lab_cpu->SetLabel(lab);
     1148  therm_cpu->SetValue(resusg.getAverageCPULoad());
     1149 
     1150}
     1151
     1152/* --Methode-- */
    10701153void PIStdImgApp::RedirectStdOutErr(bool fg)
    10711154{
     
    16691752}
    16701753
     1754
  • trunk/SophyaPI/PIext/pistdimgapp.h

    r1971 r2106  
    2121
    2222#include PIFILECHO_H
     23#include PIPERIODIC_H
     24
    2325#include "picons.h"
    2426
     
    2931#include "pisiadw.h"
    3032#include "pistzwin.h"
     33
     34#include "pitherm.h"
     35
     36#include "resusage.h"
    3137
    3238
     
    100106    void   StatZoomWindowSetVisible(bool fg=true);
    101107
     108// Update de l'info de la fenetre stats/ressources
     109    void   UpdateStatResourceInfo();
     110
    102111// Redirection ou Non de StdOut/StdErr
    103112     void  RedirectStdOutErr(bool fg = true);
     
    144153    PIPixmap* gimv;
    145154    PICMapView* cmapv;
    146     PILabel* labstat;
     155  // Pour afficher des stats
     156    PILabel* lab_mem;
     157    PIThermometer* therm_mem;
     158    PILabel* lab_cpu;
     159    PIThermometer* therm_cpu;
    147160
    148161    PIFileChooser * pfc_fits;   // Pour les fichiers FITS
     
    183196    int mFgScSz;   // Flag ScreenSize
    184197    bool mFgCWImg; // true -> Current Widget is PIImage
     198
     199  // Pour comptabiliser l'utilisation des ressources
     200    ResourceUsage resusg;
     201    PIPeriodic* resupd_periodic;
    185202};
    186203
Note: See TracChangeset for help on using the changeset viewer.