kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Make get_motor_profile* reusable for different profile sets
rodzic
247a6b7882
commit
91d5235d4b
|
@ -856,7 +856,7 @@ void CommandSetGl124::init_regs_for_scan_session(Genesys_Device* dev, const Gene
|
||||||
} else {
|
} else {
|
||||||
exposure_time = sensor.exposure_lperiod;
|
exposure_time = sensor.exposure_lperiod;
|
||||||
}
|
}
|
||||||
const auto& motor_profile = get_motor_profile_by_exposure(dev->motor, exposure_time, session);
|
const auto& motor_profile = get_motor_profile(dev->motor.profiles, exposure_time, session);
|
||||||
|
|
||||||
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||||
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, static_cast<unsigned>(motor_profile.step_type));
|
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, static_cast<unsigned>(motor_profile.step_type));
|
||||||
|
|
|
@ -1179,7 +1179,7 @@ void CommandSetGl843::init_regs_for_scan_session(Genesys_Device* dev, const Gene
|
||||||
if (exposure < 0) {
|
if (exposure < 0) {
|
||||||
throw std::runtime_error("Exposure not defined in sensor definition");
|
throw std::runtime_error("Exposure not defined in sensor definition");
|
||||||
}
|
}
|
||||||
const auto& motor_profile = get_motor_profile_by_exposure(dev->motor, exposure, session);
|
const auto& motor_profile = get_motor_profile(dev->motor.profiles, exposure, session);
|
||||||
|
|
||||||
DBG(DBG_info, "%s : exposure=%d pixels\n", __func__, exposure);
|
DBG(DBG_info, "%s : exposure=%d pixels\n", __func__, exposure);
|
||||||
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__,
|
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__,
|
||||||
|
|
|
@ -705,7 +705,7 @@ void CommandSetGl846::init_regs_for_scan_session(Genesys_Device* dev, const Gene
|
||||||
slope_dpi = slope_dpi * (1 + dummy);
|
slope_dpi = slope_dpi * (1 + dummy);
|
||||||
|
|
||||||
exposure_time = sensor.exposure_lperiod;
|
exposure_time = sensor.exposure_lperiod;
|
||||||
const auto& motor_profile = get_motor_profile_by_exposure(dev->motor, exposure_time, session);
|
const auto& motor_profile = get_motor_profile(dev->motor.profiles, exposure_time, session);
|
||||||
|
|
||||||
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||||
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__,
|
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__,
|
||||||
|
|
|
@ -712,7 +712,7 @@ void CommandSetGl847::init_regs_for_scan_session(Genesys_Device* dev, const Gene
|
||||||
slope_dpi = slope_dpi * (1 + dummy);
|
slope_dpi = slope_dpi * (1 + dummy);
|
||||||
|
|
||||||
exposure_time = sensor.exposure_lperiod;
|
exposure_time = sensor.exposure_lperiod;
|
||||||
const auto& motor_profile = get_motor_profile_by_exposure(dev->motor, exposure_time, session);
|
const auto& motor_profile = get_motor_profile(dev->motor.profiles, exposure_time, session);
|
||||||
|
|
||||||
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||||
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__,
|
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__,
|
||||||
|
|
|
@ -1720,22 +1720,14 @@ void sanei_genesys_wait_for_home(Genesys_Device* dev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief motor profile
|
const MotorProfile* get_motor_profile_ptr(const std::vector<MotorProfile>& profiles,
|
||||||
* search for the database of motor profiles and get the best one. Each
|
unsigned exposure,
|
||||||
* profile is at full step and at a reference exposure. Use first entry
|
|
||||||
* by default.
|
|
||||||
* @param motors motor profile database
|
|
||||||
* @param motor_type motor id
|
|
||||||
* @param exposure exposure time
|
|
||||||
* @return a pointer to a MotorProfile struct
|
|
||||||
*/
|
|
||||||
const MotorProfile& get_motor_profile_by_exposure(const Genesys_Motor& motor, unsigned exposure,
|
|
||||||
const ScanSession& session)
|
const ScanSession& session)
|
||||||
{
|
{
|
||||||
int best_i = -1;
|
int best_i = -1;
|
||||||
|
|
||||||
for (unsigned i = 0; i < motor.profiles.size(); ++i) {
|
for (unsigned i = 0; i < profiles.size(); ++i) {
|
||||||
const auto& profile = motor.profiles[i];
|
const auto& profile = profiles[i];
|
||||||
|
|
||||||
if (!profile.resolutions.matches(session.params.yres)) {
|
if (!profile.resolutions.matches(session.params.yres)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1745,7 +1737,7 @@ const MotorProfile& get_motor_profile_by_exposure(const Genesys_Motor& motor, un
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile.max_exposure == exposure) {
|
if (profile.max_exposure == exposure) {
|
||||||
return profile;
|
return &profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile.max_exposure == 0 || profile.max_exposure >= exposure) {
|
if (profile.max_exposure == 0 || profile.max_exposure >= exposure) {
|
||||||
|
@ -1754,7 +1746,7 @@ const MotorProfile& get_motor_profile_by_exposure(const Genesys_Motor& motor, un
|
||||||
best_i = i;
|
best_i = i;
|
||||||
} else {
|
} else {
|
||||||
// test for better match
|
// test for better match
|
||||||
if (motor.profiles[i].max_exposure < motor.profiles[best_i].max_exposure) {
|
if (profiles[i].max_exposure < profiles[best_i].max_exposure) {
|
||||||
best_i = i;
|
best_i = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1762,10 +1754,22 @@ const MotorProfile& get_motor_profile_by_exposure(const Genesys_Motor& motor, un
|
||||||
}
|
}
|
||||||
|
|
||||||
if (best_i < 0) {
|
if (best_i < 0) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &profiles[best_i];
|
||||||
|
}
|
||||||
|
|
||||||
|
const MotorProfile& get_motor_profile(const std::vector<MotorProfile>& profiles,
|
||||||
|
unsigned exposure,
|
||||||
|
const ScanSession& session)
|
||||||
|
{
|
||||||
|
const auto* profile = get_motor_profile_ptr(profiles, exposure, session);
|
||||||
|
if (profile == nullptr) {
|
||||||
throw SaneException("Motor slope is not configured");
|
throw SaneException("Motor slope is not configured");
|
||||||
}
|
}
|
||||||
|
|
||||||
return motor.profiles[best_i];
|
return *profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
MotorSlopeTable sanei_genesys_slope_table(AsicType asic_type, int dpi, int exposure, int base_dpi,
|
MotorSlopeTable sanei_genesys_slope_table(AsicType asic_type, int dpi, int exposure, int base_dpi,
|
||||||
|
|
|
@ -388,7 +388,12 @@ void scanner_stop_action_no_move(Genesys_Device& dev, Genesys_Register_Set& regs
|
||||||
|
|
||||||
bool scanner_is_motor_stopped(Genesys_Device& dev);
|
bool scanner_is_motor_stopped(Genesys_Device& dev);
|
||||||
|
|
||||||
const MotorProfile& get_motor_profile_by_exposure(const Genesys_Motor& motor, unsigned exposure,
|
const MotorProfile* get_motor_profile_ptr(const std::vector<MotorProfile>& profiles,
|
||||||
|
unsigned exposure,
|
||||||
|
const ScanSession& session);
|
||||||
|
|
||||||
|
const MotorProfile& get_motor_profile(const std::vector<MotorProfile>& profiles,
|
||||||
|
unsigned exposure,
|
||||||
const ScanSession& session);
|
const ScanSession& session);
|
||||||
|
|
||||||
MotorSlopeTable sanei_genesys_slope_table(AsicType asic_type, int dpi, int exposure, int base_dpi,
|
MotorSlopeTable sanei_genesys_slope_table(AsicType asic_type, int dpi, int exposure, int base_dpi,
|
||||||
|
|
Ładowanie…
Reference in New Issue