From ad38bc6ecb80ddeb562841b33258dd53659b1da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 24 Aug 2020 18:44:51 +0200 Subject: New upstream version 1.0.31 --- backend/genesys/motor.cpp | 74 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 20 deletions(-) (limited to 'backend/genesys/motor.cpp') diff --git a/backend/genesys/motor.cpp b/backend/genesys/motor.cpp index 910266a..a18d6e1 100644 --- a/backend/genesys/motor.cpp +++ b/backend/genesys/motor.cpp @@ -43,9 +43,11 @@ #define DEBUG_DECLARE_ONLY +#include "low.h" #include "motor.h" #include "utilities.h" #include +#include namespace genesys { @@ -80,19 +82,38 @@ MotorSlope MotorSlope::create_from_steps(unsigned initial_w, unsigned max_w, return slope; } -void MotorSlopeTable::slice_steps(unsigned count) +void MotorSlopeTable::slice_steps(unsigned count, unsigned step_multiplier) { - if (count >= table.size() || count > steps_count) { - throw SaneException("Excepssive steps count"); + if (count > table.size() || count < step_multiplier) { + throw SaneException("Invalid steps count"); } - steps_count = count; + count = align_multiple_floor(count, step_multiplier); + table.resize(count); + generate_pixeltime_sum(); +} + +void MotorSlopeTable::expand_table(unsigned count, unsigned step_multiplier) +{ + if (table.empty()) { + throw SaneException("Can't expand empty table"); + } + count = align_multiple_ceil(count, step_multiplier); + table.resize(table.size() + count, table.back()); + generate_pixeltime_sum(); +} + +void MotorSlopeTable::generate_pixeltime_sum() +{ + pixeltime_sum_ = std::accumulate(table.begin(), table.end(), + std::size_t{0}, std::plus()); } unsigned get_slope_table_max_size(AsicType asic_type) { switch (asic_type) { case AsicType::GL646: - case AsicType::GL841: return 255; + case AsicType::GL841: + case AsicType::GL842: return 255; case AsicType::GL843: case AsicType::GL845: case AsicType::GL846: @@ -103,9 +124,9 @@ unsigned get_slope_table_max_size(AsicType asic_type) } } -MotorSlopeTable create_slope_table(const MotorSlope& slope, unsigned target_speed_w, - StepType step_type, unsigned steps_alignment, - unsigned min_size, unsigned max_size) +MotorSlopeTable create_slope_table_for_speed(const MotorSlope& slope, unsigned target_speed_w, + StepType step_type, unsigned steps_alignment, + unsigned min_size, unsigned max_size) { DBG_HELPER_ARGS(dbg, "target_speed_w: %d, step_type: %d, steps_alignment: %d, min_size: %d", target_speed_w, static_cast(step_type), steps_alignment, min_size); @@ -120,6 +141,10 @@ MotorSlopeTable create_slope_table(const MotorSlope& slope, unsigned target_spee dbg.log(DBG_warn, "failed to reach target speed"); } + if (target_speed_shifted_w >= std::numeric_limits::max()) { + throw SaneException("Target motor speed is too low"); + } + unsigned final_speed = std::max(target_speed_shifted_w, max_speed_shifted_w); table.table.reserve(max_size); @@ -130,26 +155,20 @@ MotorSlopeTable create_slope_table(const MotorSlope& slope, unsigned target_spee break; } table.table.push_back(current); - table.pixeltime_sum += current; } // make sure the target speed (or the max speed if target speed is too high) is present in // the table table.table.push_back(final_speed); - table.pixeltime_sum += table.table.back(); // fill the table up to the specified size while (table.table.size() < max_size - 1 && (table.table.size() % steps_alignment != 0 || table.table.size() < min_size)) { table.table.push_back(table.table.back()); - table.pixeltime_sum += table.table.back(); } - table.steps_count = table.table.size(); - - // fill the rest of the table with the final speed - table.table.resize(max_size, final_speed); + table.generate_pixeltime_sum(); return table; } @@ -164,15 +183,30 @@ std::ostream& operator<<(std::ostream& out, const MotorSlope& slope) return out; } +std::ostream& operator<<(std::ostream& out, const MotorProfile& profile) +{ + out << "MotorProfile{\n" + << " max_exposure: " << profile.max_exposure << '\n' + << " step_type: " << profile.step_type << '\n' + << " motor_vref: " << profile.motor_vref << '\n' + << " resolutions: " << format_indent_braced_list(4, profile.resolutions) << '\n' + << " scan_methods: " << format_indent_braced_list(4, profile.scan_methods) << '\n' + << " slope: " << format_indent_braced_list(4, profile.slope) << '\n' + << '}'; + return out; +} + std::ostream& operator<<(std::ostream& out, const Genesys_Motor& motor) { out << "Genesys_Motor{\n" - << " id: " << static_cast(motor.id) << '\n' + << " id: " << motor.id << '\n' << " base_ydpi: " << motor.base_ydpi << '\n' - << " optical_ydpi: " << motor.optical_ydpi << '\n' - << " slopes: " - << format_indent_braced_list(4, format_vector_indent_braced(4, "MotorSlope", - motor.slopes)) + << " profiles: " + << format_indent_braced_list(4, format_vector_indent_braced(4, "MotorProfile", + motor.profiles)) << '\n' + << " fast_profiles: " + << format_indent_braced_list(4, format_vector_indent_braced(4, "MotorProfile", + motor.fast_profiles)) << '\n' << '}'; return out; } -- cgit v1.2.3