update slic3r

This commit is contained in:
QIDI TECH
2025-05-08 15:05:30 +08:00
parent 126534997a
commit 011619cf23
307 changed files with 55594 additions and 19386 deletions

View File

@@ -17,6 +17,9 @@
#include "CameraPopup.hpp"
#include "libslic3r/Calib.hpp"
#include "libslic3r/Utils.hpp"
#include <wx/object.h>
#define USE_LOCAL_SOCKET_BIND 0
#define DISCONNECT_TIMEOUT 30000.f // milliseconds
@@ -35,9 +38,24 @@
#define HOLD_COUNT_MAX 3
#define HOLD_COUNT_CAMERA 6
#define HOLD_TIME_MAX 3 // 3 seconds
#define HOLD_TIME_SWITCHING 6 // 6 seconds
#define GET_VERSION_RETRYS 10
#define RETRY_INTERNAL 2000
#define VIRTUAL_TRAY_ID 254
#define MAIN_NOZZLE_ID 0
#define DEPUTY_NOZZLE_ID 1
#define UNIQUE_NOZZLE_ID MAIN_NOZZLE_ID
#define INVALID_NOZZLE_ID -1
#define VIRTUAL_TRAY_MAIN_ID 255
#define VIRTUAL_TRAY_DEPUTY_ID 254
#define VIRTUAL_AMS_MAIN_ID_STR "255"
#define VIRTUAL_AMS_DEPUTY_ID_STR "254"
#define START_SEQ_ID 20000
#define END_SEQ_ID 30000
#define SUBSCRIBE_RETRY_COUNT 5
@@ -135,6 +153,121 @@ enum ManualPaCaliMethod {
PA_PATTERN,
};
enum ExtruderSwitchState {
ES_IDLE = 0,
ES_BUSY,
ES_SWITCHING,
ES_SWITCHING_FAILED
};
enum AirDuctType {
AIR_FAN_TYPE,
AIR_DOOR_TYPE
};
enum NozzleFlowType{
NONE_FLOWTYPE,
S_FLOW,
H_FLOW
};
enum NozzleToolType {
NONE_TOOLTYPE,
H_TOOL,
C_TOOL
};
struct AmsSlot
{
std::string ams_id;
std::string slot_id;
};
struct Nozzle
{
int id;
NozzleToolType tool_type; // H nozzle or Cut
NozzleFlowType nozzle_flow; // 0-common 1-high flow
NozzleType nozzle_type; // 0-stainless_steel 1-hardened_steel
float diameter = {0.4f}; // 0-0.2mm 1-0.4mm 2-0.6 mm3-0.8mm
int max_temp = 0;
int wear = 0;
};
struct NozzleData
{
int extder_exist; //0- none exist 1-exist
int cut_exist;
int state; //0-idle 1-checking
std::vector<Nozzle> nozzles;
};
struct Extder
{
int id; // 0-right 1-left
int enable_change_nozzle{0};
int ext_has_filament{0};
int buffer_has_filament{0};
int nozzle_exist{0};
std::vector<int> filam_bak;// the refill filam
int temp{0};
int target_temp{0};
AmsSlot spre; // tray_pre
AmsSlot snow; // tray_now
AmsSlot star; // tray_tar
int ams_stat{0};
int rfid_stat{0};
int nozzle_id; // nozzle id now
int target_nozzle_id; // target nozzle id
//current nozzle
NozzleType current_nozzle_type{NozzleType::ntUndefine}; // 0-hardened_steel 1-stainless_steel
float current_nozzle_diameter = {0.4f}; // 0-0.2mm 1-0.4mm 2-0.6 mm3-0.8mm
NozzleFlowType current_nozzle_flow_type{NozzleFlowType::NONE_FLOWTYPE};//0-common 1-high flow
};
struct ExtderData
{
int current_extder_id{0};
int target_extder_id{0};
int total_extder_count {0};
int current_loading_extder_id {-1};
bool current_busy_for_loading{false};
ExtruderSwitchState switch_extder_state;
std::vector<Extder> extders;
};
struct AirMode
{
int id{-1};
std::vector<int> ctrl;
// If the fan is off, it cannot be controlled and is displayed as off
std::vector<int> off;
// If the fan is not off or ctrl, it will be displayed as auto
};
struct AirParts
{
int type{ 0 };
int id{ 0 };
int func{ 0 };
int state{ 0 };// 100%
int range_start{ 0 };// 100%
int range_end{ 0 };// 100%
};
struct AirDuctData
{
int curren_mode{ 0 };
std::vector<AirMode> modes;
std::vector<AirParts> parts;
};
struct RatingInfo {
bool request_successful;
@@ -178,6 +311,12 @@ public:
return wxColour(ret[0], ret[1], ret[2], ret[3]);
}
bool operator==(AmsTray const &o) const
{
return id == o.id && type == o.type && filament_setting_id == o.filament_setting_id && color == o.color;
}
bool operator!=(AmsTray const &o) const { return !operator==(o); }
std::string id;
std::string tag_uid; // tag_uid
std::string setting_id; // tray_info_idx
@@ -199,7 +338,7 @@ public:
int ctype = 0;
float k = 0.0f; // k range: 0 ~ 0.5
float n = 0.0f; // k range: 0.6 ~ 2.0
int cali_idx = 0;
int cali_idx = -1; // - 1 means default
wxColour wx_color;
bool is_qdt;
@@ -223,18 +362,56 @@ public:
std::string get_filament_type();
};
#define INVALID_AMS_TEMPERATURE std::numeric_limits<float>::min()
class Ams {
class Ams
{
public:
Ams(std::string ams_id) {
id = ams_id;
Ams(std::string ams_id, int nozzle_id, int type_id)
{
id = ams_id;
nozzle = nozzle_id;
type = type_id;
}
std::string id;
int humidity = 5;
bool startup_read_opt{true};
bool tray_read_opt{false};
bool is_exists{false};
std::map<std::string, AmsTray*> trayList;
std::string id;
std::string info;
int left_dry_time = 0;
int humidity = 5;
int humidity_raw = -1; // the percentage, -1 means invalid. eg. 100 means 100%
float current_temperature = INVALID_AMS_TEMPERATURE; // the temperature
bool startup_read_opt{true};
bool tray_read_opt{false};
bool is_exists{false};
std::map<std::string, AmsTray *> trayList;
int nozzle;
int type{1}; // 0:dummy 1:ams 2:ams-lite 3:n3f 4:n3s
public:
wxString get_ams_device_name() const
{
wxString ams_device_name;
if (type == 1) {
ams_device_name = "BOX-%d";
} else if (type == 2) {
ams_device_name = "BOX Lite-%d";
} else if (type == 3) {
ams_device_name = "BOX 2 PRO-%d";
} else if (type == 4) {
ams_device_name = "BOX HT-%d";
} else {
assert(0);
ams_device_name = "BOX-%d";
}
int num_id;
try {
num_id = std::stoi(id);
} catch (...) {}
int loc = (num_id > 127) ? (num_id - 127) : (num_id + 1);
return wxString::Format(ams_device_name, loc);
};
};
enum PrinterFirmwareType {
@@ -283,6 +460,34 @@ enum HMSMessageLevel {
HMS_MSG_LEVEL_MAX,
};
enum AIR_FUN {
FAN_HEAT_BREAK_0_IDX = 0,
FAN_COOLING_0_AIRDOOR = 1,
FAN_REMOTE_COOLING_0_IDX = 2,
FAN_CHAMBER_0_IDX = 3,
FAN_HEAT_BREAK_1_IDX = 4,
FAN_MC_BOARD_0_IDX = 5,
FAN_INNNER_LOOP_FAN_0_IDX = 6,
FAN_TOTAL_COUNT = 7
};
enum AIR_DOOR {
AIR_DOOR_FUNC_CHAMBER = 0,
AIR_DOOR_FUNC_INNERLOOP,
AIR_DOOR_FUNC_TOP
};
enum AIR_DUCT {
AIR_DUCT_NONE = -1,
AIR_DUCT_COOLING_FILT = 0,
AIR_DUCT_HEATING_INTERNAL_FILT,
AIR_DUCT_EXHAUST,
AIR_DUCT_FULL_COOLING,
AIR_DUCT_NUM,
AIR_DUCT_INIT = 0xFF //Initial mode, only used within mc
};
class HMSItem
{
public:
@@ -333,6 +538,8 @@ private:
public:
typedef std::function<void(const json &)> CommandCallBack;
enum LIGHT_EFFECT {
LIGHT_EFFECT_ON,
LIGHT_EFFECT_OFF,
@@ -344,6 +551,8 @@ public:
COOLING_FAN = 1,
BIG_COOLING_FAN = 2,
CHAMBER_FAN = 3,
EXHAUST_FAN,
FILTER_FAN,
};
enum UpgradingDisplayState {
@@ -369,6 +578,7 @@ public:
{
public:
std::string name;
wxString product_name;
std::string sn;
std::string hw_ver;
std::string sw_ver;
@@ -377,21 +587,35 @@ public:
ModuleVersionInfo() :firmware_status(0) {
};
public:
bool isValid() const { return !sn.empty(); }
bool isAirPump() const { return product_name.Contains("Air Pump"); }
bool isLaszer() const { return product_name.Contains("Laser"); }
bool isCuttingModule() const { return product_name.Contains("Cutting Module"); }
};
enum SdcardState {
NO_SDCARD = 0,
HAS_SDCARD_NORMAL = 1,
HAS_SDCARD_ABNORMAL = 2,
SDCARD_STATE_NUM = 3
HAS_SDCARD_READONLY = 3,
SDCARD_STATE_NUM = 4
};
enum ActiveState {
NotActive,
Active,
NotActive,
Active,
UpdateToDate
};
enum MappingOption {
USE_LEFT_AMS = 0,
USE_RIGHT_AMS,
USE_LEFT_EXT,
USE_RIGHT_EXT
};
class ExtrusionRatioInfo
{
public:
@@ -420,11 +644,12 @@ public:
//y
std::string dev_url;
std::string dev_apikey;
float nozzle_diameter { 0.0f };
bool local_use_ssl_for_mqtt { true };
bool local_use_ssl_for_ftp { true };
float nozzle_diameter { 0.0f };
bool m_busy_for_select_extruder {false};
int subscribe_counter{3};
std::string nozzle_type;
std::string dev_connection_type; /* lan | cloud */
std::string connection_type() { return dev_connection_type; }
std::string dev_connection_name; /* lan | eth */
@@ -446,6 +671,19 @@ public:
std::string get_printer_ams_type() const;
bool get_printer_is_enclosed() const;
// check printer device series
static bool is_series_n(const std::string& series_str);
static bool is_series_p(const std::string& series_str);
static bool is_series_x(const std::string& series_str);
static bool is_series_o(const std::string& series_str);
bool is_series_n() const;
bool is_series_p() const;
bool is_series_x() const;
bool is_series_o() const;
std::string get_printer_series_str() const;
void reload_printer_settings();
std::string printer_thumbnail_img;
@@ -456,9 +694,6 @@ public:
std::string product_name; // set by iot service, get /user/print
std::vector<int> filam_bak;
std::string bind_user_name;
std::string bind_user_id;
std::string bind_state; /* free | occupied */
@@ -486,7 +721,11 @@ public:
/* ams properties */
std::map<std::string, Ams*> amsList; // key: ams[id], start with 0
AmsTray vt_tray; // virtual tray
int ams_cali_id = 0;
int ams_cali_stat = 0;
//AmsTray vt_tray; // virtual tray
long ams_exist_bits = 0;
long tray_exist_bits = 0;
long tray_is_qdt_bits = 0;
@@ -498,10 +737,9 @@ public:
bool ams_calibrate_remain_flag { false };
bool ams_auto_switch_filament_flag { false };
bool ams_air_print_status { false };
bool ams_support_use_ams { false };
bool ams_support_virtual_tray { true };
int ams_humidity;
int ams_user_setting_hold_count = 0;
time_t ams_user_setting_start = 0;
time_t ams_switch_filament_start = 0;
AmsStatusMain ams_status_main;
int ams_status_sub;
int ams_version = 0;
@@ -516,6 +754,7 @@ public:
std::chrono::system_clock::time_point extrusion_cali_set_hold_start;
std::string extrusion_cali_filament_name;
bool only_exist_ext_spool() { return amsList.empty(); }
bool is_in_extrusion_cali();
bool is_extrusion_cali_finished();
void _parse_tray_now(std::string tray_now);
@@ -523,6 +762,8 @@ public:
bool is_ams_need_update;
inline bool is_ams_unload() { return m_tray_tar.compare("255") == 0; }
[[nodiscard]] bool is_ams_on_settingup() const;
Ams* get_curr_Ams();
AmsTray* get_curr_tray();
AmsTray *get_ams_tray(std::string ams_id, std::string tray_id);
@@ -530,14 +771,19 @@ public:
void _parse_ams_status(int ams_status);
bool has_ams() { return ams_exist_bits != 0; }
bool can_unload_filament();
bool is_support_ams_mapping();
bool is_support_amx_ext_mix_mapping();
void get_ams_colors(std::vector<wxColour>& ams_colors);
int ams_filament_mapping(std::vector<FilamentInfo> filaments, std::vector<FilamentInfo> &result, std::vector<int> exclude_id = std::vector<int>());
void parse_tray_info(int ams_id, int sot_id, AmsTray tray, FilamentInfo& result);
int ams_filament_mapping(std::vector<FilamentInfo> filaments, std::vector<FilamentInfo> &result, std::vector<bool> map_opt, std::vector<int> exclude_id = std::vector<int>(),bool nozzle_has_ams_then_ignore_ext =false);
bool is_valid_mapping_result(std::vector<FilamentInfo>& result, bool check_empty_slot = false);
// exceed index start with 0
bool is_mapping_exceed_filament(std::vector<FilamentInfo>& result, int &exceed_index);
void reset_mapping_result(std::vector<FilamentInfo>& result);
bool is_main_extruder_on_left() const;
bool is_multi_extruders() const;
bool need_SD_card() const;
int get_extruder_id_by_ams_id(const std::string &ams_id);
/*online*/
bool online_rfid;
@@ -546,12 +792,15 @@ public:
int last_online_version = -1;
/* temperature */
float nozzle_temp;
float nozzle_temp_target;
//float nozzle_temp;
//float nozzle_temp_target;
float bed_temp;
float bed_temp_target;
float chamber_temp;
float chamber_temp_target;
float chamber_temp_edit_min = 0;
float chamber_temp_edit_max = 60;
long chamber_temp_switch_heat = LONG_MAX;/*default to LONG_MAX*/
float frame_temp;
/* cooling */
@@ -561,6 +810,15 @@ public:
int big_fan2_speed = 0;
uint32_t fan_gear = 0;
/*extruder*/
[[nodiscard]] bool is_nozzle_flow_type_supported() const { return is_enable_np; };
[[nodiscard]] NozzleFlowType get_nozzle_flow_type(int extruder_id) const;
[[nodiscard]] Extder get_current_extruder() const;
//new fan data
AirDuctData m_air_duct_data;
void converse_to_duct(bool is_suppt_part_fun, bool is_suppt_aux_fun, bool is_suppt_cham_fun); // Convert the data to duct type to make the newand old protocols consistent
/* signals */
std::string wifi_signal;
std::string link_th;
@@ -589,6 +847,10 @@ public:
std::string ota_new_version_number;
std::string ahb_new_version_number;
int get_version_retry = 0;
ModuleVersionInfo air_pump_version_info;
ModuleVersionInfo laser_version_info;
ModuleVersionInfo cutting_module_version_info;
std::map<std::string, ModuleVersionInfo> module_vers;
std::map<std::string, ModuleVersionInfo> new_ver_list;
std::map<std::string, ExtrusionRatioInfo> extrusion_ratio_map;
@@ -607,6 +869,9 @@ public:
// key: ams_id start as 0,1,2,3
std::map<int, ModuleVersionInfo> get_ams_version();
void clear_version_info();
void store_version_info(const ModuleVersionInfo& info);
/* printing */
std::string print_type;
float nozzle { 0.0f }; // default is 0.0f as initial value
@@ -641,15 +906,14 @@ public:
ManualPaCaliMethod manual_pa_cali_method = ManualPaCaliMethod::PA_LINE;
bool has_get_pa_calib_tab{ false };
bool request_tab_from_qds { false };
std::vector<PACalibResult> pa_calib_tab;
float pa_calib_tab_nozzle_dia;
bool get_pa_calib_result { false };
std::vector<PACalibResult> pa_calib_results;
bool get_flow_calib_result { false };
std::vector<FlowRatioCalibResult> flow_ratio_results;
void reset_pa_cali_history_result()
{
pa_calib_tab_nozzle_dia = 0.4f;
has_get_pa_calib_tab = false;
pa_calib_tab.clear();
}
@@ -669,6 +933,7 @@ public:
std::vector<int> stage_list_info;
int stage_curr = 0;
int m_push_count = 0;
int m_full_msg_count = 0; /*the full message count, there are full or diff messages from network*/
bool calibration_done { false };
bool is_axis_at_home(std::string axis);
@@ -693,7 +958,7 @@ public:
int printing_speed_mag = 100;
PrintingSpeedLevel _parse_printing_speed_lvl(int lvl);
int get_bed_temperature_limit();
bool is_filament_installed();
/* camera */
bool has_ipcam { false };
bool camera_recording { false };
@@ -711,33 +976,54 @@ public:
enum LiveviewLocal {
LVL_None,
LVL_Disable,
LVL_Local,
LVL_Local,
LVL_Rtsps,
LVL_Rtsp
} liveview_local{ LVL_None };
enum LiveviewRemote {
LVR_None,
LVR_Tutk,
LVR_Tutk,
LVR_Agora,
LVR_TutkAgora
} liveview_remote{ LVR_None };
enum FileLocal {
FL_None,
FL_None,
FL_Local
} file_local{ FL_None };
enum FileRemote {
FR_None,
FR_Tutk,
FR_None,
FR_Tutk,
FR_Agora,
FR_TutkAgora
} file_remote{ FR_None };
enum PlateMakerDectect : int
{
POS_CHECK = 1,
TYPE_POS_CHECK = 2,
};
enum DoorOpenCheckState : int
{
DOOR_OPEN_CHECK_DISABLE = 0,/*do nothing*/
DOOR_OPEN_CHECK_ENABLE_WARNING = 1,/*warning*/
DOOR_OPEN_CHECK_ENABLE_PAUSE_PRINT = 2,/*pause print*/
};
enum DeviceMode : unsigned int
{
DEVICE_MODE_FDM = 0x00000001,
DEVICE_MODE_LASER = 0x00000010,
DEVICE_MODE_CUT = 0x00000100,
};
bool file_model_download{false};
bool virtual_camera{false};
int nozzle_setting_hold_count = 0;
bool xcam_ai_monitoring{ false };
int xcam_ai_monitoring_hold_count = 0;
time_t xcam_ai_monitoring_hold_start = 0;
std::string xcam_ai_monitoring_sensitivity;
bool xcam_buildplate_marker_detector{ false };
int xcam_buildplate_marker_hold_count = 0;
@@ -747,7 +1033,11 @@ public:
int xcam_auto_recovery_hold_count = 0;
int xcam_prompt_sound_hold_count = 0;
int xcam_filament_tangle_detect_count = 0;
int ams_print_option_count = 0;
int nozzle_selected_count = 0;
bool flag_update_nozzle = {true};
/*target from Studio-SwitchBoard, default to INVALID_NOZZLE_ID if no switching control from PC*/
int targ_nozzle_id_from_pc = INVALID_NOZZLE_ID;
//supported features
bool is_support_chamber_edit{false};
@@ -755,18 +1045,23 @@ public:
bool is_support_first_layer_inspect{false};
bool is_support_ai_monitoring {false};
bool is_support_lidar_calibration {false};
bool is_support_build_plate_marker_detect{false};
PlateMakerDectect m_plate_maker_detect_type{ POS_CHECK };
bool is_support_pa_calibration{false};
bool is_support_flow_calibration{false};
bool is_support_auto_flow_calibration{false};/*The flag is used to distinguish auto/on/off or on/off */
bool is_support_print_without_sd{false};
bool is_support_print_all{false};
bool is_support_send_to_sdcard {false};
bool is_support_aux_fan {false};
bool is_support_chamber_fan{false};
bool is_support_filament_backup{false};
bool is_support_show_filament_backup{false};
bool is_support_show_filament_backup{false};/*the filament is not supported shown in some previous hardware*/
bool is_support_timelapse{false};
bool is_support_update_remain{false};
bool is_support_auto_leveling{false};
int is_support_bed_leveling = 0;/*0: false; 1; on/off 2: auto/on/off*/
bool is_support_auto_recovery_step_loss{false};
bool is_support_ams_humidity {false};
bool is_support_prompt_sound{false};
@@ -777,17 +1072,28 @@ public:
bool is_support_mqtt_alive {false};
bool is_support_tunnel_mqtt{false};
bool is_support_motor_noise_cali{false};
bool is_support_nozzle_offset_cali{ false };
bool is_support_high_tempbed_cali{ false };
bool is_support_wait_sending_finish{false};
bool is_support_user_preset{false};
bool is_support_p1s_plus{false};
//bool is_support_p1s_plus{false};
bool is_support_nozzle_blob_detection{false};
bool is_support_air_print_detection{false};
bool is_support_filament_setting_inprinting{false};
bool is_support_agora{false};
bool is_support_upgrade_kit{false};
bool is_support_filament_setting_inprinting{false};
bool is_support_internal_timelapse { false };// fun[28], support timelapse without SD card
bool is_support_command_homing { false };// fun[32]
int nozzle_max_temperature = -1;
bool installed_upgrade_kit{false};
int bed_temperature_limit = -1;
/*nozzle temp range*/
std::vector<int> nozzle_temp_range;
/*temp temp range*/
std::vector<int> bed_temp_range;
/* sdcard */
MachineObject::SdcardState sdcard_state { NO_SDCARD };
MachineObject::SdcardState get_sdcard_state();
@@ -812,8 +1118,14 @@ public:
boost::thread* get_slice_info_thread { nullptr };
boost::thread* get_model_task_thread { nullptr };
/* key: sequence id, value: callback */
std::map<std::string, CommandCallBack> m_callback_list;
bool is_makeworld_subtask();
/* device type */
DeviceMode m_device_mode{ DEVICE_MODE_FDM };
inline bool is_fdm_type() const { return m_device_mode == DEVICE_MODE_FDM; }
int m_plate_index { -1 };
std::string m_gcode_file;
@@ -823,16 +1135,21 @@ public:
RatingInfo* rating_info { nullptr };
int request_model_result = 0;
bool get_model_mall_result_need_retry = false;
std::string obj_subtask_id; // subtask_id == 0 for sdcard
std::string subtask_name;
bool is_sdcard_printing();
bool has_sdcard();
bool is_timelapse();
bool is_recording_enable();
bool is_recording();
// y40
int get_liveview_remote();
int get_file_remote();
// y40 y59
MachineObject(std::string name);
MachineObject(std::string name, std::string url, std::string ip, std::string apikey = "");
MachineObject(NetworkAgent* agent, std::string name, std::string id, std::string ip);
~MachineObject();
@@ -840,14 +1157,19 @@ public:
std::string parse_version();
void parse_version_func();
bool is_studio_cmd(int seq);
/* quick check*/
bool canEnableTimelapse(wxString& error_message) const;
/* command commands */
int command_get_version(bool with_retry = true);
int command_request_push_all(bool request_now = false);
int command_pushing(std::string cmd);
int command_clean_print_error(std::string task_id, int print_error);
int command_set_printer_nozzle(std::string nozzle_type, float diameter);
int command_set_printer_nozzle2(int id, std::string nozzle_type, float diameter);
int command_get_access_code();
int command_select_extruder(int id);
/* command upgrade */
int command_upgrade_confirm();
@@ -859,29 +1181,40 @@ public:
int command_xyz_abs();
int command_auto_leveling();
int command_go_home();
int command_control_fan(FanType fan_type, bool on_off);
int command_control_fan_val(FanType fan_type, int val);
int command_go_home2();
int command_control_fan(int fan_type, int val); // Old protocol
int command_control_fan_new(int fan_id, int val, const CommandCallBack &cb); // New protocol
int command_control_air_duct(int mode_id, const CommandCallBack& cb);
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_hms_idle_ignore(const std::string &error_str, int type);
int command_hms_resume(const std::string& error_str, const std::string& job_id);
int command_hms_ignore(const std::string& error_str, const std::string& job_id);
/* buzzer*/
int command_stop_buzzer();
/* temp*/
int command_set_bed(int temp);
int command_set_nozzle(int temp);
int command_set_nozzle_new(int nozzle_id, int temp);
int command_set_chamber(int temp);
// ams controls
int command_ams_switch(int tray_index, int old_temp = 210, int new_temp = 210);
int command_ams_change_filament(int tray_id, int old_temp = 210, int new_temp = 210);
//int command_ams_switch(int tray_index, int old_temp = 210, int new_temp = 210);
int command_ams_change_filament(bool load, std::string ams_id, std::string slot_id, int old_temp = 210, int new_temp = 210);
int command_ams_user_settings(int ams_id, bool start_read_opt, bool tray_read_opt, bool remain_flag = false);
int command_ams_user_settings(int ams_id, AmsOptionType op, bool value);
int command_ams_switch_filament(bool switch_filament);
int command_ams_air_print_detect(bool air_print_detect);
int command_ams_calibrate(int ams_id);
int command_ams_filament_settings(int ams_id, int tray_id, std::string filament_id, std::string setting_id, std::string tray_color, std::string tray_type, int nozzle_temp_min, int nozzle_temp_max);
int command_ams_filament_settings(int ams_id, int slot_id, std::string filament_id, std::string setting_id, std::string tray_color, std::string tray_type, int nozzle_temp_min, int nozzle_temp_max);
int command_ams_select_tray(std::string tray_id);
int command_ams_refresh_rfid(std::string tray_id);
int command_ams_refresh_rfid2(int ams_id, int slot_id);
int command_ams_control(std::string action);
int command_set_chamber_light(LIGHT_EFFECT effect, int on_time = 500, int off_time = 500, int loops = 1, int interval = 1000);
int command_set_chamber_light2(LIGHT_EFFECT effect, int on_time = 500, int off_time = 500, int loops = 1, int interval = 1000);
int command_set_work_light(LIGHT_EFFECT effect, int on_time = 500, int off_time = 500, int loops = 1, int interval = 1000);
int command_start_extrusion_cali(int tray_index, int nozzle_temp, int bed_temp, float max_volumetric_speed, std::string setting_id = "");
int command_stop_extrusion_cali();
@@ -905,15 +1238,20 @@ public:
// axis string is X, Y, Z, E
int command_axis_control(std::string axis, double unit = 1.0f, double input_val = 1.0f, int speed = 3000);
int command_extruder_control(int nozzle_id, double val);
// calibration printer
bool is_support_command_calibration();
int command_start_calibration(bool vibration, bool bed_leveling, bool xcam_cali, bool motor_noise);
int command_start_calibration(bool vibration, bool bed_leveling, bool xcam_cali, bool motor_noise, bool nozzle_cali, bool bed_cali);
// PA calibration
int command_start_pa_calibration(const X1CCalibInfos& pa_data, int mode = 0); // 0: automatic mode; 1: manual mode. default: automatic mode
int command_set_pa_calibration(const std::vector<PACalibResult>& pa_calib_values, bool is_auto_cali);
int command_delete_pa_calibration(const PACalibIndexInfo& pa_calib);
int command_get_pa_calibration_tab(float nozzle_diameter, const std::string &filament_id = "");
int command_get_pa_calibration_tab(const PACalibExtruderInfo& calib_info);
//w
int command_get_pa_calibration_tab(float nozzle_diameter, const std::string &filament_id);
int command_get_pa_calibration_result(float nozzle_diameter);
int commnad_select_pa_calibration(const PACalibIndexInfo& pa_calib_info);
@@ -942,6 +1280,7 @@ public:
bool can_pause();
bool can_abort();
bool is_in_printing();
bool is_in_printing_pause() const;
bool is_in_prepare();
bool is_printing_finished();
bool is_core_xy();
@@ -955,7 +1294,7 @@ public:
bool is_connecting();
void set_online_state(bool on_off);
bool is_online() { return m_is_online; }
bool is_info_ready();
bool is_info_ready(bool check_version = true) const;
bool is_camera_busy_off();
std::vector<std::string> get_resolution_supported();
@@ -980,27 +1319,80 @@ public:
bool m_firmware_thread_started { false };
void get_firmware_info();
bool is_firmware_info_valid();
std::string get_string_from_fantype(FanType type);
std::string get_string_from_fantype(int type);
/*for more extruder*/
bool is_enable_np{ false };
bool is_enable_ams_np{ false };
ExtderData m_extder_data;
NozzleData m_nozzle_data;
/*vi slot data*/
std::vector<AmsTray> vt_slot;
AmsTray parse_vt_tray(json vtray);
/*get ams slot info*/
bool contains_tray(const std::string &ams_id, const std::string &tray_id) const;
AmsTray get_tray(const std::string &ams_id, const std::string &tray_id) const;/*use contains_tray() check first*/
/*for parse new info*/
bool check_enable_np(const json& print) const;
void parse_new_info(json print);
bool is_nozzle_data_invalid();
int get_flag_bits(std::string str, int start, int count = 1) const;
int get_flag_bits(int num, int start, int count = 1, int base = 10) const;
/* Device Filament Check */
std::set<std::string> m_checked_filament;
std::string m_printer_preset_name;
std::map<std::string, std::pair<int, int>> m_filament_list; // filament_id, pair<min temp, max temp>
struct FilamentData
{
std::set<std::string> checked_filament;
std::string printer_preset_name;
std::map<std::string, std::pair<int, int>> filament_list; // filament_id, pair<min temp, max temp>
};
std::map<std::string, FilamentData> m_nozzle_filament_data;
void update_filament_list();
int get_flag_bits(std::string str, int start, int count = 1);
int get_flag_bits(int num, int start, int count = 1);
void update_printer_preset_name(const std::string &nozzle_diameter_str);
void update_printer_preset_name();
void check_ams_filament_valid();
int command_handle_response(const json &response);
/* xcam door open check*/
bool support_door_open_check() const { return is_support_door_open_check;};
DoorOpenCheckState get_door_open_check_state() const { return xcam_door_open_check;};
void command_set_door_open_check(DoorOpenCheckState state);
/* xcam save remove print file to local*/
bool support_save_remote_print_file_to_storage() const { return is_support_save_remote_print_file_to_storage; };
bool get_save_remote_print_file_to_storage() const { return xcam__save_remote_print_file_to_storage; };
void command_set_save_remote_print_file_to_storage(bool save);
private:
/* xcam door open check*/
bool is_support_door_open_check = false;
DoorOpenCheckState xcam_door_open_check = DoorOpenCheckState::DOOR_OPEN_CHECK_DISABLE;
time_t xcam_door_open_check_start_time = 0;
/* xcam save remove print file to local*/
bool is_support_save_remote_print_file_to_storage = false;
bool xcam__save_remote_print_file_to_storage = false;
time_t xcam__save_remote_print_file_to_storage_start_time = 0;
};
class DeviceManagerRefresher;
class DeviceManager
{
private:
NetworkAgent* m_agent { nullptr };
NetworkAgent* m_agent { nullptr };
DeviceManagerRefresher* m_refresher{nullptr};
public:
static bool EnableMultiMachine;
DeviceManager(NetworkAgent* agent = nullptr);
~DeviceManager();
NetworkAgent *get_agent() const{ return m_agent; }
void set_agent(NetworkAgent* agent);
std::mutex listMutex;
@@ -1009,9 +1401,17 @@ public:
std::map<std::string, MachineObject*> localMachineList; /* dev_id -> MachineObject*, localMachine SSDP */
std::map<std::string, MachineObject*> userMachineList; /* dev_id -> MachineObject* cloudMachine of User */
void start_refresher();
void stop_refresher();
void keep_alive();
void check_pushing();
static float nozzle_diameter_conver(int diame);
static int nozzle_diameter_conver(float diame);
static std::string nozzle_type_conver(int type);
static int nozzle_type_conver(std::string& type);
MachineObject* get_default_machine();
MachineObject* get_local_selected_machine();
MachineObject* get_local_machine(std::string dev_id);
@@ -1054,6 +1454,7 @@ public:
static bool key_field_only;
static json function_table;
static json filaments_blacklist;
static json filaments_printable_blacklist;
template<typename T>
static T get_value_from_config(std::string type_str, std::string item){
@@ -1072,7 +1473,7 @@ public:
}
}
catch (...) {}
return "";
return T();
}
static std::string parse_printer_type(std::string type_str);
@@ -1082,19 +1483,59 @@ public:
static std::string get_printer_series(std::string type_str);
static std::string get_printer_diagram_img(std::string type_str);
static std::string get_printer_ams_img(std::string type_str);
static std::string get_printer_ext_img(std::string type_str, int pos);
static PrinterArch get_printer_arch(std::string type_str);
static std::string get_ftp_folder(std::string type_str);
static bool get_printer_is_enclosed(std::string type_str);
static bool get_printer_can_set_nozzle(std::string type_str);// can set nozzle from studio
static bool load_filaments_blacklist_config();
static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info);
static std::vector<std::string> get_resolution_supported(std::string type_str);
static std::vector<std::string> get_compatible_machine(std::string type_str);
static std::vector<std::string> get_unsupport_auto_cali_filaments(std::string type_str);
static void check_filaments_in_blacklist(std::string model_id, std::string tag_vendor, std::string tag_type, int ams_id, int slot_id, std::string tag_name, bool &in_blacklist, std::string &ac, std::string &info);
static bool check_filaments_printable(const std::string &tag_vendor, const std::string &tag_type, int ams_id, bool &in_blacklist, std::string &ac, std::string &info);
static boost::bimaps::bimap<std::string, std::string> get_all_model_id_with_name();
static std::string load_gcode(std::string type_str, std::string gcode_file);
static bool is_virtual_slot(int ams_id);
static std::string get_filament_name_from_ams(int ams_id, int slot_id);
private:
void OnMachineBindStateChanged(MachineObject* obj, const std::string &new_state);
void OnSelectedMachineLost();
};
class DeviceManagerRefresher : public wxObject
{
wxTimer *m_timer{nullptr};
int m_timer_interval_msec = 1000;
DeviceManager *m_manager{nullptr};
public:
DeviceManagerRefresher(DeviceManager* manger);
~DeviceManagerRefresher();
public:
void Start() { m_timer->Start(m_timer_interval_msec); }
void Stop() { m_timer->Stop(); }
protected:
virtual void on_timer(wxTimerEvent &event);
};
// change the opacity
void change_the_opacity(wxColour& colour);
} // namespace Slic3r
wxString generate_nozzle_id(NozzleVolumeType nozzle_type);
class JsonValParser
{
public:
static std::string get_longlong_val(const json& j);
};
}; // namespace Slic3r
#endif // slic3r_DeviceManager_hpp_