OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::DevPrintOptionsParser Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/DeviceCore/DevPrintOptions.h>

Static Public Member Functions

static void Parse (DevPrintOptions *opts, const nlohmann::json &print_json)
static void ParseDetectionV1_0 (DevPrintOptions *opts, MachineObject *obj, const nlohmann::json &print_json)
static void ParseDetectionV1_1 (DevPrintOptions *opts, MachineObject *obj, const nlohmann::json &print_json, bool enable)
static void ParseDetectionV1_2 (DevPrintOptions *opts, MachineObject *obj, const nlohmann::json &print_json)
static void ParseDetectionV2_0 (DevPrintOptions *opts, std::string cfg)
static void ParseDetectionV2_1 (DevPrintOptions *opts, std::string cfg)

Detailed Description

Member Function Documentation

◆ Parse()

void Slic3r::DevPrintOptionsParser::Parse ( DevPrintOptions * opts,
const nlohmann::json & print_json )
static
39{
40 try
41 {
42 if (print_json.contains("spd_lvl"))
43 {
44 opts->m_speed_level = static_cast<DevPrintingSpeedLevel>(print_json["spd_lvl"].get<int>());
45 }
46
47 if (print_json.contains("cfg"))
48 {
49 const std::string& cfg = print_json["cfg"].get<std::string>();
50 opts->m_speed_level = (DevPrintingSpeedLevel)DevUtil::get_flag_bits(cfg, 8, 3);
51 }
52
53 // Orca: xcam.cfg is an integer bitfield (distinct from the top-level cfg string) that
54 // carries the plate-align/FOD/displacement current values.
55 if (print_json.contains("xcam") && print_json["xcam"].contains("cfg")) {
56 int xcam_cfg = print_json["xcam"]["cfg"].get<int>();
57 if (time(nullptr) - opts->m_buildplate_align_detection.detect_hold_start > HOLD_TIME_3SEC)
58 opts->m_buildplate_align_detection.current_detect_value = DevUtil::get_flag_bits(xcam_cfg, 20);
59 if (time(nullptr) - opts->m_fod_check_detection.detect_hold_start > HOLD_TIME_3SEC)
60 opts->m_fod_check_detection.current_detect_value = DevUtil::get_flag_bits(xcam_cfg, 21);
61 if (time(nullptr) - opts->m_displacement_detection.detect_hold_start > HOLD_TIME_3SEC)
62 opts->m_displacement_detection.current_detect_value = DevUtil::get_flag_bits(xcam_cfg, 22);
63 }
64
65 // Orca: fun2 support bits (distinct from the top-level cfg/fun fields). ORCA's DevUtil has no
66 // no-border extractor, so the MachineObject helper is used here instead.
67 if (print_json.contains("fun2") && print_json["fun2"].is_string()) {
68 std::string fun2 = print_json["fun2"].get<std::string>();
69 if (!fun2.empty()) {
70 opts->m_buildplate_align_detection.is_support_detect = opts->m_obj->get_flag_bits_no_border(fun2, 2) == 1;
71 opts->m_purify_air_at_print_end.is_support_detect = opts->m_obj->get_flag_bits_no_border(fun2, 4);
72 opts->m_fod_check_detection.is_support_detect = opts->m_obj->get_flag_bits_no_border(fun2, 13);
73 opts->m_displacement_detection.is_support_detect = opts->m_obj->get_flag_bits_no_border(fun2, 14);
74 opts->m_smart_nozzle_blob_detection.is_support_detect = opts->m_obj->get_flag_bits_no_border(fun2, 15);
75 }
76 }
77 }
78 catch (const std::exception& e)
79 {
80 BOOST_LOG_TRIVIAL(error) << "DevPrintOptionsParser::Parse: Failed to parse print options from JSON." << e.what();
81 }
82}
#define HOLD_TIME_3SEC
Definition DeviceManager.hpp:56
static int get_flag_bits(std::string str, int start, int count=1)
Definition DevUtil.cpp:18
DevPrintingSpeedLevel
Definition DevDefs.h:135

References Slic3r::PrintOptionData::current_detect_value, Slic3r::PrintOptionData::detect_hold_start, Slic3r::DevUtil::get_flag_bits(), Slic3r::MachineObject::get_flag_bits_no_border(), HOLD_TIME_3SEC, Slic3r::PrintOptionData::is_support_detect, Slic3r::DevPrintOptions::m_buildplate_align_detection, Slic3r::DevPrintOptions::m_displacement_detection, Slic3r::DevPrintOptions::m_fod_check_detection, Slic3r::DevPrintOptions::m_obj, Slic3r::DevPrintOptions::m_purify_air_at_print_end, Slic3r::DevPrintOptions::m_smart_nozzle_blob_detection, and Slic3r::DevPrintOptions::m_speed_level.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParseDetectionV1_0()

void Slic3r::DevPrintOptionsParser::ParseDetectionV1_0 ( DevPrintOptions * opts,
MachineObject * obj,
const nlohmann::json & print_json )
static
85{
86 try {
87 if (print_json.contains("xcam")) {
88 if (time(nullptr) - opts->m_ai_monitoring_detection.detect_hold_start > HOLD_TIME_3SEC) {
89 if (print_json["xcam"].contains("printing_monitor")) {
90 // new protocol
91 opts->m_ai_monitoring_detection.current_detect_value = print_json["xcam"]["printing_monitor"].get<bool>();
92 } else {
93 // old version protocol
94 if (print_json["xcam"].contains("spaghetti_detector")) {
95 opts->m_ai_monitoring_detection.current_detect_value = print_json["xcam"]["spaghetti_detector"].get<bool>();
96 if (print_json["xcam"].contains("print_halt")) {
97 bool print_halt = print_json["xcam"]["print_halt"].get<bool>();
98 if (print_halt) { opts->m_ai_monitoring_detection.current_detect_sensitivity_value = "medium"; }
99 }
100 }
101 }
102 if (print_json["xcam"].contains("halt_print_sensitivity")) {
103 opts->m_ai_monitoring_detection.current_detect_sensitivity_value = print_json["xcam"]["halt_print_sensitivity"].get<std::string>();
104 }
105 }
106
107 if (time(nullptr) - opts->m_first_layer_detection.detect_hold_start > HOLD_TIME_3SEC) {
108 if (print_json["xcam"].contains("first_layer_inspector")) { opts->m_first_layer_detection.current_detect_value = print_json["xcam"]["first_layer_inspector"].get<bool>(); }
109 }
110
111 if (time(nullptr) - opts->m_buildplate_mark_detection.detect_hold_start > HOLD_TIME_3SEC) {
112 if (print_json["xcam"].contains("buildplate_marker_detector")) {
113 opts->m_buildplate_mark_detection.current_detect_value = print_json["xcam"]["buildplate_marker_detector"].get<bool>();
114 obj->is_support_build_plate_marker_detect = true;
115 } else {
116 obj->is_support_build_plate_marker_detect = false;
117 }
118 }
119 }
120 } catch (...) {
121 ;
122 }
123}
bool contains(const std::vector< T > &vector, const Point &point)
Definition Geometry.cpp:55

References Slic3r::Geometry::contains(), Slic3r::PrintOptionData::current_detect_sensitivity_value, Slic3r::PrintOptionData::current_detect_value, Slic3r::PrintOptionData::detect_hold_start, HOLD_TIME_3SEC, Slic3r::MachineObject::is_support_build_plate_marker_detect, Slic3r::DevPrintOptions::m_ai_monitoring_detection, Slic3r::DevPrintOptions::m_buildplate_mark_detection, and Slic3r::DevPrintOptions::m_first_layer_detection.

Here is the call graph for this function:

◆ ParseDetectionV1_1()

void Slic3r::DevPrintOptionsParser::ParseDetectionV1_1 ( DevPrintOptions * opts,
MachineObject * obj,
const nlohmann::json & print_json,
bool enable )
static
126{
127 if (print_json["module_name"].get<std::string>() == "first_layer_inspector") {
128 if (time(nullptr) - opts->m_first_layer_detection.detect_hold_start > HOLD_TIME_3SEC) {
129 opts->m_first_layer_detection.current_detect_value = enable;
130 }
131 } else if (print_json["module_name"].get<std::string>() == "buildplate_marker_detector") {
132 if (time(nullptr) - opts->m_buildplate_mark_detection.detect_hold_start > HOLD_TIME_3SEC) {
133 opts->m_buildplate_mark_detection.current_detect_value = enable;
134 }
135 } else if (print_json["module_name"].get<std::string>() == "printing_monitor") {
136 if (time(nullptr) - opts->m_ai_monitoring_detection.detect_hold_start > HOLD_TIME_3SEC) {
137 opts->m_ai_monitoring_detection.current_detect_value = enable;
138 if (print_json.contains("halt_print_sensitivity")) {
139 opts->m_ai_monitoring_detection.current_detect_sensitivity_value = print_json["halt_print_sensitivity"].get<std::string>();
140 }
141 }
142 } else if (print_json["module_name"].get<std::string>() == "spaghetti_detector") {
143 if (time(nullptr) - opts->m_ai_monitoring_detection.detect_hold_start > HOLD_TIME_3SEC) {
144 // old protocol
145 opts->m_ai_monitoring_detection.current_detect_value = enable;
146 if (print_json.contains("print_halt")) {
147 if (print_json["print_halt"].get<bool>()) { opts->m_ai_monitoring_detection.current_detect_sensitivity_value = "medium"; }
148 }
149 }
150 }
151}

References Slic3r::PrintOptionData::current_detect_sensitivity_value, Slic3r::PrintOptionData::current_detect_value, Slic3r::PrintOptionData::detect_hold_start, HOLD_TIME_3SEC, Slic3r::DevPrintOptions::m_ai_monitoring_detection, Slic3r::DevPrintOptions::m_buildplate_mark_detection, and Slic3r::DevPrintOptions::m_first_layer_detection.

◆ ParseDetectionV1_2()

void Slic3r::DevPrintOptionsParser::ParseDetectionV1_2 ( DevPrintOptions * opts,
MachineObject * obj,
const nlohmann::json & print_json )
static
153 {
154
155 try {
156 if (print_json.contains("option")) {
157 if (print_json["option"].is_number()) {
158 int option = print_json["option"].get<int>();
159 if (time(nullptr) - opts->m_auto_recovery_detection.detect_hold_start > HOLD_TIME_3SEC) { opts->m_auto_recovery_detection.current_detect_value = ((option & 0x01) != 0); }
160 }
161 }
162
163 if (time(nullptr) - opts->m_auto_recovery_detection.detect_hold_start > HOLD_TIME_3SEC) {
164 if (print_json.contains("auto_recovery")) { opts->m_auto_recovery_detection.current_detect_value = print_json["auto_recovery"].get<bool>(); }
165 }
166 } catch (...) {}
167
168}

References Slic3r::PrintOptionData::current_detect_value, Slic3r::PrintOptionData::detect_hold_start, HOLD_TIME_3SEC, and Slic3r::DevPrintOptions::m_auto_recovery_detection.

◆ ParseDetectionV2_0()

void Slic3r::DevPrintOptionsParser::ParseDetectionV2_0 ( DevPrintOptions * opts,
std::string cfg )
static
171{
172
173 if (time(nullptr) - opts->m_first_layer_detection.detect_hold_start > HOLD_TIME_3SEC) {
174 opts->m_first_layer_detection.current_detect_value = DevUtil::get_flag_bits(print_json, 12);
175 }
176
177 if (time(nullptr) - opts->m_ai_monitoring_detection.detect_hold_start > HOLD_COUNT_MAX) {
178 opts->m_ai_monitoring_detection.current_detect_value = DevUtil::get_flag_bits(print_json, 15);
179
180 switch (DevUtil::get_flag_bits(print_json, 13, 2)) {
181 case 0: opts->m_ai_monitoring_detection.current_detect_sensitivity_value = "never_halt"; break;
182 case 1: opts->m_ai_monitoring_detection.current_detect_sensitivity_value = "low"; break;
183 case 2: opts->m_ai_monitoring_detection.current_detect_sensitivity_value = "medium"; break;
184 case 3: opts->m_ai_monitoring_detection.current_detect_sensitivity_value = "high"; break;
185 default: break;
186 }
187 }
188
189 if (time(nullptr) - opts->m_auto_recovery_detection.detect_hold_start > HOLD_COUNT_MAX){
190 opts->m_auto_recovery_detection.current_detect_value = DevUtil::get_flag_bits(print_json, 16);
191 }
192
193 if (time(nullptr) - opts->m_allow_prompt_sound_detection.detect_hold_start > HOLD_TIME_3SEC) {
194 opts->m_allow_prompt_sound_detection.current_detect_value = DevUtil::get_flag_bits(print_json, 22);
195 }
196
197 if (time(nullptr) - opts->m_filament_tangle_detection.detect_hold_start > HOLD_TIME_3SEC) {
198 opts->m_filament_tangle_detection.current_detect_value = DevUtil::get_flag_bits(print_json, 23);
199 }
200}
#define HOLD_COUNT_MAX
Definition DevFilaSystem.h:21

References Slic3r::PrintOptionData::current_detect_sensitivity_value, Slic3r::PrintOptionData::current_detect_value, Slic3r::PrintOptionData::detect_hold_start, Slic3r::DevUtil::get_flag_bits(), HOLD_COUNT_MAX, HOLD_TIME_3SEC, Slic3r::DevPrintOptions::m_ai_monitoring_detection, Slic3r::DevPrintOptions::m_allow_prompt_sound_detection, Slic3r::DevPrintOptions::m_auto_recovery_detection, Slic3r::DevPrintOptions::m_filament_tangle_detection, and Slic3r::DevPrintOptions::m_first_layer_detection.

Here is the call graph for this function:

◆ ParseDetectionV2_1()

void Slic3r::DevPrintOptionsParser::ParseDetectionV2_1 ( DevPrintOptions * opts,
std::string cfg )
static
202 {
203 if (time(nullptr) - opts->m_idel_heating_protect_detection.detect_hold_start > HOLD_TIME_3SEC)
204 opts->m_idel_heating_protect_detection.current_detect_value = DevUtil::get_flag_bits(cfg, 32, 2);
205
206 // Orca: further top-level cfg-string detection bits, parsed here alongside idle-heating.
207 if (time(nullptr) - opts->m_purify_air_at_print_end.detect_hold_start > HOLD_TIME_3SEC)
208 opts->m_purify_air_at_print_end.current_detect_value = DevUtil::get_flag_bits(cfg, 36, 2);
209
210 // Smart nozzle blob detection mode: cfg bits 43-44 (2 bits), 0=off, 1=on, 2=auto
211 if (time(nullptr) - opts->m_smart_nozzle_blob_detection.detect_hold_start > HOLD_TIME_3SEC)
212 opts->m_smart_nozzle_blob_detection.current_detect_value = DevUtil::get_flag_bits(cfg, 43, 2);
213
214 if (time(nullptr) - opts->m_snapshot_detection.detect_hold_start > HOLD_TIME_3SEC) {
215 opts->m_snapshot_detection.current_detect_value = DevUtil::get_flag_bits(cfg, 38, 2);
216 opts->m_snapshot_detection.is_support_detect =
217 opts->m_snapshot_detection.current_detect_value != 0 && opts->m_snapshot_detection.current_detect_value != 3;
218 }
219}

References Slic3r::PrintOptionData::current_detect_value, Slic3r::PrintOptionData::detect_hold_start, Slic3r::DevUtil::get_flag_bits(), HOLD_TIME_3SEC, Slic3r::PrintOptionData::is_support_detect, Slic3r::DevPrintOptions::m_idel_heating_protect_detection, Slic3r::DevPrintOptions::m_purify_air_at_print_end, Slic3r::DevPrintOptions::m_smart_nozzle_blob_detection, and Slic3r::DevPrintOptions::m_snapshot_detection.

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

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: