|
|
@ -12,23 +12,27 @@ |
|
|
|
#include "selfdrive/ui/qt/api.h" |
|
|
|
#include "selfdrive/ui/qt/api.h" |
|
|
|
#include "selfdrive/ui/replay/util.h" |
|
|
|
#include "selfdrive/ui/replay/util.h" |
|
|
|
|
|
|
|
|
|
|
|
Route::Route(const QString &route) : route_(route) {} |
|
|
|
Route::Route(const QString &route, const QString &data_dir) : route_(route), data_dir_(data_dir) {} |
|
|
|
|
|
|
|
|
|
|
|
bool Route::load() { |
|
|
|
bool Route::load() { |
|
|
|
QEventLoop loop; |
|
|
|
if (data_dir_.isEmpty()) { |
|
|
|
auto onError = [&loop](const QString &err) { loop.quit(); }; |
|
|
|
QEventLoop loop; |
|
|
|
|
|
|
|
auto onError = [&loop](const QString &err) { loop.quit(); }; |
|
|
|
bool ret = false; |
|
|
|
|
|
|
|
HttpRequest http(nullptr, !Hardware::PC()); |
|
|
|
bool ret = false; |
|
|
|
QObject::connect(&http, &HttpRequest::failedResponse, onError); |
|
|
|
HttpRequest http(nullptr, !Hardware::PC()); |
|
|
|
QObject::connect(&http, &HttpRequest::timeoutResponse, onError); |
|
|
|
QObject::connect(&http, &HttpRequest::failedResponse, onError); |
|
|
|
QObject::connect(&http, &HttpRequest::receivedResponse, [&](const QString json) { |
|
|
|
QObject::connect(&http, &HttpRequest::timeoutResponse, onError); |
|
|
|
ret = loadFromJson(json); |
|
|
|
QObject::connect(&http, &HttpRequest::receivedResponse, [&](const QString json) { |
|
|
|
loop.quit(); |
|
|
|
ret = loadFromJson(json); |
|
|
|
}); |
|
|
|
loop.quit(); |
|
|
|
http.sendRequest("https://api.commadotai.com/v1/route/" + route_ + "/files"); |
|
|
|
}); |
|
|
|
loop.exec(); |
|
|
|
http.sendRequest("https://api.commadotai.com/v1/route/" + route_ + "/files"); |
|
|
|
return ret; |
|
|
|
loop.exec(); |
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return loadFromLocal(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool Route::loadFromJson(const QString &json) { |
|
|
|
bool Route::loadFromJson(const QString &json) { |
|
|
@ -66,6 +70,40 @@ bool Route::loadFromJson(const QString &json) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Route::loadFromLocal() { |
|
|
|
|
|
|
|
QString prefix = route_.split('|').last(); |
|
|
|
|
|
|
|
if (prefix.isEmpty()) return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QDir log_dir(data_dir_); |
|
|
|
|
|
|
|
QStringList folders = log_dir.entryList(QDir::Dirs | QDir::NoDot | QDir::NoDotDot, QDir::NoSort); |
|
|
|
|
|
|
|
if (folders.isEmpty()) return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (auto folder : folders) { |
|
|
|
|
|
|
|
const int seg_num = folder.split("--")[2].toInt(); |
|
|
|
|
|
|
|
if (segments_.size() <= seg_num) { |
|
|
|
|
|
|
|
segments_.resize(seg_num + 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
QDir segment_dir(log_dir.filePath(folder)); |
|
|
|
|
|
|
|
for (auto f : segment_dir.entryList(QDir::Files)) { |
|
|
|
|
|
|
|
const QString file_path = segment_dir.absoluteFilePath(f); |
|
|
|
|
|
|
|
if (f.startsWith("rlog")) { |
|
|
|
|
|
|
|
segments_[seg_num].rlog = file_path; |
|
|
|
|
|
|
|
} else if (f.startsWith("qlog")) { |
|
|
|
|
|
|
|
segments_[seg_num].qlog = file_path; |
|
|
|
|
|
|
|
} else if (f.startsWith("fcamera")) { |
|
|
|
|
|
|
|
segments_[seg_num].road_cam = file_path; |
|
|
|
|
|
|
|
} else if (f.startsWith("dcamera")) { |
|
|
|
|
|
|
|
segments_[seg_num].driver_cam = file_path; |
|
|
|
|
|
|
|
} else if (f.startsWith("ecamera")) { |
|
|
|
|
|
|
|
segments_[seg_num].wide_road_cam = file_path; |
|
|
|
|
|
|
|
} else if (f.startsWith("qcamera")) { |
|
|
|
|
|
|
|
segments_[seg_num].qcamera = file_path; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// class Segment
|
|
|
|
// class Segment
|
|
|
|
|
|
|
|
|
|
|
|
Segment::Segment(int n, const SegmentFile &segment_files, bool load_dcam, bool load_ecam) : seg_num_(n), files_(segment_files) { |
|
|
|
Segment::Segment(int n, const SegmentFile &segment_files, bool load_dcam, bool load_ecam) : seg_num_(n), files_(segment_files) { |
|
|
@ -154,7 +192,7 @@ void Segment::load() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString Segment::localPath(const QUrl &url) { |
|
|
|
QString Segment::localPath(const QUrl &url) { |
|
|
|
if (url.isLocalFile()) return url.toString(); |
|
|
|
if (url.isLocalFile() || QFile(url.toString()).exists()) return url.toString(); |
|
|
|
|
|
|
|
|
|
|
|
QByteArray url_no_query = url.toString(QUrl::RemoveQuery).toUtf8(); |
|
|
|
QByteArray url_no_query = url.toString(QUrl::RemoveQuery).toUtf8(); |
|
|
|
return CACHE_DIR.filePath(QString(QCryptographicHash::hash(url_no_query, QCryptographicHash::Sha256).toHex())); |
|
|
|
return CACHE_DIR.filePath(QString(QCryptographicHash::hash(url_no_query, QCryptographicHash::Sha256).toHex())); |
|
|
|