Exemple #1
0
/**
 * Copy all of the data (event lists) from the source workspace to this
 *workspace.
 *
 * @param source: EventWorkspace from which we are taking data.
 * @param sourceStartWorkspaceIndex: index in the workspace of source where we
 *start
 *          copying the data. This index will be 0 in the "this" workspace.
 *          Default: -1, meaning copy all.
 * @param sourceEndWorkspaceIndex: index in the workspace of source where we
 *stop.
 *          It is inclusive = source[sourceEndWorkspaceIndex[ WILL be copied.
 *          Default: -1, meaning copy all.
 *
 */
void EventWorkspace::copyDataFrom(const EventWorkspace &source,
                                  std::size_t sourceStartWorkspaceIndex,
                                  std::size_t sourceEndWorkspaceIndex) {
  // Start with nothing.
  this->clearData(); // properly de-allocates memory!

  // Copy the vector of EventLists
  EventListVector source_data = source.data;
  EventListVector::iterator it;
  EventListVector::iterator it_start = source_data.begin();
  EventListVector::iterator it_end = source_data.end();
  size_t source_data_size = source_data.size();

  // Do we copy only a range?
  if (sourceEndWorkspaceIndex == size_t(-1))
    sourceEndWorkspaceIndex = source_data_size - 1;
  if ((sourceStartWorkspaceIndex < source_data_size) &&
      (sourceEndWorkspaceIndex < source_data_size) &&
      (sourceEndWorkspaceIndex >= sourceStartWorkspaceIndex)) {
    it_start += sourceStartWorkspaceIndex;
    it_end = source_data.begin() + sourceEndWorkspaceIndex + 1;
  }

  for (it = it_start; it != it_end; ++it) {
    // Create a new event list, copying over the events
    EventList *newel = new EventList(**it);
    // Make sure to update the MRU to point to THIS event workspace.
    newel->setMRU(this->mru);
    this->data.push_back(newel);
  }
  // Save the number of vectors
  m_noVectors = this->data.size();

  this->clearMRU();
}
Exemple #2
0
TEST(TestSuite, aTest) {
    // Create a list of events with time, set the size to 5 events

    EventList<Event_T> testList = EventList<Event_T>(5);
    testList[0].source = 0;
    testList[0].dest = 1;
    testList[0].setTime(1);
    testList[1].source = 0;
    testList[1].dest = 2;
    testList[1].setTime(2);
    testList[2].source = 0;
    testList[2].dest = 1;
    testList[2].setTime(4);
    testList[3].source = 2;
    testList[3].dest = 0;
    testList[3].setTime(5);
    testList[4].source = 0;
    testList[4].dest = 1;
    testList[4].setTime(7);

    // cout << "Simple event list:" << endl;
    for (int i = 0; i < testList.size; i++) {
        EXPECT_GT(testList[i].getLongEventInformation().length(), 0);
    }

    // Test writing and reading binary file
    char *testFileName = (char *) "test1.bin";
    testList.WriteFile_Binary(testFileName);

    EventList<Event_T> testList2 = EventList<Event_T>(0);
    testList2.ReadFile_Binary(testFileName);

    if (remove(testFileName) != 0) {
        cout << "Error while deleting file " << testFileName << endl;
    }


    // cout << "Simple event list after writing and reading binary file:" << endl;
    for (int i = 0; i < testList2.size; i++) {
        Event_T e1 = testList[i];
        Event_T e2 = testList2[i];

        EXPECT_GT(testList2[i].getLongEventInformation().length(), 0);

        EXPECT_EQ(e1.getDest(), e2.getDest());
        EXPECT_EQ(e1.getSource(), e2.getSource());
        EXPECT_EQ(e1.getTime(), e2.getTime());
    }

    // Test reading a file, compare result to explicit event list
    EventList<Event_T> testList_file = EventList<Event_T>(0);

    char *testListFileName = (char *) "../eventpy/data/eventlist_small1_sdt.txt";

    // cout << "Reading in some SourceDestTime data" << endl;
    testList_file.ReadFile_SourceDestTime(testListFileName);
    EXPECT_EQ(testList_file.size, testList.size);


}
static EventList createEventList( const QDate& start, const QDate& end, int minutes, const TaskId& taskId )
{
    Q_ASSERT( start < end );

    EventList events;

    const int days = start.daysTo( end );
#if QT_VERSION >= 0x040700
    events.reserve( days );
#endif
    for ( int i = 0; i < days; ++i ) {
        const QDate date = start.addDays( i );
        //for each work day, create an event starting at 8 am
        if ( isWorkDay( date ) ) {
            const QDateTime startTime = QDateTime( date, QTime( 8, 0  ) );
            const QDateTime endTime = startTime.addSecs( minutes * 60 );
            Event event;
            event.setTaskId( taskId );
            event.setStartDateTime( startTime );
            event.setEndDateTime( endTime );
            event.setComment( QObject::tr( "(created by vacation dialog)" ) );
            events.append( event );
        }
    }
    return events;
}
void SqLiteStorageTests::deleteTaskWithEventsTest()
{
    // make a task
    const int TaskId = 1;
    const QString Task1Name( "Task-Name" );
    Task task;
    task.setId( TaskId );
    task.setName( Task1Name );
    task.setValidFrom( QDateTime::currentDateTime() );
    QVERIFY( m_storage->deleteAllTasks() );
    QVERIFY( m_storage->deleteAllEvents() );
    QVERIFY( m_storage->getAllTasks().size() == 0 );
    QVERIFY( m_storage->addTask( task ) );
    QVERIFY( m_storage->getAllTasks().size() == 1 );
    Task task2;
    task2.setId( 2 );
    task2.setName( "Task-2-Name" );
    QVERIFY( m_storage->addTask( task2 ) );
    QVERIFY( m_storage->getAllTasks().size() == 2 );

    // create 3 events, 2 for task 1, and one for another one
    {
        Event event = m_storage->makeEvent();
        QVERIFY( event.isValid() );
        event.setTaskId( task.id() );
        event.setUserId( 1 );
        event.setReportId( 42 );
        const QString EventComment( "Event-Comment" );
        event.setComment( EventComment );
        QVERIFY( m_storage->modifyEvent( event ) );
    }
    {
        Event event = m_storage->makeEvent();
        QVERIFY( event.isValid() );
        event.setTaskId( task.id() );
        event.setUserId( 1 );
        event.setReportId( 43 );
        const QString EventComment( "Event-Comment 2" );
        event.setComment( EventComment );
        QVERIFY( m_storage->modifyEvent( event ) );
    }
    // this is the event that is supposed to remain in the DB:
    Event event = m_storage->makeEvent();
    QVERIFY( event.isValid() );
    event.setTaskId( task2.id() );
    event.setUserId( 1 );
    event.setReportId( 43 );
    const QString EventComment( "Event-Comment 2" );
    event.setComment( EventComment );
    QVERIFY( m_storage->modifyEvent( event ) );

    // verify task database entries
    QVERIFY( m_storage->deleteTask( task ) );
    EventList events = m_storage->getAllEvents();
    QVERIFY( events.count() == 1 );
    QVERIFY( events.first() == event );
}
/**
 * \brief ocl::Image::copyToAsync Copies asynchronously from this Image to the destination Image.
 *
 * \param queue is a command queue on which the command is executed.
 * \param src_origin is the 3D offset in bytes from which the Image is read.
 * \param region is the 3D region of the data. It is given with {image_width, image_height, image_depth}.
 * \param dest is the Image into which the data is going to be copied.
 * \param dest_origin is the 3D offset in bytes from which the destionation Image is read.
 * \param list contains all events for which this command has to wait.
 * \return event which can be integrated into other EventList.
 */
ocl::Event ocl::Image::copyToAsync(const Queue &queue, size_t *src_origin, const size_t *region, const Image &dest, size_t *dest_origin, const EventList &list)
{
    TRUE_ASSERT(this->context() == dest.context(), "Context of this and dest must be equal");
    TRUE_ASSERT(queue.context() == *this->context(), "Context of queue and this must be equal");
    cl_event event_id;
    OPENCL_SAFE_CALL( clEnqueueCopyImage(queue.id(), this->id(), dest.id(),
                                         src_origin, dest_origin, region, list.size(),
                                         list.events().data(), &event_id) );
    return ocl::Event(event_id, this->context());
}
/**
 * \brief ocl::Image::copyToAsync Copies asynchronously from this Image to the destination Image.
 *
 * \param src_origin is the 3D offset in bytes from which the Image is read.
 * \param region is the 3D region of the data. It is given with {image_width, image_height, image_depth}.
 * \param dest is the Image into which the data is going to be copied.
 * \param dest_origin is the 3D offset in bytes from which the destionation Image is read.
 * \param list contains all events for which this command has to wait.
 * \return event which can be integrated into other EventList.
 */
ocl::Event ocl::Image::copyToAsync(size_t *src_origin, const size_t *region, const Image &dest, size_t *dest_origin, const EventList &list)
{
    TRUE_ASSERT(this->context() == dest.context(), "Context of this and dest must be equal");
    TRUE_ASSERT(this->id() != dest.id(), "Images must not be equal this->id() " << this->id() << "; other.id " << dest.id());
    cl_event event_id;
    OPENCL_SAFE_CALL( clEnqueueCopyImage(this->activeQueue().id(), this->id(), dest.id(),
                                         src_origin, dest_origin, region, list.size(),
                                         list.events().data(), &event_id) );
    return ocl::Event(event_id, this->context());
}
Exemple #7
0
void Song::cmdResizePart(Track* track, Part* oPart, unsigned int len)/*{{{*/
{
        {
            startUndo();

            MidiPart* nPart = new MidiPart(*(MidiPart*) oPart);
            nPart->setLenTick(len);
            // Indicate no undo, and do port controller values but not clone parts.
            audio->msgChangePart(oPart, nPart, false, true, false);

            // cut Events in nPart
            // Changed by T356. Don't delete events if this is a clone part.
            // The other clones might be longer than this one and need these events.
            if (nPart->cevents()->arefCount() <= 1)
            {
                if (oPart->lenTick() > len)
                {
                    EventList* el = nPart->events();
                    iEvent ie = el->lower_bound(len);
                    for (; ie != el->end();)
                    {
                        iEvent i = ie;
                        ++ie;
                        // Indicate no undo, and do port controller values and clone parts.
                        audio->msgDeleteEvent(i->second, nPart, false, true, true);
                    }
                }
            }

            /*
            // cut Events in nPart
            // Changed by T356. Don't delete events if this is a clone part.
            // The other clones might be longer than this one and need these events.
            if(oPart->cevents()->arefCount() <= 1)
            {
              if (oPart->lenTick() > len) {
                    EventList* el = nPart->events();
                    iEvent ie = el->lower_bound(len);
                    for (; ie != el->end();) {
                          iEvent i = ie;
                          ++ie;
                          // Indicate no undo, and do not do port controller values and clone parts.
                          //audio->msgDeleteEvent(i->second, nPart, false);
                          audio->msgDeleteEvent(i->second, nPart, false, false, false);
                          }
                    }
            }
            // Indicate no undo, and do port controller values but not clone parts.
            //audio->msgChangePart(oPart, nPart, false);
            audio->msgChangePart(oPart, nPart, false, true, false);
             */

            endUndo(SC_PART_MODIFIED);
        }
}/*}}}*/
Exemple #8
0
void Song::cmdGluePart(Track* track, Part* oPart)
{
    PartList* pl = track->parts();
    Part* nextPart = 0;

    for (iPart ip = pl->begin(); ip != pl->end(); ++ip)
    {
        if (ip->second == oPart)
        {
            ++ip;
            if (ip == pl->end())
                return;
            nextPart = ip->second;
            break;
        }
    }

    Part* nPart = track->newPart(oPart);
    nPart->setLenTick(nextPart->tick() + nextPart->lenTick() - oPart->tick());

    // populate nPart with Events from oPart and nextPart

    EventList* sl1 = oPart->events();
    EventList* dl = nPart->events();

    for (iEvent ie = sl1->begin(); ie != sl1->end(); ++ie)
        dl->add(ie->second);

    EventList* sl2 = nextPart->events();

    //int frameOffset = nextPart->frame() - oPart->frame();
    //for (iEvent ie = sl2->begin(); ie != sl2->end(); ++ie) {
    //      Event event = ie->second.clone();
    //      event.setFrame(event.frame() + frameOffset);
    //      dl->add(event);
    //      }
    // p3.3.54 Changed.

    {
        int tickOffset = nextPart->tick() - oPart->tick();
        for (iEvent ie = sl2->begin(); ie != sl2->end(); ++ie)
        {
            Event event = ie->second.clone();
            event.setTick(event.tick() + tickOffset);
            dl->add(event);
        }
    }

    startUndo();
    audio->msgRemovePart(nextPart, false);
    // Indicate no undo, and do port controller values but not clone parts.
    //audio->msgChangePart(oPart, nPart, false);
    audio->msgChangePart(oPart, nPart, false, true, false);
    endUndo(SC_PART_MODIFIED | SC_PART_REMOVED);
}
EventList EventsView::selectedEvents() const
{
    EventList result;

    const QModelIndexList &selectedItems = selectionModel()->selectedRows();
    foreach (const QModelIndex &selectedItem, selectedItems)
    {
        EventData *eventData = selectedItem.data(EventsModel::EventDataPtr).value<EventData*>();
        if (eventData)
            result.append(*eventData);
    }
Exemple #10
0
int main(int argc, char **argv)
{
    EventList eventlist;
    ProcessList processes;

    long ev_EndSimulation = 0;
    
    Traverser traverser(&eventlist);
    ColdTestCell cell1(&eventlist,&traverser);
    ColdTestCell cell2(&eventlist, &traverser);
    ColdTestCell cell3(&eventlist, &traverser);
    Source supply(&eventlist, &traverser);
    Sink derig(&eventlist);

    processes.push_back(&traverser);
    processes.push_back(&cell1);
    processes.push_back(&cell2);
    processes.push_back(&cell3);
    processes.push_back(&supply);
    processes.push_back(&derig);
    
    // Connect up production layout
    
    traverser.cell1(&cell1);
    traverser.cell2(&cell2);
    traverser.cell3(&cell3);
    traverser.infeed(&supply);
    traverser.outfeed(&derig);

    // Initialise the processes

    eventlist.push(new Event(100000,
                             nullptr,
                             ev_EndSimulation)); // End Simulation Event
    bool change;
    do {
        change = false;
        for (ProcessList::iterator i = processes.begin();
                 i != processes.end(); i++)
            change |= (*i)->run(); // Run each process until no change
    } while (change);


    // Run the event management loop.
    while (Event *event = eventlist.top()) {
        eventlist.pop(); // Remove the top element from the list
        SimulationTime += event->getTime(); // Advance simulation time
        if (event->getEventType() == ev_EndSimulation)
            break;
        event->getProcess()->HandleEvent(event);
        delete event; // no longer needed
    }
}
/**
 * \brief ocl::Image::map Maps the Image into the host memory.
 *
 *  No data transfer is performed. Note that in order to map data of the Image the active queue must be a cpu and must have been allocated
 *  with the Image access mode AllocHost. You cannot modify the Image with OpenCL until unmap.
 * \param ptr is returned and contains the address of a pointer to the host memory.
 * \param origin is the 3D offset in bytes from which the image is read.
 * \param region is the 3D region in bytes to be mapped.
 * \param access specifies in what way the host_mem is used.
 * \param list contains all events for which this command has to wait.
 * \return event which can be integrated into other EventList
 */
ocl::Event ocl::Image::mapAsync(void **ptr, size_t *origin, const size_t *region, Memory::Access access, const EventList &list) const
{
    TRUE_ASSERT(this->activeQueue().device().isCpu(), "Device " << this->activeQueue().device().name() << " is not a cpu!");
    cl_int status;
    cl_event event_id;
    cl_map_flags flags = access;
    *ptr = clEnqueueMapImage(this->activeQueue().id(), this->id(), CL_TRUE, flags,
                                      origin, region, 0, 0, list.size(), list.events().data(), &event_id, &status);
    OPENCL_SAFE_CALL (status ) ;
    TRUE_ASSERT(ptr != NULL, "Could not map image!");
    return ocl::Event(event_id, this->context());
}
Exemple #12
0
/// Executes the algorithm for events
void UnaryOperation::execEvent() {
  g_log.information("Processing event workspace");

  const MatrixWorkspace_const_sptr matrixInputWS = getProperty(inputPropName());

  // generate the output workspace pointer
  API::MatrixWorkspace_sptr matrixOutputWS = getProperty(outputPropName());
  if (matrixOutputWS != matrixInputWS) {
    matrixOutputWS = MatrixWorkspace_sptr(matrixInputWS->clone().release());
    setProperty(outputPropName(), matrixOutputWS);
  }
  auto outputWS = boost::dynamic_pointer_cast<EventWorkspace>(matrixOutputWS);

  // Now fetch any properties defined by concrete algorithm
  retrieveProperties();

  int64_t numHistograms = static_cast<int64_t>(outputWS->getNumberHistograms());
  API::Progress prog = API::Progress(this, 0.0, 1.0, numHistograms);
  PARALLEL_FOR1(outputWS)
  for (int64_t i = 0; i < numHistograms; ++i) {
    PARALLEL_START_INTERUPT_REGION
    // switch to weighted events if needed, and use the appropriate helper
    // function
    EventList *evlist = outputWS->getEventListPtr(i);
    switch (evlist->getEventType()) {
    case TOF:
      // Switch to weights if needed.
      evlist->switchTo(WEIGHTED);
    /* no break */
    // Fall through

    case WEIGHTED:
      unaryOperationEventHelper(evlist->getWeightedEvents());
      break;

    case WEIGHTED_NOTIME:
      unaryOperationEventHelper(evlist->getWeightedEventsNoTime());
      break;
    }

    prog.report();
    PARALLEL_END_INTERUPT_REGION
  }
  PARALLEL_CHECK_INTERUPT_REGION

  outputWS->clearMRU();
  auto inputWS = boost::dynamic_pointer_cast<EventWorkspace>(matrixOutputWS);
  if (inputWS->getNumberEvents() != outputWS->getNumberEvents()) {
    g_log.information() << "Number of events has changed!!!" << std::endl;
  }
}
Exemple #13
0
void Track::splitPart(Part* part, int tickpos, Part*& p1, Part*& p2)
{
    int l1 = 0; // len of first new part (ticks or samples)
    int l2 = 0; // len of second new part

    int samplepos = tempomap.tick2frame(tickpos);

    {
            l1 = tickpos - part->tick();
            l2 = part->lenTick() - l1;
    }

    if (l1 <= 0 || l2 <= 0)
        return;

    p1 = newPart(part); // new left part
    p2 = newPart(part); // new right part

    // Added by Tim. p3.3.6
    //printf("Track::splitPart part ev %p sz:%d ref:%d p1 %p sz:%d ref:%d p2 %p sz:%d ref:%d\n", part->events(), part->events()->size(), part->events()->arefCount(), p1->events(), p1->events()->size(), p1->events()->arefCount(), p2->events(), p2->events()->size(), p2->events()->arefCount());

    {
            p1->setLenTick(l1);
            p2->setTick(tickpos);
            p2->setLenTick(l2);
    }

    p2->setSn(p2->newSn());

    EventList* se = part->events();
    EventList* de1 = p1->events();
    EventList* de2 = p2->events();

    p1->setColorIndex(part->colorIndex());
    p2->setColorIndex(part->colorIndex());

    {
        for (iEvent ie = se->begin(); ie != se->end(); ++ie)
        {
            Event event = ie->second.clone();
            int t = event.tick();
            if (t >= l1)
            {
                event.move(-l1);
                de2->add(event);
            }
            else
                de1->add(event);
        }
    }
}
void EventListIntegration::a_hoster_stops_updating()
{
    EventList testee;

    const QString expected_user = "******";
    const QString expected_event = "Beer";
    testee.update_event(expected_user, expected_event);

    IM::Events result = testee.get_active_events();
    QCOMPARE(result.size(), 1);
    QCOMPARE(result.first().nick_name, expected_user);
    QCOMPARE(result.first().event_name, expected_event);

    QSignalSpy block_and(this, SIGNAL(dummy()));

    block_and.wait(4000);
    testee.update_event(expected_user, expected_event);
    result = testee.get_active_events();
    QCOMPARE(result.size(), 1);
    QCOMPARE(result.first().nick_name, expected_user);
    QCOMPARE(result.first().event_name, expected_event);

    block_and.wait(4000);
    testee.update_event(expected_user, expected_event);
    result = testee.get_active_events();
    QCOMPARE(result.size(), 1);
    QCOMPARE(result.first().nick_name, expected_user);
    QCOMPARE(result.first().event_name, expected_event);

    block_and.wait(7800);

    result = testee.get_active_events();

    QCOMPARE(result.size(), 0);
}
Exemple #15
0
EventList*
EventList::allEventsForObject(QObject *widget)
{
    if (!widget)  return 0;

    EventList *l = new EventList();
    EventList::ConstIterator endIt = constEnd();
    for (EventList::ConstIterator it = constBegin(); it != endIt; ++it) {
        if (((*it)->sender() == widget) || ((*it)->receiver() == widget))
            l->addEvent(*it);
    }

    return l;
}
Exemple #16
0
QueueLoggerSampling::QueueLoggerSampling(simtime_picosec period, EventList &eventlist)
: EventSource(eventlist,"QueuelogSampling"),
        _queue(NULL), _lastlook(0), _period(period), _lastq(0), 
	_seenQueueInD(false), _cumidle(0), _cumarr(0), _cumdrop(0)
	{	
	eventlist.sourceIsPendingRel(*this,0);
	}
Exemple #17
0
/// Обновление
  void UpdateEvent (const char* name, ResourceState state)
  {
    EventMap::iterator iter = event_map.find (name);

    if (iter == event_map.end ())
    {
      EventPtr event = EventPtr (new EventDesc (name, state), false);

      EventList::iterator iter = event_list.insert (event_list.end (), event);

      event_map.insert_pair (name, iter);
    }
    else
    {
      EventPtr event = *iter->second;

      if (state == event->state)
        return;

      if (event->state == ResourceState_Ignore)
      {
        event_list.splice (event_list.end (), event_list, iter->second);

        event->state = state;

        return;
      }

      switch (state)
      {
        case ResourceState_Unloaded:
          event->state = ResourceState_Ignore;
          break;
        case ResourceState_Prefetched:
          if (event->state != ResourceState_Unloaded)
            return;

          event_list.splice (event_list.end (), event_list, iter->second);

          event->state = state;          

          break;
        case ResourceState_Loaded:
          if (event->state == ResourceState_Unloaded) event->state = ResourceState_Ignore;
          else 
          {
            event_list.splice (event_list.end (), event_list, iter->second);

            event->state = state;
          }

          break;
        default:
          break;
      }
    }    
  }
/** Integrate all the spectra in the matrix workspace within the range given.
 * Default implementation, can be overridden by base classes if they know
 *something smarter!
 *
 * @param out :: returns the vector where there is one entry per spectrum in the
 *workspace. Same
 *            order as the workspace indices.
 * @param minX :: minimum X bin to use in integrating.
 * @param maxX :: maximum X bin to use in integrating.
 * @param entireRange :: set to true to use the entire range. minX and maxX are
 *then ignored!
 */
void EventWorkspace::getIntegratedSpectra(std::vector<double> &out,
                                          const double minX, const double maxX,
                                          const bool entireRange) const {
  // Start with empty vector
  out.resize(this->getNumberHistograms(), 0.0);

  // We can run in parallel since there is no cross-reading of event lists
  PARALLEL_FOR_NO_WSP_CHECK()
  for (int wksp_index = 0; wksp_index < int(this->getNumberHistograms());
       wksp_index++) {
    // Get Handle to data
    EventList *el = this->data[wksp_index];

    // Let the eventList do the integration
    out[wksp_index] = el->integrate(minX, maxX, entireRange);
  }
}
/*
 * This function checks if there is free terminal
 * and generates arrival if there is free terminal
 */
static void generateArrEvent(int numTerminals)
{
  if((countInfo.terminalPool>0) && (countInfo.terminalPool<=numTerminals))
  {
    Elist.insert(clock + exp_rv(configInfo.arrivalRate),ARR);
    countInfo.terminalPool--;
  }
}
Exemple #20
0
void CtEvent::getEventList(EventList& event_list)
{
  DEB_MEMBER_FUNCT();

  AutoMutex l = lock();
  DEB_PARAM() << DEB_VAR2(event_list.size(), m_event_list.size());

  if (!event_list.empty())
    THROW_CTL_ERROR(InvalidValue) << "Not empty event_list (" 
				  << DEB_VAR1(event_list.size()) << "): "
				  << "Where all the events deleted?";
  else if (hasRegisteredCallback())
    DEB_WARNING() << "An EventCallback is registered, events are dispatched";

  event_list = m_event_list;
  m_event_list.clear();
}
Exemple #21
0
std::vector<double> beatTrack(const AgentParameters &params,
                              const EventList &events,
                              const EventList &beats)
      {
      AgentList agents;
      int count = 0;
      double beatTime = -1;
      if (!beats.empty()) {
            count = beats.size() - 1;
            EventList::const_iterator itr = beats.end();
            --itr;
            beatTime = itr->time;
            }
      if (count > 0) {        // tempo given by mean of initial beats
            double ioi = (beatTime - beats.begin()->time) / count;
            agents.push_back(new Agent(params, ioi));
            }
      else            // tempo not given; use tempo induction
            agents = Induction::beatInduction(params, events);

      if (!beats.empty()) {
            for (AgentList::iterator itr = agents.begin(); itr != agents.end(); ++itr) {
                  (*itr)->beatTime = beatTime;
                  (*itr)->beatCount = count;
                  (*itr)->events = beats;
                  }
            }
      agents.beatTrack(events, params, -1);

      Agent *best = agents.bestAgent();
      std::vector<double> resultBeatTimes;

      if (best) {
            best->fillBeats(beatTime);
            for (EventList::const_iterator itr = best->events.begin();
                        itr != best->events.end(); ++itr) {
                  resultBeatTimes.push_back(itr->time);
                  }
            }
      for (AgentList::iterator ai = agents.begin(); ai != agents.end(); ++ai) {
            delete *ai;
            }

      return resultBeatTimes;
      }
Exemple #22
0
 void EventList::append(const EventList& other)
 {
     for(size_t i = 0; i < other.size(); ++i)
     {
         cl_event e = other._events[i];
         clRetainEvent(e);
         _events.push_back(e);
     }
 }
void EventQueue::InsertEvent( Event *event, ncycle_t when, int priority )
{
    event->SetCycle( when );

    /* If this event time is before our previous nextEventCycle, change it. */
    if( when < nextEventCycle )
    {
        nextEventCycle = when;
    }

    /* If there are no events at this time, create a new mapping. */ 
    if( eventMap.count( when ) == 0 )
    {
        EventList eventList;

        eventList.push_back( event );

        eventMap.insert( std::pair<ncycle_t, EventList>( when, eventList ) );
    }
    /* Otherwise append this event to the event list for this cycle. */
    else
    {
        EventList& eventList = eventMap[when];

        EventList::iterator it;
        bool inserted = false;

        for( it = eventList.begin(); it != eventList.end(); it++ )
        {
            if( (*it)->GetPriority( ) > priority )
            {
                eventList.insert( it, event );
                inserted = true;
                break;
            }
        }

        if( !inserted )
        {
            eventList.push_back( event );
        }
    }
}
Exemple #24
0
int CEventListHandler::exec(CMenuTarget* parent, const std::string &/*actionKey*/)
{
	int           res = menu_return::RETURN_REPAINT;
	EventList     *e;
	CChannelList  *channelList;


	if (parent)
		parent->hide();

	e = new EventList;

	channelList = CNeutrinoApp::getInstance()->channelList;

	e->exec(live_channel_id, channelList->getActiveChannelName()); // UTF-8
	delete e;

	return res;
}
Exemple #25
0
 // In specific order many at a time:
 bool waitForEventList(const EventList& evts, Duration timeout=Duration::seconds(5)) {
     for(uint idx = 0; idx < evts.size(); idx++) {
         Event read_evt;
         bool got_event = _events.blockingPop(read_evt, timeout);
         TS_ASSERT(got_event);
         if (!got_event) return false;
         TS_ASSERT_EQUALS(evts[idx], read_evt);
         if (evts[idx] != read_evt) return false;
     }
     return true;
 }
Exemple #26
0
void AgentList::beatTrack(const EventList &el,
                          const AgentParameters &params,
                          double stop)
      {
      EventList::const_iterator ei = el.begin();
      bool phaseGiven = !empty() && ((*begin())->beatTime >= 0); // if given for one, assume given for others
      while (ei != el.end()) {
            Event ev = *ei;
            ++ei;
            if ((stop > 0) && (ev.time > stop))
                  break;
            bool created = phaseGiven;
            double prevBeatInterval = -1.0;
                        // cc: Duplicate our list of agents, and scan through the
                        // copy.  This means we can safely add agents to our own
                        // list while scanning without disrupting our scan.  Each
                        // agent needs to be re-added to our own list explicitly
                        // (since it is modified by e.g. considerAsBeat)
            Container currentAgents = list;
            list.clear();
            for (Container::iterator ai = currentAgents.begin();
                        ai != currentAgents.end(); ++ai) {
                  Agent *currentAgent = *ai;
                  if (currentAgent->beatInterval != prevBeatInterval) {
                        if ((prevBeatInterval >= 0) && !created && (ev.time < 5.0)) {
                                          // Create new agent with different phase
                              Agent *newAgent = new Agent(params, prevBeatInterval);
                                          // This may add another agent to our list as well
                              newAgent->considerAsBeat(ev, *this);
                              add(newAgent);
                              }
                        prevBeatInterval = currentAgent->beatInterval;
                        created = phaseGiven;
                        }
                  if (currentAgent->considerAsBeat(ev, *this))
                        created = true;
                  add(currentAgent);
                  }           // loop for each agent
            removeDuplicates();
            }           // loop for each event
      }
Exemple #27
0
//-------------------------------------------- Constructeurs - destructeur
EventList::EventList ( const EventList & aEventList )
// Algorithme :
//
{
#ifdef MAPD
    cout << "Appel au constructeur de copie de <EventList>" << endl;
#endif

    root = aEventList.GetRoot();
    nbEvents = 0;

} //----- Fin de EventList (constructeur de copie)
Exemple #28
0
	int Game::Run()
	{
		EventList eventList;
		this->window->setFramerateLimit(60);
		//clock.restart();
		sf::Time elapsed = clock.restart();

		while ( this->window->isOpen() )
		{

			sf::Event event;

			while ( window->pollEvent(event) )
			{
				if ( event.type == sf::Event::Closed )
					window->close();
	//       else if ( event.type = sf::Event::Resized )
	// 	this->windowResized = true;
			else
			  eventList.insert( std::pair< sf::Event::EventType,sf::Event >( event.type,event ) );

		}

			window->clear();

			this->Update( elapsed , &eventList );

			this->Draw();

			this->window->display();

			eventList.clear();

			elapsed = clock.restart();

		}


		return 0;
	}
void EventWorkspace::init(const HistogramData::Histogram &histogram) {
  if (histogram.xMode() != HistogramData::Histogram::XMode::BinEdges)
    throw std::runtime_error(
        "EventWorkspace can only be initialized with XMode::BinEdges");

  if (histogram.sharedY() || histogram.sharedE())
    throw std::runtime_error(
        "EventWorkspace cannot be initialized non-NULL Y or E data");

  data.resize(numberOfDetectorGroups(), nullptr);
  EventList el;
  el.setHistogram(histogram);
  for (size_t i = 0; i < data.size(); i++) {
    data[i] = new EventList(el);
    data[i]->setMRU(mru);
    data[i]->setSpectrumNo(specnum_t(i));
  }

  m_axes.resize(2);
  m_axes[0] = new API::RefAxis(this);
  m_axes[1] = new API::SpectraAxis(this);
}
void tst_QQuickAccessible::cleanup()
{
    const EventList list = QTestAccessibility::events();
    if (!list.isEmpty()) {
        qWarning("%d accessibility event(s) were not handled in testfunction '%s':", list.count(),
                 QString(QTest::currentTestFunction()).toLatin1().constData());
        for (int i = 0; i < list.count(); ++i)
            qWarning(" %d: Object: %p Event: '%s' Child: %d", i + 1, list.at(i)->object(),
                     qAccessibleEventString(list.at(i)->type()), list.at(i)->child());
    }
    QTestAccessibility::clearEvents();
}