Tech ENABLE_TRAVEL_TIME - Show estimated time for travel moves in legend when they are visible

This commit is contained in:
enricoturri1966 2021-10-07 14:07:33 +02:00
parent 89ed41750a
commit eee8d97f49
4 changed files with 83 additions and 6 deletions
src/libslic3r/GCode

View file

@ -189,6 +189,9 @@ void GCodeProcessor::TimeMachine::reset()
max_travel_acceleration = 0.0f;
extrude_factor_override_percentage = 1.0f;
time = 0.0f;
#if ENABLE_TRAVEL_TIME
travel_time = 0.0f;
#endif // ENABLE_TRAVEL_TIME
stop_times = std::vector<StopTime>();
curr.reset();
prev.reset();
@ -303,9 +306,17 @@ void GCodeProcessor::TimeMachine::calculate_time(size_t keep_last_n_blocks)
const TimeBlock& block = blocks[i];
float block_time = block.time();
time += block_time;
#if ENABLE_TRAVEL_TIME
if (block.move_type == EMoveType::Travel)
travel_time += block_time;
else
roles_time[static_cast<size_t>(block.role)] += block_time;
#endif // ENABLE_TRAVEL_TIME
gcode_time.cache += block_time;
moves_time[static_cast<size_t>(block.move_type)] += block_time;
#if !ENABLE_TRAVEL_TIME
roles_time[static_cast<size_t>(block.role)] += block_time;
#endif // !ENABLE_TRAVEL_TIME
if (block.layer_id > 0) {
if (block.layer_id >= layers_time.size()) {
size_t curr_size = layers_time.size();
@ -1327,6 +1338,18 @@ std::string GCodeProcessor::get_time_dhm(PrintEstimatedStatistics::ETimeMode mod
return (mode < PrintEstimatedStatistics::ETimeMode::Count) ? short_time(get_time_dhms(m_time_processor.machines[static_cast<size_t>(mode)].time)) : std::string("N/A");
}
#if ENABLE_TRAVEL_TIME
float GCodeProcessor::get_travel_time(PrintEstimatedStatistics::ETimeMode mode) const
{
return (mode < PrintEstimatedStatistics::ETimeMode::Count) ? m_time_processor.machines[static_cast<size_t>(mode)].travel_time : 0.0f;
}
std::string GCodeProcessor::get_travel_time_dhm(PrintEstimatedStatistics::ETimeMode mode) const
{
return (mode < PrintEstimatedStatistics::ETimeMode::Count) ? short_time(get_time_dhms(m_time_processor.machines[static_cast<size_t>(mode)].travel_time)) : std::string("N/A");
}
#endif // ENABLE_TRAVEL_TIME
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> GCodeProcessor::get_custom_gcode_times(PrintEstimatedStatistics::ETimeMode mode, bool include_remaining) const
{
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> ret;
@ -3332,6 +3355,9 @@ void GCodeProcessor::update_estimated_times_stats()
auto update_mode = [this](PrintEstimatedStatistics::ETimeMode mode) {
PrintEstimatedStatistics::Mode& data = m_result.print_statistics.modes[static_cast<size_t>(mode)];
data.time = get_time(mode);
#if ENABLE_TRAVEL_TIME
data.travel_time = get_travel_time(mode);
#endif // ENABLE_TRAVEL_TIME
data.custom_gcode_times = get_custom_gcode_times(mode, true);
data.moves_times = get_moves_time(mode);
data.roles_times = get_roles_time(mode);