"Fossies" - the Fresh Open Source Software Archive

Member "xosview-1.23/hpux/pagemeter.cc" (11 Jul 2020, 1751 Bytes) of package /linux/misc/xosview-1.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "pagemeter.cc" see the Fossies "Dox" file reference documentation.

    1 //  
    2 //  Copyright (c) 1997 by Mike Romberg (romberg@fsl.noaa.gov)
    3 //
    4 //  This file may be distributed under terms of the GPL
    5 //
    6 
    7 #include "pagemeter.h"
    8 #include "xosview.h"
    9 #include <stdlib.h>
   10 #include <sys/pstat.h>
   11 
   12 PageMeter::PageMeter( XOSView *parent, float max )
   13   : FieldMeterDecay( parent, 3, "PAGE", "IN/OUT/IDLE" ){
   14   for ( int i = 0 ; i < 2 ; i++ )
   15     for ( int j = 0 ; j < 2 ; j++ )
   16       pageinfo_[j][i] = 0;
   17 
   18   maxspeed_ = max;
   19   pageindex_ = 0;
   20 }
   21 
   22 PageMeter::~PageMeter( void ){
   23 }
   24 
   25 void PageMeter::checkResources( void ){
   26   FieldMeterDecay::checkResources();
   27 
   28   setfieldcolor( 0, parent_->getResource( "pageInColor" ) );
   29   setfieldcolor( 1, parent_->getResource( "pageOutColor" ) );
   30   setfieldcolor( 2, parent_->getResource( "pageIdleColor" ) );
   31   priority_ = atoi (parent_->getResource( "pagePriority" ) );
   32   maxspeed_ *= priority_ / 10.0;
   33   dodecay_ = parent_->isResourceTrue( "pageDecay" );
   34   SetUsedFormat( parent_->getResource( "pageUsedFormat" ) );
   35 }
   36 
   37 void PageMeter::checkevent( void ){
   38   getpageinfo();
   39   drawfields();
   40 }
   41 
   42 void PageMeter::getpageinfo( void ){
   43 
   44   struct pst_vminfo vminfo;
   45   pstat_getvminfo(&vminfo, sizeof(vminfo), 1, 0);
   46 
   47   total_ = 0;
   48 
   49   pageinfo_[pageindex_][0] = vminfo.psv_spgin;
   50   pageinfo_[pageindex_][1] = vminfo.psv_spgout;
   51 
   52   int oldindex = (pageindex_+1)%2;
   53   
   54   for ( int i = 0; i < 2; i++ ) {
   55     if ( pageinfo_[oldindex][i] == 0 )
   56       pageinfo_[oldindex][i] = pageinfo_[pageindex_][i];
   57 
   58     fields_[i] = pageinfo_[pageindex_][i] - pageinfo_[oldindex][i];
   59     total_ += fields_[i];
   60   }
   61 
   62   if ( total_ > maxspeed_ )
   63     fields_[2] = 0.0;
   64   else {
   65     fields_[2] = maxspeed_ - total_;
   66     total_ = maxspeed_;
   67   }
   68 
   69   setUsed (total_ - fields_[2], maxspeed_ );
   70   pageindex_ = (pageindex_ + 1) % 2;
   71 }