ENH: waiting for printer ack in printing job
JIRA: STUDIO-4175 Change-Id: I94c26497979d7ffecebf378a4c4bc244914491fd Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
38b86616ce
commit
2ff4173db3
|
@ -1645,6 +1645,7 @@ int MachineObject::command_control_fan_val(FanType fan_type, int val)
|
|||
|
||||
int MachineObject::command_task_abort()
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(trace) << "command_task_abort: ";
|
||||
json j;
|
||||
j["print"]["command"] = "stop";
|
||||
j["print"]["param"] = "";
|
||||
|
@ -1653,6 +1654,18 @@ int MachineObject::command_task_abort()
|
|||
return this->publish_json(j.dump(), 1);
|
||||
}
|
||||
|
||||
int MachineObject::command_task_cancel(std::string job_id)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(trace) << "command_task_cancel: " << job_id;
|
||||
json j;
|
||||
j["print"]["command"] = "stop";
|
||||
j["print"]["param"] = "";
|
||||
j["print"]["job_id"] = job_id;
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
|
||||
return this->publish_json(j.dump(), 1);
|
||||
}
|
||||
|
||||
int MachineObject::command_task_pause()
|
||||
{
|
||||
json j;
|
||||
|
@ -2460,6 +2473,7 @@ void MachineObject::reset()
|
|||
nozzle_diameter = 0.0f;
|
||||
network_wired = false;
|
||||
dev_connection_name = "";
|
||||
job_id_ = "";
|
||||
|
||||
// reset print_json
|
||||
json empty_j;
|
||||
|
@ -3064,6 +3078,10 @@ int MachineObject::parse_json(std::string payload)
|
|||
if (jj.contains("gcode_state")) {
|
||||
this->set_print_state(jj["gcode_state"].get<std::string>());
|
||||
}
|
||||
if (jj.contains("job_id")) {
|
||||
this->job_id_ = jj["job_id"].get<std::string>();
|
||||
}
|
||||
|
||||
if (jj.contains("queue_number")) {
|
||||
this->queue_number = jj["queue_number"].get<int>();
|
||||
} else {
|
||||
|
@ -4010,6 +4028,15 @@ int MachineObject::parse_json(std::string payload)
|
|||
t["signal"] = this->wifi_signal;
|
||||
m_agent->track_event("ack_cmd_gcode_line", t.dump());
|
||||
}
|
||||
} else if (jj["command"].get<std::string>() == "project_prepare") {
|
||||
//ack of project file
|
||||
BOOST_LOG_TRIVIAL(info) << "parse_json, ack of project_prepare = " << j.dump(4);
|
||||
if (m_agent) {
|
||||
if (jj.contains("job_id")) {
|
||||
this->job_id_ = jj["job_id"].get<std::string>();
|
||||
}
|
||||
}
|
||||
|
||||
} else if (jj["command"].get<std::string>() == "project_file") {
|
||||
//ack of project file
|
||||
BOOST_LOG_TRIVIAL(debug) << "parse_json, ack of project_file = " << j.dump(4);
|
||||
|
@ -4020,7 +4047,6 @@ int MachineObject::parse_json(std::string payload)
|
|||
t["signal"] = this->wifi_signal;
|
||||
m_agent->track_event("ack_cmd_project_file", t.dump());
|
||||
}
|
||||
|
||||
std::string result;
|
||||
if (jj.contains("result")) {
|
||||
result = jj["result"].get<std::string>();
|
||||
|
|
|
@ -722,8 +722,6 @@ public:
|
|||
int nozzle_max_temperature = -1;
|
||||
int bed_temperature_limit = -1;
|
||||
|
||||
|
||||
|
||||
/* sdcard */
|
||||
MachineObject::SdcardState sdcard_state { NO_SDCARD };
|
||||
MachineObject::SdcardState get_sdcard_state();
|
||||
|
@ -742,6 +740,7 @@ public:
|
|||
std::string profile_id_;
|
||||
std::string task_id_;
|
||||
std::string subtask_id_;
|
||||
std::string job_id_;
|
||||
BBLSliceInfo* slice_info {nullptr};
|
||||
boost::thread* get_slice_info_thread { nullptr };
|
||||
|
||||
|
@ -786,6 +785,8 @@ public:
|
|||
int command_control_fan(FanType fan_type, bool on_off);
|
||||
int command_control_fan_val(FanType fan_type, int val);
|
||||
int command_task_abort();
|
||||
/* cancelled the job_id */
|
||||
int command_task_cancel(std::string job_id);
|
||||
int command_task_pause();
|
||||
int command_task_resume();
|
||||
int command_set_bed(int temp);
|
||||
|
|
|
@ -209,7 +209,7 @@ void PrintJob::process()
|
|||
params.filename = job_data._temp_path.string();
|
||||
params.connection_type = this->connection_type;
|
||||
|
||||
result = m_agent->start_send_gcode_to_sdcard(params, nullptr, nullptr);
|
||||
result = m_agent->start_send_gcode_to_sdcard(params, nullptr, nullptr, nullptr);
|
||||
if (result != 0) {
|
||||
BOOST_LOG_TRIVIAL(error) << "access code is invalid";
|
||||
m_enter_ip_address_fun_fail();
|
||||
|
@ -391,6 +391,51 @@ void PrintJob::process()
|
|||
return was_canceled();
|
||||
};
|
||||
|
||||
|
||||
DeviceManager* dev = wxGetApp().getDeviceManager();
|
||||
MachineObject* obj = dev->get_selected_machine();
|
||||
|
||||
auto wait_fn = [this, curr_percent, &obj](int state, std::string job_info) {
|
||||
BOOST_LOG_TRIVIAL(info) << "print_job: get_job_info = " << job_info;
|
||||
std::string curr_job_id;
|
||||
json job_info_j;
|
||||
try {
|
||||
job_info_j.parse(job_info);
|
||||
if (job_info_j.contains("job_id")) {
|
||||
curr_job_id = job_info_j["job_id"].get<std::string>();
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(trace) << "print_job: curr_obj_id=" << curr_job_id;
|
||||
|
||||
} catch(...) {
|
||||
;
|
||||
}
|
||||
|
||||
if (obj) {
|
||||
int time_out = 0;
|
||||
while (time_out < PRINT_JOB_SENDING_TIMEOUT) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "print_job: obj job_id = " << obj->job_id_;
|
||||
if (!obj->job_id_.empty() && obj->job_id_.compare(curr_job_id) == 0) {
|
||||
BOOST_LOG_TRIVIAL(info) << "print_job: got job_id = " << obj->job_id_ << ", time_out=" << time_out;
|
||||
return true;
|
||||
}
|
||||
if (obj->is_in_printing_status(obj->print_status)) {
|
||||
BOOST_LOG_TRIVIAL(info) << "print_job: printer has enter printing status, s = " << obj->print_status;
|
||||
return true;
|
||||
}
|
||||
time_out++;
|
||||
boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));
|
||||
}
|
||||
this->update_status(curr_percent, _L("Print task sending times out."));
|
||||
BOOST_LOG_TRIVIAL(info) << "print_job: timeout, cancel the job" << obj->job_id_;
|
||||
/* handle tiemout */
|
||||
obj->command_task_cancel(curr_job_id);
|
||||
return false;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "print_job: obj is null";
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
if (params.connection_type != "lan") {
|
||||
if (params.dev_ip.empty())
|
||||
params.comments = "no_ip";
|
||||
|
@ -413,7 +458,7 @@ void PrintJob::process()
|
|||
BOOST_LOG_TRIVIAL(info) << "print_job: use ftp send print only";
|
||||
this->update_status(curr_percent, _L("Sending print job over LAN"));
|
||||
is_try_lan_mode = true;
|
||||
result = m_agent->start_local_print_with_record(params, update_fn, cancel_fn);
|
||||
result = m_agent->start_local_print_with_record(params, update_fn, cancel_fn, wait_fn);
|
||||
if (result < 0) {
|
||||
error_text = wxString::Format("Access code:%s Ip address:%s", params.password, params.dev_ip);
|
||||
// try to send with cloud
|
||||
|
@ -429,7 +474,7 @@ void PrintJob::process()
|
|||
// try to send local with record
|
||||
BOOST_LOG_TRIVIAL(info) << "print_job: try to start local print with record";
|
||||
this->update_status(curr_percent, _L("Sending print job over LAN"));
|
||||
result = m_agent->start_local_print_with_record(params, update_fn, cancel_fn);
|
||||
result = m_agent->start_local_print_with_record(params, update_fn, cancel_fn, wait_fn);
|
||||
if (result == 0) {
|
||||
params.comments = "";
|
||||
}
|
||||
|
@ -444,13 +489,13 @@ void PrintJob::process()
|
|||
// try to send with cloud
|
||||
BOOST_LOG_TRIVIAL(warning) << "print_job: try to send with cloud";
|
||||
this->update_status(curr_percent, _L("Sending print job through cloud service"));
|
||||
result = m_agent->start_print(params, update_fn, cancel_fn);
|
||||
result = m_agent->start_print(params, update_fn, cancel_fn, wait_fn);
|
||||
}
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(info) << "print_job: send with cloud";
|
||||
this->update_status(curr_percent, _L("Sending print job through cloud service"));
|
||||
result = m_agent->start_print(params, update_fn, cancel_fn);
|
||||
result = m_agent->start_print(params, update_fn, cancel_fn, wait_fn);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -489,6 +534,8 @@ void PrintJob::process()
|
|||
|
||||
BOOST_LOG_TRIVIAL(error) << "print_job: failed, result = " << result;
|
||||
} else {
|
||||
// wait for printer mqtt ready the same job id
|
||||
|
||||
wxGetApp().plater()->record_slice_preset("print");
|
||||
|
||||
BOOST_LOG_TRIVIAL(error) << "print_job: send ok.";
|
||||
|
|
|
@ -10,6 +10,8 @@ namespace fs = boost::filesystem;
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
#define PRINT_JOB_SENDING_TIMEOUT 10
|
||||
|
||||
class PrintPrepareData
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -139,7 +139,7 @@ void SendJob::process()
|
|||
params.filename = job_data._temp_path.string();
|
||||
params.connection_type = this->connection_type;
|
||||
|
||||
result = m_agent->start_send_gcode_to_sdcard(params, nullptr, nullptr);
|
||||
result = m_agent->start_send_gcode_to_sdcard(params, nullptr, nullptr, nullptr);
|
||||
if (result != 0) {
|
||||
BOOST_LOG_TRIVIAL(error) << "access code is invalid";
|
||||
m_enter_ip_address_fun_fail(result);
|
||||
|
@ -317,7 +317,7 @@ void SendJob::process()
|
|||
// try to send local with record
|
||||
BOOST_LOG_TRIVIAL(info) << "send_job: try to send gcode to printer";
|
||||
this->update_status(curr_percent, _L("Sending gcode file over LAN"));
|
||||
result = m_agent->start_send_gcode_to_sdcard(params, update_fn, cancel_fn);
|
||||
result = m_agent->start_send_gcode_to_sdcard(params, update_fn, cancel_fn, nullptr);
|
||||
if (result == BAMBU_NETWORK_ERR_FTP_UPLOAD_FAILED) {
|
||||
params.comments = "upload_failed";
|
||||
} else {
|
||||
|
@ -335,7 +335,7 @@ void SendJob::process()
|
|||
} else {
|
||||
if (this->has_sdcard) {
|
||||
this->update_status(curr_percent, _L("Sending gcode file over LAN"));
|
||||
result = m_agent->start_send_gcode_to_sdcard(params, update_fn, cancel_fn);
|
||||
result = m_agent->start_send_gcode_to_sdcard(params, update_fn, cancel_fn, nullptr);
|
||||
} else {
|
||||
this->update_status(curr_percent, _L("An SD card needs to be inserted before sending to printer."));
|
||||
return;
|
||||
|
|
|
@ -895,33 +895,33 @@ int NetworkAgent::set_user_selected_machine(std::string dev_id)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::start_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn)
|
||||
int NetworkAgent::start_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && start_print_ptr) {
|
||||
ret = start_print_ptr(network_agent, params, update_fn, cancel_fn);
|
||||
ret = start_print_ptr(network_agent, params, update_fn, cancel_fn, wait_fn);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" : network_agent=%1%, ret=%2%, dev_id=%3%, task_name=%4%, project_name=%5%")
|
||||
%network_agent %ret %params.dev_id %params.task_name %params.project_name;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::start_local_print_with_record(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn)
|
||||
int NetworkAgent::start_local_print_with_record(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && start_local_print_with_record_ptr) {
|
||||
ret = start_local_print_with_record_ptr(network_agent, params, update_fn, cancel_fn);
|
||||
ret = start_local_print_with_record_ptr(network_agent, params, update_fn, cancel_fn, wait_fn);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" : network_agent=%1%, ret=%2%, dev_id=%3%, task_name=%4%, project_name=%5%")
|
||||
%network_agent %ret %params.dev_id %params.task_name %params.project_name;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::start_send_gcode_to_sdcard(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn)
|
||||
int NetworkAgent::start_send_gcode_to_sdcard(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && start_send_gcode_to_sdcard_ptr) {
|
||||
ret = start_send_gcode_to_sdcard_ptr(network_agent, params, update_fn, cancel_fn);
|
||||
ret = start_send_gcode_to_sdcard_ptr(network_agent, params, update_fn, cancel_fn, wait_fn);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" : network_agent=%1%, ret=%2%, dev_id=%3%, task_name=%4%, project_name=%5%")
|
||||
% network_agent % ret % params.dev_id % params.task_name % params.project_name;
|
||||
}
|
||||
|
|
|
@ -51,9 +51,9 @@ typedef int (*func_unbind)(void *agent, std::string dev_id);
|
|||
typedef std::string (*func_get_bambulab_host)(void *agent);
|
||||
typedef std::string (*func_get_user_selected_machine)(void *agent);
|
||||
typedef int (*func_set_user_selected_machine)(void *agent, std::string dev_id);
|
||||
typedef int (*func_start_print)(void *agent, PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn);
|
||||
typedef int (*func_start_local_print_with_record)(void *agent, PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn);
|
||||
typedef int (*func_start_send_gcode_to_sdcard)(void *agent, PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn);
|
||||
typedef int (*func_start_print)(void *agent, PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn);
|
||||
typedef int (*func_start_local_print_with_record)(void *agent, PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn);
|
||||
typedef int (*func_start_send_gcode_to_sdcard)(void *agent, PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn);
|
||||
typedef int (*func_start_local_print)(void *agent, PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn);
|
||||
typedef int (*func_get_user_presets)(void *agent, std::map<std::string, std::map<std::string, std::string>>* user_presets);
|
||||
typedef std::string (*func_request_setting_id)(void *agent, std::string name, std::map<std::string, std::string>* values_map, unsigned int* http_code);
|
||||
|
@ -153,9 +153,9 @@ public:
|
|||
std::string get_bambulab_host();
|
||||
std::string get_user_selected_machine();
|
||||
int set_user_selected_machine(std::string dev_id);
|
||||
int start_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn);
|
||||
int start_local_print_with_record(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn);
|
||||
int start_send_gcode_to_sdcard(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn);
|
||||
int start_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn);
|
||||
int start_local_print_with_record(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn);
|
||||
int start_send_gcode_to_sdcard(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn);
|
||||
int start_local_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn);
|
||||
int get_user_presets(std::map<std::string, std::map<std::string, std::string>>* user_presets);
|
||||
std::string request_setting_id(std::string name, std::map<std::string, std::string>* values_map, unsigned int* http_code);
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace BBL {
|
|||
|
||||
#define BAMBU_NETWORK_LIBRARY "bambu_networking"
|
||||
#define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent"
|
||||
#define BAMBU_NETWORK_AGENT_VERSION "01.07.06.01"
|
||||
#define BAMBU_NETWORK_AGENT_VERSION "01.07.07.01"
|
||||
|
||||
//iot preset type strings
|
||||
#define IOT_PRINTER_TYPE_STRING "printer"
|
||||
|
|
|
@ -12,4 +12,4 @@ set(BBL_INTERNAL_TESTING "1")
|
|||
endif()
|
||||
|
||||
# The build_version should start from 50 in master branch
|
||||
set(SLIC3R_VERSION "01.07.06.54")
|
||||
set(SLIC3R_VERSION "01.07.07.51")
|
||||
|
|
Loading…
Reference in New Issue