Merge branch 'master' into wipe_tower_improvements

This commit is contained in:
Lukas Matena 2018-06-21 10:41:01 +02:00
commit 6669357c81
47 changed files with 5724 additions and 6848 deletions

View file

@ -206,7 +206,7 @@ public:
do {
++i;
if (i==4) i=0;
extrude(corners[i]);
extrude(corners[i], f);
} while (i != index_of_closest);
return (*this);
}
@ -406,6 +406,7 @@ private:
float m_wipe_tower_width = 0.f;
float m_wipe_tower_depth = 0.f;
float m_last_fan_speed = 0.f;
int current_temp = -1;
const float m_default_analyzer_line_width;
std::string set_format_X(float x)
@ -1145,6 +1146,7 @@ void WipeTowerPrusaMM::save_on_last_wipe()
void WipeTowerPrusaMM::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &result)
{
if (m_plan.empty())
return;
m_extra_spacing = 1.f;
@ -1159,6 +1161,7 @@ void WipeTowerPrusaMM::generate(std::vector<std::vector<WipeTower::ToolChangeRes
make_wipe_tower_square();
m_layer_info = m_plan.begin();
m_current_tool = (unsigned int)(-2); // we don't know which extruder to start with - we'll set it according to the first toolchange
std::vector<WipeTower::ToolChangeResult> layer_result;
for (auto layer : m_plan)
@ -1172,8 +1175,11 @@ void WipeTowerPrusaMM::generate(std::vector<std::vector<WipeTower::ToolChangeRes
if (!m_peters_wipe_tower && m_layer_info->depth < m_wipe_tower_depth - m_perimeter_width)
m_y_shift = (m_wipe_tower_depth-m_layer_info->depth-m_perimeter_width)/2.f;
for (const auto &toolchange : layer.tool_changes)
for (const auto &toolchange : layer.tool_changes) {
if (m_current_tool == (unsigned int)(-2))
m_current_tool = toolchange.old_tool;
layer_result.emplace_back(tool_change(toolchange.new_tool, false));
}
if (! layer_finished()) {
auto finish_layer_toolchange = finish_layer();

View file

@ -242,7 +242,6 @@ private:
bool m_left_to_right = true;
float m_extra_spacing = 1.f;
// Calculates extrusion flow needed to produce required line width for given layer height
float extrusion_flow(float layer_height = -1.f) const // negative layer_height - return current m_extrusion_flow
{

View file

@ -41,6 +41,7 @@ struct termios2 {
//#define DEBUG_SERIAL
#ifdef DEBUG_SERIAL
#include <cstdlib>
#include <fstream>
std::fstream fs;
#endif
@ -52,7 +53,11 @@ namespace Slic3r {
GCodeSender::GCodeSender()
: io(), serial(io), can_send(false), sent(0), open(false), error(false),
connected(false), queue_paused(false)
{}
{
#ifdef DEBUG_SERIAL
std::srand(std::time(nullptr));
#endif
}
GCodeSender::~GCodeSender()
{
@ -358,15 +363,23 @@ GCodeSender::on_read(const boost::system::error_code& error,
// extract the first number from line
boost::algorithm::trim_left_if(line, !boost::algorithm::is_digit());
size_t toresend = boost::lexical_cast<size_t>(line.substr(0, line.find_first_not_of("0123456789")));
++ toresend; // N is 0-based
if (toresend >= this->sent - this->last_sent.size() && toresend < this->last_sent.size()) {
#ifdef DEBUG_SERIAL
fs << "!! line num out of sync: toresend = " << toresend << ", sent = " << sent << ", last_sent.size = " << last_sent.size() << std::endl;
#endif
if (toresend > this->sent - this->last_sent.size() && toresend <= this->sent) {
{
boost::lock_guard<boost::mutex> l(this->queue_mutex);
const auto lines_to_resend = this->sent - toresend + 1;
#ifdef DEBUG_SERIAL
fs << "!! resending " << lines_to_resend << " lines" << std::endl;
#endif
// move the unsent lines to priqueue
this->priqueue.insert(
this->priqueue.begin(), // insert at the beginning
this->last_sent.begin() + toresend - (this->sent - this->last_sent.size()) - 1,
this->last_sent.begin() + this->last_sent.size() - lines_to_resend,
this->last_sent.end()
);
@ -477,8 +490,14 @@ GCodeSender::do_send()
if (line.empty()) return;
// compute full line
std::string full_line = "N" + boost::lexical_cast<std::string>(this->sent) + " " + line;
++ this->sent;
#ifndef DEBUG_SERIAL
const auto line_num = this->sent;
#else
// In DEBUG_SERIAL mode, test line re-synchronization by sending bad line number 1/4 of the time
const auto line_num = std::rand() < RAND_MAX/4 ? 0 : this->sent;
#endif
std::string full_line = "N" + boost::lexical_cast<std::string>(line_num) + " " + line;
// calculate checksum
int cs = 0;
@ -497,8 +516,9 @@ GCodeSender::do_send()
this->last_sent.push_back(line);
this->can_send = false;
if (this->last_sent.size() > KEEP_SENT)
this->last_sent.erase(this->last_sent.begin(), this->last_sent.end() - KEEP_SENT);
while (this->last_sent.size() > KEEP_SENT) {
this->last_sent.pop_front();
}
// we can't supply boost::asio::buffer(full_line) to async_write() because full_line is on the
// stack and the buffer would lose its underlying storage causing memory corruption

View file

@ -51,7 +51,7 @@ class GCodeSender : private boost::noncopyable {
bool can_send;
bool queue_paused;
size_t sent;
std::vector<std::string> last_sent;
std::deque<std::string> last_sent;
// this mutex guards log, T, B
mutable boost::mutex log_mutex;

View file

@ -243,7 +243,7 @@ void PerimeterGenerator::process()
perimeter_spacing / 2;
// only apply infill overlap if we actually have one perimeter
if (inset > 0)
inset -= this->config->get_abs_value("infill_overlap", inset + solid_infill_spacing / 2);
inset -= scale_(this->config->get_abs_value("infill_overlap", unscale(inset + solid_infill_spacing / 2)));
// simplify infill contours according to resolution
Polygons pp;
for (ExPolygon &ex : last)

View file

@ -973,7 +973,7 @@ PrintConfigDef::PrintConfigDef()
def->default_value = new ConfigOptionFloats { 10. };
def = this->add("min_skirt_length", coFloat);
def->label = L("Minimum extrusion length");
def->label = L("Minimal filament extrusion length");
def->tooltip = L("Generate no less than the number of skirt loops required to consume "
"the specified amount of filament on the bottom layer. For multi-extruder machines, "
"this minimum applies to each extruder.");

View file

@ -14,7 +14,7 @@
#include <boost/thread.hpp>
#define SLIC3R_FORK_NAME "Slic3r Prusa Edition"
#define SLIC3R_VERSION "1.40.0-alpha2"
#define SLIC3R_VERSION "1.40.0"
#define SLIC3R_BUILD "UNKNOWN"
typedef int32_t coord_t;