Esempio n. 1
0
/**
 * @brief ResultsPageWidget::reset
 */
void ResultsPageWidget::reset()
{
    mModel.setSearchResult(nullptr);
    QVariant var;
    emit readFromStack(2, var);
    if(var.canConvert<QPointer<Algorithm>>()) {
        mAlgorithm = var.value<QPointer<Algorithm>>().data();
        SearchAlgorithm* searchAlgo = qobject_cast<SearchAlgorithm*>(mAlgorithm);
        mUseSimpleProgressBar = !(searchAlgo && searchAlgo->supportsProgressInfo());
        updateProgressBar(0.0);
        emit startAlgorithm(mAlgorithm);
    } else {
        LOG_ERR("could not find algorithm on stack");
    }
    ui->progressBar->setValue(0);
}
Esempio n. 2
0
Junction::Junction( const QVector<TrafficLight *> &junction, QLCDNumber *m_vehicleCounter, int junctionId,
                    JUNCTION_TYPE junctionType ):
    QObject( NULL ),
    m_vehicleDriveAwayCount( 0 ),
    m_trafficLightVector( junction ),
    m_pauseBetweenSubcycles( 2000 ),
    m_interval( 500 ),
    m_currentNumberOfVehicles( 0 ),
    m_vehicleCounter( m_vehicleCounter ),
    m_junctionId( junctionId ),
    m_junctionType( junctionType )
{
    m_algorithmManager = new AlgorithmManager( this );

    startTimer( 10000 );
    startAlgorithm();
}
Esempio n. 3
0
void processNote(MidiEvent message, int seqLength, int direction) {
   static Array<char>         notes;
   static Array<char>         velocities;
   static Array<int>          durations;
   static Array<int>          iois;
   static Array<int>          ontimes;
   static CircularBuffer<int> attacktimes;
   static int                 init = 0;
   static TumbleParameters    temparam;
   char vel;

   if (!init) {
      attacktimes.setSize(256);
      attacktimes.reset();
      notes.setSize(0);
      velocities.setSize(0);
      durations.setSize(0);
      iois.setSize(0);
      ontimes.setSize(128);
      ontimes.zero();
      init = 1;
   }

   char note;
   int deltatime;
   int ioi0;
   int ioix;
   if (message.isNoteOn()) {
      attacktimes.insert(message.tick);

      // check to see if the ioi is in the correct range
      if (notes.getSize() == 0) {
         // no notes yet, so don't know the first ioi
      } else {
         deltatime = attacktimes[0] - attacktimes[1];
         iois.append(deltatime);
      }
      if (iois.getSize() > 1) {
         ioi0 = iois[0];
         ioix = iois[iois.getSize()-1];
         if ((ioix < ioi0 * tolerance) || (ioix > ioi0 / tolerance)) {
            goto resettrigger;
         }
      }

      // at this point the note can be added to the sequence
      if (notes.getSize() + 1 >= seqLength) {
         // time to trigger an algorithm
         if (durations.getSize() < notes.getSize()) {
            // if the last note has not yet been turned off, approximate dur.
            deltatime = iois[iois.getSize()-1];
            durations.append(deltatime);
         }

         int i;
         for (i=0; i<seqLength; i++) {
            temparam.v[i] = velocities[i];
            temparam.i[i] = iois[i];
            temparam.d[i] = durations[i];
            temparam.n[i] = notes[i] - notes[0];
         }
         temparam.n[0]    = message.getP1() - notes[0];
         temparam.current = message.getP1();
         temparam.pos     = 1;
         temparam.max     = seqLength;
         temparam.active  = 1;
         
         startAlgorithm(temparam);
         goto resettrigger;
      } else {
         // add the note info to the algorithm pile
         note = message.getP1();
         notes.append(note);
         vel = message.getP2();
         velocities.append(vel);
         attacktimes[message.getP1()] = message.tick;
      }
   } else if (message.isNoteOff()) {
      if (notes.getSize() > 0) {
         if (notes[notes.getSize()-1] == message.getP1()) {
         deltatime = message.tick - ontimes[message.getP1()];
         durations.append(deltatime);
      } else {
         cout << "A funny error ocurred" << endl;
      }
   }

   return;

resettrigger:
   attacktimes.setSize(0);
   notes.setSize(0);
   velocities.setSize(0);
   durations.setSize(0);
   iois.setSize(0);

   if (message.isNoteOn()) {
      note = message.getP1();
      notes.append(note);
      ontimes[message.getP1()] = message.tick;
      vel = message.getP2();
      velocities.append(vel);
   }
}



//////////////////////////////
//
// startAlgorithm -- start playing the tumble algorithm.  Inserts a
//     FunctionEvent into the eventBuffer which plays the tumble
//     algorithm sequence.  The algorithm will die after the notes
//     fall off of the 88-note keyboard.
//

}
Esempio n. 4
0
Widget::Widget(QWidget *parent) : QWidget(parent)
{
    setUI();

    connect(start, SIGNAL(clicked()), this, SLOT(startAlgorithm()));
}