Files
OrcaSlicer/src/slic3r/GUI/DeviceCore/DevCtrl.cpp
T
HanifKoh 1a5f91d727 Add Missing Includes Across src/slic3r/GUI (#16048)
* Add Missing Includes Across src/slic3r/GUI

Every GUI source and header now directly includes the headers declaring what it uses, rather than relying on the precompiled header or transitive includes. Generated with clang-tidy misc-include-cleaner, plus one hand edit making CalibrationPanel.hpp self-contained.

* Drop the OS-Specific Includes Added Outside Their Platform Guards

GLib, GTK, D-Bus and POSIX headers are only used inside platform #if blocks, which already include them. Added unconditionally at the top of the file they broke the Windows build.

* Add the clang-tidy Configuration That Generated These Includes

Only misc-include-cleaner's missing-include check, with the headers it must never suggest: per-platform, internal and OS-specific ones that would break other platforms or are not meant to be included directly.

* Match Windows Paths in the clang-tidy Ignore List

Header paths use backslashes on Windows, so every / in a pattern is now [/\\]. The Windows SDK headers are ignored alongside the other OS-specific ones, and the list is one pattern per line. Suggested by @raistlin7447 from a Windows clang-cl run.
2026-10-02 14:56:56 +08:00

76 lines
1.8 KiB
C++

#include <ctime>
#include <nlohmann/json.hpp>
#include <string>
#include "DevCtrl.h"
// TODO: remove this include
#include "DevUtil.h"
#include "json_diff.hpp"
#include "slic3r/GUI/DeviceManager.hpp"
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;
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["command"] = "select_extruder";
j["print"]["extruder_index"] = id;
int rtn = m_obj->publish_json(j, 1);
if (rtn == 0)
{
m_obj->targ_nozzle_id_from_pc = id;
}
return rtn;
}
}