ENH: support AMS switching for A series; clean class AMSSetting

jira: [STUDIO-14068] [STUDIO-14330]
Change-Id: I6281fbf56f3bf406ef28103998790a2a98c3f5c0
(cherry picked from commit 8ee02ec73076691c482ea6d089a49ea1c99ad10c)
This commit is contained in:
xin.zhang
2025-09-05 17:28:41 +08:00
committed by Noisyfox
parent 8534cf5fce
commit 491100a9d2
20 changed files with 748 additions and 169 deletions

View File

@@ -9,6 +9,53 @@ using namespace nlohmann;
namespace Slic3r
{
DevCtrlInfo::DevCtrlInfo(MachineObject* obj, int sequence_id, const json& req_json,
int interval_max, int interval_min)
{
m_request_dev_id = obj->get_dev_id();
m_request_seq = sequence_id;
m_request_time = time(nullptr);
m_request_json = req_json;
m_request_interval_max = interval_max;
m_request_interval_min = interval_min;
}
bool DevCtrlInfo::CheckCanUpdateData(const nlohmann::json& jj)
{
if (m_request_json.empty()) {
return true;
}
if (m_time_out) {
return true;
}
if (time(nullptr) - m_request_time > m_request_interval_max) {
OnTimeOut();
return true;
}
if (time(nullptr) - m_request_time < m_request_interval_min) {
return false;
}
if (m_received) {
return true;
}
try {
if (jj.contains("sequence_id") && jj["sequence_id"].is_string()) {
int sequence_id = stoi(jj["sequence_id"].get<std::string>());
if (sequence_id >= m_request_seq) {
OnReceived();
return true;
}
}
} catch (...) {
;
}
return false;
}
int DevCtrl::command_select_extruder(int id)
{
json j;