Ejemplo n.º 1
0
struct time elapsedTime(struct time t1,struct time t2)
{
  struct time timeDifference;
  long int totalSeconds1,totalSeconds2;
  totalSeconds1=timeToSeconds(t1);
  totalSeconds2=timeToSeconds(t2);
  timeDifference=secondsToTime(totalSeconds2-totalSeconds1);
  return timeDifference;
}
Ejemplo n.º 2
0
boolean isDaytimeNow(int dhr, int dmin, int dsec, int mhr, int mmin, int msec) {
    // startup lamp status checks
    time_t startOfDay = timeToSeconds(dhr, dmin, dsec); // Hour,Min,Secs for start of day;
    time_t startOfNight = timeToSeconds(mhr, mmin, msec); // Hour,Min,Secs for start of Night;

    // Change the current timestamp to secs
    time_t t = timeToSeconds(hour(), minute(), second());
    // If its between startOfDay & StartOfNight return true
    return (t >= startOfDay && t < startOfNight);
}
void MainWindow::updateSubtitle()
{
	if (m_currentSubtitle == 0 && m_subtitles[m_currentTrack].count() == 0)
	{
		Subtitle subtitle;

		m_subtitles[m_currentTrack].append(subtitle);
	}

	m_subtitles[m_currentTrack][m_currentSubtitle].text = m_ui->subtitleTextEdit->toPlainText();
	m_subtitles[m_currentTrack][m_currentSubtitle].positionX = m_ui->xPositionSpinBox->value();
	m_subtitles[m_currentTrack][m_currentSubtitle].positionY = m_ui->yPositionSpinBox->value();
	m_subtitles[m_currentTrack][m_currentSubtitle].beginTime = timeToSeconds(m_ui->beginTimeEdit->time());
	m_subtitles[m_currentTrack][m_currentSubtitle].endTime = (timeToSeconds(m_ui->beginTimeEdit->time()) + timeToSeconds(m_ui->lengthTimeEdit->time()));
}
Ejemplo n.º 4
0
void KeyboardDialog::KeyButton::armCallback(GLMotif::Button::ArmCallbackData* cbData)
{
    if (!cbData->isArmed)
    {
        keyArmed = false;
    }
    else
    {
        if (!keyArmed)
        {
            fire();  // first nonrepeated firing

            keyArmed             = true;
            keyArmTime           = Misc::Time::now();
            lastKeyFireTimeDelta = 0;
        }
        else
        {
            const double nowTimeDelta = timeToSeconds(Misc::Time::now() - keyArmTime);

            if ((lastKeyFireTimeDelta < keyboard.autoRepeatDelay) && (nowTimeDelta >= keyboard.autoRepeatDelay))
            {
                // Note: this won't happen if keyboard.autoRepeatDelay <= 0
                fire();
                lastKeyFireTimeDelta = keyboard.autoRepeatDelay;
            }

            if (keyboard.autoRepeatInterval <= 0)
            {
                // Just fire as often as we get this callback if keyboard.autoRepeatInterval == 0
                fire();
                lastKeyFireTimeDelta = nowTimeDelta;
            }
            else if (lastKeyFireTimeDelta >= keyboard.autoRepeatDelay)
            {
                for (double t = lastKeyFireTimeDelta + keyboard.autoRepeatInterval; t <= nowTimeDelta; t += keyboard.autoRepeatInterval)
                {
                    fire();
                    lastKeyFireTimeDelta = t;
                }
            }
        }
    }
}
Ejemplo n.º 5
0
void GpibData::appendAsciiData(QStringList stringList) {
    /*!
      \brief When this slot is called, the list of string with data is processed

      Processing includes next steps
      \list
      \li append of the stringlist to rawAsciiData
      \li exclude empty lines and lines starting with '#', '/' and '*' then append data to measureData
      \li parse the lines starting with * and append em to transitionData
      \li last step is to convert every column in every row to double and add to ddata array
      */

    QStringList *data=&stringList;
    int tmpint;
    this->rawAsciiData.append(stringList);
    QTime start_t,current_t;
    QStringList column; //this string list will contain list of columns in current row.
    QString tmpstring, nextline;

    for (int row=0;row<data->size();row++) {
                tmpstring=data->at(row);
                tmpstring=tmpstring.trimmed();

                if (tmpstring.startsWith("#",Qt::CaseSensitive)
                    || tmpstring.startsWith("/",Qt::CaseSensitive)
                    || tmpstring.trimmed().isEmpty()
                     ) {
                    continue;
                } else if (tmpstring.startsWith("*",Qt::CaseSensitive) && this->measureData.size()>0) {
                    if (this->transitionData.last()!=this->measureData.last()) {
                        this->transitionData.append(this->measureData.last());
                    }
                    continue;
                }


        column=tmpstring.split(this->delimiterRegExp);
        int columnCount=column.count();
        if (row==data->size()-1) {
            //this will update the latestTimestamp to the very last value in incoming data
            this->latestTimestamp=column.last();
        }

        for (int columnIndex=0;columnIndex<columnCount;++columnIndex) {
            tmpstring=column.at(columnIndex);

            //this will check the first row. if it is time in format h:mm:ss,
            //it will update the starting time and calculate difference in seconds.
            if (columnIndex==0 && tmpstring.contains(":")) {
                tmpint=timeToSeconds(QTime::fromString(tmpstring,"h:mm:ss"));
                nextline+=tmpstring.setNum(tmpint);
                continue;


            } else if (columnIndex==columnCount-1) {
                tmpstring.setNum(this->timestampToSeconds(tmpstring.toDouble()));

            }
            if (columnIndex!=0)
            nextline+="\t"+tmpstring;
            else nextline+=tmpstring;

            if (columnIndex==columnCount-1) {
                this->measureData.append(nextline);
                this->appendStringToDdata(nextline);
                nextline.clear();
            }

        }

        if (row==0 && (this->transitionData.isEmpty())) {
            this->transitionData.append(this->measureData.first());
        }
    }
}
Ejemplo n.º 6
0
void
CInterval::
init()
{
  bool integral = isIntegral();

  timeType_ = TimeType::SECONDS;

  startTime_.year   = 0;
  startTime_.month  = 0;
  startTime_.day    = 0;
  startTime_.hour   = 0;
  startTime_.minute = 0;
  startTime_.second = 0;

  // Ensure min/max are in the correct order
  double min = std::min(data_.start, data_.end);
  double max = std::max(data_.start, data_.end);

  if      (isIntegral()) {
    min = std::floor(min);
    max = std::ceil (max);
  }
  else if (isDate()) {
    int y = timeLengthToYears  (min, max);
    int m = timeLengthToMonths (min, max);
    int d = timeLengthToDays   (min, max);

    startTime_.year  = timeToYear   (min);
    startTime_.month = timeToMonths (min);
    startTime_.day   = timeToDays   (min);

    min = 0;

    if      (y >= 5) {
      //std::cout << "years\n";
      timeType_ = TimeType::YEARS;
      max       = y;
    }
    else if (m >= 3) {
      //std::cout << "months\n";
      timeType_ = TimeType::MONTHS;
      max       = m;
    }
    else if (d >= 4) {
      //std::cout << "days\n";
      timeType_ = TimeType::DAYS;
      max       = d;
    }

    integral = true;
  }
  else if (isTime()) {
    int h = timeLengthToHours  (min, max);
    int m = timeLengthToMinutes(min, max);
    int s = timeLengthToSeconds(min, max);

    startTime_.hour   = timeToHours  (min);
    startTime_.minute = timeToMinutes(min);
    startTime_.second = timeToSeconds(min);

    min = 0;

    if      (h >= 12) {
      //std::cout << "hours\n";
      timeType_ = TimeType::HOURS;
      max       = h;
    }
    else if (m >= 10) {
      //std::cout << "minutes\n";
      timeType_ = TimeType::MINUTES;
      max       = m;
    }
    else {
      //std::cout << "seconds\n";
      timeType_ = TimeType::SECONDS;
      max       = s;
    }

    integral = true;
  }

  //---

  // use fixed increment
  double majorIncrement = this->majorIncrement();

  if (majorIncrement > 0.0 && (! isDate() && ! isTime())) {
    calcData_.start     = min;
    calcData_.end       = max;
    calcData_.increment = majorIncrement;

    calcData_.numMajor =
      CMathRound::RoundNearest((calcData_.end - calcData_.start)/calcData_.increment);
    calcData_.numMinor = 5;

    return;
  }

  //---

  if (data_.numMajor > 0) {
    goodTicks_.opt = data_.numMajor;
    goodTicks_.min = std::max(goodTicks_.opt/10, 1);
    goodTicks_.max = goodTicks_.opt*10;
  }
  else {
    goodTicks_ = GoodTicks();
  }

  //---

  calcData_.numMajor = -1;
  calcData_.numMinor = 5;

  //---

  calcData_.increment = data_.increment;

  if (calcData_.increment <= 0.0) {
    calcData_.increment = initIncrement(min, max, integral);

    //---

    // Calculate other test increments
    for (int i = 0; i < numIncrementTests; i++) {
      // disable non-integral increments for integral
      if (integral && ! isInteger(incrementTests[i].factor)) {
        incrementTests[i].incFactor = 0.0;
        continue;
      }

      // disable non-log increments for log
      if (isLog() && ! incrementTests[i].isLog) {
        incrementTests[i].incFactor = 0.0;
        continue;
      }

      incrementTests[i].incFactor = calcData_.increment*incrementTests[i].factor;
    }

    //---

    // Test each increment in turn (Set default start/end to force update)
    int tickIncrement = this->tickIncrement();

    GapData axisGapData;

    for (int i = 0; i < numIncrementTests; i++) {
      // skip disable tests
      if (incrementTests[i].incFactor <= 0.0)
        continue;

      // if tick increment set then skip if not multiple of increment
      if (tickIncrement > 0) {
        if (! isInteger(incrementTests[i].incFactor))
          continue;

        int incFactor1 = int(incrementTests[i].incFactor);

        if (incFactor1 % tickIncrement != 0)
          continue;
      }

      // test factor, ticks and update best
      if (testAxisGaps(min, max,
                       incrementTests[i].incFactor,
                       incrementTests[i].numTicks,
                       axisGapData)) {
        //axisGapData.print("  Best) ");
      }
    }

    //---

    calcData_.start     = axisGapData.start;
    calcData_.end       = axisGapData.end;
    calcData_.increment = axisGapData.increment;
    calcData_.numMinor  = (! isLog() ? axisGapData.numMinor : 10);
  }
  else {
    calcData_.start    = min;
    calcData_.end      = max;
    calcData_.numMinor = 5;
  }

  calcData_.numMajor =
    CMathRound::RoundNearest((calcData_.end - calcData_.start)/calcData_.increment);

  if      (isDate()) {
    if      (timeType_ == TimeType::YEARS) {
      calcData_.numMinor = 12;
    }
    else if (timeType_ == TimeType::MONTHS) {
      calcData_.numMinor = 4;
    }
    else if (timeType_ == TimeType::DAYS) {
      calcData_.numMinor = 4;
    }
  }
  else if (isTime()) {
    if      (timeType_ == TimeType::HOURS) {
      calcData_.numMinor = 6;
    }
    else if (timeType_ == TimeType::MINUTES) {
      calcData_.numMinor = 12;
    }
    else if (timeType_ == TimeType::SECONDS) {
      calcData_.numMinor = 12;
    }
  }
}
Ejemplo n.º 7
0
void VideoThumbnailer::generateThumbnail(const QString& videoFile, ImageWriter& imageWriter, QImage &image)
{
    MovieDecoder movieDecoder(videoFile, NULL);
    if (movieDecoder.getInitialized()) {
        movieDecoder.decodeVideoFrame(); //before seeking, a frame has to be decoded
        
        if ((!m_WorkAroundIssues) || (movieDecoder.getCodec() != QLatin1String("h264"))) { //workaround for bug in older ffmpeg (100% cpu usage when seeking in h264 files)
            int secondToSeekTo = m_SeekTime.isEmpty() ? movieDecoder.getDuration() * m_SeekPercentage / 100 : timeToSeconds(m_SeekTime);
            movieDecoder.seek(secondToSeekTo);
        }
    
        VideoFrame videoFrame;
        
        if (m_SmartFrameSelection) {
            generateSmartThumbnail(movieDecoder, videoFrame);
        } else {
            movieDecoder.getScaledVideoFrame(m_ThumbnailSize, m_MaintainAspectRatio, videoFrame);
        }
        
        applyFilters(videoFrame);
        imageWriter.writeFrame(videoFrame, image);
    }
}