mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-25 02:52:03 -06:00
Small adaptation and formatting
This commit is contained in:
parent
869b8c8c66
commit
f1ae74f9d3
4 changed files with 331 additions and 323 deletions
|
@ -8,74 +8,74 @@
|
|||
#include <boost/asio/streambuf.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
namespace Utils {
|
||||
namespace Utils {
|
||||
|
||||
const char * default_newline = "\n";
|
||||
const char * default_done_string = "ok";
|
||||
const char* default_newline = "\n";
|
||||
const char* default_done_string = "ok";
|
||||
|
||||
using boost::asio::ip::tcp;
|
||||
using boost::asio::ip::tcp;
|
||||
|
||||
class TCPConsole
|
||||
{
|
||||
public:
|
||||
TCPConsole(): resolver_(io_context_), socket_(io_context_), newline_(default_newline), done_string_(default_done_string) {}
|
||||
class TCPConsole
|
||||
{
|
||||
public:
|
||||
TCPConsole() : resolver_(io_context_), socket_(io_context_), newline_(default_newline), done_string_(default_done_string) {}
|
||||
|
||||
TCPConsole(const std::string &host_name, const std::string &port_name):
|
||||
resolver_(io_context_), socket_(io_context_), newline_(default_newline), done_string_(default_done_string)
|
||||
{
|
||||
set_remote(host_name, port_name);
|
||||
}
|
||||
~TCPConsole(){}
|
||||
TCPConsole(const std::string& host_name, const std::string& port_name) :
|
||||
resolver_(io_context_), socket_(io_context_), newline_(default_newline), done_string_(default_done_string)
|
||||
{
|
||||
set_remote(host_name, port_name);
|
||||
}
|
||||
~TCPConsole() {}
|
||||
|
||||
void set_line_delimiter(const std::string &newline) {
|
||||
newline_ = newline;
|
||||
}
|
||||
void set_command_done_string(const std::string &done_string) {
|
||||
done_string_ = done_string;
|
||||
}
|
||||
void set_line_delimiter(const std::string& newline) {
|
||||
newline_ = newline;
|
||||
}
|
||||
void set_command_done_string(const std::string& done_string) {
|
||||
done_string_ = done_string;
|
||||
}
|
||||
|
||||
void set_remote(const std::string &host_name, const std::string &port_name)
|
||||
{
|
||||
host_name_ = host_name;
|
||||
port_name_ = port_name;
|
||||
}
|
||||
void set_remote(const std::string& host_name, const std::string& port_name)
|
||||
{
|
||||
host_name_ = host_name;
|
||||
port_name_ = port_name;
|
||||
}
|
||||
|
||||
bool enqueue_cmd(const std::string &cmd) {
|
||||
// TODO: Add multithread protection to queue
|
||||
cmd_queue_.push_back(cmd);
|
||||
return true;
|
||||
}
|
||||
bool enqueue_cmd(const std::string& cmd) {
|
||||
// TODO: Add multithread protection to queue
|
||||
cmd_queue_.push_back(cmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool run_queue();
|
||||
std::string error_message() {
|
||||
return error_code_.message();
|
||||
}
|
||||
bool run_queue();
|
||||
std::string error_message() {
|
||||
return error_code_.message();
|
||||
}
|
||||
|
||||
private:
|
||||
void handle_connect(const boost::system::error_code& ec);
|
||||
void handle_read(const boost::system::error_code& ec, std::size_t bytes_transferred);
|
||||
void handle_write(const boost::system::error_code& ec, std::size_t bytes_transferred);
|
||||
private:
|
||||
void handle_connect(const boost::system::error_code& ec);
|
||||
void handle_read(const boost::system::error_code& ec, std::size_t bytes_transferred);
|
||||
void handle_write(const boost::system::error_code& ec, std::size_t bytes_transferred);
|
||||
|
||||
void transmit_next_command();
|
||||
void wait_next_line();
|
||||
std::string extract_next_line();
|
||||
void transmit_next_command();
|
||||
void wait_next_line();
|
||||
std::string extract_next_line();
|
||||
|
||||
std::string host_name_;
|
||||
std::string port_name_;
|
||||
std::string newline_;
|
||||
std::string done_string_;
|
||||
std::string host_name_;
|
||||
std::string port_name_;
|
||||
std::string newline_;
|
||||
std::string done_string_;
|
||||
|
||||
std::list<std::string> cmd_queue_;
|
||||
std::list<std::string> cmd_queue_;
|
||||
|
||||
boost::asio::io_context io_context_;
|
||||
tcp::resolver resolver_;
|
||||
tcp::socket socket_;
|
||||
boost::asio::streambuf recv_buffer_;
|
||||
boost::asio::io_context io_context_;
|
||||
tcp::resolver resolver_;
|
||||
tcp::socket socket_;
|
||||
boost::asio::streambuf recv_buffer_;
|
||||
|
||||
boost::system::error_code error_code_;
|
||||
};
|
||||
boost::system::error_code error_code_;
|
||||
};
|
||||
|
||||
} // Utils
|
||||
} // Utils
|
||||
} // Slic3r
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue