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

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

Collaboration diagram for Slic3r::DevNozzleMappingCtrl:

Public Types

enum class  NozzleMappingVersion : int { Version_V0 = 0 , Version_V1 = 1 }
enum class  ErrNoV1 : int {
  Success = 0 , ErrorBadRequest3mf = 1 , ErrorBadRequestVersion = 2 , ErrorBadRequestGroupId = 3 ,
  ErrorNoValidNozzles = 4 , ErrorBadRequestReadFail = 5 , ErrorRackCaliFail = 6 , ErrorRackMoving = 7 ,
  ErrorRackFull = 8 , WarningNotEnoughNozzles = 9
}

Public Member Functions

 DevNozzleMappingCtrl (MachineObject *obj)
void SetPlater (Slic3r::GUI::Plater *plater)
void Clear ()
bool HasResult () const
std::string GetResultStr () const
std::string GetMqttReason () const
int GetErrno () const
ErrNoV1 GetErrnoV1 () const
std::string GetDetailMsg () const
std::unordered_map< int, int > GetNozzleMappingMap () const
nlohmann::json GetNozzleMappingJson () const
void SetManualNozzleMappingByFila (int fila_id, int nozzle_pos_id)
std::vector< int > GetMappedNozzlePosVecByFilaId (int fila_id) const
wxString GetMappedNozzlePosStrByFilaId (int fila_id, const wxString &default_str="?") const
float GetFlushWeightBase () const
float GetFlushWeightCurrent () const
void ParseAutoNozzleMapping (const nlohmann::json &print_jj)
int CtrlGetAutoNozzleMappingV0 (Slic3r::GUI::Plater *plater, const std::vector< FilamentInfo > &ams_mapping, int flow_cali_opt, int pa_value)
int CtrlGetAutoNozzleMappingV1 (Slic3r::GUI::Plater *plater)

Private Member Functions

float GetFlushWeight (Slic3r::MachineObject *obj) const

Private Attributes

MachineObject * m_obj
Slic3r::GUI::Plater * m_plater = nullptr
std::string m_sequence_id
std::string m_result
std::string m_mqtt_reason
std::string m_type
int m_errno
std::string m_detail_msg
nlohmann::json m_detail_json
nlohmann::json m_nozzle_mapping_json
std::unordered_map< int, int > m_nozzle_mapping
float m_flush_weight_base = -1
float m_flush_weight_current = -1
NozzleMappingVersion m_req_version = NozzleMappingVersion::Version_V0
NozzleMappingVersion m_ack_version = NozzleMappingVersion::Version_V0

Friends

class MachineObject

Detailed Description

Member Enumeration Documentation

◆ ErrNoV1

enum class Slic3r::DevNozzleMappingCtrl::ErrNoV1 : int
strong
Enumerator
Success 
ErrorBadRequest3mf 
ErrorBadRequestVersion 
ErrorBadRequestGroupId 
ErrorNoValidNozzles 
ErrorBadRequestReadFail 
ErrorRackCaliFail 
ErrorRackMoving 
ErrorRackFull 
WarningNotEnoughNozzles 
34 : int {
35 Success = 0,
36 ErrorBadRequest3mf = 1,
37 ErrorBadRequestVersion = 2,
38 ErrorBadRequestGroupId = 3,
39 ErrorNoValidNozzles = 4,
40 ErrorBadRequestReadFail = 5,
41 ErrorRackCaliFail = 6,
42 ErrorRackMoving = 7,
43 ErrorRackFull = 8,
44 WarningNotEnoughNozzles = 9
45 };
@ Success
Definition AssembleList.hpp:49

◆ NozzleMappingVersion

Enumerator
Version_V0 
Version_V1 
29 : int {
30 Version_V0 = 0, // V0 means support logical fila_id -> physical nozzle_id mapping
31 Version_V1 = 1, // V1 means support logical nozzle_id -> physical nozzle_id mapping
32 };

Constructor & Destructor Documentation

◆ DevNozzleMappingCtrl()

Slic3r::DevNozzleMappingCtrl::DevNozzleMappingCtrl ( MachineObject * obj)
inline
48: m_obj(obj) {};
MachineObject * m_obj
Definition DevMappingNozzle.h:86

References m_obj, and MachineObject.

Here is the call graph for this function:

Member Function Documentation

◆ Clear()

void Slic3r::DevNozzleMappingCtrl::Clear ( )
278{
279 m_sequence_id.clear();
280 m_result.clear();
281 m_mqtt_reason.clear();
282 m_type.clear();
283 m_errno = 0;
284 m_detail_msg.clear();
285 m_detail_json.clear();
286 m_nozzle_mapping.clear();
287 m_nozzle_mapping_json.clear();
288
292}
std::string m_type
Definition DevMappingNozzle.h:93
float m_flush_weight_current
Definition DevMappingNozzle.h:103
NozzleMappingVersion m_ack_version
Definition DevMappingNozzle.h:106
std::string m_result
Definition DevMappingNozzle.h:91
float m_flush_weight_base
Definition DevMappingNozzle.h:102
@ Version_V0
Definition DevMappingNozzle.h:30
std::string m_sequence_id
Definition DevMappingNozzle.h:89
nlohmann::json m_nozzle_mapping_json
Definition DevMappingNozzle.h:99
std::unordered_map< int, int > m_nozzle_mapping
Definition DevMappingNozzle.h:100
std::string m_mqtt_reason
Definition DevMappingNozzle.h:92
nlohmann::json m_detail_json
Definition DevMappingNozzle.h:97
int m_errno
Definition DevMappingNozzle.h:95
std::string m_detail_msg
Definition DevMappingNozzle.h:96

References m_ack_version, m_detail_json, m_detail_msg, m_errno, m_flush_weight_base, m_flush_weight_current, m_mqtt_reason, m_nozzle_mapping, m_nozzle_mapping_json, m_result, m_sequence_id, m_type, and Version_V0.

Referenced by CtrlGetAutoNozzleMappingV0(), CtrlGetAutoNozzleMappingV1(), and ParseAutoNozzleMapping().

Here is the caller graph for this function:

◆ CtrlGetAutoNozzleMappingV0()

int Slic3r::DevNozzleMappingCtrl::CtrlGetAutoNozzleMappingV0 ( Slic3r::GUI::Plater * plater,
const std::vector< FilamentInfo > & ams_mapping,
int flow_cali_opt,
int pa_value )
50{
51 Clear();
52
53 m_plater = plater;
54 if (!plater) {
55 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": plater is nullptr";
56 return -1;
57 }
58
59 GCodeProcessorResult* gcode_result = plater->background_process().get_current_gcode_result();
60 if (!gcode_result) {
61 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": gcode_result is nullptr";
62 return -1;
63 }
64
65 const auto& result = gcode_result->nozzle_group_result;
66 if (!result) {
67 assert(false && "gcode_result->nozzle_group_result");
68 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": gcode_result->nozzle_group_result is NULL";
69 return -1;
70 }
71
72 if (ams_mapping.empty()) {
73 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": the ams mapping is empty";
74 return -1;// the ams mapping is empty
75 }
76
77 json command_jj;
78 command_jj["print"]["command"] = "get_auto_nozzle_mapping";
80 command_jj["print"]["sequence_id"] = m_sequence_id;
81 command_jj["print"]["calibration"] = flow_cali_opt;
82 command_jj["print"]["extrude_cali_manual_mode"] = pa_value;
83
84 // filament seq
85 json filament_seq_jj;
86 int max_fila_id = 0;
87 std::unordered_set<int> filaid_set;
88 for (int idx = 0; idx < gcode_result->filament_change_sequence.size(); idx++) {
89 int fila_id = gcode_result->filament_change_sequence[idx];
90 if (filaid_set.count(fila_id) == 0) {
91 filaid_set.insert(fila_id);
92 filament_seq_jj[fila_id + 1] = idx;
93 max_fila_id = std::max(max_fila_id, fila_id + 1);
94 }
95 }
96
97 for (int fila_id = 0; fila_id <= max_fila_id; fila_id++) {
98 if (filament_seq_jj[fila_id].is_null()) {
99 filament_seq_jj[fila_id] = -1;// fill the used fila_id with -1
100 }
101 }
102
103 command_jj["print"]["filament_seq"] = filament_seq_jj;
104
105 // ams mapping
106 std::vector<int> ams_mapping_vec(33, 0xFFFF);/* AP ask to fill them*/
107 for (auto item : ams_mapping) {
108 try {
109 int ams_id = stoi(item.ams_id);
110 int slot_id = !item.slot_id.empty() ? stoi(item.slot_id) : 0;
111 ams_mapping_vec[item.id + 1] = (ams_id << 8) | slot_id;/*using ams_id << 8 | slot_id*/
112 } catch (std::exception& e) {
113 assert(false && "invalid ams_id or slot_id");
114 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " exception: " << e.what();
115 ams_mapping_vec[item.id + 1] = item.tray_id;
116 }
117 }
118 command_jj["print"]["ams_mapping"] = ams_mapping_vec;
119
120 // filament info
121 json filament_info_jj;
122 for (int fila_id = 0; fila_id < ams_mapping.size(); fila_id++) {
123 const auto& fila = ams_mapping[fila_id];
124 const auto& nozzle_list = result->get_nozzles_for_filament(fila.id);
125 if (nozzle_list.empty()) {
126 assert(false && "nozzle_list should not be empty");
127 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "nozzle_list should not be nullptr";
128 continue;
129 }
130
131 for (const auto& nozzle_info : nozzle_list) {
132 json fila_item_jj;
133 fila_item_jj["id"] = (fila.id + 1);
134 fila_item_jj["direction"] = (nozzle_info.extruder_id == LOGIC_L_EXTRUDER_ID ? 1 : 2);
135 fila_item_jj["group"] = nozzle_info.group_id;
136 fila_item_jj["nozzle_d"] = s_get_diameter_str(nozzle_info.diameter);
137 fila_item_jj["nozzle_v"] = (nozzle_info.volume_type == NozzleVolumeType::nvtHighFlow) ? "High Flow" : "Standard";
138 fila_item_jj["cate"] = fila.filament_id;
139 fila_item_jj["color"] = fila.color;
140 filament_info_jj.push_back(fila_item_jj);
141 }
142 }
143
144 command_jj["print"]["fila_info"] = filament_info_jj;
145
146 // nozzle info
147 json nozzle_info_jj;
148 const auto& nozzle_system = m_obj->GetNozzleSystem();
149 const auto& extruder_nozzles = nozzle_system->GetExtNozzles();
150 for (const auto& nozzle : extruder_nozzles) {
151 if (nozzle.second.IsNormal()) {
152 json nozzle_item_jj;
153 nozzle_item_jj["pos"] = nozzle.second.GetNozzleId();
154 if (nozzle_system->GetReplaceNozzleTar().has_value() && nozzle_item_jj["pos"] == MAIN_EXTRUDER_ID) {
155 nozzle_item_jj["pos"] = nozzle_system->GetReplaceNozzleTar().value();// special case of tar_id. see protocol definition
156 }
157
158 nozzle_item_jj["nozzle_d"] = s_get_diameter_str(nozzle.second.GetNozzleDiameter());
159 nozzle_item_jj["nozzle_v"] = DevNozzle::ToNozzleFlowString(nozzle.second.GetNozzleFlowType());
160 nozzle_item_jj["wear"] = nozzle.second.GetNozzleWear();
161 nozzle_item_jj["cate"] = nozzle.second.GetFilamentId();
162 nozzle_item_jj["color"] = nozzle.second.GetFilamentColor();
163 nozzle_info_jj.push_back(nozzle_item_jj);
164 }
165 }
166
167 const auto& rack_nozzles = nozzle_system->GetNozzleRack()->GetRackNozzles();
168 for (const auto& nozzle : rack_nozzles) {
169 if (nozzle.second.IsNormal()) {
170 json nozzle_item_jj;
171 nozzle_item_jj["pos"] = (nozzle.second.GetNozzleId() + 0x10);
172 if (nozzle_system->GetReplaceNozzleTar().has_value() && nozzle_item_jj["pos"] == MAIN_EXTRUDER_ID) {
173 nozzle_item_jj["pos"] = nozzle_system->GetReplaceNozzleTar().value();// special case of tar_id. see protocol definition
174 }
175
176 nozzle_item_jj["nozzle_d"] = s_get_diameter_str(nozzle.second.GetNozzleDiameter());
177 nozzle_item_jj["nozzle_v"] = DevNozzle::ToNozzleFlowString(nozzle.second.GetNozzleFlowType());
178 nozzle_item_jj["wear"] = nozzle.second.GetNozzleWear();
179 nozzle_item_jj["cate"] = nozzle.second.GetFilamentId();
180 nozzle_item_jj["color"] = nozzle.second.GetFilamentColor();
181 nozzle_info_jj.push_back(nozzle_item_jj);
182 }
183 }
184
185 command_jj["print"]["nozzle_info"] = nozzle_info_jj;
187 return m_obj->publish_json(command_jj);
188}
#define LOGIC_L_EXTRUDER_ID
Definition DevDefs.h:108
#define MAIN_EXTRUDER_ID
Definition DevDefs.h:101
GCodeProcessorResult * get_current_gcode_result()
Definition BackgroundSlicingProcess.hpp:110
Slic3r::GUI::Plater * m_plater
Definition DevMappingNozzle.h:87
void Clear()
Definition DevMappingNozzle.cpp:277
NozzleMappingVersion m_req_version
Definition DevMappingNozzle.h:105
BackgroundSlicingProcess & background_process()
Definition Plater.cpp:22331
static int m_sequence_id
Definition DeviceManager.hpp:197
@ nvtHighFlow
Definition PrintConfig.hpp:620
nlohmann::json json
Definition AssembleList.cpp:42
static std::string s_get_diameter_str(float diameter)
Definition DevUtil.h:175
static std::string ToNozzleFlowString(const NozzleFlowType &type)
Definition DevNozzleSystem.cpp:94
std::shared_ptr< MultiNozzleUtils::NozzleGroupResultBase > nozzle_group_result
Definition GCodeProcessor.hpp:220

References Slic3r::GUI::Plater::background_process(), Clear(), Slic3r::GCodeProcessorResult::filament_change_sequence, Slic3r::BackgroundSlicingProcess::get_current_gcode_result(), LOGIC_L_EXTRUDER_ID, m_obj, m_plater, m_req_version, m_sequence_id, Slic3r::MachineObject::m_sequence_id, MAIN_EXTRUDER_ID, Slic3r::GCodeProcessorResult::nozzle_group_result, Slic3r::nvtHighFlow, Slic3r::s_get_diameter_str(), Slic3r::DevNozzle::ToNozzleFlowString(), and Version_V0.

Here is the call graph for this function:

◆ CtrlGetAutoNozzleMappingV1()

int Slic3r::DevNozzleMappingCtrl::CtrlGetAutoNozzleMappingV1 ( Slic3r::GUI::Plater * plater)
191{
192 Clear();
193 m_plater = plater;
194 if (!m_plater) {
195 return -1;
196 }
197
198 auto nozzle_group_res = DevUtilBackend::GetNozzleGroupResult(m_plater);
199 if (!nozzle_group_res) {
200 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": gcode_result->nozzle_group_result is NULL";
201 return -1;
202 }
203
204 json command_jj;
205 command_jj["print"]["command"] = "get_auto_nozzle_mapping";
207 command_jj["print"]["sequence_id"] = m_sequence_id;
208
209 json nozzle_group_info_jj;
210 std::unordered_set<int> used_logic_groups;
211 const auto& used_logic_nozzles = nozzle_group_res->get_used_nozzles_in_extruder();
212 for (const auto& used_logic_nozzle : used_logic_nozzles) {
213 if (used_logic_groups.count(used_logic_nozzle.group_id) != 0) {
214 continue;
215 }
216 used_logic_groups.insert(used_logic_nozzle.group_id);
217
218 json nozzle_info;
219 nozzle_info["id"] = used_logic_nozzle.group_id;
220 nozzle_info["ext"] = (used_logic_nozzle.extruder_id + 1);
221
222 try {
223 nozzle_info["dia"] = std::stof(used_logic_nozzle.diameter);
224 } catch(const std::exception& e) {
225 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": e=" << e.what();
226 continue;
227 }
228
229 if (used_logic_nozzle.volume_type == NozzleVolumeType::nvtHighFlow) {
230 nozzle_info["vol"] = "High Flow";
231 } else if(used_logic_nozzle.volume_type == NozzleVolumeType::nvtStandard){
232 nozzle_info["vol"] = "Standard";
233 } else if(used_logic_nozzle.volume_type == NozzleVolumeType::nvtTPUHighFlow){
234 nozzle_info["vol"] = "TPU Flow";
235 } else {
236 assert(0);
237 continue;
238 }
239
240 nozzle_group_info_jj.push_back(nozzle_info);
241 }
242 command_jj["print"]["group_info"] = nozzle_group_info_jj;
243
244
246 command_jj["print"]["version"] = (int)m_req_version;
247 return m_obj->publish_json(command_jj);
248}
@ Version_V1
Definition DevMappingNozzle.h:31
static std::shared_ptr< MultiNozzleUtils::NozzleGroupResultBase > GetNozzleGroupResult(Slic3r::GUI::Plater *plater)
Definition DevUtilBackend.cpp:41
@ nvtTPUHighFlow
Definition PrintConfig.hpp:624
@ nvtStandard
Definition PrintConfig.hpp:619

References Clear(), Slic3r::DevUtilBackend::GetNozzleGroupResult(), m_obj, m_plater, m_req_version, m_sequence_id, Slic3r::MachineObject::m_sequence_id, Slic3r::nvtHighFlow, Slic3r::nvtStandard, Slic3r::nvtTPUHighFlow, and Version_V1.

Here is the call graph for this function:

◆ GetDetailMsg()

std::string Slic3r::DevNozzleMappingCtrl::GetDetailMsg ( ) const
inline
63{ return m_detail_msg; }

References m_detail_msg.

◆ GetErrno()

int Slic3r::DevNozzleMappingCtrl::GetErrno ( ) const
inline
61{ return m_errno; }

References m_errno.

◆ GetErrnoV1()

ErrNoV1 Slic3r::DevNozzleMappingCtrl::GetErrnoV1 ( ) const
inline
62{ return static_cast<ErrNoV1>(m_errno); }
ErrNoV1
Definition DevMappingNozzle.h:34

References m_errno.

◆ GetFlushWeight()

float Slic3r::DevNozzleMappingCtrl::GetFlushWeight ( Slic3r::MachineObject * obj) const
private
398{
399 auto plater = Slic3r::GUI::wxGetApp().plater();
400 if (!plater) {
401 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": plater is nullptr";
402 return -1;
403 }
404
405 GCodeProcessorResult* gcode_result = plater->background_process().get_current_gcode_result();
406 if (!gcode_result) {
407 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": gcode_result is nullptr";
408 return -1;
409 }
410
411 if (gcode_result->filament_change_sequence.empty()) {
412 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": filament_change_sequence is empty";
413 return -1;
414 }
415
416 if (!Slic3r::GUI::wxGetApp().preset_bundle) {
417 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": preset_bundle is nullptr";
418 return -1;
419 };
420
421 const std::vector<std::vector<std::vector<float>>>& flush_matrix = Slic3r::GUI::wxGetApp().preset_bundle->get_full_flush_matrix();
422
423 float total_flush_volume = 0;
424 MultiNozzleUtils::NozzleStatusRecorder recorder;
425 for (auto filament : gcode_result->filament_change_sequence) {
426 const auto& nozzle_pos_vec = GetMappedNozzlePosVecByFilaId(filament);
427 if (nozzle_pos_vec.empty()) {
428 continue;
429 }
430
431 auto nozzle_pos = nozzle_pos_vec.at(0);
432 if (nozzle_pos == -1){
433 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": nozzle_pos is -1 for fila_id=" << filament;
434 continue;
435 }
436
437 auto nozzle_info = obj->GetNozzleSystem()->GetNozzleByPosId(nozzle_pos);
438 if (nozzle_info.IsEmpty()) {
439 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": nozzle_info IsEmpty for fila_id=" << filament << ", nozzle_pos=" << nozzle_pos;
440 continue;
441 }
442
443 int extruder_id = nozzle_info.GetLogicExtruderId();
444 int nozzle_id = nozzle_info.GetNozzlePosId();
445 int last_filament = recorder.get_filament_in_nozzle(nozzle_id);
446
447 if (last_filament != -1 && last_filament != filament) {
448 if (flush_matrix.size() > extruder_id &&
449 flush_matrix[extruder_id].size() > last_filament &&
450 flush_matrix[extruder_id][last_filament].size() > filament){
451 total_flush_volume += flush_matrix[extruder_id][last_filament][filament];
452 }
453 else{
454 assert(false && "missing flush volume");
455 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": missing flush volume for extruder_id=" << extruder_id
456 << ", last_filament=" << last_filament << ", filament=" << filament;
457 }
458 }
459
460 recorder.set_nozzle_status(nozzle_id, filament);
461 }
462
463 // estimate the flush weight: total_flush_volume * 1.26 * 0.001
464 return total_flush_volume * 1.26 * 0.001;
465}
std::vector< int > GetMappedNozzlePosVecByFilaId(int fila_id) const
Definition DevMappingNozzle.cpp:332
DevNozzle GetNozzleByPosId(int pos_id) const
Definition DevNozzleSystem.h:130
DevNozzleSystem * GetNozzleSystem() const
Definition DeviceManager.hpp:382
int GetLogicExtruderId() const
Definition DevNozzleSystem.cpp:176

References Slic3r::GCodeProcessorResult::filament_change_sequence, Slic3r::MultiNozzleUtils::NozzleStatusRecorder::get_filament_in_nozzle(), Slic3r::DevNozzle::GetLogicExtruderId(), GetMappedNozzlePosVecByFilaId(), Slic3r::DevNozzleSystem::GetNozzleByPosId(), Slic3r::MachineObject::GetNozzleSystem(), and Slic3r::MultiNozzleUtils::NozzleStatusRecorder::set_nozzle_status().

Referenced by ParseAutoNozzleMapping(), and SetManualNozzleMappingByFila().

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

◆ GetFlushWeightBase()

float Slic3r::DevNozzleMappingCtrl::GetFlushWeightBase ( ) const
inline
74{ return m_flush_weight_base; }

References m_flush_weight_base.

◆ GetFlushWeightCurrent()

float Slic3r::DevNozzleMappingCtrl::GetFlushWeightCurrent ( ) const
inline

◆ GetMappedNozzlePosStrByFilaId()

wxString Slic3r::DevNozzleMappingCtrl::GetMappedNozzlePosStrByFilaId ( int fila_id,
const wxString & default_str = "?" ) const
373{
374 wxString display_str;
375 const auto& physic_nozzle_pos_vec = GetMappedNozzlePosVecByFilaId(fila_id);
376 for (int idx = 0; idx < physic_nozzle_pos_vec.size(); idx++) {
377 int pos_id = physic_nozzle_pos_vec[idx];
378 if (pos_id == MAIN_EXTRUDER_ID) {
379 display_str += "R";
380 } else if (pos_id == DEPUTY_EXTRUDER_ID) {
381 display_str += "L";
382 } else if (pos_id >= 0x10) {
383 display_str += wxString::Format("R%d", pos_id - 0x10 + 1);// display 1~n for rack hotends
384 } else {
385 continue;
386 }
387
388 if (idx < physic_nozzle_pos_vec.size() - 1) {
389 display_str += " ";
390 }
391 }
392
393 return !display_str.empty() ? display_str : default_str;
394}
#define DEPUTY_EXTRUDER_ID
Definition DevDefs.h:102

References DEPUTY_EXTRUDER_ID, GetMappedNozzlePosVecByFilaId(), and MAIN_EXTRUDER_ID.

Here is the call graph for this function:

◆ GetMappedNozzlePosVecByFilaId()

std::vector< int > Slic3r::DevNozzleMappingCtrl::GetMappedNozzlePosVecByFilaId ( int fila_id) const
333{
334 std::vector<int> physic_nozzle_pos_vec;
335 auto nozzle_group_res = DevUtilBackend::GetNozzleGroupResult(m_plater);
336 if (!nozzle_group_res) {
337 return physic_nozzle_pos_vec;
338 }
339
340 const auto& used_logic_nozzles = nozzle_group_res->get_nozzles_for_filament(fila_id);
342 if (auto iter = m_nozzle_mapping.find(fila_id); iter != m_nozzle_mapping.end()) {
343 if (m_obj->GetNozzleSystem()->GetReplaceNozzleTar().has_value() &&
344 iter->second == m_obj->GetNozzleSystem()->GetReplaceNozzleTar().value()) {
345 physic_nozzle_pos_vec.push_back(MAIN_EXTRUDER_ID);
346 } else {
347 physic_nozzle_pos_vec.push_back(iter->second);
348 }
349 } else {
350 const auto& used_logic_extruders = sGetLogicExtruders(used_logic_nozzles);
351 if (used_logic_extruders.size() == 1 && *used_logic_extruders.begin() == LOGIC_L_EXTRUDER_ID) {
352 physic_nozzle_pos_vec.push_back(1);
353 return physic_nozzle_pos_vec; // only left extruder is used
354 }
355 }
357 for (const auto& used_logic_nozzle : used_logic_nozzles) {
358 if (auto iter = m_nozzle_mapping.find(used_logic_nozzle.group_id); iter != m_nozzle_mapping.end()) {
359 if (m_obj->GetNozzleSystem()->GetReplaceNozzleTar().has_value() &&
360 iter->second == m_obj->GetNozzleSystem()->GetReplaceNozzleTar().value()) {
361 physic_nozzle_pos_vec.push_back(MAIN_EXTRUDER_ID);
362 } else {
363 physic_nozzle_pos_vec.push_back(iter->second);
364 }
365 }
366 }
367 }
368
369 return physic_nozzle_pos_vec;
370}
static std::unordered_set< int > sGetLogicExtruders(const std::vector< MultiNozzleUtils::NozzleInfo > &nozzle_infos)
Definition DevMappingNozzle.cpp:319

References Slic3r::DevUtilBackend::GetNozzleGroupResult(), LOGIC_L_EXTRUDER_ID, m_ack_version, m_nozzle_mapping, m_obj, m_plater, MAIN_EXTRUDER_ID, Slic3r::sGetLogicExtruders(), Version_V0, and Version_V1.

Referenced by GetFlushWeight(), and GetMappedNozzlePosStrByFilaId().

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

◆ GetMqttReason()

std::string Slic3r::DevNozzleMappingCtrl::GetMqttReason ( ) const
inline
58{ return m_mqtt_reason; }

References m_mqtt_reason.

◆ GetNozzleMappingJson()

nlohmann::json Slic3r::DevNozzleMappingCtrl::GetNozzleMappingJson ( ) const
inline
67{ return m_nozzle_mapping_json; }

References m_nozzle_mapping_json.

◆ GetNozzleMappingMap()

std::unordered_map< int, int > Slic3r::DevNozzleMappingCtrl::GetNozzleMappingMap ( ) const
inline
66{ return m_nozzle_mapping; }

References m_nozzle_mapping.

◆ GetResultStr()

std::string Slic3r::DevNozzleMappingCtrl::GetResultStr ( ) const
inline
55{ return m_result; }

References m_result.

◆ HasResult()

bool Slic3r::DevNozzleMappingCtrl::HasResult ( ) const
inline
54{ return !m_result.empty(); }

References m_result.

◆ ParseAutoNozzleMapping()

void Slic3r::DevNozzleMappingCtrl::ParseAutoNozzleMapping ( const nlohmann::json & print_jj)
252{
253 if (print_jj.contains("command") && print_jj["command"].get<std::string>() == "get_auto_nozzle_mapping") {
254 if (print_jj.contains("sequence_id") && print_jj["sequence_id"] == m_sequence_id) {
255 Clear();
256 DevJsonValParser::ParseVal(print_jj, "result", m_result);
257 DevJsonValParser::ParseVal(print_jj, "reason", m_mqtt_reason);
258 DevJsonValParser::ParseVal(print_jj, "errno", m_errno);
259 DevJsonValParser::ParseVal(print_jj, "detail", m_detail_json);
260 DevJsonValParser::ParseVal(print_jj, "type", m_type);
261 DevJsonValParser::ParseVal(print_jj, "version", m_ack_version);
262
263 if (print_jj.contains("mapping")) {
264 m_nozzle_mapping_json = print_jj["mapping"];
265 const auto& mapping = print_jj["mapping"].get<std::vector<int>>();
266 for (int fila_id = 0; fila_id < mapping.size(); ++fila_id) {
267 m_nozzle_mapping[fila_id] = mapping[fila_id];
268 }
269 }
270
272 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": get_auto_nozzle_mapping: " << m_result;
273 }
274 }
275}
static void ParseVal(const nlohmann::json &j, const std::string &key, T &val)
Definition DevUtil.h:76
float GetFlushWeight(Slic3r::MachineObject *obj) const
Definition DevMappingNozzle.cpp:397

References Clear(), GetFlushWeight(), m_ack_version, m_detail_json, m_errno, m_flush_weight_base, m_mqtt_reason, m_nozzle_mapping, m_nozzle_mapping_json, m_obj, m_result, m_sequence_id, m_type, and Slic3r::DevJsonValParser::ParseVal().

Here is the call graph for this function:

◆ SetManualNozzleMappingByFila()

void Slic3r::DevNozzleMappingCtrl::SetManualNozzleMappingByFila ( int fila_id,
int nozzle_pos_id )
296{
297 if (nozzle_pos_id == MAIN_EXTRUDER_ID && m_obj->GetNozzleSystem()->GetReplaceNozzleTar().has_value()){
298 nozzle_pos_id = m_obj->GetNozzleSystem()->GetReplaceNozzleTar().value();// special case of tar_id. see protocol definition
299 }
300
301 if (m_nozzle_mapping[fila_id] != nozzle_pos_id) {
302 m_nozzle_mapping[fila_id] = nozzle_pos_id;
304 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": fila_id=" << fila_id << ", nozzle_pos_id=" << nozzle_pos_id;
305 }
306
307 try {
308 auto mapping = m_nozzle_mapping_json.get<std::vector<int>>();
309 if (mapping.at(fila_id) != nozzle_pos_id) {
310 mapping[fila_id] = nozzle_pos_id;
311 m_nozzle_mapping_json = mapping;
312 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": updated to " << m_nozzle_mapping_json.dump();
313 }
314 } catch (std::exception& e) {
315 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": exception: " << e.what();
316 };
317}

References GetFlushWeight(), m_flush_weight_current, m_nozzle_mapping, m_nozzle_mapping_json, m_obj, and MAIN_EXTRUDER_ID.

Here is the call graph for this function:

◆ SetPlater()

void Slic3r::DevNozzleMappingCtrl::SetPlater ( Slic3r::GUI::Plater * plater)
inline
51{ m_plater = plater; }

References m_plater.

◆ MachineObject

friend class MachineObject
friend

References MachineObject.

Referenced by DevNozzleMappingCtrl(), and MachineObject.

Member Data Documentation

◆ m_ack_version

NozzleMappingVersion Slic3r::DevNozzleMappingCtrl::m_ack_version = NozzleMappingVersion::Version_V0
private

◆ m_detail_json

nlohmann::json Slic3r::DevNozzleMappingCtrl::m_detail_json
private

Referenced by Clear(), and ParseAutoNozzleMapping().

◆ m_detail_msg

std::string Slic3r::DevNozzleMappingCtrl::m_detail_msg
private

Referenced by Clear(), and GetDetailMsg().

◆ m_errno

int Slic3r::DevNozzleMappingCtrl::m_errno
private

◆ m_flush_weight_base

float Slic3r::DevNozzleMappingCtrl::m_flush_weight_base = -1
private

◆ m_flush_weight_current

float Slic3r::DevNozzleMappingCtrl::m_flush_weight_current = -1
private

◆ m_mqtt_reason

std::string Slic3r::DevNozzleMappingCtrl::m_mqtt_reason
private

◆ m_nozzle_mapping

std::unordered_map<int, int> Slic3r::DevNozzleMappingCtrl::m_nozzle_mapping
private

◆ m_nozzle_mapping_json

nlohmann::json Slic3r::DevNozzleMappingCtrl::m_nozzle_mapping_json
private

◆ m_obj

◆ m_plater

◆ m_req_version

NozzleMappingVersion Slic3r::DevNozzleMappingCtrl::m_req_version = NozzleMappingVersion::Version_V0
private

◆ m_result

std::string Slic3r::DevNozzleMappingCtrl::m_result
private

◆ m_sequence_id

std::string Slic3r::DevNozzleMappingCtrl::m_sequence_id
private

◆ m_type

std::string Slic3r::DevNozzleMappingCtrl::m_type
private

Referenced by Clear(), and ParseAutoNozzleMapping().


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