void LogSensor::answerReceived( int id, const QList<QByteArray>& answer ) //virtual
{
  QFile mLogFile( mFileName );

  if ( !mLogFile.open( QIODevice::ReadWrite | QIODevice::Append ) ) {
    stopLogging();
    return;
  }

  switch ( id ) {
    case 42: {
      QTextStream stream( &mLogFile );
      double value = 0;
      if ( !answer.isEmpty() )
        value = answer[ 0 ].toDouble();

      if ( mLowerLimitActive && value < mLowerLimit ) {
        timerOff();
        mLimitReached = true;

        // send notification
        KNotification::event( "sensor_alarm", QString( "sensor '%1' at '%2' reached lower limit" )
                            .arg( mSensorName ).arg( mHostName), QPixmap(), 0 );

        timerOn();
      } else if ( mUpperLimitActive && value > mUpperLimit ) {
        timerOff();
        mLimitReached = true;

        // send notification
        KNotification::event( "sensor_alarm", QString( "sensor '%1' at '%2' reached upper limit" )
                            .arg( mSensorName).arg( mHostName), QPixmap(), 0 );

        timerOn();
      } else {
        mLimitReached = false;
      }

      const QDate date = QDateTime::currentDateTime().date();
      const QTime time = QDateTime::currentDateTime().time();

      stream << QString( "%1 %2 %3 %4 %5: %6\n" ).arg( date.shortMonthName( date.month() ) )
                                                 .arg( date.day() ).arg( time.toString() )
                                                 .arg( mHostName).arg( mSensorName ).arg( value );
    }
  }

  emit changed();

  mLogFile.close();
}
void LogSensor::setTimerInterval( int interval )
{
  mTimerInterval = interval;

  if ( mTimerID != NONE ) {
    timerOff();
    timerOn();
  }
}
Exemple #3
0
//------------------------------------------------------------------------------------------
ASIOError AsioSample::start ()
{
	if (callbacks)
	{
		started = false;
		samplePosition = 0;
		theSystemTime.lo = theSystemTime.hi = 0;
		toggle = 0;

		timerOn ();			// activate 'hardware'
		started = true;

		return ASE_OK;
	}
	return ASE_NotPresent;
}
Exemple #4
0
int main(int argc, char *argv[]) {

	IplImage *img1,*img2;
	double elapsed;
	uint height, width, step, channels;

	uchar *data;
	int i;
	uint channel;

	if(argc != 3) {
		printf("wave <modelo> <imagen>\n");
		exit(1);
	}

	// wavelet model
	wavelet = (struct wavelet *) NULL;
	if(! strcmp(argv[1],"haar"))
		wavelet = &haar;
	if(! strcmp(argv[1],"daub4")) 
		wavelet = &daub4;
	if(! strcmp(argv[1],"db3")) 
		wavelet = &db3;
	if(! wavelet)
		debug("No se conoce el modelo (haar, daub4)", 0);
	

  	// load an image
	img1=cvLoadImage(argv[2],1);
	if(!img1){
		printf("Could not load image file: %s\n",argv[1]);
		exit(0);
  	}

	// get the image data
	height    = img1->height;
	width     = img1->width;
	step      = img1->widthStep;
	channels  = img1->nChannels;
	data      = (uchar *)img1->imageData;
	printf("Processing a %dx%d image with %d channels - step = %d\n",height,width,channels, step);

	// prepare second image object
	img2 = cvCreateImage(cvSize(width, height),IPL_DEPTH_8U,1);
	img2->imageData = (uchar *) malloc(sizeof(uchar)* height * width * channels);
	img2->widthStep = step;
	img2->nChannels = channels;

	// copy img1 into img2
	//for(i=0; i < height * width * channels; i++)
    //   img2->imageData[i] = img1->imageData[i];
	
	timerOn();
	secuencial(wavelet, img1, img2);
//backandforth(img1,img2);
	elapsed = timerOff();
	printf("Secuencial %e ms\n",elapsed);

//	opencl();
	timerOn();
	elapsed = timerOff();
	printf("Paralelo %lf ms\n",elapsed);

}
void LogSensor::startLogging()
{
  timerOn();
}