ENH: clean codes about device
JIRA: [STUDIO-13609] Change-Id: I591de7033360b9570600006cfbce2148a8d031d5 (cherry picked from commit e9c774be8f4c89b8dafa14ef56913612fb68bd0c)
This commit is contained in:
190
src/slic3r/GUI/DeviceCore/DevFilaSystem.h
Normal file
190
src/slic3r/GUI/DeviceCore/DevFilaSystem.h
Normal file
@@ -0,0 +1,190 @@
|
||||
#pragma once
|
||||
#include "libslic3r/CommonDefs.hpp"
|
||||
#include "slic3r/Utils/json_diff.hpp"
|
||||
|
||||
#include "DevDefs.h"
|
||||
#include "DevFilaAmsSetting.h"
|
||||
|
||||
#include <map>
|
||||
#include <wx/string.h>
|
||||
#include <wx/colour.h>
|
||||
|
||||
#define HOLD_COUNT_MAX 3
|
||||
|
||||
namespace Slic3r
|
||||
{
|
||||
class MachineObject;
|
||||
|
||||
class DevAmsTray
|
||||
{
|
||||
public:
|
||||
DevAmsTray(std::string tray_id)
|
||||
{
|
||||
is_bbl = false;
|
||||
id = tray_id;
|
||||
}
|
||||
|
||||
static wxColour decode_color(const std::string& color);
|
||||
|
||||
bool operator==(DevAmsTray const& o) const
|
||||
{
|
||||
return id == o.id && type == o.type && filament_setting_id == o.filament_setting_id && color == o.color;
|
||||
}
|
||||
bool operator!=(DevAmsTray const& o) const { return !operator==(o); }
|
||||
|
||||
std::string id;
|
||||
std::string tag_uid; // tag_uid
|
||||
std::string setting_id; // tray_info_idx
|
||||
std::string filament_setting_id; // setting_id
|
||||
std::string type;
|
||||
std::string sub_brands;
|
||||
std::string color;
|
||||
std::vector<std::string> cols;
|
||||
std::string weight;
|
||||
std::string diameter;
|
||||
std::string temp;
|
||||
std::string time;
|
||||
std::string bed_temp_type;
|
||||
std::string bed_temp;
|
||||
std::string nozzle_temp_max;
|
||||
std::string nozzle_temp_min;
|
||||
std::string xcam_info;
|
||||
std::string uuid;
|
||||
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 = -1; // - 1 means default
|
||||
|
||||
wxColour wx_color;
|
||||
bool is_bbl;
|
||||
bool is_exists = false;
|
||||
int hold_count = 0;
|
||||
int remain = 0; // filament remain: 0 ~ 100
|
||||
|
||||
void set_hold_count() { hold_count = HOLD_COUNT_MAX; }
|
||||
void UpdateColorFromStr(const std::string& color);
|
||||
wxColour get_color();
|
||||
|
||||
void reset();
|
||||
|
||||
bool is_tray_info_ready();
|
||||
bool is_unset_third_filament();
|
||||
std::string get_display_filament_type();
|
||||
std::string get_filament_type();
|
||||
};
|
||||
|
||||
class DevAms
|
||||
{
|
||||
friend class DevFilaSystemParser;
|
||||
public:
|
||||
enum AmsType : int
|
||||
{
|
||||
DUMMY = 0,
|
||||
AMS = 1, // AMS
|
||||
AMS_LITE = 2, // AMS-Lite
|
||||
N3F = 3, // N3F
|
||||
N3S = 4, // N3S
|
||||
};
|
||||
|
||||
public:
|
||||
DevAms(const std::string& ams_id, int extruder_id, AmsType type);
|
||||
DevAms(const std::string& ams_id, int nozzle_id, int type);
|
||||
~DevAms();
|
||||
|
||||
public:
|
||||
std::string GetAmsId() const { return m_ams_id; }
|
||||
wxString GetDisplayName() const; // display
|
||||
|
||||
void SetAmsType(int type) { m_ams_type = (AmsType)type; }
|
||||
void SetAmsType(AmsType type) { m_ams_type = type; }
|
||||
AmsType GetAmsType() const { return m_ams_type; }
|
||||
|
||||
// exist or not
|
||||
bool IsExist() const { return m_exist; }
|
||||
|
||||
// slots
|
||||
int GetSlotCount() const;
|
||||
DevAmsTray* GetTray(const std::string& tray_id) const;
|
||||
const std::map<std::string, DevAmsTray*>& GetTrays() const { return m_trays; }
|
||||
|
||||
// installed on the extruder
|
||||
int GetExtruderId() const { return m_ext_id; }
|
||||
|
||||
// temperature and humidity
|
||||
float GetCurrentTemperature() const { return m_current_temperature; }
|
||||
|
||||
bool SupportHumidity() const { return (m_ams_type == AMS) || (m_ams_type == N3F) || (m_ams_type == N3S);}
|
||||
int GetHumidityLevel() const { return m_humidity_level; }
|
||||
int GetHumidityPercent() const { return m_humidity_percent; }
|
||||
|
||||
bool SupportDrying() const { return m_ams_type > AMS_LITE; }
|
||||
int GetLeftDryTime() const { return m_left_dry_time; }
|
||||
|
||||
private:
|
||||
AmsType m_ams_type = AmsType::AMS;
|
||||
std::string m_ams_id;
|
||||
int m_ext_id;//extruder id
|
||||
bool m_exist = false;
|
||||
|
||||
// slots and trays
|
||||
std::map<std::string, DevAmsTray*> m_trays;//id -> DevAmsTray*
|
||||
|
||||
// temperature and humidity
|
||||
float m_current_temperature = INVALID_AMS_TEMPERATURE; // the temperature
|
||||
int m_humidity_level = 5;
|
||||
int m_humidity_percent = -1; // the percentage, -1 means invalid. eg. 100 means 100%
|
||||
int m_left_dry_time = 0;
|
||||
};
|
||||
|
||||
class DevFilaSystem
|
||||
{
|
||||
friend class DevFilaSystemParser;
|
||||
public:
|
||||
DevFilaSystem(MachineObject* owner) { m_owner = owner;};
|
||||
~DevFilaSystem();
|
||||
|
||||
public:
|
||||
bool HasAms() const { return !amsList.empty(); }
|
||||
bool IsAmsSettingUp() const;
|
||||
|
||||
/* ams */
|
||||
DevAms* GetAmsById(const std::string& ams_id) const;
|
||||
std::map<std::string, DevAms*>& GetAmsList() { return amsList; }
|
||||
int GetAmsCount() const { return amsList.size(); }
|
||||
|
||||
/* tray*/
|
||||
DevAmsTray* GetAmsTray(const std::string& ams_id, const std::string& tray_id) const;
|
||||
void CollectAmsColors(std::vector<wxColour>& ams_colors) const;
|
||||
|
||||
// extruder
|
||||
int GetExtruderIdByAmsId(const std::string& ams_id) const;
|
||||
|
||||
/* AMS settings*/
|
||||
DevAmsSystemSetting& GetAmsSystemSetting() { return m_ams_system_setting; }
|
||||
bool IsDetectOnInsertEnabled() const { return m_ams_system_setting.IsDetectOnInsertEnabled(); };
|
||||
bool IsDetectOnPowerupEnabled() const { return m_ams_system_setting.IsDetectOnPowerupEnabled(); }
|
||||
bool IsDetectRemainEnabled() const { return m_ams_system_setting.IsDetectRemainEnabled(); }
|
||||
bool IsAutoRefillEnabled() const { return m_ams_system_setting.IsAutoRefillEnabled(); }
|
||||
|
||||
public:
|
||||
static bool IsBBL_Filament(std::string tag_uid);
|
||||
|
||||
private:
|
||||
MachineObject* m_owner;
|
||||
|
||||
/* ams properties */
|
||||
int m_ams_cali_stat = 0;
|
||||
|
||||
std::map<std::string, DevAms*> amsList; // key: ams[id], start with 0
|
||||
|
||||
DevAmsSystemSetting m_ams_system_setting{ this };
|
||||
};// class DevFilaSystem
|
||||
|
||||
|
||||
class DevFilaSystemParser
|
||||
{
|
||||
public:
|
||||
static void ParseV1_0(const json& print_json, MachineObject* obj, DevFilaSystem* system, bool key_field_only);
|
||||
};
|
||||
|
||||
}// namespace Slic3r
|
||||
Reference in New Issue
Block a user