OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
PrinterFileSystem.cpp File Reference
module NULL
#include "PrinterFileSystem.h"
#include "libslic3r/Utils.hpp"
#include "libslic3r/Format/bbs_3mf.hpp"
#include "libslic3r/Model.hpp"
#include "slic3r/GUI/I18N.hpp"
#include "../../Utils/NetworkAgent.hpp"
#include "../BitmapCache.hpp"
#include <algorithm>
#include <boost/algorithm/hex.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/date_time/posix_time/posix_time_duration.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/date_time/posix_time/posix_time_config.hpp>
#include <boost/endian/conversion.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/log/trivial.hpp>
#include <boost/thread/lock_types.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/uuid/detail/md5.hpp>
#include <boost/regex.hpp>
#include <string>
#include <cerrno>
#include <system_error>
#include <wx/event.h>
#include <map>
#include "slic3r/GUI/Printer/BambuTunnel.h"
#include <vector>
#include <cassert>
#include <utility>
#include <ctime>
#include <openssl/md5.h>
#include <memory>
#include <wx/log.h>
#include <ios>
#include <iterator>
#include <filesystem>
#include <functional>
#include <wx/datetime.h>
#include <sstream>
#include <istream>
#include "libslic3r/Semver.hpp"
#include <cmath>
#include <cstdio>
#include <cctype>
#include <wx/mstream.h>
#include "nlohmann/json.hpp"
#include <cstring>
#include <wx/thread.h>
#include <stdlib.h>
#include "libslic3r/PrintConfig.hpp"
#include <dlfcn.h>

Go to the source code of this file.

Classes

struct  StaticBambuLib
struct  PrinterFileSystem::Download
struct  PrinterFileSystem::Upload
struct  CallbackEvent

Macros

#define GET_FUNC(x)

Enumerations

enum  ThumbnailType {
  OldThumbnail = 0 , VideoThumbnail = 1 , ModelMetadata = 2 , ModelThumbnail = 3 ,
  FinishThumbnail
}

Functions

std::string last_system_error ()
 wxDEFINE_EVENT (EVT_STATUS_CHANGED, wxCommandEvent)
 wxDEFINE_EVENT (EVT_MODE_CHANGED, wxCommandEvent)
 wxDEFINE_EVENT (EVT_FILE_CHANGED, wxCommandEvent)
 wxDEFINE_EVENT (EVT_SELECT_CHANGED, wxCommandEvent)
 wxDEFINE_EVENT (EVT_THUMBNAIL, wxCommandEvent)
 wxDEFINE_EVENT (EVT_DOWNLOAD, wxCommandEvent)
 wxDEFINE_EVENT (EVT_RAMDOWNLOAD, wxCommandEvent)
 wxDEFINE_EVENT (EVT_MEDIA_ABILITY_CHANGED, wxCommandEvent)
 wxDEFINE_EVENT (EVT_UPLOADING, wxCommandEvent)
 wxDEFINE_EVENT (EVT_UPLOAD_CHANGED, wxCommandEvent)
 wxDEFINE_EVENT (EVT_FILE_CALLBACK, wxCommandEvent)
static std::string durationString (long duration)
static void * get_function (const char *name)
BambuLib * bambulib_get ()

Variables

static wxBitmap default_thumbnail
static std::map< int, std::string > error_messages

Macro Definition Documentation

◆ GET_FUNC

#define GET_FUNC ( x)
Value:
lib.x = reinterpret_cast<decltype(lib.x)>(get_function(#x))
static void * get_function(const char *name)
Definition PrinterFileSystem.cpp:1836

Referenced by StaticBambuLib::get().

Enumeration Type Documentation

◆ ThumbnailType

Enumerator
OldThumbnail 
VideoThumbnail 
ModelMetadata 
ModelThumbnail 
FinishThumbnail 
944{
945 OldThumbnail = 0,
946 VideoThumbnail = 1,
947 ModelMetadata = 2,
948 ModelThumbnail = 3,
950};
@ ModelMetadata
Definition PrinterFileSystem.cpp:947
@ ModelThumbnail
Definition PrinterFileSystem.cpp:948
@ VideoThumbnail
Definition PrinterFileSystem.cpp:946
@ OldThumbnail
Definition PrinterFileSystem.cpp:945
@ FinishThumbnail
Definition PrinterFileSystem.cpp:949

Function Documentation

◆ bambulib_get()

BambuLib * bambulib_get ( )
1909 {
1910 return &StaticBambuLib::get(); }
static StaticBambuLib & get(BambuLib *copy=nullptr)
Definition PrinterFileSystem.cpp:1857

References StaticBambuLib::get().

Here is the call graph for this function:

◆ durationString()

std::string durationString ( long duration)
static
994{
995 static boost::regex rx("^0d(0h)?");
996 auto time = boost::format("%1%d%2%h%3%m") % (duration / 86400) % ((duration % 86400) / 3600) % ((duration % 3600) / 60);
997 return boost::regex_replace(time.str(), rx, "");
998}

Referenced by PrinterFileSystem::ParseThumbnail().

Here is the caller graph for this function:

◆ get_function()

void * get_function ( const char * name)
static
1837{
1838 void* function = nullptr;
1839
1840 if (!module)
1841 return function;
1842
1843#if defined(_MSC_VER) || defined(_WIN32)
1844 function = reinterpret_cast<void*>(GetProcAddress(module, name));
1845#else
1846 function = dlsym(module, name);
1847#endif
1848
1849 if (!function) {
1850 BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(", can not find function %1%") % name;
1851 }
1852 return function;
1853}
static void * module
Definition Mouse3DHandlerMac.mm:93

References module.

◆ last_system_error()

std::string last_system_error ( )
63 {
64 return Slic3r::decode_path(std::error_code(
65#ifdef _WIN32
66 GetLastError(),
67#else
68 errno,
69#endif
70 std::system_category()).message().c_str());
71}
std::string decode_path(const char *src)
Definition utils.cpp:1401

References Slic3r::decode_path().

Referenced by PrinterFileSystem::DownloadNextFile(), and PrinterFileSystem::DownloadRamFile().

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

◆ wxDEFINE_EVENT() [1/11]

wxDEFINE_EVENT ( EVT_DOWNLOAD ,
wxCommandEvent  )

◆ wxDEFINE_EVENT() [2/11]

wxDEFINE_EVENT ( EVT_FILE_CALLBACK ,
wxCommandEvent  )

◆ wxDEFINE_EVENT() [3/11]

wxDEFINE_EVENT ( EVT_FILE_CHANGED ,
wxCommandEvent  )

◆ wxDEFINE_EVENT() [4/11]

wxDEFINE_EVENT ( EVT_MEDIA_ABILITY_CHANGED ,
wxCommandEvent  )

◆ wxDEFINE_EVENT() [5/11]

wxDEFINE_EVENT ( EVT_MODE_CHANGED ,
wxCommandEvent  )

◆ wxDEFINE_EVENT() [6/11]

wxDEFINE_EVENT ( EVT_RAMDOWNLOAD ,
wxCommandEvent  )

◆ wxDEFINE_EVENT() [7/11]

wxDEFINE_EVENT ( EVT_SELECT_CHANGED ,
wxCommandEvent  )

◆ wxDEFINE_EVENT() [8/11]

wxDEFINE_EVENT ( EVT_STATUS_CHANGED ,
wxCommandEvent  )

◆ wxDEFINE_EVENT() [9/11]

wxDEFINE_EVENT ( EVT_THUMBNAIL ,
wxCommandEvent  )

◆ wxDEFINE_EVENT() [10/11]

wxDEFINE_EVENT ( EVT_UPLOAD_CHANGED ,
wxCommandEvent  )

◆ wxDEFINE_EVENT() [11/11]

wxDEFINE_EVENT ( EVT_UPLOADING ,
wxCommandEvent  )

Variable Documentation

◆ default_thumbnail

wxBitmap default_thumbnail
static

◆ error_messages

std::map<int, std::string> error_messages
static
Initial value:
= {
{PrinterFileSystem::ERROR_PIPE, L("Reconnecting the printer, the operation cannot be completed immediately, please try again later.")},
{PrinterFileSystem::ERROR_RES_BUSY, L("The device cannot handle more conversations. Please retry later.")},
{PrinterFileSystem::ERROR_TIME_OUT, L("Timeout, please try again.")},
{PrinterFileSystem::FILE_NO_EXIST, L("File does not exist.")},
{PrinterFileSystem::FILE_CHECK_ERR, L("File checksum error. Please retry.")},
{PrinterFileSystem::FILE_TYPE_ERR, L("Not supported on the current printer version.")},
{PrinterFileSystem::STORAGE_UNAVAILABLE, L("Please check if the storage is inserted into the printer.\nIf it still cannot be read, you can try formatting the storage.")},
{PrinterFileSystem::API_VERSION_UNSUPPORT, L("The firmware version of the printer is too low. Please update the firmware and try again.")},
{PrinterFileSystem::FILE_EXIST, L("The file already exists, do you want to replace it?")},
{PrinterFileSystem::STORAGE_SPACE_NOT_ENOUGH, L("Insufficient storage space, please clear the space and try again.")},
{PrinterFileSystem::FILE_CREATE_ERR, L("File creation failed, please try again.")},
{PrinterFileSystem::FILE_WRITE_ERR, L("File write failed, please try again.")},
{PrinterFileSystem::MD5_COMPARE_ERR, L("MD5 verification failed, please try again.")},
{PrinterFileSystem::FILE_RENAME_ERR, L("File renaming failed, please try again.")},
{PrinterFileSystem::SEND_ERR, L("File upload failed, please try again.")}
}
#define L(s)
Definition ExtrusionEntity.cpp:25
@ ERROR_PIPE
Definition PrinterFileSystem.h:62
@ FILE_NO_EXIST
Definition PrinterFileSystem.h:66
@ ERROR_RES_BUSY
Definition PrinterFileSystem.h:64
@ FILE_WRITE_ERR
Definition PrinterFileSystem.h:78
@ API_VERSION_UNSUPPORT
Definition PrinterFileSystem.h:74
@ FILE_CHECK_ERR
Definition PrinterFileSystem.h:71
@ FILE_TYPE_ERR
Definition PrinterFileSystem.h:72
@ FILE_EXIST
Definition PrinterFileSystem.h:75
@ STORAGE_UNAVAILABLE
Definition PrinterFileSystem.h:73
@ ERROR_TIME_OUT
Definition PrinterFileSystem.h:65
@ STORAGE_SPACE_NOT_ENOUGH
Definition PrinterFileSystem.h:76
@ SEND_ERR
Definition PrinterFileSystem.h:81
@ FILE_RENAME_ERR
Definition PrinterFileSystem.h:80
@ FILE_CREATE_ERR
Definition PrinterFileSystem.h:77
@ MD5_COMPARE_ERR
Definition PrinterFileSystem.h:79
88 {
89 {PrinterFileSystem::ERROR_PIPE, L("Reconnecting the printer, the operation cannot be completed immediately, please try again later.")},
90 {PrinterFileSystem::ERROR_RES_BUSY, L("The device cannot handle more conversations. Please retry later.")},
91 {PrinterFileSystem::ERROR_TIME_OUT, L("Timeout, please try again.")},
92 {PrinterFileSystem::FILE_NO_EXIST, L("File does not exist.")},
93 {PrinterFileSystem::FILE_CHECK_ERR, L("File checksum error. Please retry.")},
94 {PrinterFileSystem::FILE_TYPE_ERR, L("Not supported on the current printer version.")},
95 {PrinterFileSystem::STORAGE_UNAVAILABLE, L("Please check if the storage is inserted into the printer.\nIf it still cannot be read, you can try formatting the storage.")},
96 {PrinterFileSystem::API_VERSION_UNSUPPORT, L("The firmware version of the printer is too low. Please update the firmware and try again.")},
97 {PrinterFileSystem::FILE_EXIST, L("The file already exists, do you want to replace it?")},
98 {PrinterFileSystem::STORAGE_SPACE_NOT_ENOUGH, L("Insufficient storage space, please clear the space and try again.")},
99 {PrinterFileSystem::FILE_CREATE_ERR, L("File creation failed, please try again.")},
100 {PrinterFileSystem::FILE_WRITE_ERR, L("File write failed, please try again.")},
101 {PrinterFileSystem::MD5_COMPARE_ERR, L("MD5 verification failed, please try again.")},
102 {PrinterFileSystem::FILE_RENAME_ERR, L("File renaming failed, please try again.")},
103 {PrinterFileSystem::SEND_ERR, L("File upload failed, please try again.")}
104};