OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::BindJob Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Jobs/BindJob.hpp>

Inheritance diagram for Slic3r::GUI::BindJob:
Collaboration diagram for Slic3r::GUI::BindJob:

Public Types

enum  JobPrepareState { PREPARE_STATE_DEFAULT = 0 , PREPARE_STATE_MENU = 1 }

Public Member Functions

 BindJob (std::string dev_id, std::string dev_ip, std::string dev_model, std::string sec_link, std::string ssdp_version)
int status_range () const
bool is_finished ()
void on_success (std::function< void()> success)
void update_status (Ctl &ctl, int st, const std::string &msg)
void process (Ctl &ctl) override
void finalize (bool canceled, std::exception_ptr &eptr) override
void set_event_handle (wxWindow *hanle)
void post_fail_event (int code, std::string info)
void set_improved (bool improved)

Private Attributes

wxWindow * m_event_handle {nullptr}
std::function< void()> m_success_fun {nullptr}
std::string m_dev_id
std::string m_dev_ip
std::string m_dev_model
std::string m_sec_link
std::string m_ssdp_version
bool m_job_finished { false }
bool m_improved {false}

Detailed Description

Member Enumeration Documentation

◆ JobPrepareState

Enumerator
PREPARE_STATE_DEFAULT 
PREPARE_STATE_MENU 
22 {
25 };
@ PREPARE_STATE_MENU
Definition Job.hpp:24
@ PREPARE_STATE_DEFAULT
Definition Job.hpp:23

Constructor & Destructor Documentation

◆ BindJob()

Slic3r::GUI::BindJob::BindJob ( std::string dev_id,
std::string dev_ip,
std::string dev_model,
std::string sec_link,
std::string ssdp_version )
31 :
32 m_dev_id(dev_id),
33 m_dev_ip(dev_ip),
34 m_dev_model(dev_model),
35 m_sec_link(sec_link),
36 m_ssdp_version(ssdp_version)
37{
38 ;
39}
std::string m_sec_link
Definition BindJob.hpp:24
std::string m_dev_ip
Definition BindJob.hpp:22
std::string m_dev_model
Definition BindJob.hpp:23
std::string m_dev_id
Definition BindJob.hpp:21
std::string m_ssdp_version
Definition BindJob.hpp:25

References m_dev_id, m_dev_ip, m_dev_model, m_sec_link, and m_ssdp_version.

Member Function Documentation

◆ finalize()

void Slic3r::GUI::BindJob::finalize ( bool canceled,
std::exception_ptr & eptr )
overridevirtual

Reimplemented from Slic3r::GUI::Job.

147{
148 try {
149 if (eptr)
150 std::rethrow_exception(eptr);
151 eptr = nullptr;
152 } catch (...) {
153 eptr = std::current_exception();
154 }
155
156 if (canceled || eptr)
157 return;
158}

◆ is_finished()

bool Slic3r::GUI::BindJob::is_finished ( )
inline
37{ return m_job_finished; }
bool m_job_finished
Definition BindJob.hpp:26

References m_job_finished.

◆ on_success()

void Slic3r::GUI::BindJob::on_success ( std::function< void()> success)
42{
43 m_success_fun = success;
44}
std::function< void()> m_success_fun
Definition BindJob.hpp:20

References m_success_fun.

◆ post_fail_event()

void Slic3r::GUI::BindJob::post_fail_event ( int code,
std::string info )
166{
167 wxCommandEvent event(EVT_BIND_MACHINE_FAIL);
168 event.SetInt(code);
169 event.SetString(info);
170 event.SetEventObject(m_event_handle);
171 wxPostEvent(m_event_handle, event);
172}
wxWindow * m_event_handle
Definition BindJob.hpp:19

References m_event_handle.

Referenced by process().

Here is the caller graph for this function:

◆ process()

void Slic3r::GUI::BindJob::process ( Ctl & ctl)
overridevirtual

Implements Slic3r::GUI::Job.

56{
57 int result_code = 0;
58 std::string result_info;
59
60 /* display info */
61 auto msg = waiting_auth_str;
62 int curr_percent = 0;
63
64 NetworkAgent* m_agent = wxGetApp().getAgent();
65 if (!m_agent) { return; }
66
67 // get timezone
68 wxDateTime::TimeZone tz(wxDateTime::Local);
69 long offset = tz.GetOffset();
70 std::string timezone = get_timezone_utc_hm(offset);
71
72 m_agent->track_update_property("ssdp_version", m_ssdp_version, "string");
73 int result = m_agent->bind(m_dev_ip, m_dev_id, m_dev_model, m_sec_link, timezone, m_improved,
74 [this, &ctl, &curr_percent, &msg, &result_code, &result_info](int stage, int code, std::string info) {
75
76 result_code = code;
77 result_info = info;
78
80 curr_percent = 15;
81 msg = _u8L("Logging in");
82 } else if (stage == BindJobStage::LoginStageLogin) {
83 curr_percent = 30;
84 msg = _u8L("Logging in");
85 } else if (stage == BindJobStage::LoginStageWaitForLogin) {
86 curr_percent = 45;
87 msg = _u8L("Logging in");
88 } else if (stage == BindJobStage::LoginStageGetIdentify) {
89 curr_percent = 60;
90 msg = _u8L("Logging in");
91 } else if (stage == BindJobStage::LoginStageWaitAuth) {
92 curr_percent = 80;
93 msg = _u8L("Logging in");
94 } else if (stage == BindJobStage::LoginStageFinished) {
95 curr_percent = 100;
96 msg = _u8L("Logging in");
97 } else {
98 msg = _u8L("Logging in");
99 }
100
101 if (code != 0) {
102 msg = _u8L("Login failed");
103 if (code == BAMBU_NETWORK_ERR_TIMEOUT) {
104 msg += _u8L("Please check the printer network connection.");
105 }
106 }
107 update_status(ctl, curr_percent, msg);
108 }
109 );
110
111 if (result < 0) {
112 BOOST_LOG_TRIVIAL(info) << "login: result = " << result;
113
115 int error_code;
116
117 try
118 {
119 error_code = stoi(result_info);
120 wxString error_msg = wxGetApp().get_hms_query()->query_print_error_msg(m_dev_id, error_code);
121 result_info = error_msg.ToStdString();
122 }
123 catch (...) {
124 ;
125 }
126 }
127
128 post_fail_event(result_code, result_info);
129 return;
130 }
131
132 DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
133 if (!dev) {
134 BOOST_LOG_TRIVIAL(error) << "login: dev is null";
135 post_fail_event(result_code, result_info);
136 return;
137 }
138 dev->update_user_machine_list_info(wxGetApp().get_printer_cloud_provider());
139
140 wxCommandEvent event(EVT_BIND_MACHINE_SUCCESS);
141 event.SetEventObject(m_event_handle);
142 wxPostEvent(m_event_handle, event);
143 return;
144}
#define BAMBU_NETWORK_ERR_TIMEOUT
Definition bambu_networking.hpp:33
#define BAMBU_NETWORK_ERR_BIND_ECODE_LOGIN_REPORT_FAILED
Definition bambu_networking.hpp:52
#define BAMBU_NETWORK_ERR_BIND_GET_PRINTER_TICKET_TIMEOUT
Definition bambu_networking.hpp:48
bool m_improved
Definition BindJob.hpp:27
void post_fail_event(int code, std::string info)
Definition BindJob.cpp:165
void update_status(Ctl &ctl, int st, const std::string &msg)
Definition BindJob.cpp:46
static auto waiting_auth_str
Definition BindJob.cpp:26
std::string get_timezone_utc_hm(long second)
Definition Utils.hpp:655
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582
@ LoginStageConnect
Definition bambu_networking.hpp:167
@ LoginStageGetIdentify
Definition bambu_networking.hpp:170
@ LoginStageFinished
Definition bambu_networking.hpp:172
@ LoginStageWaitAuth
Definition bambu_networking.hpp:171
@ LoginStageWaitForLogin
Definition bambu_networking.hpp:169
@ LoginStageLogin
Definition bambu_networking.hpp:168
#define _u8L(s)
Definition I18N.hpp:11

References _u8L, BAMBU_NETWORK_ERR_BIND_ECODE_LOGIN_REPORT_FAILED, BAMBU_NETWORK_ERR_BIND_GET_PRINTER_TICKET_TIMEOUT, BAMBU_NETWORK_ERR_TIMEOUT, Slic3r::NetworkAgent::bind(), Slic3r::get_timezone_utc_hm(), Slic3r::LoginStageConnect, Slic3r::LoginStageFinished, Slic3r::LoginStageGetIdentify, Slic3r::LoginStageLogin, Slic3r::LoginStageWaitAuth, Slic3r::LoginStageWaitForLogin, m_dev_id, m_dev_ip, m_dev_model, m_event_handle, m_improved, m_sec_link, m_ssdp_version, Slic3r::offset(), post_fail_event(), Slic3r::NetworkAgent::track_update_property(), update_status(), Slic3r::DeviceManager::update_user_machine_list_info(), and Slic3r::GUI::waiting_auth_str.

Here is the call graph for this function:

◆ set_event_handle()

void Slic3r::GUI::BindJob::set_event_handle ( wxWindow * hanle)
161{
162 m_event_handle = hanle;
163}

References m_event_handle.

◆ set_improved()

void Slic3r::GUI::BindJob::set_improved ( bool improved)
inline
45{m_improved = improved;};

References m_improved.

◆ status_range()

int Slic3r::GUI::BindJob::status_range ( ) const
inline
33 {
34 return 100;
35 }

◆ update_status()

void Slic3r::GUI::BindJob::update_status ( Ctl & ctl,
int st,
const std::string & msg )
47{
48 ctl.update_status(st, msg);
49 wxCommandEvent event(EVT_BIND_UPDATE_MESSAGE);
50 event.SetString(msg);
51 event.SetEventObject(m_event_handle);
52 wxPostEvent(m_event_handle, event);
53}

References m_event_handle, and Slic3r::GUI::Job::Ctl::update_status().

Referenced by process().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_dev_id

std::string Slic3r::GUI::BindJob::m_dev_id
private

Referenced by BindJob(), and process().

◆ m_dev_ip

std::string Slic3r::GUI::BindJob::m_dev_ip
private

Referenced by BindJob(), and process().

◆ m_dev_model

std::string Slic3r::GUI::BindJob::m_dev_model
private

Referenced by BindJob(), and process().

◆ m_event_handle

wxWindow* Slic3r::GUI::BindJob::m_event_handle {nullptr}
private
19{nullptr};

Referenced by post_fail_event(), process(), set_event_handle(), and update_status().

◆ m_improved

bool Slic3r::GUI::BindJob::m_improved {false}
private
27{false};

Referenced by process(), and set_improved().

◆ m_job_finished

bool Slic3r::GUI::BindJob::m_job_finished { false }
private
26{ false };

Referenced by is_finished().

◆ m_sec_link

std::string Slic3r::GUI::BindJob::m_sec_link
private

Referenced by BindJob(), and process().

◆ m_ssdp_version

std::string Slic3r::GUI::BindJob::m_ssdp_version
private

Referenced by BindJob(), and process().

◆ m_success_fun

std::function<void()> Slic3r::GUI::BindJob::m_success_fun {nullptr}
private
20{nullptr};

Referenced by on_success().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Jobs/BindJob.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Jobs/BindJob.cpp