Ejemplo n.º 1
0
    virtual bool get_next_row(RowT& result) {
        if (advance()) {
            if (sample_.payload.type == aku_PData::EMPTY) {
                aku_cursor_close(cursor_);
                cursor_ = nullptr;
                return false;
            }
            const int buffer_size = AKU_LIMITS_MAX_SNAME;
            char buffer[buffer_size];
            // Convert id
            auto len = aku_param_id_to_series(db_, sample_.paramid, buffer, buffer_size);
            if (len <= 0) {
                std::runtime_error err("no such id");
                BOOST_THROW_EXCEPTION(err);
            }
            std::string paramid(buffer, buffer + len - 1);

            std::string timestamp;
            if (sample_.payload.type & aku_PData::TIMESTAMP_BIT) {
                // Convert timestamp
                len = aku_timestamp_to_string(sample_.timestamp, buffer, buffer_size);
                if (len <= 0) {
                    std::runtime_error err("bad timestamp");
                    BOOST_THROW_EXCEPTION(err);
                }
                timestamp = std::string(buffer, buffer + len - 1);
            }
            // Convert payload
            if (sample_.payload.type & aku_PData::FLOAT_BIT) {
                result = { timestamp, paramid, sample_.payload.float64, sample_.paramid, sample_.timestamp };
            } else {
                result = { std::string(), paramid, NAN, sample_.paramid, sample_.timestamp };
            }
            return true;
        }
        return false;
    }
Ejemplo n.º 2
0
int AkumuliConnection::param_id_to_series(aku_ParamId id, char* buffer, size_t buffer_size) {
    return aku_param_id_to_series(db_, id, buffer, buffer_size);
}