NEW: new fan ctrl

JIRA: none

Change-Id: I4e84d455fa728dffb00706f4c07310fcd1b8335c
This commit is contained in:
Kunlong Ma 2024-12-06 15:23:28 +08:00 committed by lane.wei
parent c863a8268f
commit 0a739fe087
11 changed files with 911 additions and 545 deletions

View File

@ -1,4 +1,3 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.329102 7.14591C0.329102 6.7317 0.664888 6.39591 1.0791 6.39591H12.2525C12.6667 6.39591 13.0025 6.7317 13.0025 7.14591C13.0025 7.56013 12.6667 7.89591 12.2525 7.89591H1.0791C0.664888 7.89591 0.329102 7.56013 0.329102 7.14591Z" fill="#828280"/> <path d="M13.5941 5.15355C13.5941 4.64201 13.1826 4.23047 12.6711 4.23047C12.1595 4.23047 11.748 4.64201 11.748 5.15355V11.3074H5.59413C5.08259 11.3074 4.67105 11.7189 4.67105 12.2305C4.67105 12.742 5.08259 13.1535 5.59413 13.1535H11.748V19.3074C11.748 19.8189 12.1595 20.2305 12.6711 20.2305C13.1826 20.2305 13.5941 19.8189 13.5941 19.3074V13.1535H19.748C20.2595 13.1535 20.6711 12.742 20.6711 12.2305C20.6711 11.7189 20.2595 11.3074 19.748 11.3074H13.5941V5.15355Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.66504 0.809425C7.07925 0.809425 7.41504 1.14521 7.41504 1.55943L7.41504 12.7329C7.41504 13.1471 7.07925 13.4829 6.66504 13.4829C6.25082 13.4829 5.91504 13.1471 5.91504 12.7329L5.91504 1.55943C5.91504 1.14521 6.25083 0.809425 6.66504 0.809425Z" fill="#828280"/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 711 B

After

Width:  |  Height:  |  Size: 586 B

View File

@ -1,3 +1,3 @@
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.160156 6.5C0.160156 6.08579 0.495943 5.75 0.910156 5.75H12.0836C12.4978 5.75 12.8336 6.08579 12.8336 6.5C12.8336 6.91421 12.4978 7.25 12.0836 7.25H0.910156C0.495943 7.25 0.160156 6.91421 0.160156 6.5Z" fill="#828280"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M4 12.1305C4 11.6334 4.40294 11.2305 4.9 11.2305H19.1C19.5971 11.2305 20 11.6334 20 12.1305C20 12.6275 19.5971 13.0305 19.1 13.0305H4.9C4.40294 13.0305 4 12.6275 4 12.1305Z" fill="black"/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 374 B

After

Width:  |  Height:  |  Size: 341 B

View File

@ -0,0 +1,3 @@
<svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M20.6121 10.8975C21.128 10.8975 21.5431 10.4824 21.5431 9.96646V4.38025C21.5431 3.86431 21.128 3.44922 20.6121 3.44922C20.0961 3.44922 19.681 3.86431 19.681 4.38025V7.48758L18.9052 6.57594C17.3146 4.66732 14.9133 3.44922 12.2327 3.44922C7.43404 3.44922 3.54309 7.34017 3.54309 12.1389C3.54309 16.9376 7.43404 20.8285 12.2327 20.8285C14.1879 20.8285 15.9957 20.1807 17.4465 19.0906C17.8577 18.7803 17.9392 18.1984 17.6327 17.7872C17.3263 17.3759 16.7405 17.2945 16.3293 17.6009C15.1888 18.4583 13.7728 18.9665 12.2327 18.9665C8.46206 18.9665 5.40516 15.9096 5.40516 12.1389C5.40516 8.36818 8.46206 5.31129 12.2327 5.31129C14.3392 5.31129 16.2246 6.2656 17.4776 7.77077L17.4815 7.77853L18.5521 9.03543H15.0258C14.5099 9.03543 14.0948 9.45051 14.0948 9.96646C14.0948 10.4824 14.5099 10.8975 15.0258 10.8975H20.6121Z" fill="#00AE42"/>
</svg>

After

Width:  |  Height:  |  Size: 943 B

View File

@ -1800,26 +1800,7 @@ int MachineObject::command_go_home()
} }
// Old protocol // Old protocol
int MachineObject::command_control_fan(FanType fan_type, bool on_off) int MachineObject::command_control_fan(int fan_type, int val)
{
std::string gcode = (boost::format("M106 P%1% S%2% \n") % (int)fan_type % (on_off ? 255 : 0)).str();
try {
json j;
j["ctrl_type"] = get_string_from_fantype(fan_type);
j["value"] = on_off ? (int)1 : (int)0;
NetworkAgent* agent = GUI::wxGetApp().getAgent();
if (agent) agent->track_event("printer_control", j.dump());
}
catch (...) {}
return this->publish_gcode(gcode);
}
// Old protocol
int MachineObject::command_control_fan_val(FanType fan_type, int val)
{ {
std::string gcode = (boost::format("M106 P%1% S%2% \n") % (int)fan_type % (val)).str(); std::string gcode = (boost::format("M106 P%1% S%2% \n") % (int)fan_type % (val)).str();
try { try {
@ -1835,24 +1816,10 @@ int MachineObject::command_control_fan_val(FanType fan_type, int val)
} }
// New protocol // New protocol
int MachineObject::command_control_fan(int fan_id, bool on_off) int MachineObject::command_control_fan_new(int fan_id, int val, const CommandCallBack &cb)
{
BOOST_LOG_TRIVIAL(info) << "New protocol of fan setting(switch on/of status), fan_id = " << fan_id;
json j;
j["print"]["command"] = "set_fan";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["fan_index"] = fan_id;
// wait add, set on or off
j["print"]["speed"] = 50;
BOOST_LOG_TRIVIAL(info) << "MachineObject::command_control_fan, command info need to update, to set on or off status.";
return this->publish_json(j.dump());
}
// New protocol
int MachineObject::command_control_fan_val(int fan_id, int val)
{ {
BOOST_LOG_TRIVIAL(info) << "New protocol of fan setting(set speed), fan_id = " << fan_id; BOOST_LOG_TRIVIAL(info) << "New protocol of fan setting(set speed), fan_id = " << fan_id;
m_callback_list[std::to_string(m_sequence_id)] = cb;
json j; json j;
j["print"]["command"] = "set_fan"; j["print"]["command"] = "set_fan";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
@ -1863,6 +1830,17 @@ int MachineObject::command_control_fan_val(int fan_id, int val)
return this->publish_json(j.dump()); return this->publish_json(j.dump());
} }
int MachineObject::command_control_air_duct(int mode_id, const CommandCallBack &cb)
{
BOOST_LOG_TRIVIAL(info) << "MachineObject::command_control_air_duct, set air duct, d = " << mode_id;
m_callback_list[std::to_string(m_sequence_id)] = cb;
json j;
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["command"] = "set_airduct";
j["print"]["modeId"] = mode_id;
return this->publish_json(j.dump());
}
int MachineObject::command_task_abort() int MachineObject::command_task_abort()
{ {
@ -3680,7 +3658,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
big_fan2_speed = 0; big_fan2_speed = 0;
} }
} }
converse_to_duct();
if (jj.contains("heatbreak_fan_speed")) { if (jj.contains("heatbreak_fan_speed")) {
heatbreak_fan_speed = stoi(jj["heatbreak_fan_speed"].get<std::string>()); heatbreak_fan_speed = stoi(jj["heatbreak_fan_speed"].get<std::string>());
} }
@ -3702,35 +3680,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
} }
} }
//new fan data
if (jj.contains("airduct")) {
m_air_duct_data.airducts.clear();
m_air_duct_data.curren_duct = jj["airduct"]["cur"].get<int>();
m_air_duct_data.ducts_ctrl.push_back(jj["airduct"]["ctrl"].get<int>());
for (auto it_airduct = jj["airduct"]["info"].begin(); it_airduct != jj["airduct"]["info"].end(); it_airduct++) {
AirDuct air_duct;
air_duct.airduct_id = (*it_airduct)["id"].get<int>();
air_duct.fans_ctrl.push_back((*it_airduct)["ctrl"].get<int>());
for (auto it_fan = (*it_airduct)["info"].begin(); it_fan != (*it_airduct)["info"].end(); it_airduct++) {
AirDuctFan fan;
fan.use_new_protocol = true;
auto type = (*it_fan)["type"].get<unsigned>();
fan.id = std::log2(type >> 4);
if (type & 0x01) fan.type = AIR_DOOR_TYPE;
else if (type & 0x10) fan.type = AIR_FAN_TYPE;
fan.func = (*it_fan)["func"].get<int>();
unsigned speed = (*it_fan)["speed"].get<unsigned>();
fan.current_speed = (speed) & 0xFFFF;
fan.target_speed = (speed >> 16) & 0xFFFF;
air_duct.fans_list.push_back(fan);
}
m_air_duct_data.airducts.push_back(air_duct);
}
BOOST_LOG_TRIVIAL(trace) << "New protocol of fans, dir duct num = " << m_air_duct_data.airducts.size();
}
try { try {
if (jj.contains("stg")) { if (jj.contains("stg")) {
stage_list_info.clear(); stage_list_info.clear();
@ -4969,6 +4918,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
} catch (...) {} } catch (...) {}
} }
} }
command_handle_response(jj);
} }
} }
@ -5390,14 +5340,14 @@ bool MachineObject::is_firmware_info_valid()
return m_firmware_valid; return m_firmware_valid;
} }
std::string MachineObject::get_string_from_fantype(FanType type) std::string MachineObject::get_string_from_fantype(int type)
{ {
switch (type) { switch (type) {
case FanType::COOLING_FAN: case 1:
return "cooling_fan"; return "cooling_fan";
case FanType::BIG_COOLING_FAN: case 2:
return "big_cooling_fan"; return "big_cooling_fan";
case FanType::CHAMBER_FAN: case 3:
return "chamber_fan"; return "chamber_fan";
default: default:
return ""; return "";
@ -5405,32 +5355,45 @@ std::string MachineObject::get_string_from_fantype(FanType type)
return ""; return "";
} }
void MachineObject::converse_to_duct() { void MachineObject::converse_to_duct(bool is_suppt_part_fun, bool is_suppt_aux_fun, bool is_suppt_cham_fun)
AirDuct duct; {
duct.airduct_id = -1; m_air_duct_data.modes.clear();
AirDuctFan part_fan; m_air_duct_data.parts.clear();
part_fan.type = AIR_FAN_TYPE; m_air_duct_data.curren_mode = -1; //def mode
part_fan.id = 1;
part_fan.func = int(FAN_func_e::FAN_FUNC_PART_COOLING);
part_fan.current_speed = cooling_fan_speed;
duct.fans_list.push_back(part_fan);
AirDuctFan aux_fan;
aux_fan.type = AIR_FAN_TYPE;
aux_fan.id = 2;
aux_fan.func = int(FAN_func_e::FAN_FUNC_AUX_COOLING);
aux_fan.current_speed = big_fan1_speed;
duct.fans_list.push_back(aux_fan);
AirDuctFan chamber_fan; if (is_suppt_part_fun) {
chamber_fan.type = AIR_FAN_TYPE; AirParts part_fan;
chamber_fan.id = 3; part_fan.type = int(AirDuctType::AIR_FAN_TYPE);
chamber_fan.func = int(FAN_func_e::FAN_FUNC_EXHAUST); part_fan.id = int(AIR_FUN::FAN_COOLING_0_AIRDOOR);
chamber_fan.current_speed = cooling_fan_speed; part_fan.func = int(AIR_FUN::FAN_COOLING_0_AIRDOOR);
duct.fans_list.push_back(chamber_fan); part_fan.state = 0;
this->m_air_duct_data.airducts.clear(); part_fan.range_start = 0;
this->m_air_duct_data.airducts.push_back(duct); part_fan.range_end = 100;
this->m_air_duct_data.curren_duct = -1; m_air_duct_data.parts.push_back(part_fan);
}
if (is_suppt_aux_fun) {
AirParts aux_fan;
aux_fan.type = int(AirDuctType::AIR_FAN_TYPE);
aux_fan.id = int(AIR_FUN::FAN_REMOTE_COOLING_0_IDX);
aux_fan.func = int(AIR_FUN::FAN_REMOTE_COOLING_0_IDX);
aux_fan.state = 0;
aux_fan.range_start = 0;
aux_fan.range_end = 100;
m_air_duct_data.parts.push_back(aux_fan);
}
if (is_suppt_aux_fun) {
AirParts chamber_fan;
chamber_fan.type = int(AirDuctType::AIR_FAN_TYPE);
chamber_fan.id = int(AIR_FUN::FAN_CHAMBER_0_IDX);
chamber_fan.func = int(AIR_FUN::FAN_CHAMBER_0_IDX);
chamber_fan.state = 0;
chamber_fan.range_start = 0;
chamber_fan.range_end = 100;
m_air_duct_data.parts.push_back(chamber_fan);
}
} }
AmsTray MachineObject::parse_vt_tray(json vtray) AmsTray MachineObject::parse_vt_tray(json vtray)
@ -5668,6 +5631,46 @@ void MachineObject::parse_new_info(json print)
if (print.contains("device")) { if (print.contains("device")) {
json const& device = print["device"]; json const& device = print["device"];
//new fan data
if (device.contains("airduct")) {
m_air_duct_data.curren_mode = -1;
m_air_duct_data.modes.clear();
m_air_duct_data.parts.clear();
m_air_duct_data.curren_mode = device["airduct"]["modeCur"].get<int>();
for (auto it_mode = device["airduct"]["modeList"].begin(); it_mode != device["airduct"]["modeList"].end(); it_mode++) {
AirMode mode;
mode.id = (*it_mode)["modeId"].get<int>();
for (auto it_mode_ctrl = (*it_mode)["ctrl"].begin(); it_mode_ctrl != (*it_mode)["ctrl"].end(); it_mode_ctrl++) {
mode.ctrl.push_back((*it_mode_ctrl).get<int>() >> 4);
}
for (auto it_mode_off = (*it_mode)["off"].begin(); it_mode_off != (*it_mode)["off"].begin(); *it_mode_off++) {
mode.off.push_back((*it_mode_off).get<int>() >> 4);
}
m_air_duct_data.modes.push_back(mode);
}
for (auto it_part = device["airduct"]["parts"].begin(); it_part != device["airduct"]["parts"].end(); it_part++) {
int state = (*it_part)["state"].get<int>();
int range = (*it_part)["range"].get<int>();
AirParts part;
part.type = get_flag_bits((*it_part)["id"].get<int>(), 0, 3);
part.id = get_flag_bits((*it_part)["id"].get<int>(), 4, 12);
part.func = (*it_part)["func"].get<int>();
part.state = get_flag_bits(state, 0, 8);
part.range_start = get_flag_bits(range, 0, 15);
part.range_end = get_flag_bits(range, 16, 15);
m_air_duct_data.parts.push_back(part);
}
}
if (device.contains("type")) { if (device.contains("type")) {
int type = device["type"]; //FDM:1<<0 Laser:1<< Cut:1<<2 int type = device["type"]; //FDM:1<<0 Laser:1<< Cut:1<<2
} }
@ -5812,7 +5815,7 @@ void MachineObject::parse_new_info(json print)
m_extder_data.extders.push_back(nozzle); m_extder_data.extders.push_back(nozzle);
} }
} }
} }
} }
bool MachineObject::is_nozzle_data_invalid() bool MachineObject::is_nozzle_data_invalid()
@ -6091,6 +6094,23 @@ void MachineObject::check_ams_filament_valid()
} }
} }
int MachineObject::command_handle_response(const json &response)
{
if (!response.contains("sequence_id")) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ", error reponse.";
return -1;
}
std::string reply = response["sequence_id"].get<std::string>();
auto it = m_callback_list.find(reply);
if (it != m_callback_list.end()) {
it->second(response);
m_callback_list.erase(it);
}
return 0;
}
bool DeviceManager::EnableMultiMachine = false; bool DeviceManager::EnableMultiMachine = false;
bool DeviceManager::key_field_only = false; bool DeviceManager::key_field_only = false;

View File

@ -225,29 +225,30 @@ struct ExtderData
std::vector<Extder> extders; std::vector<Extder> extders;
}; };
struct AirDuctFan struct AirMode
{ {
//Fan and door may use the same mode_id, but they are different, they need to be distinguished by the m_type field int id{-1};
AirDuctType type; //Type of part, fan or door std::vector<int> ctrl;
bool use_new_protocol{ false }; // If the fan is off, it cannot be controlled and is displayed as off
int id; //the id of fan or air door std::vector<int> off;
int func{ 0 }; //UI display, fan or door // If the fan is not off or ctrl, it will be displayed as auto
int current_speed{0};
int target_speed{0};
}; };
struct AirDuct struct AirParts
{ {
int airduct_id{ 0 }; //Determine the UI display content, click radonbutton to switch int type{ 0 };
std::vector<bool> fans_ctrl; //Control status of each (fan) / (air door) int id{ 0 };
std::vector<AirDuctFan> fans_list; //Fan or air door s int func{ 0 };
int state{ 0 };// 100%
int range_start{ 0 };// 100%
int range_end{ 0 };// 100%
}; };
struct AirDuctData struct AirDuctData
{ {
int curren_duct{0}; int curren_mode{ 0 };
std::vector<bool> ducts_ctrl; //Control status of each duct std::vector<AirMode> modes;
std::vector<AirDuct> airducts; std::vector<AirParts> parts;
}; };
struct RatingInfo { struct RatingInfo {
@ -409,21 +410,24 @@ enum HMSMessageLevel {
}; };
enum FAN_func_e { enum AIR_FUN {
FAN_FUNC_PART_COOLING = 0, FAN_HEAT_BREAK_0_IDX = 0,
FAN_FUNC_AUX_COOLING, FAN_COOLING_0_AIRDOOR = 1,
FAN_FUNC_EXHAUST, FAN_REMOTE_COOLING_0_IDX = 2,
FAN_FUNC_FILTER, FAN_CHAMBER_0_IDX = 3,
FAN_FUNC_HEATING FAN_HEAT_BREAK_1_IDX = 4,
FAN_MC_BOARD_0_IDX = 5,
FAN_INNNER_LOOP_FAN_0_IDX = 6,
FAN_TOTAL_COUNT = 7
}; };
enum AIR_DOOR_func_e { enum AIR_DOOR {
AIR_DOOR_FUNC_CHAMBER = 0, AIR_DOOR_FUNC_CHAMBER = 0,
AIR_DOOR_FUNC_INNERLOOP, AIR_DOOR_FUNC_INNERLOOP,
AIR_DOOR_FUNC_TOP AIR_DOOR_FUNC_TOP
}; };
enum AIR_DUCT_mode_e { enum AIR_DUCT {
AIR_DUCT_NONE = -1, AIR_DUCT_NONE = -1,
AIR_DUCT_COOLING_FILT = 0, AIR_DUCT_COOLING_FILT = 0,
AIR_DUCT_HEATING_INTERNAL_FILT, AIR_DUCT_HEATING_INTERNAL_FILT,
@ -482,6 +486,8 @@ private:
std::vector<std::tuple<std::string, uint64_t, uint64_t>> message_delay; std::vector<std::tuple<std::string, uint64_t, uint64_t>> message_delay;
public: public:
typedef std::function<void(const json &)> CommandCallBack;
enum LIGHT_EFFECT { enum LIGHT_EFFECT {
LIGHT_EFFECT_ON, LIGHT_EFFECT_ON,
LIGHT_EFFECT_OFF, LIGHT_EFFECT_OFF,
@ -723,7 +729,7 @@ public:
//new fan data //new fan data
AirDuctData m_air_duct_data; AirDuctData m_air_duct_data;
void converse_to_duct(); //Convert the data to duct type to make the newand old protocols consistent void converse_to_duct(bool is_suppt_part_fun, bool is_suppt_aux_fun, bool is_suppt_cham_fun); // Convert the data to duct type to make the newand old protocols consistent
/* signals */ /* signals */
std::string wifi_signal; std::string wifi_signal;
@ -979,6 +985,9 @@ public:
boost::thread* get_slice_info_thread { nullptr }; boost::thread* get_slice_info_thread { nullptr };
boost::thread* get_model_task_thread { nullptr }; boost::thread* get_model_task_thread { nullptr };
/* key: sequence id, value: callback */
std::map<std::string, CommandCallBack> m_callback_list;
bool is_makeworld_subtask(); bool is_makeworld_subtask();
@ -1026,10 +1035,9 @@ public:
int command_xyz_abs(); int command_xyz_abs();
int command_auto_leveling(); int command_auto_leveling();
int command_go_home(); int command_go_home();
int command_control_fan(FanType fan_type, bool on_off); //Old protocol int command_control_fan(int fan_type, int val); // Old protocol
int command_control_fan_val(FanType fan_type, int val); //Old protocol int command_control_fan_new(int fan_id, int val, const CommandCallBack &cb); // New protocol
int command_control_fan(int fan_id, bool on_off); //New protocol int command_control_air_duct(int mode_id, const CommandCallBack& cb);
int command_control_fan_val(int fan_id, int val); //New protocol
int command_task_abort(); int command_task_abort();
/* cancelled the job_id */ /* cancelled the job_id */
int command_task_cancel(std::string job_id); int command_task_cancel(std::string job_id);
@ -1151,7 +1159,7 @@ public:
bool m_firmware_thread_started { false }; bool m_firmware_thread_started { false };
void get_firmware_info(); void get_firmware_info();
bool is_firmware_info_valid(); bool is_firmware_info_valid();
std::string get_string_from_fantype(FanType type); std::string get_string_from_fantype(int type);
/*for more extruder*/ /*for more extruder*/
bool is_enable_np{ false }; bool is_enable_np{ false };
@ -1180,6 +1188,8 @@ public:
void update_filament_list(); void update_filament_list();
void update_printer_preset_name(); void update_printer_preset_name();
void check_ams_filament_valid(); void check_ams_filament_valid();
int command_handle_response(const json &response);
}; };
class DeviceManager class DeviceManager

View File

@ -136,26 +136,25 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL); m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
m_line_top->SetBackgroundColour(wxColour(166, 169, 170)); m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
/*mode switch*/ /*mode switch*/
/* auto m_sizer_mode_switch = new wxBoxSizer(wxHORIZONTAL); /*auto m_sizer_mode_switch = new wxBoxSizer(wxHORIZONTAL);
m_mode_print = new SendModeSwitchButton(this, _L("Print"), true); m_mode_print = new SendModeSwitchButton(this, _L("Print"), true);
m_mode_send = new SendModeSwitchButton(this,_L("Save to printer"), false); m_mode_send = new SendModeSwitchButton(this,_L("Save to printer"), false);
m_sizer_mode_switch->Add(m_mode_print, 0, wxALIGN_CENTER, 0); m_sizer_mode_switch->Add(m_mode_print, 0, wxALIGN_CENTER, 0);
m_sizer_mode_switch->Add(0, 0, 0, wxLEFT, FromDIP(8)); m_sizer_mode_switch->Add(0, 0, 0, wxLEFT, FromDIP(8));
m_sizer_mode_switch->Add(m_mode_send,0, wxALIGN_CENTER, 0);*/ m_sizer_mode_switch->Add(m_mode_send,0, wxALIGN_CENTER, 0);
//m_mode_print->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { m_mode_print->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
// m_mode_print->setSelected(true); m_mode_print->setSelected(true);
// m_mode_send->setSelected(false); m_mode_send->setSelected(false);
// e.Skip(); e.Skip();
//}); });
//m_mode_send->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { m_mode_send->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
// m_mode_print->setSelected(false); m_mode_print->setSelected(false);
// m_mode_send->setSelected(true); m_mode_send->setSelected(true);
// e.Skip(); e.Skip();
//}); });*/
m_basic_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); m_basic_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_basic_panel->SetBackgroundColour(*wxWHITE); m_basic_panel->SetBackgroundColour(*wxWHITE);

View File

@ -330,7 +330,6 @@ void ExtruderImage::doRender(wxDC& dc)
dc.DrawBitmap(right_nozzle_bmp->bmp(), pot.x, pot.y + right_pipe_bmp->GetBmpSize().y); dc.DrawBitmap(right_nozzle_bmp->bmp(), pot.x, pot.y + right_pipe_bmp->GetBmpSize().y);
} }
else{ else{
ScalableBitmap* nozzle_bmp;
switch (m_single_ext_state) switch (m_single_ext_state)
{ {
case Slic3r::GUI::FILLED_LOAD: m_extruder_single_nozzle_filled_load; break; case Slic3r::GUI::FILLED_LOAD: m_extruder_single_nozzle_filled_load; break;
@ -1383,8 +1382,8 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
auto sizer = new wxBoxSizer(wxVERTICAL); auto sizer = new wxBoxSizer(wxVERTICAL);
wxWindowID nozzle_id = wxWindow::NewControlId(); wxWindowID nozzle_id = wxWindow::NewControlId();
m_tempCtrl_nozzle = new TempInput(parent, nozzle_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_NORMAL_TYPE, TEMP_BLANK_STR, wxString("monitor_nozzle_temp"), wxString("monitor_nozzle_temp_active"), m_tempCtrl_nozzle = new TempInput(parent, nozzle_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_MAIN_NOZZLE_TYPE, TEMP_BLANK_STR, wxString("monitor_nozzle_temp"),
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER); wxString("monitor_nozzle_temp_active"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
m_tempCtrl_nozzle->SetMinSize(TEMP_CTRL_MIN_SIZE_OF_SINGLE_NOZZLE); m_tempCtrl_nozzle->SetMinSize(TEMP_CTRL_MIN_SIZE_OF_SINGLE_NOZZLE);
m_tempCtrl_nozzle->SetMinTemp(nozzle_temp_range[0]); m_tempCtrl_nozzle->SetMinTemp(nozzle_temp_range[0]);
m_tempCtrl_nozzle->SetMaxTemp(nozzle_temp_range[1]); m_tempCtrl_nozzle->SetMaxTemp(nozzle_temp_range[1]);
@ -1487,10 +1486,10 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
m_switch_lamp->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal))); m_switch_lamp->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
line_sizer->Add(m_switch_lamp, 1, wxALIGN_CENTER | wxALL, 0); line_sizer->Add(m_switch_lamp, 1, wxALIGN_CENTER | wxALL, 0);
/*sizer->Add(line_sizer, 0, wxEXPAND, FromDIP(5)); //sizer->Add(line_sizer, 0, wxEXPAND, FromDIP(5));
line = new StaticLine(parent); line = new StaticLine(parent);
line->SetLineColour(STATIC_BOX_LINE_COL); line->SetLineColour(STATIC_BOX_LINE_COL);
sizer->Add(line, 0, wxEXPAND | wxLEFT | wxRIGHT, 12);*/ sizer->Add(line, 0, wxEXPAND | wxLEFT | wxRIGHT, 12);
m_fan_panel = new StaticBox(parent); m_fan_panel = new StaticBox(parent);
m_fan_panel->SetMinSize(MISC_BUTTON_PANEL_SIZE); m_fan_panel->SetMinSize(MISC_BUTTON_PANEL_SIZE);
@ -1500,6 +1499,7 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
m_fan_panel->SetCornerRadius(0); m_fan_panel->SetCornerRadius(0);
auto fan_line_sizer = new wxBoxSizer(wxHORIZONTAL); auto fan_line_sizer = new wxBoxSizer(wxHORIZONTAL);
/*
m_switch_nozzle_fan = new FanSwitchButton(m_fan_panel, m_bitmap_fan_on, m_bitmap_fan_off); m_switch_nozzle_fan = new FanSwitchButton(m_fan_panel, m_bitmap_fan_on, m_bitmap_fan_off);
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE); m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE); m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
@ -1558,14 +1558,27 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
m_switch_cham_fan->Bind(wxEVT_LEAVE_WINDOW, [this, parent](auto& e) { m_switch_cham_fan->Bind(wxEVT_LEAVE_WINDOW, [this, parent](auto& e) {
m_fan_panel->SetBackgroundColor(parent->GetBackgroundColour()); m_fan_panel->SetBackgroundColor(parent->GetBackgroundColour());
}); });
*/
m_switch_fan = new FanSwitchButton(m_fan_panel, m_bitmap_fan_on, m_bitmap_fan_off);
m_switch_fan->SetValue(false);
m_switch_fan->SetMinSize(MISC_BUTTON_1FAN_SIZE);
m_switch_fan->SetMaxSize(MISC_BUTTON_1FAN_SIZE);
m_switch_fan->SetPadding(FromDIP(1));
m_switch_fan->SetBorderWidth(0);
m_switch_fan->SetCornerRadius(0);
m_switch_fan->SetFont(::Label::Body_10);
m_switch_fan->SetTextColor(
StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int)StateColor::Disabled), std::make_pair(NORMAL_FAN_TEXT_COL, (int)StateColor::Normal)));
m_switch_fan->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {
m_fan_panel->SetBackgroundColor(wxColour(0, 174, 66));
});
fan_line_sizer->Add(0, 0, 0, wxLEFT, FromDIP(2)); m_switch_fan->Bind(wxEVT_LEAVE_WINDOW, [this, parent](auto& e) {
fan_line_sizer->Add(m_switch_nozzle_fan, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM , FromDIP(2)); m_fan_panel->SetBackgroundColor(parent->GetBackgroundColour());
fan_line_sizer->Add(m_switch_printing_fan, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, FromDIP(2)); });
fan_line_sizer->Add(m_switch_cham_fan, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM , FromDIP(2));
//fan_line_sizer->Add(m_switch_block_fan, 1, wxEXPAND | wxTOP | wxBOTTOM , FromDIP(2)); fan_line_sizer->Add(m_switch_fan, 1, wxEXPAND|wxALL, FromDIP(2));
fan_line_sizer->Add(0, 0, 0, wxLEFT, FromDIP(2));
m_fan_panel->SetSizer(fan_line_sizer); m_fan_panel->SetSizer(fan_line_sizer);
m_fan_panel->Layout(); m_fan_panel->Layout();
@ -1603,9 +1616,9 @@ void StatusBasePanel::reset_temp_misc_control()
m_switch_speed->SetValue(false); m_switch_speed->SetValue(false);
m_switch_lamp->SetLabels(_L("Lamp"), _L("Lamp")); m_switch_lamp->SetLabels(_L("Lamp"), _L("Lamp"));
m_switch_lamp->SetValue(false); m_switch_lamp->SetValue(false);
m_switch_nozzle_fan->SetValue(false); /*m_switch_nozzle_fan->SetValue(false);
m_switch_printing_fan->SetValue(false); m_switch_printing_fan->SetValue(false);
m_switch_cham_fan->SetValue(false); m_switch_cham_fan->SetValue(false);*/
} }
wxBoxSizer *StatusBasePanel::create_axis_control(wxWindow *parent) wxBoxSizer *StatusBasePanel::create_axis_control(wxWindow *parent)
@ -1697,6 +1710,84 @@ wxBoxSizer *StatusBasePanel::create_axis_control(wxWindow *parent)
return sizer; return sizer;
} }
//wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent)
//{
// wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
// wxBoxSizer *bSizer_z_ctrl = new wxBoxSizer(wxVERTICAL);
// auto panel = new wxPanel(parent, wxID_ANY);
// panel->SetBackgroundColour(*wxWHITE);
//
// panel->SetSize(wxSize(FromDIP(278), -1));
// panel->SetMinSize(wxSize(FromDIP(278), -1));
// panel->SetMaxSize(wxSize(FromDIP(278), -1));
//
// StateColor z_10_ctrl_bg(std::pair<wxColour, int>(BUTTON_PRESS_COL, StateColor::Pressed), std::pair<wxColour, int>(BUTTON_NORMAL1_COL, StateColor::Normal));
// StateColor z_10_ctrl_bd(std::pair<wxColour, int>(BUTTON_HOVER_COL, StateColor::Hovered), std::pair<wxColour, int>(BUTTON_NORMAL1_COL, StateColor::Normal));
//
// StateColor z_1_ctrl_bg(std::pair<wxColour, int>(BUTTON_PRESS_COL, StateColor::Pressed), std::pair<wxColour, int>(BUTTON_NORMAL2_COL, StateColor::Normal));
// StateColor z_1_ctrl_bd(std::pair<wxColour, int>(BUTTON_HOVER_COL, StateColor::Hovered), std::pair<wxColour, int>(BUTTON_NORMAL2_COL, StateColor::Normal));
//
// bSizer_z_ctrl->AddStretchSpacer();
// m_bpButton_z_10 = new Button(panel, wxString("10"), "monitor_bed_up", 0, FromDIP(15));
// m_bpButton_z_10->SetFont(::Label::Body_13);
// m_bpButton_z_10->SetBorderWidth(2);
// m_bpButton_z_10->SetBackgroundColor(z_10_ctrl_bg);
// m_bpButton_z_10->SetBorderColor(z_10_ctrl_bd);
// m_bpButton_z_10->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int)StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int)StateColor::Normal)));
// m_bpButton_z_10->SetMinSize(Z_BUTTON_SIZE);
// m_bpButton_z_10->SetCornerRadius(0);
//
// bSizer_z_ctrl->Add(m_bpButton_z_10, 0, wxEXPAND | wxALL, 0);
//
// m_bpButton_z_1 = new Button(panel, wxString(" 1"), "monitor_bed_up", 0, FromDIP(15));
// m_bpButton_z_1->SetFont(::Label::Body_13);
// m_bpButton_z_1->SetBorderWidth(2);
// m_bpButton_z_1->SetBackgroundColor(z_1_ctrl_bg);
// m_bpButton_z_1->SetBorderColor(z_1_ctrl_bd);
// m_bpButton_z_1->SetMinSize(Z_BUTTON_SIZE);
// m_bpButton_z_1->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int)StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int)StateColor::Normal)));
//
// bSizer_z_ctrl->Add(m_bpButton_z_1, 0, wxEXPAND | wxALL, 0);
// //bSizer_z_ctrl->Add(0, FromDIP(6), 0, wxEXPAND, 0);
//
// m_staticText_z_tip = new wxStaticText(panel, wxID_ANY, _L("Bed"), wxDefaultPosition, wxDefaultSize, 0);
// m_staticText_z_tip->SetFont(::Label::Body_13);
// if (wxGetApp().app_config->get("language") == "de_DE") m_staticText_z_tip->SetFont(::Label::Body_11);
// m_staticText_z_tip->Wrap(-1);
// m_staticText_z_tip->SetForegroundColour(TEXT_LIGHT_FONT_COL);
// bSizer_z_ctrl->Add(m_staticText_z_tip, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, FromDIP(5));
//
// m_bpButton_z_down_1 = new Button(panel, wxString(" 1"), "monitor_bed_down", 0, FromDIP(15));
// m_bpButton_z_down_1->SetFont(::Label::Body_13);
// m_bpButton_z_down_1->SetBorderWidth(2);
// m_bpButton_z_down_1->SetBackgroundColor(z_1_ctrl_bg);
// m_bpButton_z_down_1->SetBorderColor(z_1_ctrl_bd);
// m_bpButton_z_down_1->SetMinSize(Z_BUTTON_SIZE);
// m_bpButton_z_down_1->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int)StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int)StateColor::Normal)));
// bSizer_z_ctrl->Add(m_bpButton_z_down_1, 0, wxEXPAND | wxALL, 0);
//
// m_bpButton_z_down_10 = new Button(panel, wxString("10"), "monitor_bed_down", 0, FromDIP(15));
// m_bpButton_z_down_10->SetFont(::Label::Body_13);
// m_bpButton_z_down_10->SetBorderWidth(2);
// m_bpButton_z_down_10->SetBackgroundColor(z_10_ctrl_bg);
// m_bpButton_z_down_10->SetBorderColor(z_10_ctrl_bd);
// m_bpButton_z_down_10->SetMinSize(Z_BUTTON_SIZE);
// m_bpButton_z_down_10->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int)StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int)StateColor::Normal)));
//
// bSizer_z_ctrl->Add(m_bpButton_z_down_10, 0, wxEXPAND | wxALL, 0);
// bSizer_z_ctrl->Add(0, FromDIP(16), 0, wxEXPAND, 0);
//
// /*panel->SetSizer(bSizer_z_ctrl);
// panel->Layout();
// sizer->Add(panel, 1, wxEXPAND, 0);*/
// /*m_staticText_xy = new wxStaticText(parent, wxID_ANY, _L("X/Y Axis"), wxDefaultPosition, wxDefaultSize, 0);
// m_staticText_xy->Wrap(-1);
//
// m_staticText_xy->SetForegroundColour(TEXT_LIGHT_FONT_COL);
// sizer->Add(m_staticText_xy, 0, wxBOTTOM | wxALIGN_CENTER_HORIZONTAL, FromDIP(5));*/
// return sizer;
//}
wxPanel *StatusBasePanel::create_bed_control(wxWindow *parent) wxPanel *StatusBasePanel::create_bed_control(wxWindow *parent)
{ {
wxBoxSizer *bSizer_z_ctrl = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *bSizer_z_ctrl = new wxBoxSizer(wxHORIZONTAL);
@ -2043,7 +2134,6 @@ void StatusPanel::update_camera_state(MachineObject* obj)
StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name) StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name)
: StatusBasePanel(parent, id, pos, size, style) : StatusBasePanel(parent, id, pos, size, style)
, m_fan_control_popup(new FanControlPopup(this))
{ {
init_scaled_buttons(); init_scaled_buttons();
m_buttons.push_back(m_bpButton_z_10); m_buttons.push_back(m_bpButton_z_10);
@ -2058,9 +2148,9 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co
m_score_data->rating_id = -1; m_score_data->rating_id = -1;
/* set default values */ /* set default values */
m_switch_lamp->SetValue(false); m_switch_lamp->SetValue(false);
m_switch_printing_fan->SetValue(false); /*m_switch_printing_fan->SetValue(false);
m_switch_nozzle_fan->SetValue(false); m_switch_nozzle_fan->SetValue(false);
m_switch_cham_fan->SetValue(false); m_switch_cham_fan->SetValue(false);*/
//m_switch_fan->SetValue(false); //m_switch_fan->SetValue(false);
/* set default enable state */ /* set default enable state */
@ -2103,11 +2193,11 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co
m_tempCtrl_chamber->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(StatusPanel::on_cham_temp_kill_focus), NULL, this); m_tempCtrl_chamber->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(StatusPanel::on_cham_temp_kill_focus), NULL, this);
m_tempCtrl_chamber->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(StatusPanel::on_cham_temp_set_focus), NULL, this); m_tempCtrl_chamber->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(StatusPanel::on_cham_temp_set_focus), NULL, this);
m_switch_lamp->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_lamp_switch), NULL, this); m_switch_lamp->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_lamp_switch), NULL, this);
m_switch_nozzle_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); // TODO //m_switch_nozzle_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); // TODO
m_switch_printing_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); //m_switch_printing_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
m_switch_cham_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); //m_switch_cham_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
//m_switch_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); // TODO m_switch_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); // TODO
//m_switch_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); //m_switch_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
//m_switch_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); //m_switch_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
@ -2167,13 +2257,13 @@ StatusPanel::~StatusPanel()
m_tempCtrl_nozzle->Disconnect(wxEVT_KILL_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_kill_focus), NULL, this); m_tempCtrl_nozzle->Disconnect(wxEVT_KILL_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_kill_focus), NULL, this);
m_tempCtrl_nozzle->Disconnect(wxEVT_SET_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_set_focus), NULL, this); m_tempCtrl_nozzle->Disconnect(wxEVT_SET_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_set_focus), NULL, this);
m_switch_lamp->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_lamp_switch), NULL, this); m_switch_lamp->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_lamp_switch), NULL, this);
m_switch_nozzle_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); /*m_switch_nozzle_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
m_switch_printing_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); m_switch_printing_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
m_switch_cham_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); m_switch_cham_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);*/
//m_switch_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); //m_switch_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
//m_switch_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); //m_switch_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
//m_switch_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); m_switch_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
m_bpButton_xy->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_xy), NULL, this); m_bpButton_xy->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_xy), NULL, this);
m_bpButton_z_10->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_up_10), NULL, this); m_bpButton_z_10->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_up_10), NULL, this);
@ -2669,11 +2759,11 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area)
} else { } else {
m_switch_speed->Enable(); m_switch_speed->Enable();
m_switch_lamp->Enable(); m_switch_lamp->Enable();
m_switch_nozzle_fan->Enable(); /*m_switch_nozzle_fan->Enable();
m_switch_printing_fan->Enable(); m_switch_printing_fan->Enable();
m_switch_cham_fan->Enable(); m_switch_cham_fan->Enable();*/
//m_switch_fan->Enable(); m_switch_fan->Enable();
m_bpButton_xy->Enable(); m_bpButton_xy->Enable();
m_bpButton_z_10->Enable(); m_bpButton_z_10->Enable();
@ -2703,10 +2793,10 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area)
m_switch_speed->Enable(false); m_switch_speed->Enable(false);
m_switch_speed->SetValue(false); m_switch_speed->SetValue(false);
m_switch_lamp->Enable(false); m_switch_lamp->Enable(false);
m_switch_nozzle_fan->Enable(false); /*m_switch_nozzle_fan->Enable(false);
m_switch_printing_fan->Enable(false); m_switch_printing_fan->Enable(false);
m_switch_cham_fan->Enable(false); m_switch_cham_fan->Enable(false);*/
//m_switch_fan->Enable(false); m_switch_fan->Enable(false);
} else { } else {
m_tempCtrl_nozzle->Enable(); m_tempCtrl_nozzle->Enable();
m_tempCtrl_nozzle_deputy->Enable(); m_tempCtrl_nozzle_deputy->Enable();
@ -2715,10 +2805,10 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area)
m_switch_speed->Enable(); m_switch_speed->Enable();
m_switch_speed->SetValue(true); m_switch_speed->SetValue(true);
m_switch_lamp->Enable(); m_switch_lamp->Enable();
m_switch_nozzle_fan->Enable(); /*m_switch_nozzle_fan->Enable();
m_switch_printing_fan->Enable(); m_switch_printing_fan->Enable();
m_switch_cham_fan->Enable(); m_switch_cham_fan->Enable();*/
//m_switch_fan->Enable(); m_switch_fan->Enable();
} }
} }
@ -2860,98 +2950,15 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj)
// update extruder icon // update extruder icon
update_extruder_status(obj); update_extruder_status(obj);
bool is_suppt_part_fun = true;
bool is_suppt_aux_fun = obj->is_support_aux_fan; bool is_suppt_aux_fun = obj->is_support_aux_fan;
bool is_suppt_cham_fun = obj->is_support_chamber_fan; bool is_suppt_cham_fun = obj->is_support_chamber_fan;
if (m_fan_control_popup) {
m_fan_control_popup->update_fan_data(obj);
}
//update cham fan //update cham fan
if (m_current_support_cham_fan != is_suppt_cham_fun) {
if (is_suppt_cham_fun) {
m_switch_cham_fan->Show();
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
m_switch_printing_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
m_switch_printing_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
}
else {
m_switch_cham_fan->Hide();
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_2FAN_SIZE);
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_2FAN_SIZE);
m_switch_printing_fan->SetMinSize(MISC_BUTTON_2FAN_SIZE);
m_switch_printing_fan->SetMaxSize(MISC_BUTTON_2FAN_SIZE);
}
m_misc_ctrl_sizer->Layout();
}
if (m_current_support_aux_fan != is_suppt_aux_fun) {
if (is_suppt_aux_fun) {
if (!m_switch_printing_fan->IsShown()) {
m_switch_printing_fan->Show();
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
m_switch_cham_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
m_switch_cham_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
}
}
else {
if (m_switch_printing_fan->IsShown()) {
m_switch_printing_fan->Hide();
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_2FAN_SIZE);
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_2FAN_SIZE);
m_switch_cham_fan->SetMinSize(MISC_BUTTON_2FAN_SIZE);
m_switch_cham_fan->SetMaxSize(MISC_BUTTON_2FAN_SIZE);
}
}
m_misc_ctrl_sizer->Layout();
}
if (!is_suppt_aux_fun && !is_suppt_cham_fun) {
if (!m_switch_nozzle_fan->IsShown()) {
m_switch_nozzle_fan->Show();
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_1FAN_SIZE);
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_1FAN_SIZE);
m_misc_ctrl_sizer->Layout();
}
}
// nozzle fan
if (m_switch_nozzle_fan_timeout > 0) {
m_switch_nozzle_fan_timeout--;
} else{
int speed = round(obj->cooling_fan_speed / float(25.5));
m_switch_nozzle_fan->SetValue(speed > 0 ? true : false);
m_switch_nozzle_fan->setFanValue(speed * 10);
if (m_fan_control_popup) {
m_fan_control_popup->update_fan_data(MachineObject::FanType::COOLING_FAN, obj);
}
}
// printing fan
if (m_switch_printing_fan_timeout > 0) {
m_switch_printing_fan_timeout--;
}else{
int speed = round(obj->big_fan1_speed / float(25.5));
m_switch_printing_fan->SetValue(speed > 0 ? true : false);
m_switch_printing_fan->setFanValue(speed * 10);
if (m_fan_control_popup) {
m_fan_control_popup->update_fan_data(MachineObject::FanType::BIG_COOLING_FAN, obj);
}
}
// cham fan
if (m_switch_cham_fan_timeout > 0) {
m_switch_cham_fan_timeout--;
}else{
int speed = round(obj->big_fan2_speed / float(25.5));
m_switch_cham_fan->SetValue(speed > 0 ? true : false);
m_switch_cham_fan->setFanValue(speed * 10);
if (m_fan_control_popup) {
m_fan_control_popup->update_fan_data(MachineObject::FanType::CHAMBER_FAN, obj);
}
}
/*other*/
bool light_on = obj->chamber_light != MachineObject::LIGHT_EFFECT::LIGHT_EFFECT_OFF; bool light_on = obj->chamber_light != MachineObject::LIGHT_EFFECT::LIGHT_EFFECT_OFF;
BOOST_LOG_TRIVIAL(trace) << "light: " << light_on ? "on" : "off"; BOOST_LOG_TRIVIAL(trace) << "light: " << light_on ? "on" : "off";
if (m_switch_lamp_timeout > 0) if (m_switch_lamp_timeout > 0)
@ -2970,16 +2977,14 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj)
wxString text_speed = wxString::Format("%d%%", obj->printing_speed_mag); wxString text_speed = wxString::Format("%d%%", obj->printing_speed_mag);
m_switch_speed->SetLabels(text_speed, text_speed); m_switch_speed->SetLabels(text_speed, text_speed);
} }
m_current_support_aux_fan = is_suppt_aux_fun;
m_current_support_cham_fan = is_suppt_cham_fun;
} }
void StatusPanel::update_extruder_status(MachineObject* obj) void StatusPanel::update_extruder_status(MachineObject* obj)
{ {
if (!obj) return; if (!obj) return;
wxBitmap tmp; //wait add
if (obj->is_filament_at_extruder()) {
/*if (obj->is_filament_at_extruder()) {
if (obj->extruder_axis_status == MachineObject::ExtruderAxisStatus::LOAD) { if (obj->extruder_axis_status == MachineObject::ExtruderAxisStatus::LOAD) {
tmp = m_bitmap_extruder_filled_load; tmp = m_bitmap_extruder_filled_load;
} }
@ -2989,17 +2994,11 @@ void StatusPanel::update_extruder_status(MachineObject* obj)
} }
else { else {
if (obj->extruder_axis_status == MachineObject::ExtruderAxisStatus::LOAD) { if (obj->extruder_axis_status == MachineObject::ExtruderAxisStatus::LOAD) {
tmp = m_bitmap_extruder_empty_load; m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder_empty_load);
} else {
m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder_empty_unload);
} }
else { }*/
tmp = m_bitmap_extruder_empty_unload;
}
}
if (!tmp.IsSameAs(m_bitmap_extruder_now)) {
m_bitmap_extruder_now = tmp;
//m_bitmap_extruder_img->SetBitmap(tmp);
}
} }
void StatusPanel::update_ams(MachineObject *obj) void StatusPanel::update_ams(MachineObject *obj)
@ -4506,23 +4505,23 @@ void StatusPanel::on_fan_changed(wxCommandEvent& event)
{ {
auto type = event.GetInt(); auto type = event.GetInt();
auto speed = atoi(event.GetString().c_str()); auto speed = atoi(event.GetString().c_str());
//set_hold_count(this->m_switch_cham_fan_timeout); set_hold_count(this->m_switch_cham_fan_timeout);
//return; return;
if (type == MachineObject::FanType::COOLING_FAN) { if (type == MachineObject::FanType::COOLING_FAN) {
set_hold_count(this->m_switch_nozzle_fan_timeout); set_hold_count(this->m_switch_nozzle_fan_timeout);
m_switch_nozzle_fan->SetValue(speed > 0 ? true : false); /*m_switch_nozzle_fan->SetValue(speed > 0 ? true : false);
m_switch_nozzle_fan->setFanValue(speed * 10); m_switch_nozzle_fan->setFanValue(speed * 10);*/
} }
else if (type == MachineObject::FanType::BIG_COOLING_FAN) { else if (type == MachineObject::FanType::BIG_COOLING_FAN) {
set_hold_count(this->m_switch_printing_fan_timeout); set_hold_count(this->m_switch_printing_fan_timeout);
m_switch_printing_fan->SetValue(speed > 0 ? true : false); /*m_switch_printing_fan->SetValue(speed > 0 ? true : false);
m_switch_printing_fan->setFanValue(speed * 10); m_switch_printing_fan->setFanValue(speed * 10);*/
} }
else if (type == MachineObject::FanType::CHAMBER_FAN) { else if (type == MachineObject::FanType::CHAMBER_FAN) {
set_hold_count(this->m_switch_cham_fan_timeout); set_hold_count(this->m_switch_cham_fan_timeout);
m_switch_cham_fan->SetValue(speed > 0 ? true : false); /*m_switch_cham_fan->SetValue(speed > 0 ? true : false);
m_switch_cham_fan->setFanValue(speed * 10); m_switch_cham_fan->setFanValue(speed * 10);*/
} }
} }
@ -4651,29 +4650,35 @@ void StatusPanel::on_printing_fan_switch(wxCommandEvent &event)
void StatusPanel::on_nozzle_fan_switch(wxCommandEvent &event) void StatusPanel::on_nozzle_fan_switch(wxCommandEvent &event)
{ {
m_fan_control_popup->Destroy(); if (m_fan_control_popup) {
m_fan_control_popup = nullptr; m_fan_control_popup->Destroy();
m_fan_control_popup = new FanControlPopup(this); m_fan_control_popup = nullptr;
if (obj) {
m_fan_control_popup->show_cham_fan(obj->is_support_chamber_fan);
m_fan_control_popup->show_aux_fan(obj->is_support_aux_fan);
} }
if (!obj)
return;
auto pos = m_switch_nozzle_fan->GetScreenPosition(); if (!obj->is_enable_np)
pos.y = pos.y + m_switch_nozzle_fan->GetSize().y; obj->converse_to_duct(true, obj->is_support_aux_fan, obj->is_support_chamber_fan);
m_fan_control_popup = new FanControlPopupNew(this, obj, obj->m_air_duct_data);
auto pos = m_switch_fan->GetScreenPosition();
pos.y = pos.y + m_switch_fan->GetSize().y;
int display_idx = wxDisplay::GetFromWindow(this); int display_idx = wxDisplay::GetFromWindow(this);
auto display = wxDisplay(display_idx).GetClientArea(); auto display = wxDisplay(display_idx).GetClientArea();
wxSize screenSize = wxSize(display.GetWidth(), display.GetHeight()); wxSize screenSize = wxSize(display.GetWidth(), display.GetHeight());
auto fan_popup_size = m_fan_control_popup->GetSize(); wxSize fan_popup_size = m_fan_control_popup->GetSize();
pos.x -= FromDIP(150);
pos.y -= FromDIP(20);
if (screenSize.y - fan_popup_size.y < FromDIP(300)) { if (screenSize.y - fan_popup_size.y < FromDIP(300)) {
pos.x += FromDIP(50);
pos.y = (screenSize.y - fan_popup_size.y) / 2; pos.y = (screenSize.y - fan_popup_size.y) / 2;
} }
m_fan_control_popup->SetPosition(pos); m_fan_control_popup->SetPosition(pos);
m_fan_control_popup->Popup(); m_fan_control_popup->Popup();
@ -5006,12 +5011,15 @@ void StatusPanel::msw_rescale()
m_switch_lamp->SetImages(m_bitmap_lamp_on, m_bitmap_lamp_off); m_switch_lamp->SetImages(m_bitmap_lamp_on, m_bitmap_lamp_off);
m_switch_lamp->SetMinSize(MISC_BUTTON_2FAN_SIZE); m_switch_lamp->SetMinSize(MISC_BUTTON_2FAN_SIZE);
m_switch_lamp->Rescale(); m_switch_lamp->Rescale();
m_switch_nozzle_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off); /*m_switch_nozzle_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off);
m_switch_nozzle_fan->Rescale(); m_switch_nozzle_fan->Rescale();
m_switch_printing_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off); m_switch_printing_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off);
m_switch_printing_fan->Rescale(); m_switch_printing_fan->Rescale();
m_switch_cham_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off); m_switch_cham_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off);
m_switch_cham_fan->Rescale(); m_switch_cham_fan->Rescale();*/
m_switch_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off);
m_switch_fan->Rescale();
//m_switch_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off); //m_switch_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off);
//m_switch_fan->Rescale(); //m_switch_fan->Rescale();

View File

@ -426,8 +426,6 @@ protected:
int m_temp_bed_timeout {0}; int m_temp_bed_timeout {0};
TempInput * m_tempCtrl_chamber; TempInput * m_tempCtrl_chamber;
int m_temp_chamber_timeout {0}; int m_temp_chamber_timeout {0};
bool m_current_support_cham_fan{true};
bool m_current_support_aux_fan{true};
FanSwitchButton *m_switch_nozzle_fan; FanSwitchButton *m_switch_nozzle_fan;
int m_switch_nozzle_fan_timeout{0}; int m_switch_nozzle_fan_timeout{0};
FanSwitchButton *m_switch_printing_fan; FanSwitchButton *m_switch_printing_fan;
@ -564,7 +562,7 @@ protected:
SecondaryCheckDialog* sdcard_hint_dlg = nullptr; SecondaryCheckDialog* sdcard_hint_dlg = nullptr;
SecondaryCheckDialog* axis_go_home_dlg = nullptr; SecondaryCheckDialog* axis_go_home_dlg = nullptr;
FanControlPopup* m_fan_control_popup{nullptr}; FanControlPopupNew* m_fan_control_popup{nullptr};
ExtrusionCalibration *m_extrusion_cali_dlg{nullptr}; ExtrusionCalibration *m_extrusion_cali_dlg{nullptr};

View File

@ -15,6 +15,8 @@ wxDEFINE_EVENT(EVT_FAN_ADD, wxCommandEvent);
wxDEFINE_EVENT(EVT_FAN_DEC, wxCommandEvent); wxDEFINE_EVENT(EVT_FAN_DEC, wxCommandEvent);
wxDEFINE_EVENT(EVT_FAN_CHANGED, wxCommandEvent); wxDEFINE_EVENT(EVT_FAN_CHANGED, wxCommandEvent);
constexpr int time_out = 20;
/************************************************* /*************************************************
Description:Fan Description:Fan
**************************************************/ **************************************************/
@ -174,8 +176,8 @@ void FanOperate::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, con
wxWindow::Create(parent, id, pos, size, wxBORDER_NONE); wxWindow::Create(parent, id, pos, size, wxBORDER_NONE);
SetBackgroundColour(*wxWHITE); SetBackgroundColour(*wxWHITE);
m_bitmap_add = ScalableBitmap(this, "fan_control_add", FromDIP(11)); m_bitmap_add = ScalableBitmap(this, "fan_control_add", FromDIP(24));
m_bitmap_decrease = ScalableBitmap(this, "fan_control_decrease", FromDIP(11)); m_bitmap_decrease = ScalableBitmap(this, "fan_control_decrease", FromDIP(24));
SetMinSize(wxSize(FromDIP(SIZE_OF_FAN_OPERATE.x), FromDIP(SIZE_OF_FAN_OPERATE.y))); SetMinSize(wxSize(FromDIP(SIZE_OF_FAN_OPERATE.x), FromDIP(SIZE_OF_FAN_OPERATE.y)));
Bind(wxEVT_PAINT, &FanOperate::paintEvent, this); Bind(wxEVT_PAINT, &FanOperate::paintEvent, this);
@ -189,15 +191,15 @@ void FanOperate::on_left_down(wxMouseEvent& event)
auto mouse_pos = ClientToScreen(event.GetPosition()); auto mouse_pos = ClientToScreen(event.GetPosition());
auto win_pos = ClientToScreen(wxPoint(0, 0)); auto win_pos = ClientToScreen(wxPoint(0, 0));
auto decrease_fir = GetSize().x / 3 + win_pos.x; auto decrease_fir = FromDIP(24);
auto add_fir = GetSize().x / 3 * 2 + win_pos.x; auto add_fir = GetSize().x - FromDIP(24);
if (mouse_pos.x > win_pos.x && mouse_pos.x < decrease_fir && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + GetSize().y)) { if (mouse_pos.x > win_pos.x && mouse_pos.x < (decrease_fir + win_pos.x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + GetSize().y)) {
decrease_fan_speeds(); decrease_fan_speeds();
return; return;
} }
if (mouse_pos.x > add_fir && mouse_pos.x < (win_pos.x + GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + GetSize().y)) { if (mouse_pos.x > (add_fir + win_pos.x) && mouse_pos.x < (win_pos.x + GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + GetSize().y)) {
add_fan_speeds(); add_fan_speeds();
return; return;
} }
@ -277,112 +279,110 @@ void FanOperate::doRender(wxDC& dc)
//splt //splt
auto left_fir = size.x / 3; auto left_fir = size.x / 3;
dc.DrawLine(left_fir, FromDIP(4), left_fir, size.y - FromDIP(4)); dc.DrawBitmap(m_bitmap_decrease.bmp(), 0, (size.y - m_bitmap_decrease.GetBmpHeight()) / 2);
dc.DrawLine(left_fir * 2, FromDIP(4), left_fir * 2, size.y - FromDIP(4)); dc.DrawBitmap(m_bitmap_add.bmp(), size.x - m_bitmap_add.GetBmpWidth(), (size.y - m_bitmap_add.GetBmpSize().y) / 2);
dc.DrawBitmap(m_bitmap_decrease.bmp(), (left_fir - m_bitmap_decrease.GetBmpSize().x) / 2, (size.y - m_bitmap_decrease.GetBmpSize().y) / 2); wxPoint pot(m_bitmap_decrease.GetBmpWidth(), (size.y - m_bitmap_decrease.GetBmpHeight()) / 2);
dc.DrawBitmap(m_bitmap_add.bmp(), (left_fir * 2 + (left_fir - m_bitmap_decrease.GetBmpSize().x) / 2), (size.y - m_bitmap_add.GetBmpSize().y) / 2); dc.DrawLine(pot.x, 0, pot.x, size.y);
dc.DrawLine(size.x - m_bitmap_add.GetBmpWidth(), 0, size.x - m_bitmap_add.GetBmpWidth(), size.y);
//txt //txt
dc.SetFont(::Label::Body_12); dc.SetFont(::Label::Body_12);
dc.SetTextForeground(StateColor::darkModeColorFor(wxColour(0x898989))); dc.SetTextForeground(StateColor::darkModeColorFor(wxColour(0x898989)));
wxString text = wxString::Format("%d%%", 10); wxString text = wxString::Format("%d%%", m_current_speeds * 10);
wxSize text_size = dc.GetTextExtent(text); wxSize text_size = dc.GetTextExtent(text);
dc.DrawText(text, wxPoint(left_fir + (left_fir- text_size.x) / 2, (size.y- text_size.y) / 2)); auto text_width = size.x - m_bitmap_decrease.GetBmpWidth() * 2;
dc.DrawText(text, wxPoint(pot.x + (text_width - text_size.x) / 2, (size.y - text_size.y) / 2));
} }
void FanOperate::msw_rescale() { void FanOperate::msw_rescale() {
} }
/************************************************* static void nop_deleter_fan_control(FanControlNew* ){}
Description:FanControl /*************************************************
Description:FanControlNew
**************************************************/ **************************************************/
FanControl::FanControl(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size) FanControlNew::FanControlNew(wxWindow *parent, const AirDuctData &fan_data, int mode_id, int part_id, wxWindowID id, const wxPoint &pos, const wxSize &size)
:wxWindow(parent, id, pos, size) : wxWindow(parent, id, pos, size)
, m_fan_data(fan_data)
, m_mode_id(mode_id)
, m_part_id(part_id)
{ {
auto m_bitmap_fan = new ScalableBitmap(this, "fan_icon", 18); SetMaxSize(wxSize(FromDIP(180), FromDIP(80)));
m_bitmap_toggle_off = new ScalableBitmap(this, "toggle_off", 14); SetMinSize(wxSize(FromDIP(180), FromDIP(80)));
m_bitmap_toggle_on = new ScalableBitmap(this, "toggle_on", 14); auto m_bitmap_fan = new ScalableBitmap(this, "fan_icon", 20);
m_bitmap_toggle_off = new ScalableBitmap(this, "toggle_off", 16);
m_bitmap_toggle_on = new ScalableBitmap(this, "toggle_on", 16);
SetBackgroundColour(wxColour(248, 248, 248));
SetBackgroundColour(*wxWHITE);
wxBoxSizer* m_sizer_main = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* m_sizer_main = new wxBoxSizer(wxHORIZONTAL);
m_fan = new Fan(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); //m_sizer_main->Add(0, 0, 0, wxLEFT, FromDIP(18));
m_sizer_main->Add(m_fan, 1, wxEXPAND | wxALL, 0);
m_sizer_main->Add(0, 0, 0, wxLEFT, FromDIP(18));
wxBoxSizer* sizer_control = new wxBoxSizer(wxVERTICAL); wxBoxSizer* sizer_control = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* sizer_control_top = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sizer_control_top = new wxBoxSizer(wxHORIZONTAL);
m_sizer_control_bottom = new wxBoxSizer(wxVERTICAL);
auto m_static_bitmap_fan = new wxStaticBitmap(this, wxID_ANY, m_bitmap_fan->bmp(), wxDefaultPosition, wxDefaultSize); auto m_static_bitmap_fan = new wxStaticBitmap(this, wxID_ANY, m_bitmap_fan->bmp(), wxDefaultPosition, wxDefaultSize);
m_static_name = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END|wxALIGN_CENTER_HORIZONTAL); m_static_name = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END | wxALIGN_CENTER_HORIZONTAL);
m_static_name->SetForegroundColour(wxColour(DRAW_TEXT_COLOUR)); m_static_name->SetForegroundColour(wxColour(DRAW_HEAD_TEXT_COLOUR));
m_static_name->SetBackgroundColour(*wxWHITE); m_static_name->SetBackgroundColour(wxColour(248, 248, 248));
m_static_name->SetMinSize(wxSize(FromDIP(50), -1)); m_static_name->SetFont(Label::Head_18);
m_static_name->SetMaxSize(wxSize(FromDIP(50), -1)); m_static_name->SetMinSize(wxSize(FromDIP(100), -1));
m_static_name->SetMaxSize(wxSize(FromDIP(100), -1));
m_switch_button = new wxStaticBitmap(this, wxID_ANY, m_bitmap_toggle_off->bmp(), wxDefaultPosition, wxDefaultSize, 0); m_switch_button = new wxStaticBitmap(this, wxID_ANY, m_bitmap_toggle_off->bmp(), wxDefaultPosition, wxDefaultSize, 0);
m_switch_button->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_HAND); }); m_switch_button->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_HAND); });
m_switch_button->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_RIGHT_ARROW); }); m_switch_button->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_RIGHT_ARROW); });
m_switch_button->Bind(wxEVT_LEFT_DOWN, &FanControl::on_swith_fan, this); m_switch_button->Bind(wxEVT_LEFT_DOWN, &FanControlNew::on_swith_fan, this);
sizer_control_top->Add(m_static_bitmap_fan, 0, wxALIGN_CENTER, 5); sizer_control_top->Add(m_static_bitmap_fan, 0, wxLEFT | wxTOP, FromDIP(8));
sizer_control_top->Add(m_static_name, 0, wxALIGN_CENTER, 0); sizer_control_top->Add(m_static_name, 0, wxLEFT | wxTOP, FromDIP(5));
sizer_control_top->Add( 0, 0, 1, wxEXPAND, 0 ); sizer_control_top->Add(0, 0, 1, wxEXPAND, 0);
sizer_control_top->Add(m_switch_button, 0, wxALIGN_CENTER, 0); sizer_control_top->Add(m_switch_button, 0, wxALIGN_RIGHT | wxRIGHT | wxTOP, FromDIP(10));
sizer_control->Add(sizer_control_top, 0, wxEXPAND, 0);
sizer_control->Add(sizer_control_top, 0, wxALIGN_CENTER, 0); m_static_status_name = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END | wxALIGN_CENTER_HORIZONTAL);
sizer_control->Add(0, 0, 0, wxTOP, FromDIP(15)); m_static_status_name->SetForegroundColour(wxColour(0x00AE42));
m_static_status_name->SetBackgroundColour(wxColour(248, 248, 248));
m_static_status_name->SetFont(Label::Head_18);
m_static_status_name->SetMinSize(wxSize(FromDIP(100), -1));
m_static_status_name->SetMaxSize(wxSize(FromDIP(100), -1));
m_fan_operate = new FanOperate(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); m_fan_operate = new FanOperate(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
sizer_control->Add(m_fan_operate, 0, wxALIGN_CENTER, 0);
m_fan_operate->Bind(EVT_FAN_SWITCH_ON, [this](const wxCommandEvent &e) {
m_current_speed = e.GetInt();
m_switch_button->SetBitmap(m_bitmap_toggle_on->bmp());
m_switch_fan = true;
});
m_fan_operate->Bind(EVT_FAN_SWITCH_OFF, [this](const wxCommandEvent &e) {
m_current_speed = e.GetInt();
m_switch_button->SetBitmap(m_bitmap_toggle_off->bmp());
m_switch_fan = false;
});
m_fan_operate->Bind(EVT_FAN_ADD, [this](const wxCommandEvent &e) {
m_current_speed = e.GetInt();
command_control_fan();
});
m_sizer_control_bottom->Add(m_static_status_name, 0, wxALL, FromDIP(10));
m_sizer_control_bottom->Add(m_fan_operate, 0, wxALL, FromDIP(10));
sizer_control->Add(m_sizer_control_bottom, 0, wxALL, 0);
m_sizer_main->Add(sizer_control, 0, wxALIGN_CENTER, 0); m_sizer_main->Add(sizer_control, 0, wxALIGN_CENTER, 0);
update_mode();
this->SetSizer(m_sizer_main); this->SetSizer(m_sizer_main);
this->Layout(); this->Layout();
m_sizer_main->Fit(this); m_sizer_main->Fit(this);
m_fan_operate->Bind(EVT_FAN_SWITCH_ON, [this](wxCommandEvent& e) {
m_current_speed = e.GetInt();
m_switch_button->SetBitmap(m_bitmap_toggle_on->bmp());
m_switch_fan = true;
m_fan->set_fan_speeds(m_current_speed);
});
m_fan_operate->Bind(EVT_FAN_SWITCH_OFF, [this](wxCommandEvent& e) {
m_current_speed = e.GetInt();
m_switch_button->SetBitmap(m_bitmap_toggle_off->bmp());
m_switch_fan = false;
m_fan->set_fan_speeds(m_current_speed);
});
m_fan_operate->Bind(EVT_FAN_ADD, [this](wxCommandEvent& e) {
m_current_speed = e.GetInt();
m_fan->set_fan_speeds(m_current_speed);
command_control_fan();
});
m_fan_operate->Bind(EVT_FAN_DEC, [this](wxCommandEvent& e) {
m_current_speed = e.GetInt();
m_fan->set_fan_speeds(m_current_speed);
command_control_fan();
});
} }
void FanControl::on_left_down(wxMouseEvent& evt) void FanControlNew::on_left_down(wxMouseEvent& evt)
{ {
auto mouse_pos = ClientToScreen(evt.GetPosition()); auto mouse_pos = ClientToScreen(evt.GetPosition());
auto tag_pos = m_fan_operate->ScreenToClient(mouse_pos); auto tag_pos = m_fan_operate->ScreenToClient(mouse_pos);
@ -390,17 +390,28 @@ void FanControl::on_left_down(wxMouseEvent& evt)
m_fan_operate->on_left_down(evt); m_fan_operate->on_left_down(evt);
} }
void FanControl::command_control_fan() void FanControlNew::command_control_fan()
{ {
if (m_current_speed < 0 || m_current_speed > 10) { return; } if (m_current_speed < 0 || m_current_speed > 10) { return; }
int speed = floor(m_current_speed * float(25.5));
if (m_update_already && m_obj) { BOOST_LOG_TRIVIAL(info) << "Functions Need to be supplemented! :FanControlNew::command_control_fan. the speed may change";
m_obj->command_control_fan_val(m_type, speed); token.reset(this, nop_deleter_fan_control);
post_event(wxCommandEvent(EVT_FAN_CHANGED)); if (m_obj) {
if (!m_obj->is_enable_np){
int speed = floor(m_current_speed * float(25.5));
m_obj->command_control_fan(m_part_id, speed);
} else {
m_obj->command_control_fan_new(m_part_id, m_current_speed, [this, w = std::weak_ptr<FanControlNew>(token)](const json &reply) {
if (w.expired())
return;
post_event(1);
});
}
post_event(0);
} }
} }
void FanControl::on_swith_fan(wxMouseEvent& evt) void FanControlNew::on_swith_fan(wxMouseEvent& evt)
{ {
int speed = 0; int speed = 0;
if (m_switch_fan) { if (m_switch_fan) {
@ -417,7 +428,7 @@ void FanControl::on_swith_fan(wxMouseEvent& evt)
command_control_fan(); command_control_fan();
} }
void FanControl::on_swith_fan(bool on) void FanControlNew::on_swith_fan(bool on)
{ {
m_switch_fan = on; m_switch_fan = on;
if (m_switch_fan) { if (m_switch_fan) {
@ -428,30 +439,58 @@ void FanControl::on_swith_fan(bool on)
} }
} }
void FanControl::set_machine_obj(MachineObject* obj) void FanControlNew::update_mode()
{
int cur_mode = m_mode_id;
if (cur_mode < 0) {
m_static_status_name->Hide();
m_fan_operate->Show();
} else {
auto mode = m_fan_data.modes[cur_mode];
auto it = std::find(mode.off.begin(), mode.off.end(), m_part_id);
if (it != mode.off.end()) {
m_show_mode = 2;
m_static_status_name->SetLabelText(_L("Off"));
} else {
auto it_ctrl = std::find(mode.ctrl.begin(), mode.ctrl.end(), m_part_id);
if (it_ctrl == mode.ctrl.end()) {
m_show_mode = 1;
m_static_status_name->SetLabelText(_L("Auto"));
} else {
m_show_mode = 0;
}
}
if (m_show_mode == 0) {
m_static_status_name->Hide();
m_switch_button->Show();
m_fan_operate->Show();
} else {
m_static_status_name->Show();
m_switch_button->Hide();
m_fan_operate->Hide();
}
}
}
void FanControlNew::set_machine_obj(MachineObject* obj)
{ {
m_update_already = true; m_update_already = true;
m_obj = obj; m_obj = obj;
} }
void FanControl::set_type(MachineObject::FanType type) void FanControlNew::set_name(wxString name) {
{
m_type = type;
}
void FanControl::set_name(wxString name)
{
m_static_name->SetLabelText(name); m_static_name->SetLabelText(name);
} }
void FanControl::set_fan_speed(int g) void FanControlNew::set_fan_speed(int g)
{ {
if (g < 0 || g > 255) return; if (g < 0 || g > 255) return;
int speed = round(float(g) / float(25.5)); int speed = round(float(g) / float(25.5));
if (m_current_speed != speed) { if (m_current_speed != speed) {
m_current_speed = speed; m_current_speed = speed;
m_fan->set_fan_speeds(speed);
m_fan_operate->set_fan_speeds(m_current_speed); m_fan_operate->set_fan_speeds(m_current_speed);
if (m_current_speed <= 0) { if (m_current_speed <= 0) {
@ -461,191 +500,308 @@ void FanControl::set_fan_speed(int g)
on_swith_fan(true); on_swith_fan(true);
} }
} }
} }
void FanControl::set_fan_switch(bool s) void FanControlNew::set_fan_speed_percent(int speed)
{ {
if (m_current_speed != speed) {
m_current_speed = speed;
m_fan_operate->set_fan_speeds(m_current_speed);
if (m_current_speed <= 0) {
on_swith_fan(false);
} else {
on_swith_fan(true);
}
}
} }
void FanControl::post_event(wxCommandEvent&& event) void FanControlNew::set_fan_switch(bool s)
{ {
event.SetInt(m_type); }
void FanControlNew::post_event(int type)
{
auto event = wxCommandEvent(EVT_FAN_CHANGED);
event.SetInt(type);
event.SetString(wxString::Format("%d", m_current_speed)); event.SetString(wxString::Format("%d", m_current_speed));
event.SetEventObject(GetParent()); event.SetEventObject(GetParent());
wxPostEvent(GetParent(), event); wxPostEvent(GetParent(), event);
event.Skip(); event.Skip();
} }
/************************************************* /*************************************************
Description:FanControlPopup Description:FanControlPopupNew
**************************************************/ **************************************************/
FanControlPopup::FanControlPopup(wxWindow* parent) static void nop_deleter_fan_control_popup(FanControlPopupNew *) {}
FanControlPopupNew::FanControlPopupNew(wxWindow* parent, MachineObject* obj,AirDuctData data)
:PopupWindow(parent, wxBORDER_NONE) :PopupWindow(parent, wxBORDER_NONE)
{ {
this->SetSizeHints(wxDefaultSize, wxDefaultSize); SetBackgroundColour(*wxWHITE);
init_names();
m_data = data;
m_obj = obj;
m_sizer_main = new wxBoxSizer(wxVERTICAL); m_sizer_main = new wxBoxSizer(wxVERTICAL);
m_part_fan = new FanControl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); m_radio_btn_sizer = new wxGridSizer( 0, 3, 3, 3 );
m_part_fan->set_type(MachineObject::FanType::COOLING_FAN); m_sizer_fanControl = new wxGridSizer( 0, 3, 3, 10 );
m_part_fan->set_name(_L("Part"));
m_aux_fan = new FanControl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); m_mode_sizer = new wxBoxSizer(wxHORIZONTAL);
m_aux_fan->set_type(MachineObject::FanType::BIG_COOLING_FAN);
m_aux_fan->set_name(_L("Aux"));
m_cham_fan = new FanControl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); m_button_refresh = new Button(this, wxString(""), "fan_poppingup_refresh", 0, FromDIP(24));
m_cham_fan->set_type(MachineObject::FanType::CHAMBER_FAN); m_button_refresh->SetBackgroundColor(*wxWHITE);
m_cham_fan->set_name(_L("Cham")); m_button_refresh->SetBorderColor(*wxWHITE);
m_button_refresh->SetMinSize(wxSize(FromDIP(26), FromDIP(26)));
m_button_refresh->SetMaxSize(wxSize(FromDIP(26), FromDIP(26)));
m_line_top = new wxWindow(this, wxID_ANY); m_mode_sizer->Add(m_radio_btn_sizer, 0, wxALIGN_CENTRE_VERTICAL, 0);
m_line_top->SetSize(wxSize(-1, 1)); m_mode_sizer->Add(m_button_refresh, 0, wxALIGN_CENTRE_VERTICAL, 0);
m_line_top->SetBackgroundColour(0xF1F1F1);
m_line_bottom = new wxWindow(this, wxID_ANY); m_cooling_text = new wxStaticText(this, wxID_ANY, wxT(""));
m_line_bottom->SetSize(wxSize(-1, 1)); m_cooling_text->SetBackgroundColour(*wxWHITE);
m_line_bottom->SetBackgroundColour(0xF1F1F1);
//Control the show or hide of controls based on id
m_sizer_main->Add(m_part_fan, 0, wxALL, FromDIP(14)); m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(23));
m_sizer_main->Add(m_line_top, 0, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(8)); m_sizer_main->Add(m_mode_sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, FromDIP(30));
m_sizer_main->Add(m_aux_fan, 0, wxALL, FromDIP(14)); m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(m_line_bottom, 0, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(8)); m_sizer_main->Add(m_cooling_text, 0, wxLEFT | wxRIGHT, FromDIP(30));
m_sizer_main->Add(m_cham_fan, 0, wxALL, FromDIP(14)); m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(m_sizer_fanControl, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, 0);
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(16));
CreateDuct();
this->SetSizer(m_sizer_main); SetSizer(m_sizer_main);
this->Layout(); Layout();
m_sizer_main->Fit(this); Fit();
this->Centre(wxBOTH); this->Centre(wxBOTH);
Bind(wxEVT_PAINT, &FanControlPopup::paintEvent, this); Bind(wxEVT_PAINT, &FanControlPopupNew::paintEvent, this);
#if __APPLE__ #if __APPLE__
Bind(wxEVT_LEFT_DOWN, &FanControlPopup::on_left_down, this); Bind(wxEVT_LEFT_DOWN, &FanControlPopupNew::on_left_down, this);
#endif #endif
#ifdef __WXOSX__ #ifdef __WXOSX__
Bind(wxEVT_IDLE, [](wxIdleEvent& evt) {}); Bind(wxEVT_IDLE, [](wxIdleEvent& evt) {});
#endif #endif
Bind(wxEVT_SHOW, &FanControlPopupNew::on_show, this);
Bind(EVT_FAN_CHANGED, &FanControlPopupNew::on_fan_changed, this);
Bind(wxEVT_SHOW, &FanControlPopup::on_show, this); for (const auto& btn : m_mode_switch_btn_list) {
SetBackgroundColour(*wxWHITE); btn->Bind(wxEVT_LEFT_DOWN, &FanControlPopupNew::on_mode_changed, this);
}
} }
void FanControlPopup::show_cham_fan(bool support_cham_fun) void FanControlPopupNew::CreateDuct(){
//tips
UpdateTips(m_data.curren_mode);
//fan or door
UpdateParts(m_data.curren_mode);
if (m_data.modes.empty()) {
m_button_refresh->Hide();
return;
}
size_t mode_size = m_data.modes.size();
for (auto i = 0; i < mode_size; i++) {
wxString text = wxString::Format("%s", radio_btn_name[AIR_DUCT(m_data.modes[i].id)]);
SendModeSwitchButton *radio_btn = new SendModeSwitchButton(this, text, m_data.curren_mode == m_data.modes[i].id);
m_mode_switch_btn_list.emplace_back(radio_btn);
m_radio_btn_sizer->Add(radio_btn, wxALL, FromDIP(5));
}
}
void FanControlPopupNew::UpdateParts(int mode_id)
{ {
m_sizer_fanControl->Clear(true);
if (support_cham_fun && !m_is_suppt_cham_fun) { for (const auto& part : m_data.parts) {
m_cham_fan->Show();
m_line_bottom->Show(); auto part_id = part.id;
Layout(); auto part_func = part.func;
Fit(); auto part_name = fan_func_name[AIR_FUN(part_id)];
auto part_state = part.state;
auto fan_control = new FanControlNew(this, m_data, mode_id, part_id, wxID_ANY, wxDefaultPosition, wxDefaultSize);
fan_control->set_machine_obj(m_obj);
fan_control->set_name(part_name);
m_fan_control_list[part_id] = fan_control;
m_sizer_fanControl->Add(fan_control, 0, wxALL, FromDIP(5));
/*if (fan_control.type == AIR_FAN_TYPE)
m_duct_fans_list[fan.id] = fan_control;
else if (fan_control.type == AIR_DOOR_TYPE)
m_duct_doors_list[fan.id] = fan_control;*/
} }
if (!support_cham_fun && m_is_suppt_cham_fun) { m_sizer_fanControl->Layout();
m_cham_fan->Hide();
m_line_bottom->Hide(); /*update state*/
Layout();
Fit(); //m_sizer_fanControl->Clear();
} //if (m_fan_control_list.find(duct_id) == m_fan_control_list.end()) return;
m_is_suppt_cham_fun = support_cham_fun; //for (auto fan_control_list : m_fan_control_list){
// if (fan_control_list.first == duct_id) continue;
// for (auto fan_control : fan_control_list.second){
// fan_control.second->Hide();
// }
//}
//auto fan_control_new_list = m_fan_control_list[duct_id];
//for (auto it : fan_control_new_list){
// //m_sizer_fanControl->Add(it.second, 0, wxALL | wxEXPAND, 0);
// m_sizer_fanControl->Add(it.second, 0, wxALL, 5);
// it.second->Show();
//}
//m_sizer_fanControl->Layout();
} }
void FanControlPopup::show_aux_fan(bool support_aux_fun) void FanControlPopupNew::UpdateTips(int model)
{
auto text = label_text[AIR_DUCT(model)];
m_cooling_text->SetLabelText(text);
m_cooling_text->Wrap(FromDIP(600));
Layout();
}
void FanControlPopupNew::update_fan_data(MachineObject *obj)
{
if (!obj)
return;
if (obj->is_enable_np) {
if (m_air_duct_time_out == 0) {
m_air_duct_time_out--;
return;
}
update_fan_data(obj->m_air_duct_data);
} else {
if (m_fan_set_time_out > 0) {
m_fan_set_time_out--;
return;
}
int cooling_fan_speed = round(obj->cooling_fan_speed / float(25.5));
int big_fan1_speed = round(obj->big_fan1_speed / float(25.5));
int big_fan2_speed = round(obj->big_fan2_speed / float(25.5));
update_fan_data(AIR_FUN::FAN_COOLING_0_AIRDOOR, cooling_fan_speed);
update_fan_data(AIR_FUN::FAN_REMOTE_COOLING_0_IDX, big_fan1_speed);
update_fan_data(AIR_FUN::FAN_REMOTE_COOLING_0_IDX, big_fan2_speed);
}
}
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);
if (it != m_fan_control_list.end()) {
auto fan_control = m_fan_control_list[part_id];
fan_control->set_fan_speed_percent(part_state);
}
}
}
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);
if (it != m_fan_control_list.end()) {
auto fan_control = m_fan_control_list[part_id];
fan_control->update_mode();
fan_control->set_fan_speed_percent(speed);
}
}
}
}
// device change
void FanControlPopupNew::update_device(AirDuctData data, MachineObject* obj)
{ {
if (support_aux_fun && !m_is_suppt_aux_fun) { //for (int i = 0; i < data.airducts.size(); i++){
m_aux_fan->Show(); // auto duct = data.airducts[i];
m_line_bottom->Show(); // if (m_fan_control_list.find(duct.airduct_id) == m_fan_control_list.end())
Layout(); // CreateDuct(duct);
Fit(); // else{
} // auto fan_list = m_fan_control_list[duct.airduct_id];
// for (auto fan : duct.fans_list){
// if (fan_list.find(fan.id) == fan_list.end())
// CreateFanAndDoor(duct.airduct_id, fan);
// else{
// auto fan_control = fan_list[fan.id];
// fan_control->update_fan_data(fan);
// }
// }
// }
// m_duct_ctrl[duct.airduct_id] = duct.fans_ctrl[i];
//}
//m_data = data;
//for (auto fan_list_of_duct : m_fan_control_list){
// for (auto fan : fan_list_of_duct.second){
// if (fan.second != nullptr)
// fan.second->set_machine_obj(obj);
// }
//}
////auto text = wxString::Format("%s", radio_btn_name[AIR_DUCT_mode_e(m_data.curren_duct)]);
//auto text = wxT("The fan controls the temperature during printing to improve print quality.The system automatically adjusts the fan's switch and speed according to dif");
//m_cooling_text->SetLabelText(text);
//m_cooling_text->Wrap(FromDIP(360));
if (!support_aux_fun && m_is_suppt_aux_fun) { //ChangeCoolingTips(m_data.airducts.size());
m_aux_fan->Hide();
m_line_bottom->Hide(); //if (data.airducts.size() <= 1)
Layout(); // m_radio_btn_sizer->Show(false);
Fit(); //else
} // m_radio_btn_sizer->Show(true);
m_is_suppt_aux_fun = support_aux_fun;
//this->Layout();
//Bind(EVT_FAN_CHANGED, [this](wxCommandEvent& e) {
// post_event(e.GetInt(), e.GetString());
// });
} }
void FanControlPopupNew::on_left_down(wxMouseEvent& evt)
void FanControlPopup::update_fan_data(MachineObject::FanType type, MachineObject* obj)
{
m_is_suppt_cham_fun = obj->is_support_chamber_fan;
show_cham_fan(m_is_suppt_cham_fun);
if (type == MachineObject::FanType::COOLING_FAN && obj->cooling_fan_speed >= 0) {
m_part_fan->set_fan_speed(obj->cooling_fan_speed);
}
if (type == MachineObject::FanType::BIG_COOLING_FAN && obj->big_fan1_speed >= 0) {
m_aux_fan->set_fan_speed(obj->big_fan1_speed);
}
if (type == MachineObject::FanType::CHAMBER_FAN && obj->big_fan2_speed >= 0) {
m_cham_fan->set_fan_speed(obj->big_fan2_speed);
}
m_part_fan->set_machine_obj(obj);
m_aux_fan->set_machine_obj(obj);
m_cham_fan->set_machine_obj(obj);
Bind(EVT_FAN_CHANGED, [this](wxCommandEvent& e) {
post_event(e.GetInt(), e.GetString());
});
}
void FanControlPopup::on_left_down(wxMouseEvent& evt)
{ {
auto mouse_pos = ClientToScreen(evt.GetPosition()); auto mouse_pos = ClientToScreen(evt.GetPosition());
auto win_pos = m_part_fan->m_switch_button->ClientToScreen(wxPoint(0, 0));
auto size = m_part_fan->m_switch_button->GetSize();
if (mouse_pos.x > win_pos.x && mouse_pos.x < (win_pos.x + m_part_fan->m_switch_button->GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + m_part_fan->m_switch_button->GetSize().y)) {
m_part_fan->on_swith_fan(evt);
}
win_pos = m_aux_fan->m_switch_button->ClientToScreen(wxPoint(0, 0));
size = m_aux_fan->m_switch_button->GetSize();
if (mouse_pos.x > win_pos.x && mouse_pos.x < (win_pos.x + m_aux_fan->m_switch_button->GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + m_aux_fan->m_switch_button->GetSize().y)) {
m_aux_fan->on_swith_fan(evt);
}
win_pos = m_cham_fan->m_switch_button->ClientToScreen(wxPoint(0, 0));
size = m_cham_fan->m_switch_button->GetSize();
if (mouse_pos.x > win_pos.x && mouse_pos.x < (win_pos.x + m_cham_fan->m_switch_button->GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + m_cham_fan->m_switch_button->GetSize().y)) {
m_cham_fan->on_swith_fan(evt);
}
auto part_tag_pos = m_part_fan->ScreenToClient(mouse_pos);
evt.SetPosition(part_tag_pos);
m_part_fan->on_left_down(evt);
auto aux_tag_pos = m_aux_fan->ScreenToClient(mouse_pos); for (auto fan_it : m_fan_control_list){
evt.SetPosition(aux_tag_pos); auto fan = fan_it.second;
m_aux_fan->on_left_down(evt); auto win_pos = fan->m_switch_button->ClientToScreen(wxPoint(0, 0));
auto size = fan->m_switch_button->GetSize();
if (mouse_pos.x > win_pos.x && mouse_pos.x < (win_pos.x + fan->m_switch_button->GetSize().x) && mouse_pos.y > win_pos.y &&
mouse_pos.y < (win_pos.y + fan->m_switch_button->GetSize().y)) {
fan->on_swith_fan(evt);
}
}
auto cham_tag_pos = m_cham_fan->ScreenToClient(mouse_pos);
evt.SetPosition(cham_tag_pos);
m_cham_fan->on_left_down(evt);
evt.Skip(); evt.Skip();
} }
void FanControlPopup::OnDismiss() void FanControlPopupNew::OnDismiss()
{ {
m_part_fan->update_obj_state(false);
m_aux_fan->update_obj_state(false);
m_cham_fan->update_obj_state(false);
} }
void FanControlPopup::post_event(int fan_type, wxString speed) void FanControlPopupNew::post_event(int fan_type, wxString speed)
{ {
wxCommandEvent event(EVT_FAN_CHANGED); // id, speed
wxCommandEvent event(EVT_FAN_CHANGED);
event.SetInt(fan_type); event.SetInt(fan_type);
event.SetString(speed); event.SetString(speed);
event.SetEventObject(GetParent()); event.SetEventObject(GetParent());
@ -653,21 +809,114 @@ void FanControlPopup::post_event(int fan_type, wxString speed)
event.Skip(); event.Skip();
} }
bool FanControlPopup::ProcessLeftDown(wxMouseEvent& event) bool FanControlPopupNew::ProcessLeftDown(wxMouseEvent& event)
{ {
return PopupWindow::ProcessLeftDown(event); return PopupWindow::ProcessLeftDown(event);
} }
void FanControlPopup::on_show(wxShowEvent& evt) void FanControlPopupNew::on_show(wxShowEvent& evt)
{ {
wxGetApp().UpdateDarkUIWin(this); wxGetApp().UpdateDarkUIWin(this);
} }
void FanControlPopup::paintEvent(wxPaintEvent& evt) void FanControlPopupNew::command_control_air_duct(int mode_id)
{
m_air_duct_time_out = time_out;
token.reset(this, nop_deleter_fan_control_popup);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", control air duct, id = " << mode_id;
if (m_obj) {
m_obj->command_control_air_duct(mode_id, [this, w = std::weak_ptr<FanControlPopupNew>(token), mode_id](const json& reply) {
if (w.expired())
return;
m_air_duct_time_out = 0;
if (reply.contains("errno")) {
int result = reply["errno"].get<int>();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", control air duct, errno = " << result;
if (result == 0) {
int update_id = mode_id;
if (reply.contains("modeId")) {
update_id = reply["modeId"].get<int>();
this->UpdateParts(update_id);
this->UpdateTips(update_id);
}
}
this->Layout();
this->Refresh();
}
});
}
}
void FanControlPopupNew::paintEvent(wxPaintEvent& evt)
{ {
wxPaintDC dc(this); wxPaintDC dc(this);
dc.SetPen(wxColour(0xAC, 0xAC, 0xAC)); dc.SetPen(wxColour(0xAC, 0xAC, 0xAC));
dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0); dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0);
} }
void FanControlPopupNew::on_mode_changed(const wxMouseEvent &event)
{
size_t btn_list_size = m_mode_switch_btn_list.size();
for (size_t i = 0; i < btn_list_size; ++i) {
if (m_mode_switch_btn_list[i]->GetId() == event.GetId()) {
if (m_mode_switch_btn_list[i]->isSelected())
return;
m_mode_switch_btn_list[i]->setSelected(true);
command_control_air_duct(i);
} else {
m_mode_switch_btn_list[i]->setSelected(false);
}
}
}
void FanControlPopupNew::on_fan_changed(const wxCommandEvent &event)
{
int type = event.GetInt();
if (type == 0)
m_fan_set_time_out = time_out;
else
m_fan_set_time_out = 0;
}
void FanControlPopupNew::init_names() {
//Iint fan/door/func/duct name lists
radio_btn_name[AIR_DUCT::AIR_DUCT_COOLING_FILT] = _L("Cooling Filter");
radio_btn_name[AIR_DUCT::AIR_DUCT_HEATING_INTERNAL_FILT] = L("Internal Filter");
radio_btn_name[AIR_DUCT::AIR_DUCT_EXHAUST] = L("Exhaust");
radio_btn_name[AIR_DUCT::AIR_DUCT_FULL_COOLING] = L("Full Cooling");
radio_btn_name[AIR_DUCT::AIR_DUCT_NUM] = L("Num?");
radio_btn_name[AIR_DUCT::AIR_DUCT_INIT] = L("Init");
fan_func_name[AIR_FUN::FAN_HEAT_BREAK_0_IDX] = _L("Nozzle0");
fan_func_name[AIR_FUN::FAN_COOLING_0_AIRDOOR] = _L("Part");
fan_func_name[AIR_FUN::FAN_REMOTE_COOLING_0_IDX] = _L("Aux");
fan_func_name[AIR_FUN::FAN_CHAMBER_0_IDX] = _L("Chamber");
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("Innerloop");
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");
label_text[AIR_DUCT::AIR_DUCT_NONE] = _L("The fan controls the temperature during printing to improve print quality.The system automatically adjusts the fan's switch and speed according to different printing materials.");
label_text[AIR_DUCT::AIR_DUCT_COOLING_FILT] = L("Cooling-filtering mode is suitable for printing PLA/PETG/TPU materials. In this mode, the chamber temperature is low, and the air in the chamber can be filtered while cooling the printed part.");
label_text[AIR_DUCT::AIR_DUCT_HEATING_INTERNAL_FILT] = L("Cooling-filtering mode is suitable for printing PLA/PETG/TPU materials. In this mode, the chamber temperature is low, and the air in the chamber can be filtered while cooling the printed part.");
label_text[AIR_DUCT::AIR_DUCT_EXHAUST] = L("Exhaust");
label_text[AIR_DUCT::AIR_DUCT_FULL_COOLING] = L("Strong cooling mode is suitable for printing PLA/TPU materials. In this mode, the printed part will be cooled in all directions.");
label_text[AIR_DUCT::AIR_DUCT_NUM] = _L("Num");
label_text[AIR_DUCT::AIR_DUCT_INIT] = _L("Init");
/*label_text[AIR_DUCT_mode_e::AIR_DUCT_NONE] = "...";
label_text[AIR_DUCT_mode_e::AIR_DUCT_COOLING_FILT] = "...";
label_text[AIR_DUCT_mode_e::AIR_DUCT_HEATING_INTERNAL_FILT] = "...";
label_text[AIR_DUCT_mode_e::AIR_DUCT_EXHAUST] = "Exhaust";
label_text[AIR_DUCT_mode_e::AIR_DUCT_FULL_COOLING] = "...";
label_text[AIR_DUCT_mode_e::AIR_DUCT_NUM] = "Num";
label_text[AIR_DUCT_mode_e::AIR_DUCT_INIT] = "Init";*/
}
}} // namespace Slic3r::GUI }} // namespace Slic3r::GUI

View File

@ -6,6 +6,7 @@
#include "StepCtrl.hpp" #include "StepCtrl.hpp"
#include "Button.hpp" #include "Button.hpp"
#include "PopupWindow.hpp" #include "PopupWindow.hpp"
#include "../SelectMachine.hpp"
#include "../DeviceManager.hpp" #include "../DeviceManager.hpp"
#include "slic3r/GUI/Event.hpp" #include "slic3r/GUI/Event.hpp"
#include <wx/simplebook.h> #include <wx/simplebook.h>
@ -21,11 +22,22 @@ namespace GUI {
/************************************************* /*************************************************
Description:Fan Description:Fan
**************************************************/ **************************************************/
#define SIZE_OF_FAN_OPERATE wxSize(100, 28) #define SIZE_OF_FAN_OPERATE wxSize(154, 28)
#define DRAW_TEXT_COLOUR wxColour(0x898989) #define DRAW_TEXT_COLOUR wxColour(0x898989)
#define DRAW_HEAD_TEXT_COLOUR wxColour(0x262e30)
#define DRAW_OPERATE_LINE_COLOUR wxColour(0xDEDEDE) #define DRAW_OPERATE_LINE_COLOUR wxColour(0xDEDEDE)
enum FanControlType
{
PART_FAN = 0,
AUX_FAN,
EXHAUST_FAN,
FILTER_FAN,
CHAMBER_FAN,
TOP_FAN
};
struct RotateOffSet struct RotateOffSet
{ {
float rotate; float rotate;
@ -94,80 +106,145 @@ public:
void decrease_fan_speeds(); void decrease_fan_speeds();
private: private:
int m_current_speeds; int m_current_speeds;
int m_target_speed;
int m_min_speeds; int m_min_speeds;
int m_max_speeds; int m_max_speeds;
ScalableBitmap m_bitmap_add; ScalableBitmap m_bitmap_add;
ScalableBitmap m_bitmap_decrease; ScalableBitmap m_bitmap_decrease;
}; };
/************************************************* /*************************************************
Description:FanControl Description:FanControlNew
**************************************************/ **************************************************/
class FanControl : public wxWindow class FanControlNew : public wxWindow
{ {
public: public:
FanControl(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); FanControlNew(wxWindow *parent, const AirDuctData& fan_data, int mode_id, int part_id, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
~FanControl() {}; ~FanControlNew() {};
protected: protected:
MachineObject::FanType m_type;
MachineObject* m_obj; MachineObject* m_obj;
wxStaticText* m_static_name{ nullptr }; wxStaticText* m_static_name{ nullptr };
int m_fan_id;
ScalableBitmap* m_bitmap_toggle_off{ nullptr }; ScalableBitmap* m_bitmap_toggle_off{ nullptr };
ScalableBitmap* m_bitmap_toggle_on{ nullptr }; ScalableBitmap* m_bitmap_toggle_on{ nullptr };
Fan* m_fan{ nullptr };
FanOperate* m_fan_operate{ nullptr }; FanOperate* m_fan_operate{ nullptr };
bool m_switch_fan{ false }; bool m_switch_fan{ false };
bool m_update_already{false}; bool m_update_already{ false };
int m_current_speed{0}; int m_current_speed{ 0 };
int m_part_id{0};
int m_mode_id{0};
wxBoxSizer *m_sizer_control_bottom{ nullptr };
wxStaticText *m_static_status_name{nullptr};
int m_show_mode{0};// 0 - ctrl, 1 - auto, 2 - off
//Fan and door may use the same mode_id, but they are different, they need to be distinguished by the m_type field
AirDuctData m_fan_data;
bool m_new_protocol{ false };
std::shared_ptr<FanControlNew> token;
public: public:
wxStaticBitmap* m_switch_button{ nullptr }; wxStaticBitmap* m_switch_button{ nullptr };
void update_obj_state(bool stat) {m_update_already = stat;}; void update_obj_state(bool stat) { m_update_already = stat; };
void update_fan_data(const AirDuctData& data) { m_fan_data = data; };
void command_control_fan(); void command_control_fan();
void set_machine_obj(MachineObject* obj); void set_machine_obj(MachineObject* obj);
void set_type(MachineObject::FanType type);
void set_name(wxString name); void set_name(wxString name);
void set_part_id(int id){m_part_id = id;};
void set_fan_speed(int g); void set_fan_speed(int g);
void set_fan_speed_percent(int speed);
void set_fan_switch(bool s); void set_fan_switch(bool s);
void post_event(wxCommandEvent&& event); void post_event(int type);
void on_swith_fan(wxMouseEvent& evt); void on_swith_fan(wxMouseEvent& evt);
void on_swith_fan(bool on); void on_swith_fan(bool on);
void update_mode();
void on_left_down(wxMouseEvent& event); void on_left_down(wxMouseEvent& event);
void on_mode_change(wxMouseEvent& event);
}; };
/************************************************* class FanControlPopupNew : public PopupWindow
Description:FanControlPopup
**************************************************/
class FanControlPopup : public PopupWindow
{ {
public: public:
FanControlPopup(wxWindow* parent); FanControlPopupNew(wxWindow* parent, MachineObject* obj, AirDuctData data);
~FanControlPopup() {}; ~FanControlPopupNew() {};
private: private:
wxBoxSizer* m_sizer_main; wxBoxSizer* m_sizer_main{ nullptr };
FanControl* m_part_fan;
FanControl* m_aux_fan; //old protocol
FanControl* m_cham_fan; //FanControl* m_part_fan;
//FanControl* m_aux_fan;
//FanControl* m_cham_fan;
wxWindow* m_line_top; wxWindow* m_line_top;
wxWindow* m_line_bottom; wxWindow* m_line_bottom;
bool m_is_suppt_cham_fun{true}; bool m_is_suppt_cham_fun{ true };
bool m_is_suppt_aux_fun{true}; bool m_is_suppt_aux_fun{ true };
//new protocol
wxGridSizer* m_radio_btn_sizer{ nullptr };
wxGridSizer* m_sizer_fanControl { nullptr };
wxBoxSizer *m_mode_sizer{ nullptr };
wxBoxSizer *m_bottom_sizer{ nullptr };
AirDuctData m_data;
std::map<int, FanControlNew*> m_fan_control_list; //<duct_id, <fan_id, FanControl>>
std::vector<SendModeSwitchButton*> m_mode_switch_btn_list;
int m_air_duct_time_out { 0 };
int m_fan_set_time_out{ 0 };
std::map<int, bool> m_duct_ctrl;
std::map<int, FanControlNew*> m_duct_fans_list;
std::map<int, FanControlNew*> m_duct_doors_list;
Button* m_button_refresh;
wxStaticText* m_cooling_text;
MachineObject *m_obj{nullptr};
std::string m_strong_str = "Strong string ...wait fill";
std::string m_filter_str = "Filtering string ...wait fill";
std::string m_chamber_str = "Chamber string ...wait fill";
std::string m_normal_str = "Normal string ...wait fill"; //For X version machine
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;
std::shared_ptr<FanControlPopupNew> token;
void on_mode_changed(const wxMouseEvent &event);
void on_fan_changed(const wxCommandEvent &event);
void init_names();
void CreateDuct();
void UpdateParts(int mode_id);
void UpdateTips(int mode_id);
void BackupOfCreate();
void update_fans(); //New protocol
public: public:
void show_cham_fan(bool support_cham_fun); void show_cham_fan(bool support_cham_fun);
void show_aux_fan(bool support_aux_fun); void show_aux_fan(bool support_aux_fun);
void update_fan_data(MachineObject::FanType type, MachineObject* obj); void update_fan_data(MachineObject *obj);
void update_fan_data(const AirDuctData& data);
void update_fan_data(AIR_FUN id, int speed);
void update_device(AirDuctData data, MachineObject *obj); // New protocol
void on_left_down(wxMouseEvent& evt); void on_left_down(wxMouseEvent& evt);
void paintEvent(wxPaintEvent& evt); void paintEvent(wxPaintEvent& evt);
void post_event(int fan_type, wxString speed); void post_event(int fan_type, wxString speed);
void on_show(wxShowEvent& evt); void on_show(wxShowEvent& evt);
void command_control_air_duct(int mode_id);
virtual void OnDismiss() wxOVERRIDE; virtual void OnDismiss() wxOVERRIDE;
virtual bool ProcessLeftDown(wxMouseEvent& event) wxOVERRIDE; virtual bool ProcessLeftDown(wxMouseEvent& event) wxOVERRIDE;
}; };
wxDECLARE_EVENT(EVT_FAN_SWITCH_ON, wxCommandEvent); wxDECLARE_EVENT(EVT_FAN_SWITCH_ON, wxCommandEvent);
wxDECLARE_EVENT(EVT_FAN_SWITCH_OFF, wxCommandEvent); wxDECLARE_EVENT(EVT_FAN_SWITCH_OFF, wxCommandEvent);
wxDECLARE_EVENT(EVT_FAN_ADD, wxCommandEvent); wxDECLARE_EVENT(EVT_FAN_ADD, wxCommandEvent);

View File

@ -293,7 +293,10 @@ void FanSwitchButton::render(wxDC& dc)
dc.DrawText(fan_txt, pt); dc.DrawText(fan_txt, pt);
pt.y = size.y / 2 + FromDIP(3); pt.y = size.y / 2 + FromDIP(3);
wxString fan_num_txt = GetLabel(); wxString fan_num_txt = GetLabel();
dc.SetFont(::Label::Body_11);
dc.SetFont(::Label::Body_12);
dc.SetTextForeground(0x6b6b6b);
dc.DrawText(fan_num_txt, pt); dc.DrawText(fan_num_txt, pt);