mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-14 00:52:04 +00:00
FIX: check axis at home
jira: [STUDIO-13678] Change-Id: If9363485ce2ccd434f5c22c0484c6420bbfb67c8 (cherry picked from commit 04e7e8d00f885fbe4ce4ff86ea2897c61e909881)
This commit is contained in:
@@ -494,7 +494,6 @@ MachineObject::MachineObject(DeviceManager* manager, NetworkAgent* agent, std::s
|
||||
mc_print_percent = 0;
|
||||
mc_print_sub_stage = 0;
|
||||
mc_left_time = 0;
|
||||
home_flag = -1;
|
||||
hw_switch_state = 0;
|
||||
|
||||
has_ipcam = true; // default true
|
||||
@@ -836,18 +835,17 @@ bool MachineObject::check_pa_result_validation(PACalibResult& result)
|
||||
|
||||
bool MachineObject::is_axis_at_home(std::string axis)
|
||||
{
|
||||
if (home_flag < 0)
|
||||
return true;
|
||||
if (m_home_flag == 0) { return true; }
|
||||
|
||||
if (axis == "X") {
|
||||
return (home_flag & 1) == 1;
|
||||
return (m_home_flag & 1) == 1;
|
||||
} else if (axis == "Y") {
|
||||
return ((home_flag >> 1) & 1) == 1;
|
||||
return ((m_home_flag >> 1) & 1) == 1;
|
||||
} else if (axis == "Z") {
|
||||
return ((home_flag >> 2) & 1) == 1;
|
||||
} else {
|
||||
return true;
|
||||
return ((m_home_flag >> 2) & 1) == 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MachineObject::is_filament_at_extruder()
|
||||
@@ -921,8 +919,10 @@ void MachineObject::parse_state_changed_event()
|
||||
last_mc_print_stage = mc_print_stage;
|
||||
}
|
||||
|
||||
void MachineObject::parse_status(int flag)
|
||||
void MachineObject::parse_home_flag(int flag)
|
||||
{
|
||||
m_home_flag = flag;
|
||||
|
||||
is_220V_voltage = ((flag >> 3) & 0x1) != 0;
|
||||
if (time(nullptr) - xcam_auto_recovery_hold_start > HOLD_TIME_3SEC) {
|
||||
xcam_auto_recovery_step_loss = ((flag >> 4) & 0x1) != 0;
|
||||
@@ -1299,16 +1299,16 @@ int MachineObject::command_auto_leveling()
|
||||
|
||||
int MachineObject::command_go_home()
|
||||
{
|
||||
return this->publish_gcode("G28 \n");
|
||||
}
|
||||
if (m_support_mqtt_homing)
|
||||
{
|
||||
json j;
|
||||
j["print"]["command"] = "back_to_center";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
return this->publish_json(j);
|
||||
}
|
||||
|
||||
int MachineObject::command_go_home2()
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << "New protocol of command_go_home2";
|
||||
json j;
|
||||
j["print"]["command"] = "back_to_center";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
return this->publish_json(j);
|
||||
// gcode command
|
||||
return this->is_in_printing() ? this->publish_gcode("G28 X\n") : this->publish_gcode("G28 \n");
|
||||
}
|
||||
|
||||
int MachineObject::command_task_abort()
|
||||
@@ -2940,10 +2940,7 @@ int MachineObject::parse_json(std::string tunnel, std::string payload, bool key_
|
||||
DevStorage::ParseV1_0(jj, m_storage);
|
||||
|
||||
if (!key_field_only) {
|
||||
if (jj.contains("home_flag")) {
|
||||
home_flag = jj["home_flag"].get<int>();
|
||||
parse_status(home_flag);
|
||||
}
|
||||
if (jj.contains("home_flag")) { parse_home_flag(jj["home_flag"].get<int>());}
|
||||
|
||||
/*the param is invalid in np for Yeshu*/
|
||||
if (jj.contains("hw_switch_state")) {
|
||||
@@ -4826,7 +4823,7 @@ void MachineObject::parse_new_info(json print)
|
||||
is_support_nozzle_blob_detection = get_flag_bits(fun, 13);
|
||||
is_support_upgrade_kit = get_flag_bits(fun, 14);
|
||||
is_support_internal_timelapse = get_flag_bits(fun, 28);
|
||||
is_support_command_homing = get_flag_bits(fun, 32);
|
||||
m_support_mqtt_homing = get_flag_bits(fun, 32);
|
||||
is_support_brtc = get_flag_bits(fun, 31);
|
||||
m_support_mqtt_axis_control = get_flag_bits(fun, 38);
|
||||
m_support_mqtt_bet_ctrl = get_flag_bits(fun, 39);
|
||||
|
||||
@@ -378,7 +378,7 @@ public:
|
||||
int mc_print_percent; /* left print progess in percent */
|
||||
int mc_left_time; /* left time in seconds */
|
||||
int last_mc_print_stage;
|
||||
int home_flag;
|
||||
int m_home_flag = 0;
|
||||
int hw_switch_state;
|
||||
bool is_system_printing();
|
||||
|
||||
@@ -451,7 +451,7 @@ public:
|
||||
bool is_calibration_done();
|
||||
|
||||
void parse_state_changed_event();
|
||||
void parse_status(int flag);
|
||||
void parse_home_flag(int flag);
|
||||
|
||||
/* printing status */
|
||||
std::string print_status; /* enum string: FINISH, SLICING, RUNNING, PAUSE, INIT, FAILED */
|
||||
@@ -581,7 +581,7 @@ public:
|
||||
bool is_support_upgrade_kit{false};
|
||||
bool is_support_filament_setting_inprinting{false};
|
||||
bool is_support_internal_timelapse { false };// fun[28], support timelapse without SD card
|
||||
bool is_support_command_homing { false };// fun[32]
|
||||
bool m_support_mqtt_homing { false };// fun[32]
|
||||
bool is_support_brtc{false}; // fun[31], support tcp and upload protocol
|
||||
bool is_support_ext_change_assist{false};
|
||||
|
||||
@@ -677,7 +677,6 @@ public:
|
||||
int command_xyz_abs();
|
||||
int command_auto_leveling();
|
||||
int command_go_home();
|
||||
int command_go_home2();
|
||||
|
||||
int command_task_abort();
|
||||
/* cancelled the job_id */
|
||||
|
||||
@@ -3944,42 +3944,33 @@ void StatusPanel::reset_printing_values()
|
||||
void StatusPanel::on_axis_ctrl_xy(wxCommandEvent &event)
|
||||
{
|
||||
if (!obj) return;
|
||||
if (event.GetInt() == 0) { obj->command_axis_control("Y", 1.0, 10.0f, 3000); }
|
||||
if (event.GetInt() == 1) { obj->command_axis_control("X", 1.0, -10.0f, 3000); }
|
||||
if (event.GetInt() == 2) { obj->command_axis_control("Y", 1.0, -10.0f, 3000); }
|
||||
if (event.GetInt() == 3) { obj->command_axis_control("X", 1.0, 10.0f, 3000); }
|
||||
if (event.GetInt() == 4) { obj->command_axis_control("Y", 1.0, 1.0f, 3000); }
|
||||
if (event.GetInt() == 5) { obj->command_axis_control("X", 1.0, -1.0f, 3000); }
|
||||
if (event.GetInt() == 6) { obj->command_axis_control("Y", 1.0, -1.0f, 3000); }
|
||||
if (event.GetInt() == 7) { obj->command_axis_control("X", 1.0, 1.0f, 3000); }
|
||||
if (event.GetInt() == 8) {
|
||||
if (obj->is_support_command_homing) {
|
||||
obj->command_go_home2();
|
||||
} else {
|
||||
obj->command_go_home();
|
||||
}
|
||||
}
|
||||
|
||||
//check is at home
|
||||
if (event.GetInt() == 1
|
||||
|| event.GetInt() == 3
|
||||
|| event.GetInt() == 5
|
||||
|| event.GetInt() == 7) {
|
||||
if (!obj->is_axis_at_home("X")) {
|
||||
BOOST_LOG_TRIVIAL(info) << "axis x is not at home";
|
||||
show_recenter_dialog();
|
||||
return;
|
||||
}
|
||||
static std::unordered_set<int> s_x_ctrl_idxes { 1, 3, 5, 7};
|
||||
static std::unordered_set<int> s_y_ctrl_idxes{ 0, 2, 4, 6 };
|
||||
if (s_x_ctrl_idxes.count(event.GetInt()) != 0 && !obj->is_axis_at_home("X"))
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << "axis x is not at home";
|
||||
show_recenter_dialog();
|
||||
return;
|
||||
}
|
||||
else if (event.GetInt() == 0
|
||||
|| event.GetInt() == 2
|
||||
|| event.GetInt() == 4
|
||||
|| event.GetInt() == 6) {
|
||||
if (!obj->is_axis_at_home("Y")) {
|
||||
BOOST_LOG_TRIVIAL(info) << "axis y is not at home";
|
||||
show_recenter_dialog();
|
||||
return;
|
||||
}
|
||||
else if (s_y_ctrl_idxes.count(event.GetInt()) != 0 && !obj->is_axis_at_home("Y"))
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << "axis y is not at home";
|
||||
show_recenter_dialog();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.GetInt() == 0) { obj->command_axis_control("Y", 1.0, 10.0f, 3000); }
|
||||
else if (event.GetInt() == 1) { obj->command_axis_control("X", 1.0, -10.0f, 3000); }
|
||||
else if (event.GetInt() == 2) { obj->command_axis_control("Y", 1.0, -10.0f, 3000); }
|
||||
else if (event.GetInt() == 3) { obj->command_axis_control("X", 1.0, 10.0f, 3000); }
|
||||
else if (event.GetInt() == 4) { obj->command_axis_control("Y", 1.0, 1.0f, 3000); }
|
||||
else if (event.GetInt() == 5) { obj->command_axis_control("X", 1.0, -1.0f, 3000); }
|
||||
else if (event.GetInt() == 6) { obj->command_axis_control("Y", 1.0, -1.0f, 3000); }
|
||||
else if (event.GetInt() == 7) { obj->command_axis_control("X", 1.0, 1.0f, 3000); }
|
||||
else if (event.GetInt() == 8) {
|
||||
if (obj) { obj->command_go_home(); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user