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.h | 76 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 16 deletions(-) (limited to 'backend/genesys/motor.h') diff --git a/backend/genesys/motor.h b/backend/genesys/motor.h index d80da6d..c433c0e 100644 --- a/backend/genesys/motor.h +++ b/backend/genesys/motor.h @@ -44,9 +44,12 @@ #ifndef BACKEND_GENESYS_MOTOR_H #define BACKEND_GENESYS_MOTOR_H +#include #include #include #include "enums.h" +#include "sensor.h" +#include "value_filter.h" namespace genesys { @@ -123,20 +126,47 @@ struct MotorSlope struct MotorSlopeTable { std::vector table; - unsigned steps_count = 0; - unsigned pixeltime_sum = 0; - void slice_steps(unsigned count); + void slice_steps(unsigned count, unsigned step_multiplier); + + // expands the table by the given number of steps + void expand_table(unsigned count, unsigned step_multiplier); + + std::uint64_t pixeltime_sum() const { return pixeltime_sum_; } + + void generate_pixeltime_sum(); +private: + std::uint64_t pixeltime_sum_ = 0; }; 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); std::ostream& operator<<(std::ostream& out, const MotorSlope& slope); +struct MotorProfile +{ + MotorProfile() = default; + MotorProfile(const MotorSlope& a_slope, StepType a_step_type, unsigned a_max_exposure) : + slope{a_slope}, step_type{a_step_type}, max_exposure{a_max_exposure} + {} + + MotorSlope slope; + StepType step_type = StepType::FULL; + int motor_vref = -1; + + // the resolutions this profile is good for + ValueFilterAny resolutions = VALUE_FILTER_ANY; + // the scan method this profile is good for. If the list is empty, good for any method. + ValueFilterAny scan_methods = VALUE_FILTER_ANY; + + unsigned max_exposure = 0; // 0 - any exposure +}; + +std::ostream& operator<<(std::ostream& out, const MotorProfile& profile); struct Genesys_Motor { @@ -146,27 +176,41 @@ struct Genesys_Motor MotorId id = MotorId::UNKNOWN; // motor base steps. Unit: 1/inch int base_ydpi = 0; - // maximum resolution in y-direction. Unit: 1/inch - int optical_ydpi = 0; // slopes to derive individual slopes from - std::vector slopes; + std::vector profiles; + // slopes to derive individual slopes from for fast moving + std::vector fast_profiles; - MotorSlope& get_slope(StepType step_type) + MotorSlope& get_slope_with_step_type(StepType step_type) { - return slopes[static_cast(step_type)]; + for (auto& p : profiles) { + if (p.step_type == step_type) + return p.slope; + } + throw SaneException("No motor profile with step type"); } - const MotorSlope& get_slope(StepType step_type) const + const MotorSlope& get_slope_with_step_type(StepType step_type) const { - return slopes[static_cast(step_type)]; + for (const auto& p : profiles) { + if (p.step_type == step_type) + return p.slope; + } + throw SaneException("No motor profile with step type"); } StepType max_step_type() const { - if (slopes.empty()) { - throw std::runtime_error("Slopes table is empty"); + if (profiles.empty()) { + throw std::runtime_error("Profiles table is empty"); + } + StepType step_type = StepType::FULL; + for (const auto& p : profiles) { + step_type = static_cast( + std::max(static_cast(step_type), + static_cast(p.step_type))); } - return static_cast(slopes.size() - 1); + return step_type; } }; -- cgit v1.2.3