mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 14:44:19 -06:00
Finished GCodeSender
This commit is contained in:
parent
8b438dc0de
commit
b126f92f41
7 changed files with 222 additions and 68 deletions
|
@ -3,28 +3,47 @@
|
|||
#ifdef BOOST_LIBS
|
||||
|
||||
#include <myinit.h>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
namespace asio = boost::asio;
|
||||
|
||||
class GCodeSender {
|
||||
class GCodeSender : private boost::noncopyable {
|
||||
public:
|
||||
GCodeSender(std::string devname, unsigned int baud_rate);
|
||||
void send(const std::vector<std::string> &lines);
|
||||
void send(const std::string &s);
|
||||
|
||||
void disconnect();
|
||||
bool error_status() const;
|
||||
bool is_connected() const;
|
||||
size_t queue_size() const;
|
||||
|
||||
private:
|
||||
asio::io_service io;
|
||||
asio::serial_port serial;
|
||||
std::vector<std::string> lines;
|
||||
boost::thread background_thread;
|
||||
boost::asio::streambuf read_buffer;
|
||||
bool open; // whether the serial socket is connected
|
||||
bool connected; // whether the printer is online
|
||||
bool error;
|
||||
mutable boost::mutex error_mutex;
|
||||
|
||||
void send_line(const std::string &line);
|
||||
void read_line(std::string* line);
|
||||
mutable boost::mutex queue_mutex;
|
||||
std::queue<std::string> queue;
|
||||
bool can_send;
|
||||
size_t sent;
|
||||
|
||||
void set_error_status(bool e);
|
||||
void do_close();
|
||||
void do_read();
|
||||
void on_read(const boost::system::error_code& error, size_t bytes_transferred);
|
||||
void send();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue