#include "passthrough_processor.hpp"

namespace radar::processing {

auto PassThroughProcessor::name() const -> std::string {
    return "pass_through";
}

auto PassThroughProcessor::process_collection(
    const config::RunConfig& /*run_config*/,
    const ipc::PreprocessedCollection& collection,
    std::span<const ipc::PreprocessedCollection> /*previous_collections*/,
    const ProcessingLiveConfig& live_config
) -> ipc::ResultCollection {
    ipc::ResultCollection results{};
    results.collection_id = collection.collection_id;
    results.monotonic_ns = collection.monotonic_ns;
    results.blocks.reserve(collection.traces.size());

    for (const auto& trace : collection.traces) {
        ipc::ResultPayload payload{};
        payload.processing_name = name();
        payload.kind = ipc::ResultKind::TraceComplex;
        payload.frequency_hz = trace.frequency_hz;
        if (live_config.pass_through_channel == "s11") {
            payload.trace = trace.s11;
        } else {
            payload.trace = trace.s21;
        }

        ipc::ResultBlock block{};
        block.combo = trace.combo;
        block.payloads.push_back(std::move(payload));
        results.blocks.push_back(std::move(block));
    }

    return results;
}

}  // namespace radar::processing
