ENH: update airducts

jira: [STUDIO-13296]
Change-Id: I5cdb34cc254933be9a91313462a6b03b0dca117b
(cherry picked from commit fbf88ce6f226496723344e60f57632eadfaf5ee9)
This commit is contained in:
xin.zhang 2025-08-14 16:01:23 +08:00 committed by Noisyfox
parent 296e001856
commit db05e4ac64
6 changed files with 85 additions and 30 deletions

View file

@ -108,6 +108,53 @@ std::string DevPrinterConfigUtil::get_fan_text(const std::string& type_str, cons
return std::string();
}
std::string DevPrinterConfigUtil::get_fan_text(const std::string& type_str, int airduct_mode, int airduct_func, int submode)
{
std::vector<std::string> filaments;
std::string config_file = m_resource_file_path + "/printers/" + type_str + ".json";
boost::nowide::ifstream json_file(config_file.c_str());
try
{
json jj;
if (json_file.is_open())
{
json_file >> jj;
if (jj.contains("00.00.00.00"))
{
json const& printer = jj["00.00.00.00"];
if (!printer.contains("fan"))
{
return std::string();
}
json const& fan_item = printer["fan"];
const auto& airduct_mode_str = std::to_string(airduct_mode);
if (!fan_item.contains(airduct_mode_str))
{
return std::string();
}
json const& airduct_item = fan_item[airduct_mode_str];
const auto& airduct_func_str = std::to_string(airduct_func);
if (airduct_item.contains(airduct_func_str))
{
const auto& airduct_func_item = airduct_item[airduct_func_str];
if (airduct_func_item.is_object())
{
return airduct_func_item[std::to_string(submode)].get<std::string>();
}
else if (airduct_func_item.is_string())
{
return airduct_func_item.get<std::string>();
}
}
}
}
}
catch (...) {}
return std::string();
}
std::map<std::string, std::vector<std::string>> DevPrinterConfigUtil::get_all_subseries(std::string type_str)
{
std::vector<wxString> m_files;

View file

@ -66,6 +66,7 @@ public:
/*fan*/
static std::string get_fan_text(const std::string& type_str, const std::string& key);
static std::string get_fan_text(const std::string& type_str, int airduct_mode, int airduct_func, int submode);
/*extruder*/
static bool get_printer_can_set_nozzle(std::string type_str) { return get_value_from_config<bool>(type_str, "enable_set_nozzle_info"); }// can set nozzle from studio

View file

@ -204,7 +204,7 @@ void Slic3r::DevFan::ParseV2_0(const json &print_json) {
AirParts part;
part.type = m_owner->get_flag_bits((*it_part)["id"].get<int>(), 0, 4);
part.id = m_owner->get_flag_bits((*it_part)["id"].get<int>(), 4, 9);
part.id = m_owner->get_flag_bits((*it_part)["id"].get<int>(), 4, 8);
part.func = (*it_part)["func"].get<int>();
part.state = m_owner->get_flag_bits(state, 0, 8);
part.range_start = m_owner->get_flag_bits(range, 0, 16);

View file

@ -11,7 +11,7 @@ typedef std::function<void(const json &)> CommandCallBack;
enum AIR_FUN {
enum AIR_FUN : int {
FAN_HEAT_BREAK_0_IDX = 0,
FAN_COOLING_0_AIRDOOR = 1,
FAN_REMOTE_COOLING_0_IDX = 2,
@ -19,13 +19,14 @@ enum AIR_FUN {
FAN_HEAT_BREAK_1_IDX = 4,
FAN_MC_BOARD_0_IDX = 5,
FAN_INNNER_LOOP_FAN_0_IDX = 6,
FAN_TOTAL_COUNT = 7
FAN_TOTAL_COUNT = 7,
FAN_REMOTE_COOLING_1_IDX = 10
};
enum AIR_DOOR { AIR_DOOR_FUNC_CHAMBER = 0, AIR_DOOR_FUNC_INNERLOOP, AIR_DOOR_FUNC_TOP };
enum AIR_DUCT {
enum AIR_DUCT : int {
AIR_DUCT_NONE = -1,
AIR_DUCT_COOLING_FILT = 0,
AIR_DUCT_HEATING_INTERNAL_FILT,
@ -87,7 +88,7 @@ public:
};
bool IsSupportCoolingFilter() const { return m_support_cooling_filter; }
bool IsCoolingFilerOn() const { return m_sub_mode == 0; }
bool IsCoolingFilerOn() const { return m_sub_mode == 1; }
};
class DevFan

View file

@ -357,7 +357,7 @@ FanControlNew::FanControlNew(wxWindow *parent, const AirDuctData &fan_data, int
m_static_name = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END | wxALIGN_CENTER_HORIZONTAL);
m_static_name->SetBackgroundColour(wxColour(248, 248, 248));
m_static_name->SetFont(Label::Head_18);
m_static_name->SetFont(Label::Head_16);
m_static_name->SetMinSize(wxSize(FromDIP(100), -1));
m_static_name->SetMaxSize(wxSize(FromDIP(100), -1));
@ -692,8 +692,6 @@ void FanControlPopupNew::CreateDuct()
for (const auto& part : m_data.parts)
{
auto part_id = part.id;
auto part_func = part.func;
auto part_name = fan_func_name[AIR_FUN(part_id)];
auto part_state = part.state;
auto it = m_fan_control_list.find(part_id);
@ -731,7 +729,7 @@ void FanControlPopupNew::UpdateParts()
for (const auto& part : m_data.parts) {
auto part_id = part.id;
auto part_name = fan_func_name[AIR_FUN(part_id)];
auto part_name = get_fan_func_name(m_data.curren_mode, m_data.m_sub_mode, AIR_FUN(part_id));
auto fan_control = m_fan_control_list[part_id];
if (!fan_control)
@ -774,7 +772,7 @@ void FanControlPopupNew::UpdatePartSubMode()
if (msg_wingow.ShowModal() != wxID_OK) { return; }
}
int submode = m_cooling_filter_switch_panel->IsSwitchOn() ? 0 : 1;
int submode = m_cooling_filter_switch_panel->IsSwitchOn() ? 1 : 0;
command_control_air_duct(m_data.curren_mode, submode);
});
@ -827,8 +825,6 @@ void FanControlPopupNew::update_fan_data(const AirDuctData &data)
m_data = data;
for (const auto& part : m_data.parts) {
auto part_id = part.id;
auto part_func = part.func;
auto part_name = fan_func_name[AIR_FUN(part_id)];
auto part_state = part.state;
auto it = m_fan_control_list.find(part_id);
@ -845,9 +841,6 @@ void FanControlPopupNew::update_fan_data(AIR_FUN id, int speed)
{
for (auto& part : m_data.parts) {
auto part_id = part.id;
auto part_func = part.func;
auto part_name = fan_func_name[AIR_FUN(part_id)];
if (id == part_id) {
part.state = speed;
auto it = m_fan_control_list.find(part_id);
@ -979,14 +972,6 @@ void FanControlPopupNew::init_names(MachineObject* obj) {
radio_btn_name[AIR_DUCT::AIR_DUCT_FULL_COOLING] = _L("Full Cooling");
radio_btn_name[AIR_DUCT::AIR_DUCT_INIT] = L("Init");
fan_func_name[AIR_FUN::FAN_HEAT_BREAK_0_IDX] = _L("Hotend");
fan_func_name[AIR_FUN::FAN_COOLING_0_AIRDOOR] = _L("Parts");
fan_func_name[AIR_FUN::FAN_REMOTE_COOLING_0_IDX] = _L("Aux");
fan_func_name[AIR_FUN::FAN_CHAMBER_0_IDX] = _L("Exhaust");
fan_func_name[AIR_FUN::FAN_HEAT_BREAK_1_IDX] = _L("Nozzle1");
fan_func_name[AIR_FUN::FAN_MC_BOARD_0_IDX] = _L("MC Board");
fan_func_name[AIR_FUN::FAN_INNNER_LOOP_FAN_0_IDX] = _L("Heat");
air_door_func_name[AIR_DOOR::AIR_DOOR_FUNC_CHAMBER] = _L("Chamber");
air_door_func_name[AIR_DOOR::AIR_DOOR_FUNC_INNERLOOP] = _L("Innerloop");
air_door_func_name[AIR_DOOR::AIR_DOOR_FUNC_TOP] = L("Top");/*UNUSED*/
@ -1007,15 +992,36 @@ void FanControlPopupNew::init_names(MachineObject* obj) {
L("Cooling mode is suitable for printing PLA/PETG/TPU materials."); //some potential text, add i18n flags
label_text[AIR_DUCT::AIR_DUCT_COOLING_FILT] = special_cooling_text;
}
const std::string& special_func_aux_text = DevPrinterConfigUtil::get_fan_text(obj->printer_type, "special_func_aux_text");
if (!special_func_aux_text.empty()) {
L_CONTEXT("Right", "air_duct");
fan_func_name[AIR_FUN::FAN_REMOTE_COOLING_0_IDX] = _CTX(special_func_aux_text, "air_duct");
}
}
}
wxString FanControlPopupNew::get_fan_func_name(int mode, int submode, AIR_FUN func) const
{
if (m_obj)
{
const std::string& func_text = DevPrinterConfigUtil::get_fan_text(m_obj->printer_type, mode, (int)func, submode);
if (!func_text.empty())
{
L_CONTEXT("Right(Aux)", "air_duct");
L_CONTEXT("Right(Filter)", "air_duct");
return _CTX(func_text, "air_duct");
}
}
static std::map<AIR_FUN, wxString> s_fan_func_name
{
{ AIR_FUN::FAN_HEAT_BREAK_0_IDX, _L("Hotend") },
{ AIR_FUN::FAN_COOLING_0_AIRDOOR, _L("Parts") },
{ AIR_FUN::FAN_REMOTE_COOLING_0_IDX, _L("Aux") },
{ AIR_FUN::FAN_CHAMBER_0_IDX, _L("Exhaust") },
{ AIR_FUN::FAN_HEAT_BREAK_1_IDX, _L("Nozzle1") },
{ AIR_FUN::FAN_MC_BOARD_0_IDX, _L("MC Board") },
{ AIR_FUN::FAN_INNNER_LOOP_FAN_0_IDX, _L("Heat") },
};
auto iter = s_fan_func_name.find(func);
return (iter != s_fan_func_name.end()) ? iter->second : wxString::Format(_L("Fan"));
}
wxDEFINE_EVENT(EVT_FANCTRL_SWITCH, wxCommandEvent);
FanControlNewSwitchPanel::FanControlNewSwitchPanel(wxWindow* parent, const wxString& title, const wxString& tips, bool on)

View file

@ -237,12 +237,12 @@ private:
int m_fan_set_time_out{ 0 };
std::map<AIR_DUCT, wxString> radio_btn_name;
std::map<AIR_FUN, wxString> fan_func_name;
std::map<AIR_DOOR, wxString> air_door_func_name;
std::map<AIR_DUCT, wxString> label_text;
private:
void init_names(MachineObject* obj);
wxString get_fan_func_name(int mode, int submode, AIR_FUN func) const;
void CreateDuct();