ENH: auto stop liveview when print idle
Change-Id: I06dcc2a6ae469df8c39c1dc6c8626f66bc778f81 Jira: none
This commit is contained in:
parent
69ad831570
commit
06bbd235b8
|
@ -321,6 +321,10 @@ void AppConfig::set_defaults()
|
||||||
set_bool("backup_switch", true);
|
set_bool("backup_switch", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (get("liveview", "auto_stop_liveview").empty()) {
|
||||||
|
set("liveview", "auto_stop_liveview", true);
|
||||||
|
}
|
||||||
|
|
||||||
if (get("backup_interval").empty()) {
|
if (get("backup_interval").empty()) {
|
||||||
set("backup_interval", "10");
|
set("backup_interval", "10");
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
|
||||||
m_media_ctrl->Bind(EVT_MEDIA_CTRL_STAT, [this](auto & e) {
|
m_media_ctrl->Bind(EVT_MEDIA_CTRL_STAT, [this](auto & e) {
|
||||||
#if !BBL_RELEASE_TO_PUBLIC
|
#if !BBL_RELEASE_TO_PUBLIC
|
||||||
wxSize size = m_media_ctrl->GetVideoSize();
|
wxSize size = m_media_ctrl->GetVideoSize();
|
||||||
m_label_stat->SetLabel(e.GetString() + wxString::Format(" VS:%ix%i", size.x, size.y));
|
m_label_stat->SetLabel(e.GetString() + wxString::Format(" VS:%ix%i LD:%i", size.x, size.y, m_load_duration));
|
||||||
#endif
|
#endif
|
||||||
wxString str = e.GetString();
|
wxString str = e.GetString();
|
||||||
m_stat.clear();
|
m_stat.clear();
|
||||||
|
@ -183,9 +183,20 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
|
||||||
agent->get_camera_url(machine, [](auto) {});
|
agent->get_camera_url(machine, [](auto) {});
|
||||||
m_last_user_play = wxDateTime::Now();
|
m_last_user_play = wxDateTime::Now();
|
||||||
}
|
}
|
||||||
if (m_last_state == wxMediaState::wxMEDIASTATE_PLAYING && SecondsSinceLastInput() > 900) { // 15 minutes
|
if (m_last_state == wxMediaState::wxMEDIASTATE_PLAYING) {
|
||||||
m_next_retry = wxDateTime();
|
auto now = std::chrono::system_clock::now();
|
||||||
Stop(_L("Temporarily closed because there is no operating for a long time."));
|
if (m_play_timer <= now) {
|
||||||
|
m_play_timer = now + 1min;
|
||||||
|
auto obj = wxGetApp().getDeviceManager()->get_selected_machine();
|
||||||
|
if (obj && obj->is_in_printing()) {
|
||||||
|
m_print_idle = 0;
|
||||||
|
} else if (++m_print_idle >= 5) {
|
||||||
|
auto close = wxGetApp().app_config->get("liveview", "auto_stop_liveview") == "true";
|
||||||
|
if (close) {
|
||||||
|
Stop(_L("Temporarily closed because there is no printing for a long time."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -323,6 +334,7 @@ void MediaPlayCtrl::Play()
|
||||||
|
|
||||||
m_label_stat->SetLabel({});
|
m_label_stat->SetLabel({});
|
||||||
SetStatus(_L("Initializing..."));
|
SetStatus(_L("Initializing..."));
|
||||||
|
m_play_timer = std::chrono::system_clock::now();
|
||||||
|
|
||||||
if (agent) {
|
if (agent) {
|
||||||
agent->get_camera_url(m_machine,
|
agent->get_camera_url(m_machine,
|
||||||
|
@ -627,6 +639,10 @@ void MediaPlayCtrl::onStateChanged(wxMediaEvent &event)
|
||||||
m_last_state = state;
|
m_last_state = state;
|
||||||
m_failed_code = 0;
|
m_failed_code = 0;
|
||||||
SetStatus(_L("Playing..."), false);
|
SetStatus(_L("Playing..."), false);
|
||||||
|
m_print_idle = 0;
|
||||||
|
auto now = std::chrono::system_clock::now();
|
||||||
|
m_load_duration = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_play_timer).count();
|
||||||
|
m_play_timer = now + 1min;
|
||||||
|
|
||||||
// track event
|
// track event
|
||||||
json j;
|
json j;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <boost/thread/condition_variable.hpp>
|
#include <boost/thread/condition_variable.hpp>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
@ -101,6 +102,9 @@ private:
|
||||||
std::set<int> m_last_failed_codes;
|
std::set<int> m_last_failed_codes;
|
||||||
wxDateTime m_last_user_play;
|
wxDateTime m_last_user_play;
|
||||||
wxDateTime m_next_retry;
|
wxDateTime m_next_retry;
|
||||||
|
std::chrono::system_clock::time_point m_play_timer;
|
||||||
|
int m_print_idle = 0;
|
||||||
|
int m_load_duration = 0;
|
||||||
|
|
||||||
::Button *m_button_play;
|
::Button *m_button_play;
|
||||||
::Label * m_label_stat;
|
::Label * m_label_stat;
|
||||||
|
|
|
@ -630,8 +630,9 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
|
||||||
auto checkbox = new ::CheckBox(parent);
|
auto checkbox = new ::CheckBox(parent);
|
||||||
if (param == "privacyuse") {
|
if (param == "privacyuse") {
|
||||||
checkbox->SetValue((app_config->get("firstguide", param) == "true") ? true : false);
|
checkbox->SetValue((app_config->get("firstguide", param) == "true") ? true : false);
|
||||||
}
|
} else if (param == "auto_stop_liveview") {
|
||||||
else {
|
checkbox->SetValue((app_config->get("liveview", param) == "true") ? true : false);
|
||||||
|
} else {
|
||||||
checkbox->SetValue((app_config->get(param) == "true") ? true : false);
|
checkbox->SetValue((app_config->get(param) == "true") ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,6 +662,9 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
|
||||||
}
|
}
|
||||||
app_config->save();
|
app_config->save();
|
||||||
}
|
}
|
||||||
|
else if (param == "auto_stop_liveview") {
|
||||||
|
app_config->set("liveview", param, checkbox->GetValue());
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
app_config->set_bool(param, checkbox->GetValue());
|
app_config->set_bool(param, checkbox->GetValue());
|
||||||
app_config->save();
|
app_config->save();
|
||||||
|
@ -1077,8 +1081,9 @@ wxWindow* PreferencesDialog::create_general_page()
|
||||||
auto item_backup_interval = create_item_backup_input(_L("every"), page, _L("The peroid of backup in seconds."), "backup_interval");
|
auto item_backup_interval = create_item_backup_input(_L("every"), page, _L("The peroid of backup in seconds."), "backup_interval");
|
||||||
|
|
||||||
//downloads
|
//downloads
|
||||||
auto title_downloads = create_item_title(_L("Downloads"), page, _L("Downloads"));
|
auto title_media = create_item_title(_L("Media"), page, _L("Media"));
|
||||||
auto item_downloads = create_item_downloads(page,50,"download_path");
|
auto item_downloads = create_item_downloads(page,50,"download_path");
|
||||||
|
auto item_auto_stop_liveview = create_item_checkbox(_L("Auto Stop Liveview"), page, _L("Automatically close the video after printing."), 50, "auto_stop_liveview");
|
||||||
|
|
||||||
//dark mode
|
//dark mode
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -1136,8 +1141,9 @@ wxWindow* PreferencesDialog::create_general_page()
|
||||||
sizer_page->Add(item_backup, 0, wxTOP,FromDIP(3));
|
sizer_page->Add(item_backup, 0, wxTOP,FromDIP(3));
|
||||||
item_backup->Add(item_backup_interval, 0, wxLEFT, 0);
|
item_backup->Add(item_backup_interval, 0, wxLEFT, 0);
|
||||||
|
|
||||||
sizer_page->Add(title_downloads, 0, wxTOP| wxEXPAND, FromDIP(20));
|
sizer_page->Add(title_media, 0, wxTOP| wxEXPAND, FromDIP(20));
|
||||||
sizer_page->Add(item_downloads, 0, wxEXPAND, FromDIP(3));
|
sizer_page->Add(item_downloads, 0, wxEXPAND, FromDIP(3));
|
||||||
|
sizer_page->Add(item_auto_stop_liveview, 0, wxEXPAND, FromDIP(3));
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
sizer_page->Add(title_darkmode, 0, wxTOP | wxEXPAND, FromDIP(20));
|
sizer_page->Add(title_darkmode, 0, wxTOP | wxEXPAND, FromDIP(20));
|
||||||
|
|
Loading…
Reference in New Issue