ENH: Optimize buried point information

JIRA: NONE

Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com>
Change-Id: I7186844e84a6ad77907beab4af5088ccb7bec930
This commit is contained in:
Kunlong Ma 2024-01-02 17:43:48 +08:00 committed by Lane.Wei
parent 8c9c0e8d4b
commit 3d16dc2fee
9 changed files with 107 additions and 160 deletions

View File

@ -1641,7 +1641,8 @@ int MachineObject::command_control_fan(FanType fan_type, bool on_off)
std::string gcode = (boost::format("M106 P%1% S%2% \n") % (int)fan_type % (on_off ? 255 : 0)).str();
try {
json j;
j["fan_control"] = "fan_control";
j["crtl_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());
@ -1656,7 +1657,8 @@ 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();
try {
json j;
j["fan_control"] = "fan_control_val";
j["ctrl_type"] = get_string_from_fantype(fan_type);
j["value"] = val;
NetworkAgent* agent = GUI::wxGetApp().getAgent();
if (agent) agent->track_event("printer_control", j.dump());
@ -1714,7 +1716,8 @@ int MachineObject::command_set_bed(int temp)
std::string gcode_str = (boost::format("M140 S%1%\n") % temp).str();
try {
json j;
j["temp_control"] = "bed_temp";
j["ctrl_type"] = "bed_temp";
j["value"] = temp;
NetworkAgent* agent = GUI::wxGetApp().getAgent();
if (agent) agent->track_event("printer_control", j.dump());
@ -1729,7 +1732,8 @@ int MachineObject::command_set_nozzle(int temp)
std::string gcode_str = (boost::format("M104 S%1%\n") % temp).str();
try {
json j;
j["temp_control"] = "nozzle_temp";
j["ctrl_type"] = "nozzle_temp";
j["value"] = temp;
NetworkAgent* agent = GUI::wxGetApp().getAgent();
if (agent) agent->track_event("printer_control", j.dump());
@ -4091,6 +4095,7 @@ int MachineObject::parse_json(std::string payload)
json t;
t["dev_id"] = this->dev_id;
t["signal"] = this->wifi_signal;
t["gcode"] = j.dump();
m_agent->track_event("ack_cmd_gcode_line", t.dump());
}
} else if (jj["command"].get<std::string>() == "project_prepare") {
@ -4597,6 +4602,7 @@ int MachineObject::publish_gcode(std::string gcode_str)
json t;
t["dev_id"] = this->dev_id;
t["signal"] = this->wifi_signal;
t["gcode"] = j.dump();
m_agent->track_event("cmd_gcode_line", t.dump());
}
return publish_json(j.dump());
@ -4903,6 +4909,21 @@ bool MachineObject::is_firmware_info_valid()
return m_firmware_valid;
}
std::string MachineObject::get_string_from_fantype(FanType type)
{
switch (type) {
case FanType::COOLING_FAN:
return "cooling_fan";
case FanType::BIG_COOLING_FAN:
return "big_cooling_fan";
case FanType::CHAMBER_FAN:
return "chamber_fan";
default:
return "";
}
return "";
}
DeviceManager::DeviceManager(NetworkAgent* agent)
{
m_agent = agent;

View File

@ -942,6 +942,7 @@ public:
bool m_firmware_thread_started { false };
void get_firmware_info();
bool is_firmware_info_valid();
std::string get_string_from_fantype(FanType type);
};
class DeviceManager

View File

@ -7819,19 +7819,23 @@ void GLCanvas3D::_render_return_toolbar() const
GLCanvas3D* view_3d = wxGetApp().plater()->get_view3D_canvas3D();
GLToolbarItem* assembly_item = view_3d->m_assemble_view_toolbar.get_item("assembly_view");
std::chrono::system_clock::time_point end = std::chrono::system_clock::now();
std::chrono::duration<double> duration = std::chrono::duration_cast<std::chrono::duration<double>>(end - assembly_item->get_start_time_point());
float times = duration.count();
std::chrono::duration<int> duration = std::chrono::duration_cast<std::chrono::duration<int>>(end - assembly_item->get_start_time_point());
int times = duration.count();
NetworkAgent* agent = GUI::wxGetApp().getAgent();
if (agent) {
std::string name = assembly_item->get_name() + "_duration";
std::string value = "";
float existing_time = 0;
int existing_time = 0;
agent->track_get_property(name, value);
if (value != "") {
existing_time = std::stof(value);
try {
if (value != "") {
existing_time = std::stoi(value);
}
}
catch (...) {}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " tool name:" << name << " duration: " << times + existing_time;
agent->track_update_property(name, std::to_string(times + existing_time));
}

View File

@ -107,19 +107,23 @@ void GLToolbarItem::set_state(EState state)
(m_state == HoverPressed && state == Normal)) {
if (m_data.name != "assembly_view") {
std::chrono::system_clock::time_point end = std::chrono::system_clock::now();
std::chrono::duration<double> duration = std::chrono::duration_cast<std::chrono::duration<double>>(end - start);
float times = duration.count();
std::chrono::duration<int> duration = std::chrono::duration_cast<std::chrono::duration<int>>(end - start);
int times = duration.count();
NetworkAgent* agent = GUI::wxGetApp().getAgent();
if (agent) {
std::string name = m_data.name + "_duration";
std::string value = "";
float existing_time = 0;
int existing_time = 0;
agent->track_get_property(name, value);
if (value != "") {
existing_time = std::stof(value);
try {
if (value != "") {
existing_time = std::stoi(value);
}
}
catch (...) {}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " tool name:" << name << " duration: " << times + existing_time;
agent->track_update_property(name, std::to_string(times + existing_time));
}

View File

@ -1446,7 +1446,7 @@ wxMenu* MenuFactory::assemble_multi_selection_menu()
append_menu_item_change_extruder(menu);
{
NetworkAgent* agent = GUI::wxGetApp().getAgent();
if (agent) agent->track_update_property("asseble_mulit_selection_menu", std::to_string(++assemble_mulit_selection_menu_count));
if (agent) agent->track_update_property("asseble_multi_selection_menu", std::to_string(++assemble_multi_selection_menu_count));
}
return menu;
}

View File

@ -104,7 +104,7 @@ private:
int multi_selection_menu_count{ 0 };
int assemble_object_menu_ocunt{ 0 };
int assemble_part_menu_count{ 0 };
int assemble_mulit_selection_menu_count{ 0 };
int assemble_multi_selection_menu_count{ 0 };
// Removed/Prepended Items according to the view mode
std::array<wxMenuItem*, mtCount> items_increase;

View File

@ -220,19 +220,23 @@ void GLGizmoBase::set_state(EState state)
}
else if (m_state == On && state == Off) {
std::chrono::system_clock::time_point end = std::chrono::system_clock::now();
std::chrono::duration<double> duration = std::chrono::duration_cast<std::chrono::duration<double>>(end - start);
float times = duration.count();
std::chrono::duration<int> duration = std::chrono::duration_cast<std::chrono::duration<int>>(end - start);
int times = duration.count();
NetworkAgent* agent = GUI::wxGetApp().getAgent();
if (agent) {
std::string full_name = name + "_duration";
std::string value = "";
float existing_time = 0;
int existing_time = 0;
agent->track_get_property(full_name, value);
if (value != "") {
existing_time = std::stof(value);
try {
if (value != "") {
existing_time = std::stoi(value);
}
}
catch (...) {}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " tool name:" << full_name << " duration: " << times + existing_time;
agent->track_update_property(full_name, std::to_string(times + existing_time));
}

View File

@ -477,158 +477,71 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
NetworkAgent* agent = GUI::wxGetApp().getAgent();
if (agent) {
json j;
std::string value;
agent->track_get_property("auto_orient", value);
j["auto_orient"] = value;
value = "";
agent->track_get_property("auto_arrange", value);
j["auto_arrange"] = value;
value = "";
agent->track_get_property("split_to_object", value);
j["split_to_object"] = value;
value = "";
agent->track_get_property("split_to_part", value);
j["split_to_part"] = value;
value = "";
agent->track_get_property("custom_height", value);
j["custom_height"] = value;
value = "";
agent->track_get_property(get_name_from_gizmo_etype(GLGizmosManager::EType::Move), value);
j["move"] = value;
value = "";
agent->track_get_property(get_name_from_gizmo_etype(GLGizmosManager::EType::Rotate), value);
j["rotate"] = value;
value = "";
agent->track_get_property(get_name_from_gizmo_etype(GLGizmosManager::EType::Scale), value);
j["scale"] = value;
value = "";
agent->track_get_property(get_name_from_gizmo_etype(GLGizmosManager::EType::Flatten), value);
j["flatten"] = value;
value = "";
agent->track_get_property(get_name_from_gizmo_etype(GLGizmosManager::EType::Cut), value);
j["cut"] = value;
value = "";
agent->track_get_property(get_name_from_gizmo_etype(GLGizmosManager::EType::MeshBoolean), value);
j["meshboolean"] = value;
value = "";
agent->track_get_property(get_name_from_gizmo_etype(GLGizmosManager::EType::FdmSupports), value);
j["custom_support"] = value;
value = "";
agent->track_get_property(get_name_from_gizmo_etype(GLGizmosManager::EType::Seam), value);
j["custom_seam"] = value;
value = "";
agent->track_get_property(get_name_from_gizmo_etype(GLGizmosManager::EType::Text), value);
j["text_shape"] = value;
value = "";
agent->track_get_property(get_name_from_gizmo_etype(GLGizmosManager::EType::MmuSegmentation), value);
j["color_painting"] = value;
value = "";
auto get_value = [&agent](const std::string& name) -> std::string {
std::string value = "";
agent->track_get_property(name, value);
if (value == "")
value = "0";
agent->track_get_property("assembly_view", value);
j["assembly_view"] = value;
return value;
};
j["auto_orient"] = get_value("auto_orient");
j["auto_arrange"] = get_value("auto_arrange");
j["split_to_object"] = get_value("split_to_object");
j["split_to_part"] = get_value("split_to_part");
j["custom_height"] = get_value("custom_height");
j["move"] = get_value(get_name_from_gizmo_etype(GLGizmosManager::EType::Move));
j["rotate"] = get_value(get_name_from_gizmo_etype(GLGizmosManager::EType::Rotate));
j["scale"] = get_value(get_name_from_gizmo_etype(GLGizmosManager::EType::Scale));
j["flatten"] = get_value(get_name_from_gizmo_etype(GLGizmosManager::EType::Flatten));
j["cut"] = get_value(get_name_from_gizmo_etype(GLGizmosManager::EType::Cut));
j["meshboolean"] = get_value(get_name_from_gizmo_etype(GLGizmosManager::EType::MeshBoolean));
j["custom_support"] = get_value(get_name_from_gizmo_etype(GLGizmosManager::EType::FdmSupports));
j["custom_seam"] = get_value(get_name_from_gizmo_etype(GLGizmosManager::EType::Seam));
j["text_shape"] = get_value(get_name_from_gizmo_etype(GLGizmosManager::EType::Text));
j["color_painting"] = get_value(get_name_from_gizmo_etype(GLGizmosManager::EType::MmuSegmentation));
j["assembly_view"] = get_value("assembly_view");
agent->track_event("key_func", j.dump());
j.clear();
value = "";
agent->track_get_property("arrange_duration", value);
j["auto_arrange"] = value;
value = "";
agent->track_get_property("layersediting_duration", value);
j["custom_height"] = value;
value = "";
agent->track_get_property("Move_duration", value);
j["move"] = value;
value = "";
agent->track_get_property("Rotate_duration", value);
j["rotate"] = value;
agent->track_get_property("Scale_duration", value);
j["scale"] = value;
agent->track_get_property("Lay on face_duration", value);
j["flatten"] = value;
value = "";
agent->track_get_property("Cut_duration", value);
j["cut"] = value;
value = "";
agent->track_get_property("Mesh Boolean_duration", value);
j["mesh_boolean"] = value;
value = "";
agent->track_get_property("Supports Painting_duration", value);
j["custom_support"] = value;
value = "";
agent->track_get_property("Seam painting_duration", value);
j["custom_seam"] = value;
value = "";
agent->track_get_property("Text shape_duration", value);
j["text_shape"] = value;
value = "";
agent->track_get_property("Color Painting_duration", value);
j["color_painting"] = value;
value = "";
agent->track_get_property("assembly_view_duration", value);
j["assembly_view"] = value;
j["auto_arrange_duration"] = get_value("arrange_duration");
j["custom_height_duration"] = get_value("layersediting_duration");
j["move_duration"] = get_value("Move_duration");
j["rotate_duration"] = get_value("Rotate_duration");
j["scale_duration"] = get_value("Scale_duration");
j["flatten_duration"] = get_value("Lay on face_duration");
j["cut_duration"] = get_value("Cut_duration");
j["meshboolean_duration"] = get_value("Mesh Boolean_duration");
j["custom_support_duration"] = get_value("Supports Painting_duration");
j["custom_seam_duration"] = get_value("Seam painting_duration");
j["text_shape_duration"] = get_value("Text shape_duration");
j["color_painting_duration"] = get_value("Color Painting_duration");
j["assembly_view_duration"] = get_value("assembly_view_duration");
agent->track_event("key_func_duration", j.dump());
j.clear();
value = "";
agent->track_get_property("default_menu", value);
j["default_menu"] = value;
value = "";
agent->track_get_property("object_menu", value);
j["object_menu"] = value;
value = "";
agent->track_get_property("sla_object_menu", value);
j["sla_object_menu"] = value;
value = "";
agent->track_get_property("part_menu", value);
j["part_menu"] = value;
value = "";
agent->track_get_property("instance_menu", value);
j["instance_menu"] = value;
value = "";
agent->track_get_property("layer_menu", value);
j["layer_menu"] = value;
value = "";
agent->track_get_property("multi_selection_menu", value);
j["multi_selection_menu"] = value;
value = "";
agent->track_get_property("plate_menu", value);
j["plate_menu"] = value;
value = "";
agent->track_get_property("assemble_object_menu", value);
j["assemble_object_menu"] = value;
value = "";
agent->track_get_property("assemble_part_menu", value);
j["assemble_part_menu"] = value;
value = "";
agent->track_get_property("assemble_mulit_selection_menu", value);
j["assemble_mulit_selection_menu"] = value;
value = "";
j["default_menu"] = get_value("default_menu");
j["object_menu"] = get_value("object_ment");
j["part_menu"] = get_value("part_menu");
j["layer_menu"] = get_value("layer_menu");
j["multi_selection_menu"] = get_value("multi_selection_menu");
j["plate_menu"] = get_value("plate_menu");
j["assemble_object_menu"] = get_value("assemble_object_menu");
j["assemble_part_menu"] = get_value("assemble_part_menu");
j["assemble_multi_selection_menu"] = get_value("assemble_multi_selection_menu");
agent->track_event("menu_click", j.dump());
j.clear();
value = "";
agent->track_get_property("select_device_page", value);
j["device_page"] = value;
value = "";
agent->track_get_property("Status", value);
j["status"] = value;
value = "";
agent->track_get_property("MicroSD Card", value);
j["MicroSD_card"] = value;
value = "";
agent->track_get_property("Update", value);
j["update"] = value;
value = "";
agent->track_get_property("HMS", value);
j["HMS"] = value;
value = "";
j["device_page"] = get_value("select_device_page");
j["status"] = get_value("Status");
j["MicroSD_card"] = get_value("MicroSD Card");
j["HMS"] = get_value("HMS");
agent->track_event("device_ctrl", j.dump());
}
}
catch (...) {}

View File

@ -8339,8 +8339,8 @@ void Plater::priv::record_start_print_preset(std::string action) {
json j_workflow_debug;
std::chrono::system_clock::time_point end = std::chrono::system_clock::now();
std::chrono::duration<double> duration = std::chrono::duration_cast<std::chrono::duration<double>>(end - start);
float times = duration.count();
std::chrono::duration<int> duration = std::chrono::duration_cast<std::chrono::duration<int>>(end - start);
int times = duration.count();
j_workflow_debug["duration"] = times;
j["record_event"] = action;