OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
DeviceManager.cpp File Reference
#include "PrinterNetworkTypes.hpp"
#include <nlohmann/json.hpp>
#include "DeviceManager.hpp"
#include "HMS.hpp"
#include "I18N.hpp"
#include "libslic3r/Thread.hpp"
#include "libslic3r/PresetBundle.hpp"
#include "slic3r/Utils/Http.hpp"
#include "slic3r/Utils/NetworkAgent.hpp"
#include "slic3r/Utils/NetworkAgentFactory.hpp"
#include "GUI_App.hpp"
#include "DeviceErrorDialog.hpp"
#include "MainFrame.hpp"
#include "Plater.hpp"
#include "ReleaseNote.hpp"
#include <string>
#include <boost/log/trivial.hpp>
#include <cstdlib>
#include <cstddef>
#include "libslic3r/PrintConfig.hpp"
#include <cassert>
#include "slic3r/GUI/DeviceCore/DevConfigUtil.h"
#include "libslic3r/Utils.hpp"
#include <boost/filesystem/operations.hpp>
#include <chrono>
#include "slic3r/GUI/DeviceCore/DevDefs.h"
#include <memory>
#include "slic3r/GUI/DeviceCore/DevCalib.h"
#include <boost/algorithm/string/predicate.hpp>
#include <cstdint>
#include <map>
#include "libslic3r/calib.hpp"
#include <ctime>
#include "slic3r/GUI/DeviceCore/DevFilaAmsSetting.h"
#include <cstdio>
#include "slic3r/GUI/DeviceCore/DevFirmware.h"
#include <optional>
#include <exception>
#include "libslic3r/LocalesUtils.hpp"
#include "libslic3r/LifecycleEvents.hpp"
#include <system_error>
#include "libslic3r/ProjectTask.hpp"
#include <cstring>
#include <boost/chrono/duration.hpp>
#include <iterator>
#include "slic3r/GUI/UserNotification.hpp"
#include <cctype>
#include <algorithm>
#include <limits>
#include <stdexcept>
#include "libslic3r/Config.hpp"
#include <set>
#include <sstream>
#include <ios>
#include <iomanip>
#include <thread>
#include <mutex>
#include <charconv>
#include <codecvt>
#include <boost/foreach.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <unordered_set>
#include <utility>
#include <vector>
#include <wx/colour.h>
#include <tuple>
#include <wx/app.h>
#include <wx/dir.h>
#include <wx/string.h>
#include <wx/event.h>
#include <wx/gdicmn.h>
#include "fast_float/fast_float.h"
#include "DeviceCore/DevFilaSystem.h"
#include "DeviceCore/DevFilaSwitch.h"
#include "DeviceCore/DevExtensionTool.h"
#include "DeviceCore/DevExtruderSystem.h"
#include "DeviceCore/DevNozzleSystem.h"
#include "DeviceCore/DevBed.h"
#include "DeviceCore/DevLamp.h"
#include "DeviceCore/DevFan.h"
#include "DeviceCore/DevStorage.h"
#include "DeviceCore/DevConfig.h"
#include "DeviceCore/DevCtrl.h"
#include "DeviceCore/DevPrintOptions.h"
#include "DeviceCore/DevPrintTaskInfo.h"
#include "DeviceCore/DevHMS.h"
#include "DeviceCore/DevMappingNozzle.h"
#include "DeviceCore/DevManager.h"
#include "DeviceCore/DevUtil.h"
#include "DeviceCore/DevAxis.h"
#include "DeviceCore/DevChamber.h"
#include "DeviceCore/DevStatus.h"
#include "DeviceCore/DevUpgrade.h"
#include "IPrinterAgent.hpp"
#include "libslic3r/AppConfig.hpp"
#include "libslic3r/Preset.hpp"
#include "slic3r/GUI/Jobs/SendJob.hpp"

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{DeviceManager.cpp}
namespace  Slic3r
 |/ Copyright (c) Prusa Research 2020 - 2023 Enrico Turri @enricoturri1966 |/ |/ PrusaSlicer is released under the terms of the AGPLv3 or higher |/

Macros

#define CALI_DEBUG
#define MINUTE_30   1800000
#define TIME_OUT   5000
#define ORCA_NETWORK_DEBUG

Functions

float string_to_float (const std::string &str_value)
int get_tray_id_by_ams_id_and_slot_id (int ams_id, int slot_id)
const std::unordered_set< std::string > * anonymous_namespace{DeviceManager.cpp}::pick_stringing_set (float nozzle_diameter)
std::string to_string_nozzle_diameter (float nozzle_diameter)
void sanitizeToUtf8 (std::string &str)
void Slic3r::split_string (std::string s, std::vector< std::string > &v)
static wxString Slic3r::_generate_nozzle_id (NozzleVolumeType nozzle_type, const std::string &diameter)
static NozzleVolumeType Slic3r::convert_to_nozzle_type (const std::string &str)
template<class ENUM>
static ENUM Slic3r::enum_index_of (char const *key, char const **enum_names, int enum_count, ENUM defl=static_cast< ENUM >(0))
static bool Slic3r::is_hex_digit (char c)
void Slic3r::change_the_opacity (wxColour &colour)

Variables

const std::unordered_set< std::string > anonymous_namespace{DeviceManager.cpp}::g_stringing_prone_for_0_4
const std::unordered_set< std::string > anonymous_namespace{DeviceManager.cpp}::g_stringing_prone_for_0_6_0_8

Macro Definition Documentation

◆ CALI_DEBUG

#define CALI_DEBUG

◆ MINUTE_30

#define MINUTE_30   1800000

◆ ORCA_NETWORK_DEBUG

#define ORCA_NETWORK_DEBUG

◆ TIME_OUT

#define TIME_OUT   5000

Function Documentation

◆ get_tray_id_by_ams_id_and_slot_id()

int get_tray_id_by_ams_id_and_slot_id ( int ams_id,
int slot_id )
130{
131 if (ams_id == VIRTUAL_TRAY_MAIN_ID || ams_id == VIRTUAL_TRAY_DEPUTY_ID) {
132 return ams_id;
133 } else {
134 return ams_id * 4 + slot_id;
135 }
136}
#define VIRTUAL_TRAY_DEPUTY_ID
Definition DevDefs.h:90
#define VIRTUAL_TRAY_MAIN_ID
Definition DevDefs.h:89

References VIRTUAL_TRAY_DEPUTY_ID, and VIRTUAL_TRAY_MAIN_ID.

Referenced by Slic3r::MachineObject::parse_json().

Here is the caller graph for this function:

◆ sanitizeToUtf8()

void sanitizeToUtf8 ( std::string & str)
325 {
326 std::string result;
327 size_t i = 0;
328
329 while (i < str.size()) {
330 unsigned char c = str[i];
331 size_t remainingBytes = 0;
332 bool valid = true;
333
334 if ((c & 0x80) == 0x00) { // 1-byte character (ASCII)
335 remainingBytes = 0;
336 }
337 else if ((c & 0xE0) == 0xC0) { // 2-byte character
338 remainingBytes = 1;
339 }
340 else if ((c & 0xF0) == 0xE0) { // 3-byte character
341 remainingBytes = 2;
342 }
343 else if ((c & 0xF8) == 0xF0) { // 4-byte character
344 remainingBytes = 3;
345 }
346 else {
347 valid = false; // Invalid first byte
348 }
349
350 if (valid && i + remainingBytes < str.size()) {
351 for (size_t j = 1; j <= remainingBytes; ++j) {
352 if ((str[i + j] & 0xC0) != 0x80) {
353 valid = false; // Invalid continuation byte
354 break;
355 }
356 }
357 }
358 else {
359 valid = false; // Truncated character
360 }
361
362 if (valid) {
363 // Append valid UTF-8 character
364 result.append(str, i, remainingBytes + 1);
365 i += remainingBytes + 1;
366 }
367 else {
368 // Replace invalid character with space
369 result += ' ';
370 ++i; // Skip the invalid byte
371 }
372 }
373 str = std::move(result);
374}

Referenced by Slic3r::MachineObject::parse_json().

Here is the caller graph for this function:

◆ string_to_float()

float string_to_float ( const std::string & str_value)
123 {
124 float value = 0.0;
125 fast_float::from_chars(str_value.c_str(), str_value.c_str() + str_value.size(), value);
126 return value;
127}

◆ to_string_nozzle_diameter()

std::string to_string_nozzle_diameter ( float nozzle_diameter)
308{
309 float eps = 1e-3;
310 if (abs(nozzle_diameter - 0.2) < eps) {
311 return "0.2";
312 }
313 else if (abs(nozzle_diameter - 0.4) < eps) {
314 return "0.4";
315 }
316 else if (abs(nozzle_diameter - 0.6) < eps) {
317 return "0.6";
318 }
319 else if (abs(nozzle_diameter - 0.8) < eps) {
320 return "0.8";
321 }
322 return "0";
323}

Referenced by Slic3r::MachineObject::command_delete_pa_calibration(), Slic3r::MachineObject::command_get_flow_ratio_calibration_result(), Slic3r::MachineObject::command_get_pa_calibration_result(), Slic3r::MachineObject::command_get_pa_calibration_tab(), Slic3r::MachineObject::command_set_pa_calibration(), Slic3r::MachineObject::command_start_flow_ratio_calibration(), Slic3r::MachineObject::command_start_pa_calibration(), and Slic3r::MachineObject::commnad_select_pa_calibration().

Here is the caller graph for this function: