sensor.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Hans Karlsson                                   *
00003  *   karlsson.h@home.se                                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 #include "sensor.h"
00011 Sensor::Sensor(int iMsec)
00012 {
00013     objList = new QObjectList();
00014     objList->setAutoDelete( true );
00015     msec = iMsec;
00016 }
00017 
00018 void Sensor::start()
00019 {
00020     if (!timer.isActive())
00021     {
00022         connect (&timer,SIGNAL(timeout()),this,SLOT(update()));
00023         timer.start( (msec == 0)?1000:msec);
00024     }
00025 }
00026 
00027 Sensor::~Sensor()
00028 {
00029 objList->clear();
00030 delete objList;
00031 }
00032 
00033 void Sensor::addMeter( SensorParams *sp )
00034 {
00035   objList->append(sp);
00036 }
00037 
00038 SensorParams* Sensor::hasMeter( Meter *meter )
00039 {
00040   QObjectListIt it( *objList );
00041   while ( it != 0 )
00042     {
00043       if (((SensorParams*) *it)->getMeter() == meter)
00044         {
00045           return (SensorParams*) *it;
00046         }
00047       ++it;
00048     }
00049   return NULL;
00050 }
00051 
00052 void Sensor::deleteMeter( Meter *meter )
00053 {
00054   SensorParams* sp = hasMeter(meter);
00055 
00056   if (sp)
00057     objList->removeRef(sp);
00058 }
00059 
00060 void Sensor::setMaxValue( SensorParams* )
00061 {
00062 }
00063 
00064 #include "sensor.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys