Bug 49913 - When some sersors are missing, the wnole window is not updated
Summary: When some sersors are missing, the wnole window is not updated
Status: RESOLVED FIXED
Alias: None
Product: ksysguard
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: RedHat Enterprise Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KSysGuard Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-30 06:37 UTC by Aleksey Nogin
Modified: 2006-12-04 01:41 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksey Nogin 2002-10-30 06:37:02 UTC
Version:           1.2.0 (using KDE KDE 3.0.3)
Installed from:    RedHat RPMs
OS:          Linux

I have configured a window with 6 sensors:

localhost:network/interfaces/eth0/transmitter/data
localhost:network/interfaces/eth0/receiver/data
localhost:network/interfaces/wvlan0/transmitter/data
localhost:network/interfaces/wvlan0/receiver/data
localhost:network/interfaces/eth1/transmitter/data
localhost:network/interfaces/eth1/receiver/data

It works OK when all 3 devices are present (but not necessarily all up).

The problem is - when eth1 is not there (not physically present), the applet displays the "connect creating" icon and never actually displays anything. This happens both in the panel applet and in the application.

It should recognize the device is not there and display the sensors for devices that are there.

P.S. ALso filed as https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=75504
Comment 1 Chris Schlaeger 2002-11-05 20:51:14 UTC
That's a feature rather than a bug. You want to know if there is a problem 
with a sensor. Maybe displaying the icon plus the other still functional 
sensors would help.
Comment 2 Aleksey Nogin 2002-11-05 22:06:38 UTC
Can this be made configurable (at least per-session)?
Comment 3 John Tapsell 2006-12-04 01:41:01 UTC
SVN commit 610277 by johnflux:

* The tooltip for the signal plotter now indicates if the sensor had an error
* Fix a stupid bug in the ordering of the tootips
* When some sensors are missing, still update the whole window


BUG: 49913


 M  +40 -18    FancyPlotter.cc  
 M  +4 -0      FancyPlotter.h  
 M  +2 -1      SensorDisplay.cc  


--- trunk/KDE/kdebase/workspace/ksysguard/gui/SensorDisplayLib/FancyPlotter.cc #610276:610277
@@ -39,6 +39,7 @@
   : KSGRD::SensorDisplay( parent, title, workSheetSettings )
 {
   mBeams = 0;
+  mNumAccountedFor = 0;
   mPlotter = new KSignalPlotter( this );
   mPlotter->setVerticalLinesColor(KSGRD::Style->firstForegroundColor());
   mPlotter->setHorizontalLinesColor(KSGRD::Style->secondForegroundColor());
@@ -257,19 +258,32 @@
 void FancyPlotter::setTooltip()
 {
   QString tooltip;
+
+  QString description;
+  QString lastValue;
   for ( uint i = 0; i < mBeams; ++i ) {
-    if(sensors().at( mBeams -i - 1)->isLocalhost()) {
+    description = sensors().at(i)->description();
+    if(description.isEmpty()) {
+      description = sensors().at(i)->name();
+    }
+    if(sensors().at( i)->isOk()) {
+      lastValue = mPlotter->lastValue(i);
+    } else {
+      lastValue = i18n("Error");
+    }
+    if(sensors().at( i)->isLocalhost()) {
+      
       tooltip += QString( "%1%2%3 (%4)" ).arg( i != 0 ? "<br>" : "<qt>")
             .arg("<font color=\"" + mPlotter->beamColors()[ i ].name() + "\">#</font>")
-            .arg( sensors().at( mBeams - i - 1  )->description() )
-	    .arg( mPlotter->lastValue(i) );
+            .arg( description )
+	    .arg( lastValue );
 
     } else {
       tooltip += QString( "%1%2%3:%4 (%5)" ).arg( i != 0 ? "<br>" : "<qt>" )
                  .arg("<font color=\"" + mPlotter->beamColors()[ i ].name() + "\">#</font>")
-                 .arg( sensors().at( mBeams - i - 1 )->hostName() )
-                 .arg( sensors().at( mBeams - i - 1  )->description() )
-	         .arg( mPlotter->lastValue(i) );
+                 .arg( sensors().at( i )->hostName() )
+                 .arg( description )
+	         .arg( lastValue );
     }
   }
 
@@ -286,26 +300,34 @@
   return mPlotter->sizeHint();
 }
 
+void FancyPlotter::timerEvent( QTimerEvent*event ) //virtual
+{
+  if(!mSampleBuf.isEmpty()) {
+    while((uint)mSampleBuf.count() < mBeams)
+      mSampleBuf.append(0); //we might have invalid sensors missing so set their values to 0 at least
+    mPlotter->addSample( mSampleBuf );
+  }
+  mSampleBuf.clear();
+  SensorDisplay::timerEvent(event);
+}
 void FancyPlotter::answerReceived( int id, const QStringList &answerlist )
 {
   QString answer;
   if(!answerlist.isEmpty()) answer = answerlist[0];
   if ( (uint)id < mBeams ) {
-    if ( id != (int)mSampleBuf.count() ) {
-      if ( id == 0 )
-        sensorError( mBeams - 1, true );
-      else
-        sensorError( id - 1, true );
+
+    //Make sure that we put the answer in the correct place.  It's index in the list should be equal to id
+    
+    while(id < mSampleBuf.count())
+      mSampleBuf.append(0);
+
+    if(id == mSampleBuf.count()) {
+      mSampleBuf.append( answer.toDouble() );
+    } else {
+      mSampleBuf[id] = answer.toDouble();
     }
-    mSampleBuf.append( answer.toDouble() );
-
     /* We received something, so the sensor is probably ok. */
     sensorError( id, false );
-
-    if ( id == (int)mBeams - 1 ) {
-      mPlotter->addSample( mSampleBuf );
-      mSampleBuf.clear();
-    }
   } else if ( id >= 100 ) {
     KSGRD::SensorFloatInfo info( answer );
     QString unit = info.unit();
--- trunk/KDE/kdebase/workspace/ksysguard/gui/SensorDisplayLib/FancyPlotter.h #610276:610277
@@ -80,12 +80,16 @@
     void applySettings();
 
   protected:
+    /** When we receive a timer event, draw the beams */
+    virtual void timerEvent( QTimerEvent* );
     virtual bool eventFilter( QObject*, QEvent* );
     virtual void resizeEvent( QResizeEvent* );
     void setTooltip();
 
   private:
     uint mBeams;
+    /** Number of beams we've recieved an answer from since asking last */
+    uint mNumAccountedFor;
 
     KSignalPlotter* mPlotter;
 
--- trunk/KDE/kdebase/workspace/ksysguard/gui/SensorDisplayLib/SensorDisplay.cc #610276:610277
@@ -403,7 +403,8 @@
 void SensorDisplay::setSensorOk( bool ok )
 {
   if ( ok ) {
-    delete mErrorIndicator;
+    if(mErrorIndicator)
+      delete mErrorIndicator;
     mErrorIndicator = 0;
   } else {
     if ( mErrorIndicator )