コード例 #1
0
ファイル: StopperAlg.cpp プロジェクト: l1calo/gaudi
//------------------------------------------------------------------------------
StatusCode StopperAlg::execute() {
//------------------------------------------------------------------------------
  MsgStream         log( msgSvc(), name() );
  static int count = 0;

  if ( ++count >= m_stopcount ) {
    log << MSG::INFO << "scheduling a event processing stop...." << endmsg;
    IEventProcessor* evt = svc<IEventProcessor>("ApplicationMgr");
    if (evt->stopRun().isFailure()) {
      log << MSG::ERROR << "unable to issue a stopRun to the EventProcessor"
	  << endmsg;
      return StatusCode::FAILURE;
    }
    evt->release();
  }

  return StatusCode::SUCCESS;
}
コード例 #2
0
ファイル: PodioInput.cpp プロジェクト: faltovaj/FCCSW
StatusCode PodioInput::execute() {
  size_t cntr = 0;
  for (auto& id : m_collectionIDs) {
    podio::CollectionBase* collection(nullptr);
    m_provider.get(id, collection);
    auto wrapper = new DataWrapper<podio::CollectionBase>;
    wrapper->setData(collection);
    const std::string& collName = m_collectionNames.at(cntr++);
    debug() << "Registering collection to read " << collName << " with id " << id << endmsg;
    m_podioDataSvc->registerObject(collName, wrapper);
  }
  m_provider.clearCaches();
  m_reader.endOfEvent();
  if(m_eventNum++ > m_eventMax) {
    info() << "Reached end of file with event " << m_eventMax << endmsg;
    IEventProcessor* eventProcessor;
    service("ApplicationMgr",eventProcessor);
    eventProcessor->stopRun();
  }
  return StatusCode::SUCCESS;
}
コード例 #3
0
ファイル: EventUpnp.cpp プロジェクト: wifigeek/ohNet
void EventSessionUpnp::ProcessNotification(IEventProcessor& aEventProcessor, const Brx& aEntity)
{
    aEventProcessor.EventUpdateStart();
    OutputProcessorUpnp outputProcessor;
    Brn propertySet = XmlParserBasic::Find("propertyset", aEntity);
    Brn prop;
    Brn remaining;
    try {
        for (;;) {
            prop.Set(XmlParserBasic::Find("property", propertySet, remaining));
            prop.Set(Ascii::Trim(prop));
            if (prop.Bytes() < 8 || prop[0] != '<' || prop[1] == '/') {
                THROW(XmlError);
            }
            Parser parser(prop);
            (void)parser.Next('<');
            Brn tagName = parser.Next('>');
            Brn val = parser.Next('<');
            Brn closingTag = parser.Next('/');
            closingTag.Set(parser.Next('>'));
            if (tagName != closingTag) {
                THROW(XmlError);
            }

            try {
                aEventProcessor.EventUpdate(tagName, val, outputProcessor);
            }
            catch(AsciiError&) {
                THROW(XmlError);
            }

            propertySet.Set(remaining);
        }
    }
    catch(XmlError&) {}
    aEventProcessor.EventUpdateEnd();
}
コード例 #4
0
ファイル: EventUpnp.cpp プロジェクト: sewood/ohNet
void EventSessionUpnp::ProcessNotification(IEventProcessor& aEventProcessor, const Brx& aEntity)
{
    aEventProcessor.EventUpdateStart();
    OutputProcessorUpnp outputProcessor;
    Brn propertySet = XmlParserBasic::Find("propertyset", aEntity);
    Brn prop;
    Brn remaining;
    try {
        for (;;) {
            try {
                prop.Set(XmlParserBasic::Find("property", propertySet, remaining));
            }
            catch (XmlError&) {
                // we've successfully processed all <property> tags from aEntity
                break;
            }
            prop.Set(Ascii::Trim(prop));
            if (prop.Bytes() < 8 || prop[0] != '<' || prop[1] == '/') {
                THROW(XmlError);
            }
            Parser parser(prop);
            (void)parser.Next('<');
            Brn tagNameFull = parser.Next('>');
            Brn tagName = tagNameFull;
            TUint bytes = tagNameFull.Bytes();
            TUint i;
            for (i = 0; i < bytes; i++) {
                if (Ascii::IsWhitespace(tagNameFull[i])) {
                    break;
                }
            }
            if (i < bytes) {
                tagName.Set(tagNameFull.Split(0, i));
            }
            Brn val;
            if (bytes > 0 && tagNameFull[bytes-1] == '/') {
                // empty element tag
                val.Set(Brx::Empty());
                if (i == bytes) { // no white space before '/'
                    tagName.Set(tagName.Split(0, bytes-1));
                }
            }
            else {
                val.Set(parser.Next('<'));
                Brn closingTag = parser.Next('/');
                closingTag.Set(parser.Next('>'));
                if (tagName != closingTag) {
                    THROW(XmlError);
                }
            }

            try {
                aEventProcessor.EventUpdate(tagName, val, outputProcessor);
            }
            catch(AsciiError&) {
                THROW(XmlError);
            }

            propertySet.Set(remaining);
        }
        aEventProcessor.EventUpdateEnd();
    }
    catch(XmlError&) {
        aEventProcessor.EventUpdateError();
    }
}
コード例 #5
0
ファイル: CpiDeviceLpec.cpp プロジェクト: Jacik/ohNet
void CpiDeviceLpec::HandleEventedUpdate(const Brx& aUpdate)
{
    Parser parser(aUpdate);
    Brn lpecId = parser.Next(' ');
    Bws<128> sid(iDevice->Udn());
    sid.Append('-');
    sid.Append(lpecId);
    CpiSubscription* subscription = iCpStack.SubscriptionManager().FindSubscription(sid);
    if (subscription == NULL) {
        /* There is a very short window between Subscribe() returning and the new
           subscription being added to its manager.  As a lazy workaround for this,
           sleep for a short period and retry before rejecting the update */
        Thread::Sleep(1000);
        subscription = iCpStack.SubscriptionManager().FindSubscription(sid);
    }
    if (subscription == NULL) {
        LOG(kLpec, "LPEC: evented update received for unknown subscription - ");
        LOG(kLpec, sid);
        LOG(kLpec, "\n");
        return;
    }
    Brn seqBuf = parser.Next(' ');
    TUint seq;
    try {
        seq = Ascii::Uint(seqBuf);
    }
    catch (AsciiError&) {
        LOG(kLpec, "LPEC: invalid sequence number - ");
        LOG(kLpec, seqBuf);
        LOG(kLpec, "in evented update\n");
        subscription->RemoveRef();
        return;
    }
    if (!subscription->UpdateSequenceNumber(seq)) {
        LOG(kLpec, "LPEC: out of sequence update (%d) for ", seq);
        LOG(kLpec, sid);
        LOG(kLpec, "\n");
        subscription->SetNotificationError();
        subscription->RemoveRef();
        return;
    }
    IEventProcessor* processor = static_cast<IEventProcessor*>(subscription);
    processor->EventUpdateStart();
    OutputProcessor outputProcessor;
    try {
        for (;;) {
            Brn propName = parser.Next(' ');
            if (propName.Bytes() == 0) {
                // processed entire update
                break;
            }
            (void)parser.Next(Lpec::kArgumentDelimiter);
            Brn propVal = parser.Next(Lpec::kArgumentDelimiter);
            processor->EventUpdate(propName, propVal, outputProcessor);
        }
        processor->EventUpdateEnd();
    }
    catch (AsciiError&) {
        LOG2(kLpec, kError, "LPEC: Invalid evented update - ");
        LOG2(kLpec, kError, aUpdate);
        LOG2(kLpec, kError, "\n");
        processor->EventUpdateError();
    }
    subscription->Unlock();
    subscription->RemoveRef();
}