Beispiel #1
0
void ProcessorGraph::clearSignalChain()
{

    int n = 0;

    while (getNumNodes() > 4)
    {
        Node* node = getNode(n);
        int nodeId = node->nodeId;

        if (nodeId != OUTPUT_NODE_ID &&
            nodeId != AUDIO_NODE_ID &&
            nodeId != RECORD_NODE_ID &&
            nodeId != RESAMPLING_NODE_ID)
        {
            GenericProcessor* p =(GenericProcessor*) node->getProcessor();
            removeProcessor(p);
        }
        else
        {
            n++;
        }
    }

}
Beispiel #2
0
void ProcessorGraph::clearSignalChain()
{

    Array<GenericProcessor*> processors = getListOfProcessors();

    for (int i = 0; i < processors.size(); i++)
    {
        removeProcessor(processors[i]);
    }

}
Beispiel #3
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void Application::registerProcessor(const std::string& networkCode,
                                    const std::string& stationCode,
                                    const std::string& locationCode,
                                    const std::string& channelCode,
                                    TimeWindowProcessor *twp) {
	registerProcessor(networkCode, stationCode, locationCode, channelCode, (WaveformProcessor*)twp);

	twp->computeTimeWindow();

	RecordSequence* seq = _waveformBuffer.sequence(
		StreamBuffer::WaveformID(networkCode, stationCode, locationCode, channelCode));
	if ( !seq ) return;

	Core::Time startTime = twp->timeWindow().startTime() - twp->margin();
	Core::Time endTime = twp->timeWindow().endTime() +  twp->margin();

	if ( startTime < seq->timeWindow().startTime() ) {
		// TODO: Fetch historical data
		// Actually feed as much data as possible
		TimeWindowProcessorPtr twp_ptr = twp;

		for ( RecordSequence::iterator it = seq->begin(); it != seq->end(); ++it ) {
			if ( (*it)->startTime() > endTime )
				break;
			twp->feed((*it).get());
		}
	}
	else {
		// find the position in the recordsequence to fill the requested timewindow
		RecordSequence::reverse_iterator rit;
		for ( rit = seq->rbegin(); rit != seq->rend(); ++rit ) {
			if ( (*rit)->endTime() < startTime )
				break;
		}

		RecordSequence::iterator it;
		if ( rit == seq->rend() )
			it = seq->begin();
		else
			it = --rit.base();

		while ( it != seq->end() && (*it)->startTime() <= endTime ) {
			twp->feed((*it).get());
			++it;
		}
	}

	if ( twp->isFinished() ) {
		processorFinished(twp->lastRecord(), twp);
		removeProcessor(twp);
	}
}
Beispiel #4
0
void Net::processAll(){  
  if(EthernetInterrupt::available()){
    analogWrite(PIN_G, light->read(255-5)+5);
    for(int8_t c=0;c<processorCount;c++){
      if(processor[c]()){
        removeProcessor(processor[c]);
        c--;
      }
    }
    EthernetInterrupt::next();
    digitalWrite(PIN_G, LOW);
  }
}
Beispiel #5
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void Application::handleRecord(Record *rec) {
	std::string streamID = rec->streamID();
	std::list<WaveformProcessor*> trashList;

	RecordPtr tmp(rec);

	if ( rec->data() == NULL ) return;

	if ( !_waveformBuffer.feed(rec) ) return;

	if ( _waveformBuffer.addedNewStream() )
		handleNewStream(rec);

	_registrationBlocked = true;

	std::pair<ProcessorMap::iterator, ProcessorMap::iterator> itq = _processors.equal_range(streamID);
	for ( ProcessorMap::iterator it = itq.first; it != itq.second; ++it ) {
		// The proc must not be already on the removal list
		if ( std::find(_waveformProcessorRemovalQueue.begin(),
		               _waveformProcessorRemovalQueue.end(),
		               it->second) != _waveformProcessorRemovalQueue.end() )
			continue;

		// Schedule the processor for deletion when finished
		if ( it->second->isFinished() )
			trashList.push_back(it->second.get());
		else {
			it->second->feed(rec);
			if ( it->second->isFinished() )
				trashList.push_back(it->second.get());
		}
	}

	// Delete finished processors
	for ( std::list<WaveformProcessor*>::iterator itt = trashList.begin();
	      itt != trashList.end(); ++itt ) {
		processorFinished(rec, *itt);
		removeProcessor(*itt);
	}

	trashList.clear();

	_registrationBlocked = false;

	// Remove outdated processors if not already on the trash list
	while ( !_waveformProcessorRemovalQueue.empty() ) {
		WaveformProcessorPtr wp = _waveformProcessorRemovalQueue.front();
		_waveformProcessorRemovalQueue.pop_front();
		removeProcessor(wp.get());
	}

	// Register pending processors
	while ( !_waveformProcessorQueue.empty() ) {
		WID wid = _waveformProcessorQueue.front().first;
		WaveformProcessorPtr wp = _waveformProcessorQueue.front().second;
		_waveformProcessorQueue.pop_front();

		registerProcessor(wid.networkCode(), wid.stationCode(),
		                  wid.locationCode(), wid.channelCode(), wp.get());
	}

	while ( !_timeWindowProcessorQueue.empty() ) {
		WID wid = _timeWindowProcessorQueue.front().first;
		TimeWindowProcessorPtr twp = _timeWindowProcessorQueue.front().second;
		_timeWindowProcessorQueue.pop_front();

		registerProcessor(wid.networkCode(), wid.stationCode(),
		                  wid.locationCode(), wid.channelCode(), twp.get());
	}
}
Beispiel #6
0
void ProcessorBus::removeAll()
{
    while (processorCount)
        removeProcessor(processors[0]);
}