void Printer::handle_rr_more (rr_dev dev) { if (printing && gcode_iter) { time_t time_used = time(NULL) - gcode_iter->time_started; if (time_used != lasttimeshown) { // show once a second int n_buffered = rr_dev_buffered_lines(device); int donelines = gcode_iter->m_cur_line - n_buffered; if (donelines < 100) gcode_iter->time_started = time(NULL); //int tot_lines = gcode_iter->m_line_count; // done by view // if (tot_lines>0) { // if (donelines > 30) { // m_view->get_view_progress()->update (donelines, false); // } // } if (lastdonelines > 0) // don't stop the progress bar m_view->showCurrentPrinting(lastdonelines); lastdonelines = donelines; lasttimeshown = time_used; } while (rr_dev_write_more (device) && !gcode_iter->finished()) { std::string line = gcode_iter->next_line_stripped(); if (line.length() > 0 && line[0] != ';') { rr_dev_enqueue_cmd (device, RR_PRIO_NORMAL, line.data(), line.size()); } } if (gcode_iter->finished()) { set_printing (false); m_view->showCurrentPrinting(0); //m_view->get_view_progress()->stop (_("Printed")); } } }
void RR_CALL Model::rr_more_fn (rr_dev dev, void *closure) { Model *model = static_cast<Model*>(closure); if (model->m_printing && model->m_iter) { model->m_progress.update (model->m_iter->m_cur_line - rr_dev_buffered_lines (model->m_device)); while (rr_dev_write_more (model->m_device) && !model->m_iter->finished()) { std::string line = model->m_iter->next_line(); if (line.length() > 0 && line[0] != ';') rr_dev_enqueue_cmd (model->m_device, RR_PRIO_NORMAL, line.data(), line.size()); } if (model->m_iter->finished()) model->m_progress.stop ("Printed"); } }