NEW: add more info for multi-nozzles printers
JIRA: STUDIO-9111 Change-Id: I5ed619d57b6857f5d4a1e38662d2fe03640222a3 Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
68b314eebd
commit
993228d3e9
|
@ -416,6 +416,15 @@ std::string get_extruder_variant_string(ExtruderType extruder_type, NozzleVolume
|
|||
return variant_string;
|
||||
}
|
||||
|
||||
std::string get_nozzle_volume_type_string(NozzleVolumeType nozzle_volume_type)
|
||||
{
|
||||
if (nozzle_volume_type > nvtMaxNozzleVolumeType) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(", unsupported NozzleVolumeType=%1%") % nozzle_volume_type;
|
||||
return "";
|
||||
}
|
||||
return s_keys_names_NozzleVolumeType[nozzle_volume_type];
|
||||
}
|
||||
|
||||
std::vector<std::map<int, int>> get_extruder_ams_count(const std::vector<std::string>& strs)
|
||||
{
|
||||
std::vector<std::map<int, int>> extruder_ams_counts;
|
||||
|
|
|
@ -308,6 +308,8 @@ enum FilamentMapMode {
|
|||
|
||||
extern std::string get_extruder_variant_string(ExtruderType extruder_type, NozzleVolumeType nozzle_volume_type);
|
||||
|
||||
std::string get_nozzle_volume_type_string(NozzleVolumeType nozzle_volume_type);
|
||||
|
||||
static std::string bed_type_to_gcode_string(const BedType type)
|
||||
{
|
||||
std::string type_str;
|
||||
|
|
|
@ -246,6 +246,7 @@ void PrintJob::process()
|
|||
params.ams_mapping = this->task_ams_mapping;
|
||||
params.ams_mapping2 = this->task_ams_mapping2;
|
||||
params.ams_mapping_info = this->task_ams_mapping_info;
|
||||
params.nozzles_info = this->task_nozzles_info;
|
||||
params.connection_type = this->connection_type;
|
||||
params.task_use_ams = this->task_use_ams;
|
||||
params.task_bed_type = this->task_bed_type;
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
std::string task_ams_mapping;
|
||||
std::string task_ams_mapping2;
|
||||
std::string task_ams_mapping_info;
|
||||
std::string task_nozzles_info;
|
||||
std::string connection_type;
|
||||
std::string m_print_type;
|
||||
std::string m_dst_path;
|
||||
|
|
|
@ -58,6 +58,20 @@ static std::string MachineBedTypeString[BED_TYPE_COUNT] = {
|
|||
"suprtack"
|
||||
};
|
||||
|
||||
static std::string get_nozzle_volume_type_cloud_string(NozzleVolumeType nozzle_volume_type)
|
||||
{
|
||||
if (nozzle_volume_type == NozzleVolumeType::nvtStandard) {
|
||||
return "standard_flow";
|
||||
}
|
||||
else if (nozzle_volume_type == NozzleVolumeType::nvtHighFlow) {
|
||||
return "high_flow";
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SelectMachineDialog::stripWhiteSpace(std::string& str)
|
||||
{
|
||||
|
@ -1275,28 +1289,34 @@ bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str,
|
|||
if (invalid_count == m_ams_mapping_result.size()) {
|
||||
return false;
|
||||
} else {
|
||||
|
||||
json mapping_v0_json = json::array();
|
||||
json mapping_v1_json = json::array();
|
||||
|
||||
json mapping_info_json = json::array();
|
||||
|
||||
/* get filament maps */
|
||||
std::vector<int> filament_maps;
|
||||
Plater* plater = wxGetApp().plater();
|
||||
if (plater) {
|
||||
PartPlate* curr_plate = plater->get_partplate_list().get_curr_plate();
|
||||
if (curr_plate) {
|
||||
filament_maps = curr_plate->get_filament_maps();
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "get_ams_mapping_result, curr_plate is nullptr";
|
||||
}
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "get_ams_mapping_result, plater is nullptr";
|
||||
}
|
||||
|
||||
for (int i = 0; i < wxGetApp().preset_bundle->filament_presets.size(); i++) {
|
||||
|
||||
int tray_id = -1;
|
||||
|
||||
json mapping_item_v1;
|
||||
mapping_item_v1["ams_id"] = 0xff;
|
||||
mapping_item_v1["slot_id"] = 0xff;
|
||||
|
||||
json mapping_item;
|
||||
mapping_item["ams"] = tray_id;
|
||||
mapping_item["targetColor"] = "";
|
||||
mapping_item["filamentId"] = "";
|
||||
mapping_item["filamentType"] = "";
|
||||
|
||||
|
||||
|
||||
for (int k = 0; k < m_ams_mapping_result.size(); k++) {
|
||||
if (m_ams_mapping_result[k].id == i) {
|
||||
tray_id = m_ams_mapping_result[k].tray_id;
|
||||
|
@ -1306,6 +1326,10 @@ bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str,
|
|||
if (it != nullptr) {
|
||||
mapping_item["filamentId"] = it->filament_id;
|
||||
}
|
||||
/* nozzle id */
|
||||
if (i >= 0 && i < filament_maps.size()) {
|
||||
mapping_item["nozzleId"] = convert_filament_map_nozzle_id_to_task_nozzle_id(filament_maps[i]);
|
||||
}
|
||||
//convert #RRGGBB to RRGGBBAA
|
||||
mapping_item["sourceColor"] = m_filaments[k].color;
|
||||
mapping_item["targetColor"] = m_ams_mapping_result[k].color;
|
||||
|
@ -1315,7 +1339,6 @@ bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str,
|
|||
}
|
||||
|
||||
/*new ams mapping data*/
|
||||
|
||||
try
|
||||
{
|
||||
if (m_ams_mapping_result[k].ams_id.empty() || m_ams_mapping_result[k].slot_id.empty()) { // invalid case
|
||||
|
@ -1347,6 +1370,56 @@ bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SelectMachineDialog::build_nozzles_info(std::string& nozzles_info)
|
||||
{
|
||||
/* init nozzles info */
|
||||
json nozzle_info_json = json::array();
|
||||
nozzles_info = nozzle_info_json.dump();
|
||||
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
if (!preset_bundle)
|
||||
return false;
|
||||
auto opt_nozzle_diameters = preset_bundle->printers.get_edited_preset().config.option<ConfigOptionFloatsNullable>("nozzle_diameter");
|
||||
if (opt_nozzle_diameters == nullptr) {
|
||||
BOOST_LOG_TRIVIAL(error) << "build_nozzles_info, opt_nozzle_diameters is nullptr";
|
||||
return false;
|
||||
}
|
||||
auto opt_nozzle_volume_type = preset_bundle->project_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type");
|
||||
if (opt_nozzle_volume_type == nullptr) {
|
||||
BOOST_LOG_TRIVIAL(error) << "build_nozzles_info, opt_nozzle_volume_type is nullptr";
|
||||
return false;
|
||||
}
|
||||
json nozzle_item;
|
||||
/* only o1d two nozzles has build_nozzles info now */
|
||||
if (opt_nozzle_diameters->size() != 2) {
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 0; i < opt_nozzle_diameters->size(); i++) {
|
||||
if (i == (size_t)ConfigNozzleIdx::NOZZLE_LEFT) {
|
||||
nozzle_item["id"] = CloudTaskNozzleId::NOZZLE_LEFT;
|
||||
}
|
||||
else if (i == (size_t)ConfigNozzleIdx::NOZZLE_RIGHT) {
|
||||
nozzle_item["id"] = CloudTaskNozzleId::NOZZLE_RIGHT;
|
||||
}
|
||||
else {
|
||||
/* unknown ConfigNozzleIdx */
|
||||
BOOST_LOG_TRIVIAL(error) << "build_nozzles_info, unknown ConfigNozzleIdx = " << i;
|
||||
assert(false);
|
||||
continue;
|
||||
}
|
||||
nozzle_item["type"] = nullptr;
|
||||
if (i >= 0 && i < opt_nozzle_volume_type->size()) {
|
||||
nozzle_item["flowSize"] = get_nozzle_volume_type_cloud_string((NozzleVolumeType)opt_nozzle_volume_type->get_at(i));
|
||||
}
|
||||
if (i >= 0 && i < opt_nozzle_diameters->size()) {
|
||||
nozzle_item["diameter"] = opt_nozzle_diameters->get_at(i);
|
||||
}
|
||||
nozzle_info_json.push_back(nozzle_item);
|
||||
}
|
||||
nozzles_info = nozzle_info_json.dump();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SelectMachineDialog::can_hybrid_mapping(ExtderData data) {
|
||||
// Mixed mappings are not allowed
|
||||
return false;
|
||||
|
@ -1453,6 +1526,21 @@ bool SelectMachineDialog::is_nozzle_type_match(ExtderData data) {
|
|||
return true;
|
||||
}
|
||||
|
||||
int SelectMachineDialog::convert_filament_map_nozzle_id_to_task_nozzle_id(int nozzle_id)
|
||||
{
|
||||
if (nozzle_id == (int)FilamentMapNozzleId::NOZZLE_LEFT) {
|
||||
return (int)CloudTaskNozzleId::NOZZLE_LEFT;
|
||||
}
|
||||
else if (nozzle_id == (int)FilamentMapNozzleId::NOZZLE_RIGHT) {
|
||||
return (int)CloudTaskNozzleId::NOZZLE_RIGHT;
|
||||
}
|
||||
else {
|
||||
/* unsupported nozzle id */
|
||||
assert(false);
|
||||
return nozzle_id;
|
||||
}
|
||||
}
|
||||
|
||||
void SelectMachineDialog::prepare(int print_plate_idx)
|
||||
{
|
||||
m_print_plate_idx = print_plate_idx;
|
||||
|
@ -2389,6 +2477,11 @@ void SelectMachineDialog::on_send_print()
|
|||
m_print_job->task_ams_mapping_info = "";
|
||||
}
|
||||
|
||||
/* build nozzles info for multi extruders printers */
|
||||
if (build_nozzles_info(m_print_job->task_nozzles_info)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "build_nozzle_info errors";
|
||||
}
|
||||
|
||||
m_print_job->has_sdcard = obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL;
|
||||
|
||||
|
||||
|
|
|
@ -102,6 +102,26 @@ public:
|
|||
MaterialItem *item;
|
||||
};
|
||||
|
||||
|
||||
enum class CloudTaskNozzleId : int
|
||||
{
|
||||
NOZZLE_RIGHT = 0,
|
||||
NOZZLE_LEFT = 1,
|
||||
};
|
||||
|
||||
enum class FilamentMapNozzleId : int
|
||||
{
|
||||
NOZZLE_LEFT = 1,
|
||||
NOZZLE_RIGHT = 2,
|
||||
};
|
||||
|
||||
enum class ConfigNozzleIdx : int
|
||||
{
|
||||
NOZZLE_LEFT = 0,
|
||||
NOZZLE_RIGHT = 1,
|
||||
};
|
||||
|
||||
|
||||
WX_DECLARE_HASH_MAP(int, Material *, wxIntegerHash, wxIntegerEqual, MaterialHash);
|
||||
|
||||
#define SELECT_MACHINE_DIALOG_BUTTON_SIZE wxSize(FromDIP(57), FromDIP(32))
|
||||
|
@ -441,9 +461,11 @@ public:
|
|||
bool Show(bool show);
|
||||
bool do_ams_mapping(MachineObject *obj_);
|
||||
bool get_ams_mapping_result(std::string& mapping_array_str, std::string& mapping_array_str2, std::string& ams_mapping_info);
|
||||
bool build_nozzles_info(std::string& nozzles_info);
|
||||
bool can_hybrid_mapping(ExtderData data);
|
||||
void auto_supply_with_ext(std::vector<AmsTray> slots);
|
||||
bool is_nozzle_type_match(ExtderData data);
|
||||
int convert_filament_map_nozzle_id_to_task_nozzle_id(int nozzle_id);
|
||||
|
||||
std::string get_print_status_info(PrintDialogStatus status);
|
||||
|
||||
|
|
|
@ -204,6 +204,7 @@ struct PrintParams {
|
|||
std::string ams_mapping;
|
||||
std::string ams_mapping2;
|
||||
std::string ams_mapping_info;
|
||||
std::string nozzles_info;
|
||||
std::string connection_type;
|
||||
std::string comments;
|
||||
int origin_profile_id = 0;
|
||||
|
|
Loading…
Reference in New Issue