OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::TaskStateInfo Class Reference

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

Collaboration diagram for Slic3r::TaskStateInfo:

Public Types

typedef std::function< void(TaskState state, int percent)> StateChangedFn

Public Member Functions

 TaskStateInfo (const PrintParams param)
 TaskStateInfo ()
TaskState state ()
void set_state (TaskState ts)
PrintParams get_params ()
PrintParams & params ()
std::string get_job_id ()
void update_sending_percent (int percent)
void set_sent_time (std::chrono::system_clock::time_point time)
void set_state_changed_fn (StateChangedFn fn)
void set_cancel_fn (WasCancelledFn fn)
void set_task_name (std::string name)
void set_device_name (std::string name)
void set_job_id (std::string job_id)
void update ()
void cancel ()
bool is_canceled ()
std::string get_device_name ()
std::string get_task_name ()
std::string get_sent_time ()

Public Attributes

std::chrono::system_clock::time_point sent_time
WasCancelledFn cancel_fn
OnUpdateStatusFn update_status_fn
OnWaitFn wait_fn
std::string thumbnail_url
std::string start_time
std::string end_time
std::string profile_id
int task_info_id

Static Public Attributes

static int g_task_info_id = 0

Private Attributes

bool m_cancel
TaskState m_state
std::string m_task_name
std::string m_device_name
PrintParams m_params
int m_sending_percent
std::string m_job_id
StateChangedFn m_state_changed_fn

Detailed Description

Member Typedef Documentation

◆ StateChangedFn

typedef std::function<void(TaskState state, int percent)> Slic3r::TaskStateInfo::StateChangedFn

Constructor & Destructor Documentation

◆ TaskStateInfo() [1/2]

Slic3r::TaskStateInfo::TaskStateInfo ( const PrintParams param)
83 , m_params(param)
85 , m_state_changed_fn(nullptr)
86 , m_cancel(false)
87{
89
90 this->set_task_name(param.project_name);
91 this->set_device_name(param.dev_name);
92
93 cancel_fn = [this]() {
94 return m_cancel;
95 };
96 update_status_fn = [this](int stage, int code, std::string msg) {
97
98 if (stage == PrintingStageLimit)
99 {
100 //limit
101 //wxCommandEvent event(EVT_MULTI_SEND_LIMIT);
102 //wxPostEvent(this, event);
103 GUI::wxGetApp().mainframe->CallAfter([]() {
104 GUI::wxGetApp().show_dialog(_L("The printing task exceeds the limit, supporting a maximum of 6 printers."));
105 });
106 }
107
108 const int StagePercentPoint[(int)PrintingStageFinished + 1] = {
109 10, // PrintingStageCreate
110 25, // PrintingStageUpload
111 70, // PrintingStageWaiting
112 75, // PrintingStageRecord
113 90, // PrintingStageSending
114 95, // PrintingStageFinished
115 100 // PrintingStageFinished
116 };
117 BOOST_LOG_TRIVIAL(trace) << "task_manager: update task, " << m_params.dev_id << ", stage = " << stage << "code = " << code;
118 // update current percnet
119 int curr_percent = 0;
120 if (stage >= 0 && stage <= (int)PrintingStageFinished) {
121 curr_percent = StagePercentPoint[stage];
124 && (code > 0 && code <= 100)) {
125 curr_percent = (StagePercentPoint[stage + 1] - StagePercentPoint[stage]) * code / 100 + StagePercentPoint[stage];
126 BOOST_LOG_TRIVIAL(trace) << "task_manager: percent = " << curr_percent;
127 }
128 }
129
130 BOOST_LOG_TRIVIAL(trace) << "task_manager: update task, curr_percent = " << curr_percent;
131 update_sending_percent(curr_percent);
132 };
133
134 wait_fn = [this](int status, std::string job_info) {
135 BOOST_LOG_TRIVIAL(info) << "task_manager: get_job_info = " << job_info;
136 m_job_id = job_info;
137 return true;
138 };
139}
#define _L(s)
Definition OBJ.cpp:34
TaskState m_state
Definition TaskManager.hpp:121
static int g_task_info_id
Definition TaskManager.hpp:45
bool m_cancel
Definition TaskManager.hpp:120
WasCancelledFn cancel_fn
Definition TaskManager.hpp:111
OnWaitFn wait_fn
Definition TaskManager.hpp:113
void set_device_name(std::string name)
Definition TaskManager.hpp:85
void set_task_name(std::string name)
Definition TaskManager.hpp:84
OnUpdateStatusFn update_status_fn
Definition TaskManager.hpp:112
int task_info_id
Definition TaskManager.hpp:118
void update_sending_percent(int percent)
Definition TaskManager.hpp:68
StateChangedFn m_state_changed_fn
Definition TaskManager.hpp:127
PrintParams m_params
Definition TaskManager.hpp:124
int m_sending_percent
Definition TaskManager.hpp:125
std::string m_job_id
Definition TaskManager.hpp:126
void trace(unsigned int level, const char *message)
Definition utils.cpp:247
@ PrintingStageFinished
Definition bambu_networking.hpp:154
@ PrintingStageUpload
Definition bambu_networking.hpp:149
@ PrintingStageLimit
Definition bambu_networking.hpp:156
@ PrintingStageRecord
Definition bambu_networking.hpp:152
@ TS_PENDING
Definition TaskManager.hpp:27

References _L, cancel_fn, Slic3r::PrintParams::dev_name, g_task_info_id, m_cancel, m_job_id, m_params, m_sending_percent, m_state, m_state_changed_fn, Slic3r::PrintingStageFinished, Slic3r::PrintingStageLimit, Slic3r::PrintingStageRecord, Slic3r::PrintingStageUpload, Slic3r::PrintParams::project_name, set_device_name(), set_task_name(), task_info_id, Slic3r::trace(), Slic3r::TS_PENDING, update_sending_percent(), update_status_fn, and wait_fn.

Here is the call graph for this function:

◆ TaskStateInfo() [2/2]

Slic3r::TaskStateInfo::TaskStateInfo ( )
inline

Member Function Documentation

◆ cancel()

void Slic3r::TaskStateInfo::cancel ( )
142{
143 m_cancel = true;
146 update();
147}
void update()
Definition TaskManager.hpp:88
@ TS_REMOVED
Definition TaskManager.hpp:36

References m_cancel, m_state, Slic3r::TS_PENDING, Slic3r::TS_REMOVED, and update().

Here is the call graph for this function:

◆ get_device_name()

std::string Slic3r::TaskStateInfo::get_device_name ( )
inline
97{return m_device_name;};
std::string m_device_name
Definition TaskManager.hpp:123

References m_device_name.

Referenced by Slic3r::GUI::CloudTaskManagerPage::refresh_user_device(), and Slic3r::GUI::LocalTaskManagerPage::refresh_user_device().

Here is the caller graph for this function:

◆ get_job_id()

std::string Slic3r::TaskStateInfo::get_job_id ( )
inline
66{return profile_id;}
std::string profile_id
Definition TaskManager.hpp:117

References profile_id.

Referenced by Slic3r::TaskManager::get_task_list(), and Slic3r::GUI::CloudTaskManagerPage::refresh_user_device().

Here is the caller graph for this function:

◆ get_params()

PrintParams Slic3r::TaskStateInfo::get_params ( )
inline
62{ return m_params; }

References m_params.

Referenced by Slic3r::TaskManager::schedule().

Here is the caller graph for this function:

◆ get_sent_time()

std::string Slic3r::TaskStateInfo::get_sent_time ( )
inline
99 {
100 std::time_t time = std::chrono::system_clock::to_time_t(sent_time);
101 std::tm* timeInfo = std::localtime(&time);
102
103 std::stringstream ss;
104 ss << std::put_time(timeInfo, "%Y-%m-%d %H:%M:%S");
105 std::string str = ss.str();
106 return str;
107 };
std::chrono::system_clock::time_point sent_time
Definition TaskManager.hpp:110

References sent_time.

Referenced by Slic3r::GUI::LocalTaskManagerPage::refresh_user_device().

Here is the caller graph for this function:

◆ get_task_name()

std::string Slic3r::TaskStateInfo::get_task_name ( )
inline
98{return m_task_name;};
std::string m_task_name
Definition TaskManager.hpp:122

References m_task_name.

Referenced by Slic3r::GUI::CloudTaskManagerPage::refresh_user_device(), and Slic3r::GUI::LocalTaskManagerPage::refresh_user_device().

Here is the caller graph for this function:

◆ is_canceled()

bool Slic3r::TaskStateInfo::is_canceled ( )
inline
95{ return m_cancel; }

References m_cancel.

Referenced by Slic3r::TaskManager::schedule().

Here is the caller graph for this function:

◆ params()

PrintParams & Slic3r::TaskStateInfo::params ( )
inline
64{ return m_params; }

References m_params.

Referenced by Slic3r::TaskManager::get_task_list(), Slic3r::GUI::CloudTaskManagerPage::refresh_user_device(), Slic3r::GUI::LocalTaskManagerPage::refresh_user_device(), and Slic3r::TaskManager::schedule().

Here is the caller graph for this function:

◆ set_cancel_fn()

void Slic3r::TaskStateInfo::set_cancel_fn ( WasCancelledFn fn)
inline
80 {
81 cancel_fn = fn;
82 }

References cancel_fn.

◆ set_device_name()

void Slic3r::TaskStateInfo::set_device_name ( std::string name)
inline
85{ m_device_name = name; }

References m_device_name.

Referenced by TaskStateInfo(), and Slic3r::TaskManager::get_task_list().

Here is the caller graph for this function:

◆ set_job_id()

void Slic3r::TaskStateInfo::set_job_id ( std::string job_id)
inline
86{ m_job_id = job_id; }

References m_job_id.

Referenced by Slic3r::TaskManager::get_task_list().

Here is the caller graph for this function:

◆ set_sent_time()

void Slic3r::TaskStateInfo::set_sent_time ( std::chrono::system_clock::time_point time)
inline
72 {
73 sent_time = time;
74 update();
75 }

References sent_time, and update().

Referenced by Slic3r::TaskManager::schedule().

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

◆ set_state()

void Slic3r::TaskStateInfo::set_state ( TaskState ts)
inline
55 {
56 BOOST_LOG_TRIVIAL(trace) << "TaskStateInfo set state = " << get_task_state_enum_str(ts);
57 m_state = ts;
60 }
61 }
std::string get_task_state_enum_str(TaskState ts)
Definition TaskManager.cpp:32

References Slic3r::get_task_state_enum_str(), m_sending_percent, m_state, m_state_changed_fn, and Slic3r::trace().

Referenced by Slic3r::TaskManager::get_task_list(), and Slic3r::TaskManager::schedule().

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

◆ set_state_changed_fn()

void Slic3r::TaskStateInfo::set_state_changed_fn ( StateChangedFn fn)
inline
76 {
78 update();
79 }

References m_state_changed_fn, and update().

Referenced by Slic3r::GUI::LocalTaskManagerPage::refresh_user_device().

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

◆ set_task_name()

void Slic3r::TaskStateInfo::set_task_name ( std::string name)
inline
84{ m_task_name = name; }

References m_task_name.

Referenced by TaskStateInfo(), and Slic3r::TaskManager::get_task_list().

Here is the caller graph for this function:

◆ state()

TaskState Slic3r::TaskStateInfo::state ( )
inline
54{ return m_state; }

References m_state.

Referenced by Slic3r::TaskGroup::need_schedule(), Slic3r::GUI::CloudTaskManagerPage::refresh_user_device(), Slic3r::GUI::LocalTaskManagerPage::refresh_user_device(), and Slic3r::TaskManager::schedule().

Here is the caller graph for this function:

◆ update()

void Slic3r::TaskStateInfo::update ( )
inline

References m_sending_percent, m_state, and m_state_changed_fn.

Referenced by cancel(), set_sent_time(), set_state_changed_fn(), and update_sending_percent().

Here is the caller graph for this function:

◆ update_sending_percent()

void Slic3r::TaskStateInfo::update_sending_percent ( int percent)
inline
68 {
69 m_sending_percent = percent;
70 update();
71 }

References m_sending_percent, and update().

Referenced by TaskStateInfo().

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

Member Data Documentation

◆ cancel_fn

WasCancelledFn Slic3r::TaskStateInfo::cancel_fn

◆ end_time

std::string Slic3r::TaskStateInfo::end_time

◆ g_task_info_id

int Slic3r::TaskStateInfo::g_task_info_id = 0
static

Referenced by TaskStateInfo(), and TaskStateInfo().

◆ m_cancel

bool Slic3r::TaskStateInfo::m_cancel
private

Referenced by TaskStateInfo(), cancel(), and is_canceled().

◆ m_device_name

std::string Slic3r::TaskStateInfo::m_device_name
private

Referenced by get_device_name(), and set_device_name().

◆ m_job_id

std::string Slic3r::TaskStateInfo::m_job_id
private

Referenced by TaskStateInfo(), and set_job_id().

◆ m_params

PrintParams Slic3r::TaskStateInfo::m_params
private

Referenced by TaskStateInfo(), get_params(), and params().

◆ m_sending_percent

int Slic3r::TaskStateInfo::m_sending_percent
private

◆ m_state

TaskState Slic3r::TaskStateInfo::m_state
private

◆ m_state_changed_fn

StateChangedFn Slic3r::TaskStateInfo::m_state_changed_fn
private

◆ m_task_name

std::string Slic3r::TaskStateInfo::m_task_name
private

Referenced by get_task_name(), and set_task_name().

◆ profile_id

std::string Slic3r::TaskStateInfo::profile_id

◆ sent_time

std::chrono::system_clock::time_point Slic3r::TaskStateInfo::sent_time

Referenced by get_sent_time(), and set_sent_time().

◆ start_time

std::string Slic3r::TaskStateInfo::start_time

◆ task_info_id

int Slic3r::TaskStateInfo::task_info_id

◆ thumbnail_url

std::string Slic3r::TaskStateInfo::thumbnail_url

◆ update_status_fn

OnUpdateStatusFn Slic3r::TaskStateInfo::update_status_fn

◆ wait_fn

OnWaitFn Slic3r::TaskStateInfo::wait_fn

The documentation for this class was generated from the following files: