mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-22 22:24:01 -06:00
NEW: add track events for debugging network
Change-Id: I671f91b4af00277236ca71014f8d667109756d00 Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
bd75af4a43
commit
6827b41eb3
13 changed files with 187 additions and 12 deletions
|
@ -228,14 +228,15 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
|||
m_button_download->Enable(e.GetInt() > 0);
|
||||
});
|
||||
fs->Bind(EVT_MODE_CHANGED, &MediaFilePanel::modeChanged, this);
|
||||
fs->Bind(EVT_STATUS_CHANGED, [this, wfs = boost::weak_ptr(fs)](auto &e) {
|
||||
fs->Bind(EVT_STATUS_CHANGED, [this, wfs = boost::weak_ptr(fs)](auto& e) {
|
||||
e.Skip();
|
||||
boost::shared_ptr fs(wfs.lock());
|
||||
if (m_image_grid->GetFileSystem() != fs) // canceled
|
||||
return;
|
||||
ScalableBitmap icon;
|
||||
wxString msg;
|
||||
switch (e.GetInt()) {
|
||||
int status = e.GetInt();
|
||||
switch (status) {
|
||||
case PrinterFileSystem::Initializing: icon = m_bmp_loading; msg = _L("Initializing..."); break;
|
||||
case PrinterFileSystem::Connecting: icon = m_bmp_loading; msg = _L("Connecting..."); break;
|
||||
case PrinterFileSystem::Failed: icon = m_bmp_failed; msg = _L("Connect failed [%d]!"); break;
|
||||
|
@ -246,6 +247,53 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
|||
m_image_grid->SetStatus(icon, msg);
|
||||
if (e.GetInt() == PrinterFileSystem::Initializing)
|
||||
fetchUrl(boost::weak_ptr(fs));
|
||||
|
||||
if (status == PrinterFileSystem::Failed
|
||||
|| status == PrinterFileSystem::ListReady) {
|
||||
json j;
|
||||
j["code"] = fs->GetLastError();
|
||||
j["dev_id"] = m_machine;
|
||||
j["dev_ip"] = m_lan_ip;
|
||||
NetworkAgent* agent = wxGetApp().getAgent();
|
||||
if (status == PrinterFileSystem::Failed) {
|
||||
j["result"] = "failed";
|
||||
if (agent)
|
||||
agent->track_event("download_video_conn", j.dump());
|
||||
} else if (status == PrinterFileSystem::ListReady) {
|
||||
j["result"] = "success";
|
||||
if (agent)
|
||||
agent->track_event("download_video_conn", j.dump());
|
||||
}
|
||||
}
|
||||
});
|
||||
fs->Bind(EVT_DOWNLOAD, [this, wfs = boost::weak_ptr(fs)](auto& e) {
|
||||
e.Skip();
|
||||
boost::shared_ptr fs(wfs.lock());
|
||||
if (m_image_grid->GetFileSystem() != fs) // canceled
|
||||
return;
|
||||
|
||||
int result = e.GetExtraLong();
|
||||
NetworkAgent* agent = wxGetApp().getAgent();
|
||||
if (result > 1 || result == 0) {
|
||||
json j;
|
||||
j["code"] = result;
|
||||
j["dev_id"] = m_machine;
|
||||
j["dev_ip"] = m_lan_ip;
|
||||
if (result > 1) {
|
||||
// download failed
|
||||
j["result"] = "failed";
|
||||
if (agent) {
|
||||
agent->track_event("download_video", j.dump());
|
||||
}
|
||||
} else if (result == 0) {
|
||||
// download success
|
||||
j["result"] = "success";
|
||||
if (agent) {
|
||||
agent->track_event("download_video", j.dump());
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
});
|
||||
if (IsShown()) fs->Start();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue