mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 06:57:36 -06:00
NEW: add more print option
1. add option of ai monitor 2. add option marker detection of buildplate 3. add auto recovery step loss Change-Id: I8483105fed9699d1072b5ef0f08aeff30e6f610a Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
f3c7953bdc
commit
22211f1b54
5 changed files with 440 additions and 86 deletions
|
@ -405,6 +405,11 @@ bool MachineObject::check_valid_ip()
|
|||
return true;
|
||||
}
|
||||
|
||||
void MachineObject::_parse_print_option_ack(int option)
|
||||
{
|
||||
xcam_auto_recovery_step_loss = ((option >> (int)PRINT_OP_AUTO_RECOVERY) & 0x01) != 0;
|
||||
}
|
||||
|
||||
void MachineObject::_parse_tray_now(std::string tray_now)
|
||||
{
|
||||
m_tray_now = tray_now;
|
||||
|
@ -1122,6 +1127,12 @@ void MachineObject::parse_state_changed_event()
|
|||
|
||||
void MachineObject::parse_status(int flag)
|
||||
{
|
||||
if (xcam_auto_recovery_hold_count > 0)
|
||||
xcam_auto_recovery_hold_count--;
|
||||
else {
|
||||
xcam_auto_recovery_step_loss = ((flag >> 4) & 0x1) != 0;
|
||||
}
|
||||
|
||||
camera_recording = ((flag >> 5) & 0x1) != 0;
|
||||
ams_calibrate_remain_flag = ((flag >> 7) & 0x1) != 0;
|
||||
}
|
||||
|
@ -1466,6 +1477,17 @@ int MachineObject::command_set_printing_speed(PrintingSpeedLevel lvl)
|
|||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_set_printing_option(bool auto_recovery)
|
||||
{
|
||||
int print_option = (int)auto_recovery << (int)PRINT_OP_AUTO_RECOVERY;
|
||||
json j;
|
||||
j["print"]["command"] = "print_option";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["option"] = print_option;
|
||||
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_axis_control(std::string axis, double unit, double value, int speed)
|
||||
{
|
||||
char cmd[256];
|
||||
|
@ -1540,30 +1562,52 @@ int MachineObject::command_ipcam_timelapse(bool on_off)
|
|||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_xcam_control(std::string module_name, bool on_off, bool print_halt)
|
||||
int MachineObject::command_xcam_control(std::string module_name, bool on_off, std::string lvl)
|
||||
{
|
||||
json j;
|
||||
j["xcam"]["command"] = "xcam_control_set";
|
||||
j["xcam"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["xcam"]["module_name"] = module_name;
|
||||
j["xcam"]["control"] = on_off;
|
||||
j["xcam"]["print_halt"] = print_halt;
|
||||
j["xcam"]["enable"] = on_off; //old protocol
|
||||
j["xcam"]["print_halt"] = true; //old protocol
|
||||
if (!lvl.empty()) {
|
||||
j["xcam"]["halt_print_sensitivity"] = lvl;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "command:xcam_control_set" << ", sequence_id:" << std::to_string(MachineObject::m_sequence_id)<<
|
||||
", module_name:" << module_name << ", control:" << on_off << ", halt_print_sensitivity:" << lvl;
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_xcam_control_ai_monitoring(bool on_off, std::string lvl)
|
||||
{
|
||||
bool print_halt = (lvl == "never_halt") ? false:true;
|
||||
|
||||
xcam_ai_monitoring = on_off;
|
||||
xcam_ai_monitoring_hold_count = HOLD_COUNT_MAX;
|
||||
xcam_ai_monitoring_sensitivity = lvl;
|
||||
return command_xcam_control("printing_monitor", on_off, lvl);
|
||||
}
|
||||
|
||||
int MachineObject::command_xcam_control_buildplate_marker_detector(bool on_off)
|
||||
{
|
||||
xcam_buildplate_marker_detector = on_off;
|
||||
xcam_buildplate_marker_hold_count = HOLD_COUNT_MAX;
|
||||
return command_xcam_control("buildplate_marker_detector", on_off);
|
||||
}
|
||||
|
||||
int MachineObject::command_xcam_control_first_layer_inspector(bool on_off, bool print_halt)
|
||||
{
|
||||
xcam_first_layer_inspector = on_off;
|
||||
xcam_first_layer_hold_count = HOLD_COUNT_MAX;
|
||||
return command_xcam_control("first_layer_inspector", on_off, print_halt);
|
||||
return command_xcam_control("first_layer_inspector", on_off);
|
||||
}
|
||||
|
||||
int MachineObject::command_xcam_control_spaghetti_detector(bool on_off, bool print_halt)
|
||||
int MachineObject::command_xcam_control_auto_recovery_step_loss(bool on_off)
|
||||
{
|
||||
xcam_spaghetti_detector = on_off;
|
||||
xcam_spaghetti_print_halt = print_halt;
|
||||
xcam_spaghetti_hold_count = HOLD_COUNT_MAX;
|
||||
return command_xcam_control("spaghetti_detector", on_off, print_halt);
|
||||
xcam_auto_recovery_step_loss = on_off;
|
||||
xcam_auto_recovery_hold_count = HOLD_COUNT_MAX;
|
||||
return command_set_printing_option(on_off);
|
||||
}
|
||||
|
||||
void MachineObject::set_bind_status(std::string status)
|
||||
|
@ -1763,8 +1807,14 @@ bool MachineObject::is_function_supported(PrinterFunction func)
|
|||
case FUNC_FIRSTLAYER_INSPECT:
|
||||
func_name = "FUNC_FIRSTLAYER_INSPECT";
|
||||
break;
|
||||
case FUNC_SPAGHETTI:
|
||||
func_name = "FUNC_SPAGHETTI";
|
||||
case FUNC_AI_MONITORING:
|
||||
func_name = "FUNC_AI_MONITORING";
|
||||
break;
|
||||
case FUNC_BUILDPLATE_MARKER_DETECT:
|
||||
func_name = "FUNC_BUILDPLATE_MARKER_DETECT";
|
||||
break;
|
||||
case FUNC_AUTO_RECOVERY_STEP_LOSS:
|
||||
func_name = "FUNC_AUTO_RECOVERY_STEP_LOSS";
|
||||
break;
|
||||
case FUNC_FLOW_CALIBRATION:
|
||||
func_name = "FUNC_FLOW_CALIBRATION";
|
||||
|
@ -2279,6 +2329,27 @@ int MachineObject::parse_json(std::string payload)
|
|||
|
||||
try {
|
||||
if (jj.contains("xcam")) {
|
||||
if (xcam_ai_monitoring_hold_count > 0)
|
||||
xcam_ai_monitoring_hold_count--;
|
||||
else {
|
||||
if (jj["xcam"].contains("printing_monitor")) {
|
||||
// new protocol
|
||||
xcam_ai_monitoring = jj["xcam"]["printing_monitor"].get<bool>();
|
||||
} else {
|
||||
// old version protocol
|
||||
if (jj["xcam"].contains("spaghetti_detector")) {
|
||||
xcam_ai_monitoring = jj["xcam"]["spaghetti_detector"].get<bool>();
|
||||
if (jj["xcam"].contains("print_halt")) {
|
||||
bool print_halt = jj["xcam"]["print_halt"].get<bool>();
|
||||
if (print_halt) { xcam_ai_monitoring_sensitivity = "medium"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
if (jj["xcam"].contains("halt_print_sensitivity")) {
|
||||
xcam_ai_monitoring_sensitivity = jj["xcam"]["halt_print_sensitivity"].get<std::string>();
|
||||
}
|
||||
}
|
||||
|
||||
if (xcam_first_layer_hold_count > 0)
|
||||
xcam_first_layer_hold_count--;
|
||||
else {
|
||||
|
@ -2287,14 +2358,11 @@ int MachineObject::parse_json(std::string payload)
|
|||
}
|
||||
}
|
||||
|
||||
if (xcam_spaghetti_hold_count > 0) {
|
||||
xcam_spaghetti_hold_count--;
|
||||
} else {
|
||||
if (jj["xcam"].contains("spaghetti_detector")) {
|
||||
xcam_spaghetti_detector = jj["xcam"]["spaghetti_detector"].get<bool>();
|
||||
}
|
||||
if (jj["xcam"].contains("print_halt")) {
|
||||
xcam_spaghetti_print_halt = jj["xcam"]["print_halt"].get<bool>();
|
||||
if (xcam_buildplate_marker_hold_count > 0)
|
||||
xcam_buildplate_marker_hold_count--;
|
||||
else {
|
||||
if (jj["xcam"].contains("buildplate_marker_detector")) {
|
||||
xcam_buildplate_marker_detector = jj["xcam"]["buildplate_marker_detector"].get<bool>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2614,17 +2682,54 @@ int MachineObject::parse_json(std::string payload)
|
|||
}
|
||||
}
|
||||
} else if (jj["command"].get<std::string>() == "xcam_control_set") {
|
||||
if (jj.contains("module_name") && jj.contains("control")) {
|
||||
if (jj["module_name"].get<std::string>() == "first_layer_inspector") {
|
||||
xcam_first_layer_inspector = jj["control"].get<bool>();
|
||||
xcam_first_layer_hold_count = HOLD_COUNT_MAX;
|
||||
} else if (jj["module_name"].get<std::string>() == "spaghetti_detector") {
|
||||
xcam_spaghetti_detector = jj["control"].get<bool>();
|
||||
xcam_spaghetti_hold_count = HOLD_COUNT_MAX;
|
||||
if (jj.contains("print_halt"))
|
||||
xcam_spaghetti_print_halt = jj["print_halt"].get<bool>();
|
||||
if (jj.contains("module_name")) {
|
||||
if (jj.contains("enable") || jj.contains("control")) {
|
||||
bool enable = false;
|
||||
if (jj.contains("enable"))
|
||||
enable = jj["enable"].get<bool>();
|
||||
else if (jj.contains("control"))
|
||||
enable = jj["control"].get<bool>();
|
||||
else {
|
||||
;
|
||||
}
|
||||
|
||||
if (jj["module_name"].get<std::string>() == "first_layer_inspector") {
|
||||
xcam_first_layer_inspector = enable;
|
||||
xcam_first_layer_hold_count = HOLD_COUNT_MAX;
|
||||
}
|
||||
else if (jj["module_name"].get<std::string>() == "buildplate_marker_detector") {
|
||||
xcam_buildplate_marker_detector = enable;
|
||||
xcam_buildplate_marker_hold_count = HOLD_COUNT_MAX;
|
||||
}
|
||||
else if (jj["module_name"].get<std::string>() == "printing_monitor") {
|
||||
xcam_ai_monitoring = enable;
|
||||
xcam_ai_monitoring_hold_count = HOLD_COUNT_MAX;
|
||||
if (jj.contains("halt_print_sensitivity")) {
|
||||
xcam_ai_monitoring_sensitivity = jj["halt_print_sensitivity"].get<std::string>();
|
||||
}
|
||||
}
|
||||
else if (jj["module_name"].get<std::string>() == "spaghetti_detector") {
|
||||
// old protocol
|
||||
xcam_ai_monitoring = enable;
|
||||
xcam_ai_monitoring_hold_count = HOLD_COUNT_MAX;
|
||||
if (jj.contains("print_halt")) {
|
||||
if (jj["print_halt"].get<bool>())
|
||||
xcam_ai_monitoring_sensitivity = "medium";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if(jj["command"].get<std::string>() == "print_option") {
|
||||
try {
|
||||
if (jj.contains("option")) {
|
||||
if (jj["option"].is_number()) {
|
||||
int option = jj["option"].get<int>();
|
||||
_parse_print_option_ack(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(...) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue