Implement manual printer setup
This commit is contained in:
parent
cbc97f4ae7
commit
f4acdd775e
4 changed files with 41 additions and 21 deletions
|
@ -5496,18 +5496,28 @@ void DeviceManager::on_machine_alive(std::string json_str)
|
|||
}
|
||||
}
|
||||
|
||||
MachineObject* DeviceManager::insert_local_device(std::string dev_name, std::string dev_id, std::string dev_ip, std::string connection_type, std::string bind_state, std::string version, std::string access_code)
|
||||
MachineObject* DeviceManager::insert_local_device(const BBLocalMachine& machine, std::string connection_type, std::string bind_state, std::string version, std::string access_code)
|
||||
{
|
||||
MachineObject* obj;
|
||||
obj = new MachineObject(m_agent, dev_name, dev_id, dev_ip);
|
||||
obj->printer_type = MachineObject::parse_printer_type("C11");
|
||||
auto it = localMachineList.find(machine.dev_id);
|
||||
if (it != localMachineList.end()) {
|
||||
obj = it->second;
|
||||
} else {
|
||||
obj = new MachineObject(m_agent, machine.dev_name, machine.dev_id, machine.dev_ip);
|
||||
localMachineList.insert(std::make_pair(machine.dev_id, obj));
|
||||
}
|
||||
obj->printer_type = MachineObject::parse_printer_type(machine.printer_type);
|
||||
obj->dev_connection_type = connection_type;
|
||||
obj->bind_state = bind_state;
|
||||
obj->bind_sec_link = "secure";
|
||||
obj->bind_ssdp_version = version;
|
||||
obj->m_is_online = true;
|
||||
obj->last_alive = Slic3r::Utils::get_current_time_utc();
|
||||
obj->set_access_code(access_code, false);
|
||||
obj->set_user_access_code(access_code, false);
|
||||
|
||||
update_local_machine(*obj);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ using namespace nlohmann;
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
struct BBLocalMachine;
|
||||
class SecondaryCheckDialog;
|
||||
enum PrinterArch {
|
||||
ARCH_CORE_XY,
|
||||
|
@ -1032,7 +1033,7 @@ public:
|
|||
|
||||
/* create machine or update machine properties */
|
||||
void on_machine_alive(std::string json_str);
|
||||
MachineObject* insert_local_device(std::string dev_name, std::string dev_id, std::string dev_ip, std::string connection_type, std::string bind_state, std::string version, std::string access_code);
|
||||
MachineObject* insert_local_device(const BBLocalMachine& machine, std::string connection_type, std::string bind_state, std::string version, std::string access_code);
|
||||
/* disconnect all machine connections */
|
||||
void disconnect_all();
|
||||
int query_bind_status(std::string &msg);
|
||||
|
|
|
@ -1922,6 +1922,7 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt)
|
|||
m_trouble_shoot->Hide();
|
||||
std::string str_ip = m_input_ip->GetTextCtrl()->GetValue().ToStdString();
|
||||
std::string str_access_code = m_input_access_code->GetTextCtrl()->GetValue().ToStdString();
|
||||
std::string str_name = m_input_printer_name->GetTextCtrl()->GetValue().Strip(wxString::both).ToStdString();
|
||||
std::string str_sn = m_input_sn->GetTextCtrl()->GetValue().ToStdString();
|
||||
std::string str_model_id = "";
|
||||
|
||||
|
@ -1940,7 +1941,7 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt)
|
|||
Refresh();
|
||||
Layout();
|
||||
Fit();
|
||||
m_thread = new boost::thread(boost::bind(&InputIpAddressDialog::workerThreadFunc, this, str_ip, str_access_code, str_sn, str_model_id));
|
||||
m_thread = new boost::thread(boost::bind(&InputIpAddressDialog::workerThreadFunc, this, str_ip, str_access_code, str_sn, str_model_id, str_name));
|
||||
}
|
||||
|
||||
void InputIpAddressDialog::update_test_msg_event(wxCommandEvent& evt)
|
||||
|
@ -1961,7 +1962,7 @@ void InputIpAddressDialog::post_update_test_msg(wxString text, bool beconnect)
|
|||
wxPostEvent(this, event);
|
||||
}
|
||||
|
||||
void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_access_code, std::string sn, std::string model_id)
|
||||
void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_access_code, std::string sn, std::string model_id, std::string name)
|
||||
{
|
||||
post_update_test_msg(_L("connecting..."), true);
|
||||
|
||||
|
@ -1977,10 +1978,11 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_
|
|||
|
||||
} else {
|
||||
result = 0;
|
||||
detectData.dev_name = sn;
|
||||
detectData.model_id = model_id;
|
||||
detectData.dev_name = name;
|
||||
detectData.dev_id = sn;
|
||||
detectData.connect_type = "lan";
|
||||
detectData.connect_type = "free";
|
||||
detectData.bind_state = "free";
|
||||
}
|
||||
|
||||
if (result < 0) {
|
||||
|
@ -2012,27 +2014,34 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_
|
|||
return;
|
||||
}
|
||||
|
||||
DeviceManager* dev = wxGetApp().getDeviceManager();
|
||||
m_obj = dev->insert_local_device(detectData.dev_name, detectData.dev_id, str_ip, detectData.connect_type, detectData.bind_state, detectData.version, str_access_code);
|
||||
CallAfter([this, detectData, str_ip, str_access_code]() {
|
||||
DeviceManager* dev = wxGetApp().getDeviceManager();
|
||||
BBLocalMachine machine;
|
||||
machine.dev_name = detectData.dev_name;
|
||||
machine.dev_ip = str_ip;
|
||||
machine.dev_id = detectData.dev_id;
|
||||
machine.printer_type = detectData.model_id;
|
||||
m_obj = dev->insert_local_device(machine, detectData.connect_type, detectData.bind_state, detectData.version, str_access_code);
|
||||
|
||||
|
||||
if (m_obj) {
|
||||
m_obj->set_user_access_code(str_access_code);
|
||||
wxGetApp().getDeviceManager()->set_selected_machine(m_obj->dev_id);
|
||||
}
|
||||
if (m_obj) {
|
||||
m_obj->set_user_access_code(str_access_code);
|
||||
wxGetApp().getDeviceManager()->set_selected_machine(m_obj->dev_id, true);
|
||||
}
|
||||
|
||||
|
||||
closeCount = 1;
|
||||
closeCount = 1;
|
||||
|
||||
post_update_test_msg(wxEmptyString, true);
|
||||
post_update_test_msg(wxString::Format(_L("Connecting to printer... The dialog will close later"), closeCount), true);
|
||||
post_update_test_msg(wxEmptyString, true);
|
||||
post_update_test_msg(wxString::Format(_L("Connecting to printer... The dialog will close later"), closeCount), true);
|
||||
|
||||
#ifdef __APPLE__
|
||||
wxCommandEvent event(EVT_CLOSE_IPADDRESS_DLG);
|
||||
wxPostEvent(this, event);
|
||||
wxCommandEvent event(EVT_CLOSE_IPADDRESS_DLG);
|
||||
wxPostEvent(this, event);
|
||||
#else
|
||||
closeTimer->Start(1000);
|
||||
closeTimer->Start(1000);
|
||||
#endif
|
||||
});
|
||||
}
|
||||
|
||||
void InputIpAddressDialog::OnTimer(wxTimerEvent& event) {
|
||||
|
|
|
@ -329,7 +329,7 @@ public:
|
|||
void on_ok(wxMouseEvent& evt);
|
||||
void update_test_msg_event(wxCommandEvent &evt);
|
||||
void post_update_test_msg(wxString text, bool beconnect);
|
||||
void workerThreadFunc(std::string str_ip, std::string str_access_code, std::string sn, std::string model_id);
|
||||
void workerThreadFunc(std::string str_ip, std::string str_access_code, std::string sn, std::string model_id, std::string name);
|
||||
void OnTimer(wxTimerEvent& event);
|
||||
void on_text(wxCommandEvent& evt);
|
||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||
|
|
Loading…
Reference in a new issue