예제 #1
0
QString Logic::getVersion() const
{
    QScopedPointer<QObject> parent(new QObject(nullptr));
    QScopedPointer<QProcess> rpm(new QProcess(parent.data()));
    QStringList args;
    args << "-qa"
         << "--queryformat"
         << "'%{name}-%{version}-%{release}\n'";
    rpm->start("rpm", args);
    if (!rpm->waitForStarted()) {
        return QString();
    }
    if (!rpm->waitForFinished()) {
        return QString();
    }
    QString rpms(rpm->readAll());
    QString packageName = "harbour-docscanner";
    if (rpms.contains(packageName, Qt::CaseInsensitive)) {
        QRegExp rx(packageName + "-" + "(\\d+\\.\\d+)");
        rx.setCaseSensitivity(Qt::CaseInsensitive);
        int pos = rx.indexIn(rpms);
        if (pos > -1) {
            return rx.cap(1);
        }
    }
    return QString();
}
예제 #2
0
파일: ecu.c 프로젝트: mridley/emuecu
int main(void)
{
  uart0_init();

  setup_timers();

  setup_inputs();
  
  printf("EMU ECU\n");
 
  sei(); // Enable Global Interrupt

  uint16_t engine_stop_ms = ticks_ms();

  uint16_t loop_ms = 0;
  while (1)
  {
    uint16_t curr_rpm = rpm();
    if (!curr_rpm)
    {
      // keep the stop time sliding for when we attempt to start again
      if ((ticks_ms() - engine_stop_ms) > DWELL_TIME_MS)
      {
        engine_stop_ms = ticks_ms() - DWELL_TIME_MS;
      }
    }
    if (!ignition_enabled())
    {
      if (curr_rpm > 0 && (ticks_ms() - engine_stop_ms) > DWELL_TIME_MS)
      {
        ignition_enable();
        pump_enable();
        printf("engine start\n");
      }
    }
    else
    {
      if (curr_rpm > RPM_LIMIT)
      {
        printf("overrev - forced engine stop\n");
        ignition_disable();
        pump_disable();
        engine_stop_ms = ticks_ms();
      }
      if (!curr_rpm)
      {
        printf("engine has stopped\n");
        ignition_disable();
        pump_disable();
      }
    }

    uint16_t pwm_in = pwm_input();
    uint16_t pwm_out = clamp_pwm(pwm_in);
    set_pwm(0, pwm_out);

    const float t_scale = 1.0 / (float)(PWM_MAX - PWM_MIN);
    float throttle = (float)(pwm_out - PWM_MIN) * t_scale;

    update_inj_row(throttle);

    uint16_t ms = ticks_ms();
    //uint32_t us = ticks_us();

    if ((ms - loop_ms) >= 1000)
    {
      loop_ms += 1000;
      //start_adc();
      //int16_t a = analogue(0);

      //printf("pwm_in=%u pwm_out=%u us=%lu a0=%d\n", pwm_in, pwm_out, us, a);
      printf("pwm=%d throttle=%d rpm=%u ticks=%u \n", pwm_in, (int)(100*throttle), rpm(), inj_ticks_(rpm()));
    }
    //sleep(1000);
    //_delay_ms(1000);
  }  
}