Exemplo n.º 1
0
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));
}
Exemplo n.º 2
0
void CalculateAmplitudes::subscribeData(Processing::AmplitudeProcessor *proc,
                                        const DataModel::Pick *pick,
                                        int c) {
    if ( proc->streamConfig((WaveformProcessor::Component)c).code().empty() )
        return;

    if ( proc->streamConfig((WaveformProcessor::Component)c).gain == 0.0 )
        return;

    WaveformStreamID cwid = pick->waveformID();
    cwid.setChannelCode(proc->streamConfig((WaveformProcessor::Component)c).code());
    std::string streamID = waveformIDToStdString(cwid);

    pair<ProcessorMap::iterator, bool> handle = _processors.insert(ProcessorMap::value_type(streamID, ProcessorSlot()));
    if ( handle.second )
        _thread->addStream(cwid.networkCode(), cwid.stationCode(), cwid.locationCode(), cwid.channelCode());

    handle.first->second.push_back(proc);

    // Add processors timewindow to global acquisition timewindow
    _timeWindow = _timeWindow | proc->safetyTimeWindow();
}