303{
304
305 bool need_flush = false;
306 std::string cmd(line.cmd());
307 double time = 0;
308 int16_t fan_speed = -1;
309 if (cmd.length() > 1) {
310 if (line.has_f())
312 switch (::toupper(cmd[0])) {
313 case 'T':
314 case 't':
316 break;
317 case 'G':
318 {
319 if (::atoi(&cmd[1]) == 1 || ::atoi(&cmd[1]) == 0) {
320 double distx = line.dist_X(reader);
321 double disty = line.dist_Y(reader);
322 double distz = line.dist_Z(reader);
323 double dist = distx * distx + disty * disty + distz * distz;
327 }
328 }
329 break;
330 }
331 case 'M':
332 {
334 if (fan_speed >= 0) {
335 const auto fan_baseline = 255.0;
336 fan_speed = 100 * fan_speed / fan_baseline;
337
340
343
344 time = -1;
345
346
348
351 }
352
353
354
356
358
362 } else {
364 }
365
367 float time_count = kickstart_duration;
369 while (it !=
m_buffer.end() && time_count > 0) {
370 time_count -= it->time;
371 if (time_count< 0) {
372
373 _put_in_middle_G1(it, it->time + time_count, BufferData(std::string(line.raw()), 0, fan_speed,
true));
374
375 break;
376 }
377 ++it;
378 }
379 if (time_count > 0) {
380
384 }
386 } else {
387
389
393 } else {
395 }
397 }
398 } else {
400
401
403
405
407
408 } else {
409
414
415 time = -1;
416 }
418
419 time = -1;
420
422
423
425 , 0, fan_speed, true));
426
427
428
432 }
433 }
434 }
435
437 } else {
438
439 need_flush = true;
440 }
441 }
442 break;
443 }
444 }
445 } else {
446 if(!line.raw().empty() && line.raw().front() == ';')
447 {
448 if (line.raw().size() > 10 && line.raw().rfind(";TYPE:", 0) == 0) {
449
450 std::string extrusion_string = line.raw().substr(6, line.raw().size() - 6);
452 }
453 if (line.raw().rfind(";_FAN_MOVER_SKIP_", 0) == 0) {
454
456 time = -1;
457 }
458 if (line.raw().size() > 16) {
459 if (line.raw().rfind("; custom gcode", 0) != std::string::npos) {
460 if (line.raw().rfind("; custom gcode end", 0) != std::string::npos)
462 else
464 }
465 }
466 }
467 }
468
469 if (time >= 0) {
470 BufferData& new_data =
put_in_buffer(BufferData(line.raw(), time, fan_speed));
473 new_data.x = reader.x();
474 new_data.dx = line.dist_X(reader);
475 }
477 new_data.y = reader.y();
478 new_data.dy = line.dist_Y(reader);
479 }
481 new_data.z = reader.z();
482 new_data.dz = line.dist_Z(reader);
483 }
485 new_data.e = reader.e();
487 new_data.de = line.e();
488 else
489 new_data.de = line.dist_E(reader);
490 }
491
495
497 }
498 }
499 }
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523 if (time >= 0) {
525 BufferData& frontdata =
m_buffer.front();
528
530
532 } else {
534 if (frontdata.fan_speed >= 0) {
535
536
538 }
539 }
540 }
542 }
543 }
544 double sum = 0;
545 for (
auto& data :
m_buffer) sum += data.time;
547}
#define EPSILON
Definition ColorUtils.cpp:64
static ExtrusionRole string_to_role(const std::string_view role)
Definition ExtrusionEntity.cpp:701
void _remove_slow_fan(int16_t min_speed, float past_sec)
Definition FanMover.cpp:237
ExtrusionRole current_role
Definition FanMover.hpp:50
BufferData & put_in_buffer(BufferData &&data)
Definition FanMover.hpp:83
std::list< BufferData > m_buffer
Definition FanMover.hpp:62
void _process_T(const std::string_view command)
Definition FanMover.cpp:283
void _print_in_middle_G1(BufferData &line_to_split, float nb_sec, const std::string &line_to_write)
Definition FanMover.cpp:193
std::string _set_fan(int16_t speed)
Definition FanMover.cpp:254
void _put_in_middle_G1(std::list< BufferData >::iterator item_to_split, float nb_sec, BufferData &&line_to_write)
Definition FanMover.cpp:135
int m_back_buffer_fan_speed
Definition FanMover.hpp:58
int m_front_buffer_fan_speed
Definition FanMover.hpp:57
double m_buffer_time_size
Definition FanMover.hpp:63
bool m_is_custom_gcode
Definition FanMover.hpp:53
double m_current_speed
Definition FanMover.hpp:52
BufferData m_current_kickstart
Definition FanMover.hpp:59
std::list< BufferData >::iterator remove_from_buffer(std::list< BufferData >::iterator data)
Definition FanMover.hpp:88
T dist(const boost::polygon::point_data< T > &p1, const boost::polygon::point_data< T > &p2)
Definition Geometry.cpp:298
@ erOverhangPerimeter
Definition ExtrusionEntity.hpp:30
int16_t get_fan_speed(const std::string &line, GCodeFlavor flavor)
Definition FanMover.cpp:109
@ Y
Definition libslic3r.h:142
@ Z
Definition libslic3r.h:143
@ E
Definition libslic3r.h:144
@ X
Definition libslic3r.h:141