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

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

Static Public Member Functions

static void ParseV1_0 (const nlohmann::json &nozzletype_json, const nlohmann::json &diameter_json, DevNozzleSystem *system, std::optional< int > flag_e3d)
static void ParseV2_0 (const nlohmann::json &device_json, DevNozzleSystem *system)

Detailed Description

Member Function Documentation

◆ ParseV1_0()

void Slic3r::DevNozzleSystemParser::ParseV1_0 ( const nlohmann::json & nozzletype_json,
const nlohmann::json & diameter_json,
DevNozzleSystem * system,
std::optional< int > flag_e3d )
static
476{
477 //Since both the old and new protocols push data.
478 // assert(system->m_ext_nozzles.size() < 2);
479 DevNozzle nozzle;
480 nozzle.SetRack(system->GetNozzleRack());
481 nozzle.m_nozzle_id = 0;
482 nozzle.m_nozzle_flow = NozzleFlowType::S_FLOW; // default flow type
483
484 {
485 float nozzle_diameter = 0.0f;
486 if (diameter_json.is_number_float())
487 {
488 nozzle_diameter = diameter_json.get<float>();
489 }
490 else if (diameter_json.is_string())
491 {
492 nozzle_diameter = DevUtil::string_to_float(diameter_json.get<std::string>());
493 }
494
495 if (nozzle_diameter == 0.0f)
496 {
497 nozzle.m_diameter = 0.0f;
498 }
499 else
500 {
501 nozzle.m_diameter = round(nozzle_diameter * 10) / 10;
502 }
503 }
504
505 {
506 if (nozzletype_json.is_string())
507 {
508 s_parse_nozzle_type(nozzletype_json.get<std::string>(), nozzle);
509 }
510 }
511
512 {
513 if (flag_e3d.has_value()) {
514 // 0: BBL S_FLOW; 1:E3D H_FLOW (only P)
515 if (flag_e3d.value() == 1) {
516 // note: E3D = E3D nozzle type + High Flow
517 nozzle.m_nozzle_flow = NozzleFlowType::H_FLOW;
518 nozzle.m_nozzle_type = NozzleType::ntE3D;
519 } else {
520 nozzle.m_nozzle_flow = NozzleFlowType::S_FLOW;
521 }
522 }
523 }
524
525 system->m_ext_nozzles[nozzle.m_nozzle_id] = nozzle;
526}
static float string_to_float(const std::string &str_value)
Definition DevUtil.cpp:146
zaa_minimize_perimeter_height nozzle_diameter((ConfigOptionBool, reduce_infill_retraction))((ConfigOptionBool
@ H_FLOW
Definition DevDefs.h:119
@ S_FLOW
Definition DevDefs.h:118
@ ntE3D
Definition CommonDefs.hpp:19
static void s_parse_nozzle_type(const std::string &nozzle_type_str, DevNozzle &nozzle)
Definition DevNozzleSystem.cpp:445

References Slic3r::DevNozzleSystem::GetNozzleRack(), Slic3r::H_FLOW, Slic3r::DevNozzle::m_diameter, Slic3r::DevNozzleSystem::m_ext_nozzles, Slic3r::DevNozzle::m_nozzle_flow, Slic3r::DevNozzle::m_nozzle_id, Slic3r::DevNozzle::m_nozzle_type, Slic3r::nozzle_diameter(), Slic3r::ntE3D, Slic3r::S_FLOW, Slic3r::s_parse_nozzle_type(), Slic3r::DevNozzle::SetRack(), and Slic3r::DevUtil::string_to_float().

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

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

◆ ParseV2_0()

void Slic3r::DevNozzleSystemParser::ParseV2_0 ( const nlohmann::json & device_json,
DevNozzleSystem * system )
static
530{
531 if (device_json.contains("nozzle"))
532 {
533 const json& nozzle_json = device_json["nozzle"];
534 if (nozzle_json.contains("exist"))
535 {
536 system->m_extder_exist = DevUtil::get_flag_bits(nozzle_json["exist"].get<int>(), 0, 16);
537 }
538
539 if (nozzle_json.contains("state"))
540 {
541 system->m_state_0_4 = DevUtil::get_flag_bits(nozzle_json["state"].get<int>(), 0, 4);
542 int new_reading_idx = DevUtil::get_flag_bits(nozzle_json["state"].get<int>(), 8, 4);
543 int new_reading_count = DevUtil::get_flag_bits(nozzle_json["state"].get<int>(), 4, 4);
544 if (system->m_reading_count != new_reading_count || system->m_reading_idx != new_reading_idx)
545 {
546 system->m_reading_idx = new_reading_idx;
547 system->m_reading_count = new_reading_count;
548 if (system->m_reading_count == 0)
549 {
550 system->m_nozzle_rack->SendReadingFinished();
551 }
552 }
553 }
554
555 // replace-nozzle state: a rack nozzle standing in for the toolhead position.
556 // Absent for every non-rack printer's "nozzle" block => both stay std::nullopt (inert).
557 if (nozzle_json.contains("src_id"))
558 {
559 system->m_replace_nozzle_src = std::make_optional(nozzle_json["src_id"].get<int>());
560 }
561
562 if (nozzle_json.contains("tar_id"))
563 {
564 system->m_replace_nozzle_tar = std::make_optional(nozzle_json["tar_id"].get<int>());
565 }
566
567 system->ClearNozzles();
568 for (auto it = nozzle_json["info"].begin(); it != nozzle_json["info"].end(); it++)
569 {
570 DevNozzle nozzle_obj;
571 nozzle_obj.SetRack(system->GetNozzleRack());
572
573 const auto& njon = it.value();
574 nozzle_obj.m_nozzle_id = DevUtil::get_hex_bits(njon["id"].get<int>(), 0);
575 nozzle_obj.m_diameter = njon["diameter"].get<float>();
576 s_parse_nozzle_type(njon["type"].get<std::string>(), nozzle_obj);
577 if (njon.contains("stat"))/*maybe not contains*/
578 {
579 nozzle_obj.SetStatus(njon["stat"].get<int>());
580 }
581
582 DevJsonValParser::ParseVal(njon, "fila_id", nozzle_obj.m_fila_id);
583 DevJsonValParser::ParseVal(njon, "wear", nozzle_obj.m_wear);
584 if (njon.contains("p_t"))/*maybe not contains*/
585 {
586 nozzle_obj.m_nozzle_print_time = njon["p_t"].get<int>();
587 }
588 if (njon.contains("color_m"))/*maybe not contains*/
589 {
590 nozzle_obj.m_filament_clr = njon["color_m"].get<std::string>();
591 }
592
593 if (DevUtil::get_hex_bits(njon["id"].get<int>(), 1) == 1)
594 {
595 system->m_nozzle_rack->AddRackNozzle(nozzle_obj);
596 }
597 else
598 {
599 system->m_ext_nozzles[nozzle_obj.m_nozzle_id] = nozzle_obj;
600 }
601 }
602 }
603
604 if (device_json.contains("holder"))
605 {
606 system->m_nozzle_rack->ParseRackInfo(device_json["holder"]);
607 }
608}
static void ParseVal(const nlohmann::json &j, const std::string &key, T &val)
Definition DevUtil.h:76
static int get_flag_bits(std::string str, int start, int count=1)
Definition DevUtil.cpp:18
static int get_hex_bits(int num, int pos, int input_num_base=10)
Definition DevUtil.h:44
T * begin(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:838
nlohmann::json json
Definition AssembleList.cpp:42

References Slic3r::DevNozzleSystem::ClearNozzles(), Slic3r::DevUtil::get_flag_bits(), Slic3r::DevUtil::get_hex_bits(), Slic3r::DevNozzleSystem::GetNozzleRack(), Slic3r::DevNozzle::m_diameter, Slic3r::DevNozzleSystem::m_ext_nozzles, Slic3r::DevNozzleSystem::m_extder_exist, Slic3r::DevNozzle::m_fila_id, Slic3r::DevNozzle::m_filament_clr, Slic3r::DevNozzle::m_nozzle_id, Slic3r::DevNozzle::m_nozzle_print_time, Slic3r::DevNozzleSystem::m_nozzle_rack, Slic3r::DevNozzleSystem::m_reading_count, Slic3r::DevNozzleSystem::m_reading_idx, Slic3r::DevNozzleSystem::m_replace_nozzle_src, Slic3r::DevNozzleSystem::m_replace_nozzle_tar, Slic3r::DevNozzleSystem::m_state_0_4, Slic3r::DevNozzle::m_wear, Slic3r::DevJsonValParser::ParseVal(), Slic3r::s_parse_nozzle_type(), Slic3r::DevNozzle::SetRack(), and Slic3r::DevNozzle::SetStatus().

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: