mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-09 08:41:14 +00:00
* Stop Leaking json Through Headers and Drop Includes Kept Only for the Name AppConfig.hpp, DeviceManager.hpp and UserManager.hpp carried a global "using namespace nlohmann;", json_diff.hpp a global "using json = nlohmann::json;" and PrinterFileSystem.h a global "using nlohmann::json;". Every file that included one of them, directly or not, could write a bare json, and 63 did without declaring it. The last two also made the include checker treat json_diff.hpp and PrinterFileSystem.h as the headers that provide json, so they were included from files that use nothing else from them: 57 of the 59 includers of json_diff.hpp never name json_diff. The five statements are removed. Headers that use the type now spell nlohmann::json, source files declare their own "using json = nlohmann::json;", and the includes that only supplied the name are dropped or replaced by <nlohmann/json.hpp>. Eight files reached json_diff.hpp only through an include that is now gone and with it lost that header's "using namespace std;". The std names they used unqualified are qualified. * Declare json in OrcaSlicer.cpp on Every Platform OrcaSlicer.cpp had its "using namespace nlohmann;" and the json include inside the Linux-only include block, so on Windows and macOS it took json from AppConfig.hpp's global directive, which is gone. The include and a "using json = nlohmann::json;" now sit outside the block.
59 lines
2.4 KiB
C++
59 lines
2.4 KiB
C++
#include <nlohmann/json.hpp>
|
|
#include <string>
|
|
#include "DevFilaSystem.h"
|
|
|
|
#include "slic3r/GUI/DeviceManager.hpp"// TODO: remove this include
|
|
|
|
using namespace nlohmann;
|
|
namespace Slic3r
|
|
{
|
|
|
|
int DevFilaSystem::CtrlAmsReset() const
|
|
{
|
|
json jj_command;
|
|
jj_command["print"]["command"] = "ams_reset";
|
|
jj_command["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
|
return m_owner->publish_json(jj_command);
|
|
}
|
|
|
|
int DevFilaSystem::CtrlAmsStartDryingHour(int ams_id,
|
|
std::string filament_type,
|
|
int tag_temp,
|
|
int tag_duration_hour,
|
|
bool rotate_tray,
|
|
int cooling_temp,
|
|
bool close_power_conflict) const
|
|
{
|
|
json jj_command;
|
|
jj_command["print"]["command"] = "ams_filament_drying";
|
|
jj_command["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
|
jj_command["print"]["ams_id"] = ams_id;
|
|
jj_command["print"]["mode"] = static_cast<int>(DevAms::DryCtrlMode::OnTime); // Orca: cast scoped enum for json
|
|
jj_command["print"]["filament"] = filament_type; // Orca: fix comma-operator typo
|
|
jj_command["print"]["temp"] = tag_temp;
|
|
jj_command["print"]["duration"] = tag_duration_hour;
|
|
jj_command["print"]["humidity"] = 0;
|
|
jj_command["print"]["rotate_tray"] = rotate_tray;
|
|
jj_command["print"]["cooling_temp"] = cooling_temp;
|
|
jj_command["print"]["close_power_conflict"] = close_power_conflict;
|
|
return m_owner->publish_json(jj_command);
|
|
}
|
|
|
|
int DevFilaSystem::CtrlAmsStopDrying(int ams_id) const
|
|
{
|
|
json jj_command;
|
|
jj_command["print"]["command"] = "ams_filament_drying";
|
|
jj_command["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
|
jj_command["print"]["ams_id"] = ams_id;
|
|
jj_command["print"]["mode"] = static_cast<int>(DevAms::DryCtrlMode::Off); // Orca: cast scoped enum for json
|
|
jj_command["print"]["filament"] = ""; // Orca: fix comma-operator typo
|
|
jj_command["print"]["temp"] = 0;
|
|
jj_command["print"]["duration"] = 0;
|
|
jj_command["print"]["humidity"] = 0;
|
|
jj_command["print"]["rotate_tray"] = false;
|
|
jj_command["print"]["cooling_temp"] = 0;
|
|
jj_command["print"]["close_power_conflict"] = false;
|
|
return m_owner->publish_json(jj_command);
|
|
}
|
|
|
|
} |