1141cc406Sopenharmony_ci/* sane - Scanner Access Now Easy. 2141cc406Sopenharmony_ci 3141cc406Sopenharmony_ci Copyright (C) 2019 Povilas Kanapickas <povilas@radix.lt> 4141cc406Sopenharmony_ci 5141cc406Sopenharmony_ci This file is part of the SANE package. 6141cc406Sopenharmony_ci 7141cc406Sopenharmony_ci This program is free software; you can redistribute it and/or 8141cc406Sopenharmony_ci modify it under the terms of the GNU General Public License as 9141cc406Sopenharmony_ci published by the Free Software Foundation; either version 2 of the 10141cc406Sopenharmony_ci License, or (at your option) any later version. 11141cc406Sopenharmony_ci 12141cc406Sopenharmony_ci This program is distributed in the hope that it will be useful, but 13141cc406Sopenharmony_ci WITHOUT ANY WARRANTY; without even the implied warranty of 14141cc406Sopenharmony_ci MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15141cc406Sopenharmony_ci General Public License for more details. 16141cc406Sopenharmony_ci 17141cc406Sopenharmony_ci You should have received a copy of the GNU General Public License 18141cc406Sopenharmony_ci along with this program. If not, see <https://www.gnu.org/licenses/>. 19141cc406Sopenharmony_ci*/ 20141cc406Sopenharmony_ci 21141cc406Sopenharmony_ci#ifndef BACKEND_GENESYS_CALIBRATION_H 22141cc406Sopenharmony_ci#define BACKEND_GENESYS_CALIBRATION_H 23141cc406Sopenharmony_ci 24141cc406Sopenharmony_ci#include "sensor.h" 25141cc406Sopenharmony_ci#include "settings.h" 26141cc406Sopenharmony_ci#include <ctime> 27141cc406Sopenharmony_ci 28141cc406Sopenharmony_cinamespace genesys { 29141cc406Sopenharmony_ci 30141cc406Sopenharmony_cistruct Genesys_Calibration_Cache 31141cc406Sopenharmony_ci{ 32141cc406Sopenharmony_ci Genesys_Calibration_Cache() = default; 33141cc406Sopenharmony_ci ~Genesys_Calibration_Cache() = default; 34141cc406Sopenharmony_ci 35141cc406Sopenharmony_ci // used to check if entry is compatible 36141cc406Sopenharmony_ci SetupParams params; 37141cc406Sopenharmony_ci 38141cc406Sopenharmony_ci std::time_t last_calibration = 0; 39141cc406Sopenharmony_ci 40141cc406Sopenharmony_ci Genesys_Frontend frontend; 41141cc406Sopenharmony_ci Genesys_Sensor sensor; 42141cc406Sopenharmony_ci 43141cc406Sopenharmony_ci ScanSession session; 44141cc406Sopenharmony_ci size_t average_size = 0; 45141cc406Sopenharmony_ci std::vector<std::uint16_t> white_average_data; 46141cc406Sopenharmony_ci std::vector<std::uint16_t> dark_average_data; 47141cc406Sopenharmony_ci 48141cc406Sopenharmony_ci bool operator==(const Genesys_Calibration_Cache& other) const 49141cc406Sopenharmony_ci { 50141cc406Sopenharmony_ci return params == other.params && 51141cc406Sopenharmony_ci last_calibration == other.last_calibration && 52141cc406Sopenharmony_ci frontend == other.frontend && 53141cc406Sopenharmony_ci sensor == other.sensor && 54141cc406Sopenharmony_ci session == other.session && 55141cc406Sopenharmony_ci average_size == other.average_size && 56141cc406Sopenharmony_ci white_average_data == other.white_average_data && 57141cc406Sopenharmony_ci dark_average_data == other.dark_average_data; 58141cc406Sopenharmony_ci } 59141cc406Sopenharmony_ci}; 60141cc406Sopenharmony_ci 61141cc406Sopenharmony_citemplate<class Stream> 62141cc406Sopenharmony_civoid serialize(Stream& str, Genesys_Calibration_Cache& x) 63141cc406Sopenharmony_ci{ 64141cc406Sopenharmony_ci serialize(str, x.params); 65141cc406Sopenharmony_ci serialize_newline(str); 66141cc406Sopenharmony_ci serialize(str, x.last_calibration); 67141cc406Sopenharmony_ci serialize_newline(str); 68141cc406Sopenharmony_ci serialize(str, x.frontend); 69141cc406Sopenharmony_ci serialize_newline(str); 70141cc406Sopenharmony_ci serialize(str, x.sensor); 71141cc406Sopenharmony_ci serialize_newline(str); 72141cc406Sopenharmony_ci serialize(str, x.session); 73141cc406Sopenharmony_ci serialize(str, x.average_size); 74141cc406Sopenharmony_ci serialize_newline(str); 75141cc406Sopenharmony_ci serialize(str, x.white_average_data); 76141cc406Sopenharmony_ci serialize_newline(str); 77141cc406Sopenharmony_ci serialize(str, x.dark_average_data); 78141cc406Sopenharmony_ci} 79141cc406Sopenharmony_ci 80141cc406Sopenharmony_ci} // namespace genesys 81141cc406Sopenharmony_ci 82141cc406Sopenharmony_ci#endif // BACKEND_GENESYS_CALIBRATION_H 83