xosview  1.23
About: xosview is an X Windows based system monitor (cpu, memory, swap and network usage; interrupt and serial activities; load average).
  Fossies Dox: xosview-1.23.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

fieldmeter.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 1994, 1995, 2006 by Mike Romberg ( mike.romberg@noaa.gov )
3 //
4 // This file may be distributed under terms of the GPL
5 //
6 
7 #ifndef _FIELDMETER_H_
8 #define _FIELDMETER_H_
9 
10 #include "meter.h"
11 #include "xosview.h"
12 #include "timer.h"
13 
14 
15 class FieldMeter : public Meter {
16 public:
17  FieldMeter( XOSView *parent, int numfields,
18  const char *title = "", const char *legend = "",
19  int docaptions = 0, int dolegends = 0, int dousedlegends = 0 );
20  virtual ~FieldMeter( void );
21 
22  virtual void drawfields( int mandatory = 0 );
23  void setfieldcolor( int field, const char *color );
24  void setfieldcolor( int field, unsigned long color);
25  void docaptions( int val ) { docaptions_ = val; }
26  void dolegends( int val ) { dolegends_ = val; }
27  void dousedlegends( int val ) { dousedlegends_ = val; }
28  void reset( void );
29  void setUsed (double val, double total);
30  void draw( void );
31  void checkevent( void );
32  void disableMeter ( void );
33 
34  virtual void checkResources( void );
35 
36 protected:
38 
40  double *fields_;
42  int *lastvals_, *lastx_;
43  unsigned long *colors_;
44  unsigned long usedcolor_;
48  bool metric_;
50 
51  void SetUsedFormat ( const char * const str );
52  void drawlegend( void );
53  void drawused( int mandatory );
54  bool checkX(int x, int width) const;
55 
56  void setNumFields(int n);
57 
58 
59 private:
61 protected:
64  // Before, we simply called _timer.report(), which returns usecs.
65  // However, it suffers from wrap/overflow/sign-bit problems, so
66  // instead we use doubles for everything.
68  double IntervalTimeInSecs() { return _timer.report_usecs()/1e6; }
69 };
70 
71 #endif
virtual ~FieldMeter(void)
Definition: fieldmeter.cc:47
void reset(void)
Definition: fieldmeter.cc:103
double total_
Definition: fieldmeter.h:41
int printedZeroTotalMesg_
Definition: fieldmeter.h:46
virtual void checkResources(void)
Definition: fieldmeter.cc:54
void setfieldcolor(int field, const char *color)
Definition: fieldmeter.cc:108
bool metric_
Definition: fieldmeter.h:48
int numWarnings_
Definition: fieldmeter.h:47
void drawlegend(void)
Definition: fieldmeter.cc:136
Timer _timer
Definition: fieldmeter.h:60
FieldMeter(XOSView *parent, int numfields, const char *title="", const char *legend="", int docaptions=0, int dolegends=0, int dousedlegends=0)
Definition: fieldmeter.cc:15
void setUsed(double val, double total)
Definition: fieldmeter.cc:76
void drawused(int mandatory)
Definition: fieldmeter.cc:171
void dousedlegends(int val)
Definition: fieldmeter.h:27
virtual void drawfields(int mandatory=0)
Definition: fieldmeter.cc:221
int numfields_
Definition: fieldmeter.h:39
int usedoffset_
Definition: fieldmeter.h:49
unsigned long usedcolor_
Definition: fieldmeter.h:44
double IntervalTimeInMicrosecs()
Definition: fieldmeter.h:67
void checkevent(void)
Definition: fieldmeter.cc:259
void IntervalTimerStart()
Definition: fieldmeter.h:62
void setNumFields(int n)
Definition: fieldmeter.cc:263
double * fields_
Definition: fieldmeter.h:40
void dolegends(int val)
Definition: fieldmeter.h:26
void docaptions(int val)
Definition: fieldmeter.h:25
unsigned long * colors_
Definition: fieldmeter.h:43
int * lastvals_
Definition: fieldmeter.h:42
void IntervalTimerStop()
Definition: fieldmeter.h:63
int * lastx_
Definition: fieldmeter.h:42
double lastused_
Definition: fieldmeter.h:41
UsedType print_
Definition: fieldmeter.h:45
void draw(void)
Definition: fieldmeter.cc:116
double used_
Definition: fieldmeter.h:41
void SetUsedFormat(const char *const str)
Definition: fieldmeter.cc:60
@ INVALID_TAIL
Definition: fieldmeter.h:37
bool checkX(int x, int width) const
Definition: fieldmeter.cc:283
double IntervalTimeInSecs()
Definition: fieldmeter.h:68
void disableMeter(void)
Definition: fieldmeter.cc:36
Definition: meter.h:14
const char * title(void)
Definition: meter.h:25
int docaptions_
Definition: meter.h:53
int dolegends_
Definition: meter.h:53
int dousedlegends_
Definition: meter.h:53
const char * legend(void)
Definition: meter.h:27
Definition: timer.h:22
double report_usecs(void) const
Definition: timer.h:32
void start(void)
Definition: timer.h:27
void stop(void)
Definition: timer.h:28