void CalculateAmplitudes::addProcessor(Processing::AmplitudeProcessor *proc,
                                       const DataModel::Pick *pick,
                                       int c) {
    static const char *names[3] = {"vertical", "first horizontal", "second horizontal"};
    char component;
    ThreeComponents tc;

    try {
        tc = Client::Inventory::Instance()->getThreeComponents(pick);
    }
    catch ( ... ) {}

    WaveformStreamID cwid = pick->waveformID();

    if ( tc.comps[ThreeComponents::Component(c)] == NULL )
        component = '\0';
    else {
        cwid.setChannelCode(tc.comps[ThreeComponents::Component(c)]->code());
        component = *cwid.channelCode().rbegin();
    }

    std::string streamID = waveformIDToStdString(cwid);

    int row = addProcessingRow(streamID, proc->type());

    if ( component == '\0' ) {
        setError(row, QString("no %1 component found").arg(names[c]));
        return;
    }

    StreamMap::iterator it = _streams.find(streamID);
    if ( it != _streams.end() )
        proc->streamConfig((WaveformProcessor::Component)c) = *it->second;
    else {
        Processing::StreamPtr stream = new Processing::Stream;
        stream->init(cwid.networkCode(),
                     cwid.stationCode(),
                     cwid.locationCode(),
                     cwid.channelCode(),
                     pick->time().value());
        _streams[streamID] = stream;

        proc->streamConfig((WaveformProcessor::Component)c) = *stream;
    }

    if ( proc->streamConfig((WaveformProcessor::Component)c).gain == 0.0 ) {
        setError(row, "no gain found");
        return;
    }

    if ( proc->status() != WaveformProcessor::WaitingForData ) {
        setError(row, QString("%1 (%2)").arg(proc->status().toString()).arg(proc->statusValue(), 0, 'f', 2));
        return;
    }
    else
        setError(row, proc->status().toString());

    _rows.insert(TableRowMap::value_type(proc, row));
}
示例#2
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void Envelope::addProcessor(SensorLocation *loc, const WaveformStreamID &id,
                            const Core::Time &timestamp, const char *type,
                            const char *short_type) {
	DataModel::ThreeComponents tc;
	DataModel::WaveformStreamID tmp(id);
	try {
		DataModel::getThreeComponents(
			tc, loc, id.channelCode().c_str(), timestamp
		);
	}
	catch ( exception &e ) {
		SEISCOMP_ERROR("%s: cannot query three components: %s: "
		               "%s channels not used",
		               Private::toStreamID(tmp).c_str(),
		               e.what(), type);
	}

	for ( int i = 0; i < 3; ++i ) {
		if ( tc.comps[i] == NULL ) continue;
		tmp.setChannelCode(tc.comps[i]->code());
		if ( !_streamFirewall.isAllowed(Private::toStreamID(tmp)) ) continue;

		SEISCOMP_INFO("%s: +%s", Private::toStreamID(tmp).c_str(), short_type);
		recordStream()->addStream(tmp.networkCode(), tmp.stationCode(),
		                          tmp.locationCode(), tmp.channelCode());
		ProcessorPtr proc = new Processor(_config.baselineCorrectionBufferLength);
		switch ( i ) {
			case ThreeComponents::Vertical:
				proc->setUsedComponent(Processing::WaveformProcessor::Vertical);
				proc->setName("Z");
				break;
			case ThreeComponents::FirstHorizontal:
				proc->setUsedComponent(Processing::WaveformProcessor::FirstHorizontal);
				proc->setName("H1");
				break;
			case ThreeComponents::SecondHorizontal:
				proc->setUsedComponent(Processing::WaveformProcessor::SecondHorizontal);
				proc->setName("H2");
				break;
		}

		Processing::StreamPtr stream = new Processing::Stream;
		stream->init(tmp.networkCode(), tmp.stationCode(),
		             tmp.locationCode(), tmp.channelCode(),
		             timestamp);

		proc->streamConfig((Processing::WaveformProcessor::Component)proc->usedComponent()) = *stream;
		proc->setWaveformID(tmp);
		proc->setSaturationThreshold(_config.saturationThreshold);
		proc->useVSFilterImplementation(!_config.useSC3Filter);

		if ( proc->streamConfig((Processing::WaveformProcessor::Component)proc->usedComponent()).gain == 0.0 ) {
			SEISCOMP_WARNING("%s: -%s: gain not defined (= 0.0)",
			                 short_type, Private::toStreamID(tmp).c_str());
			continue;
		}

		proc->setPublishFunction(boost::bind(&Envelope::emitResult, this, _1, _2, _3, _4, _5, _6));
		_processors[Private::toStreamID(tmp)] = proc;
	}
}