迁移校正数据

This commit is contained in:
gb 2024-01-13 17:14:12 +08:00
parent d0fe2c8679
commit 19ac608a14
14 changed files with 259 additions and 871 deletions

View File

@ -26,6 +26,7 @@ typedef struct Mode_FPGA
unsigned short int adcA : 1; unsigned short int adcA : 1;
unsigned short int adcB : 1; unsigned short int adcB : 1;
unsigned short int selftest : 1; unsigned short int selftest : 1;
unsigned short int sp; unsigned short int sp;
} ModeFpga; } ModeFpga;

File diff suppressed because one or more lines are too long

View File

@ -21,7 +21,7 @@
// LPPACKIMAGE: image information, ignored when bool is false // LPPACKIMAGE: image information, ignored when bool is false
#define IMAGE_HANDLER_PROTO void(dyn_mem_ptr, bool, LPPACKIMAGE) #define IMAGE_HANDLER_PROTO void(dyn_mem_ptr, bool, LPPACKIMAGE)
class FpgaComm; #include "./cis/FpgaComm.h"
class GVideoISP1; class GVideoISP1;
class gVideo; class gVideo;
class MotorBoard; class MotorBoard;
@ -60,9 +60,12 @@ class scanner_hw : public sane_opt_provider
int delay_ = 1000; int delay_ = 1000;
int frame_h_ = 12; int frame_h_ = 12;
int sample_ = 256; int sample_ = 256;
int sp_ = 816;
int exposure_[SIDE_COUNT][COLOR_IND_COUNT]; int exposure_[SIDE_COUNT][COLOR_IND_COUNT];
int gain_[SIDE_COUNT]; int gain_[SIDE_COUNT][FpgaComm::CIS_SECTOR_COUNT];
int off_[SIDE_COUNT]; int off_[SIDE_COUNT][FpgaComm::CIS_SECTOR_COUNT];
double stretch_h_ = 1.0f;
double stretch_v_ = 1.0f;
std::string paper_ = "\345\214\271\351\205\215\345\216\237\345\247\213\345\260\272\345\257\270"; std::string paper_ = "\345\214\271\351\205\215\345\216\237\345\247\213\345\260\272\345\257\270";
bool lateral_ = false; bool lateral_ = false;
@ -81,6 +84,7 @@ class scanner_hw : public sane_opt_provider
void thread_image_capture(void); void thread_image_capture(void);
bool is_scan_fatal(void); bool is_scan_fatal(void);
void retrieve_v4l2_mem(safe_fifo<int>* mem, int* used); void retrieve_v4l2_mem(safe_fifo<int>* mem, int* used);
void set_gain_value(bool front, bool gain, int sector, int val);
public: public:
scanner_hw(); scanner_hw();
@ -102,586 +106,3 @@ public:
int close(void); int close(void);
bool is_scanning(void); bool is_scanning(void);
}; };
// {
// "mode": {
// "cat": "none",
// "group": "CIS",
// "title": "颜色模式",
// "desc": "选择镜头色彩工作模式",
// "type": "string",
// "fix-id": 34819,
// "ui-pos": 10,
// "auth": 0,
// "size": 12,
// "cur": "彩色",
// "default": "彩色",
// "range": ["彩色", "灰度"]
// },
// "resolution": {
// "cat": "none",
// "group": "CIS",
// "title": "分辨率",
// "desc": "设置镜头工作的分辨率",
// "type": "int",
// "fix-id": 34840,
// "ui-pos": 11,
// "auth": 0,
// "size": 4,
// "cur": 200,
// "default": 200,
// "range": [200, 300, 600]
// },
// "paper": {
// "cat": "base",
// "group": "base",
// "title": "纸张尺寸",
// "desc": "设置出图大小",
// "type": "string",
// "fix-id": 34831,
// "ui-pos": 10,
// "auth": 0,
// "size": 44,
// "cur": "匹配原始尺寸",
// "default": "匹配原始尺寸",
// "range": ["A3", "8开", "A4", "16开", "A5", "A6", "B4", "B5", "B6", "Letter", "Double Letter", "LEGAL", "匹配原始尺寸", {
// "resolution<500": "最大扫描尺寸自动裁切"
// }, {
// "resolution<500": "最大扫描尺寸"
// }, {
// "resolution<500": "三联试卷"
// }]
// },
// "lateral": {
// "cat": "base",
// "group": "base",
// "title": "横向",
// "desc": "横向放置纸张",
// "type": "bool",
// "fix-id": 34924,
// "ui-pos": 12,
// "auth": 0,
// "affect": 6,
// "visible": 0,
// "size": 4,
// "cur": false,
// "default": false,
// "depend": "paper==A4 || paper==16开 || paper==A5 || paper==A6 || paper==B5 || paper==B6 || paper==Letter"
// },
// "paper-w": {
// "cat": "base",
// "group": "base",
// "title": "纸张宽度",
// "desc": "以毫米为单位的纸张宽",
// "type": "float",
// "fix-id": 34922,
// "ui-pos": 13,
// "auth": 0,
// "unit": "mm",
// "readonly": true,
// "visible": 0,
// "size": 8,
// "auto": false,
// "ownread": true,
// "cur": 210.000000,
// "default": 210.000000
// },
// "paper-h": {
// "cat": "base",
// "group": "base",
// "title": "纸张高度",
// "desc": "以毫米为单位的纸张高",
// "type": "float",
// "fix-id": 34923,
// "ui-pos": 14,
// "auth": 0,
// "unit": "mm",
// "readonly": true,
// "visible": 0,
// "size": 8,
// "auto": false,
// "ownread": true,
// "cur": 297.000000,
// "default": 297.000000
// },
// "is-wait-scan": {
// "cat": "base",
// "group": "feeder",
// "title": "待纸扫描",
// "desc": "启用后,文稿放入扫描仪时将自动启动扫描",
// "type": "bool",
// "fix-id": 34873,
// "ui-pos": 12,
// "auth": 0,
// "size": 4,
// "cur": false,
// "default": false
// },
// "wait-scan-exit": {
// "cat": "base",
// "group": "feeder",
// "title": "待纸扫描退出时间",
// "desc": "设置结束待纸扫描的时间",
// "type": "string",
// "fix-id": 34920,
// "ui-pos": 13,
// "auth": 0,
// "size": 16,
// "cur": "60s",
// "default": "60s",
// "range": ["15s", "30s", "60s", "2min", "4min", "8min"],
// "depend": "is-wait-scan==true"
// },
// "scan-mode": {
// "cat": "base",
// "group": "feeder",
// "title": "扫描张数",
// "desc": "选择指定数量扫描或连续扫描",
// "type": "string",
// "fix-id": 34862,
// "ui-pos": 15,
// "auth": 0,
// "size": 24,
// "cur": "连续扫描",
// "default": "连续扫描",
// "range": ["连续扫描", "扫描指定张数"],
// "depend": "is-wait-scan==false"
// },
// "scan-count": {
// "cat": "base",
// "group": "feeder",
// "title": " 扫描数量",
// "desc": "扫描指定数量",
// "type": "int",
// "fix-id": 34863,
// "ui-pos": 16,
// "auth": 0,
// "size": 4,
// "cur": -1,
// "default": -1,
// "depend": "scan-mode.enabled&&scan-mode==扫描指定张数"
// },
// "is-auto-strength": {
// "cat": "base",
// "group": "feeder",
// "title": "自动分纸强度",
// "desc": "扫描仪自动修正分纸力度",
// "type": "bool",
// "fix-id": 34876,
// "ui-pos": 27,
// "auth": 0,
// "size": 4,
// "cur": false,
// "default": false
// },
// "feed-strength-value": {
// "cat": "base",
// "group": "feeder",
// "title": " 进纸失败率",
// "desc": "高于该值时扫描仪将调整分纸力度",
// "type": "float",
// "fix-id": 34877,
// "ui-pos": 28,
// "auth": 0,
// "size": 8,
// "cur": 0.000000,
// "default": 0.000000,
// "range": {
// "min": 0.100000,
// "max": 0.900000,
// "step": 0.080000
// },
// "depend": "is-auto-strength==true"
// },
// "feed-strength": {
// "cat": "base",
// "group": "feeder",
// "title": "分纸强度",
// "desc": "设置扫描仪的分纸力度",
// "type": "string",
// "fix-id": 34874,
// "ui-pos": 30,
// "auth": 0,
// "size": 12,
// "cur": "一般",
// "default": "一般",
// "range": ["弱", "一般", "强"],
// "depend": "is-auto-strength!=true"
// },
// "time-to-sleep": {
// "cat": "base",
// "group": "feeder",
// "title": "休眠时间",
// "desc": "设置扫描仪的休眠时间",
// "type": "string",
// "fix-id": 34875,
// "ui-pos": 33,
// "auth": 0,
// "size": 16,
// "cur": "不休眠",
// "default": "不休眠",
// "range": ["不休眠", "五分钟", "十分钟", "半小时", "一小时", "两小时", "四小时"]
// },
// "baud": {
// "cat": "none",
// "group": "CIS",
// "title": "波特率",
// "desc": "CIS控制通信速率",
// "type": "int",
// "ui-pos": 20,
// "auth": 0,
// "size": 4,
// "cur": 921600,
// "default": 921600,
// "range": [110, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 500000, 921600, 1500000]
// },
// "act-after": {
// "cat": "none",
// "group": "CIS",
// "title": "延迟响应",
// "desc": "采集头接受命令后的动作延迟时间",
// "type": "int",
// "ui-pos": 21,
// "auth": 0,
// "unit": "microsec",
// "size": 4,
// "cur": 1000,
// "default": 1000
// },
// "frame-h": {
// "cat": "none",
// "group": "CIS",
// "title": "帧高度",
// "desc": "采集头每一帧的采集高度",
// "type": "int",
// "ui-pos": 22,
// "auth": 0,
// "size": 4,
// "cur": 12,
// "default": 12
// },
// "sample": {
// "cat": "none",
// "group": "CIS",
// "title": "采样频率",
// "desc": "采样频率",
// "type": "int",
// "ui-pos": 23,
// "auth": 0,
// "size": 4,
// "cur": 256,
// "default": 256
// },
// "expo-fb": {
// "cat": "none",
// "group": "CIS",
// "title": "曝光度(正面蓝色通道)",
// "desc": "正面蓝色通道的曝光强度",
// "type": "int",
// "ui-pos": 32,
// "auth": 0,
// "size": 4,
// "cur": 0,
// "default": 0,
// "range": {
// "min": -1000,
// "max": 1000,
// "step": 1
// }
// },
// "expo-fg": {
// "cat": "none",
// "group": "CIS",
// "title": "曝光度(正面绿色通道)",
// "desc": "正面绿色通道的曝光强度",
// "type": "int",
// "ui-pos": 31,
// "auth": 0,
// "size": 4,
// "cur": 0,
// "default": 0,
// "range": {
// "min": -1000,
// "max": 1000,
// "step": 1
// }
// },
// "expo-fr": {
// "cat": "none",
// "group": "CIS",
// "title": "曝光度(正面红色通道)",
// "desc": "正面红色通道的曝光强度",
// "type": "int",
// "ui-pos": 30,
// "auth": 0,
// "size": 4,
// "cur": 0,
// "default": 0,
// "range": {
// "min": -1000,
// "max": 1000,
// "step": 1
// }
// },
// "expo-bb": {
// "cat": "none",
// "group": "CIS",
// "title": "曝光度(背面蓝色通道)",
// "desc": "背面蓝色通道的曝光强度",
// "type": "int",
// "ui-pos": 35,
// "auth": 0,
// "size": 4,
// "cur": 0,
// "default": 0,
// "range": {
// "min": -1000,
// "max": 1000,
// "step": 1
// }
// },
// "expo-bg": {
// "cat": "none",
// "group": "CIS",
// "title": "曝光度(背面绿色通道)",
// "desc": "背面绿色通道的曝光强度",
// "type": "int",
// "ui-pos": 34,
// "auth": 0,
// "size": 4,
// "cur": 0,
// "default": 0,
// "range": {
// "min": -1000,
// "max": 1000,
// "step": 1
// }
// },
// "expo-br": {
// "cat": "none",
// "group": "CIS",
// "title": "曝光度(背面红色通道)",
// "desc": "背面红色通道的曝光强度",
// "type": "int",
// "ui-pos": 33,
// "auth": 0,
// "size": 4,
// "cur": 0,
// "default": 0,
// "range": {
// "min": -1000,
// "max": 1000,
// "step": 1
// }
// },
// "gain-f": {
// "cat": "none",
// "group": "CIS",
// "title": "增益(正面)",
// "desc": "正面的增益量",
// "type": "int",
// "ui-pos": 40,
// "auth": 0,
// "size": 4,
// "cur": 0,
// "default": 0,
// "range": {
// "min": -1000,
// "max": 1000,
// "step": 1
// }
// },
// "gain-b": {
// "cat": "none",
// "group": "CIS",
// "title": "增益(背面)",
// "desc": "背面的增益量",
// "type": "int",
// "ui-pos": 41,
// "auth": 0,
// "size": 4,
// "cur": 0,
// "default": 0,
// "range": {
// "min": -1000,
// "max": 1000,
// "step": 1
// }
// },
// "off-f": {
// "cat": "none",
// "group": "CIS",
// "title": "增益补偿(正面)",
// "desc": "正面的增益补偿量",
// "type": "int",
// "ui-pos": 45,
// "auth": 0,
// "size": 4,
// "cur": 0,
// "default": 0,
// "range": {
// "min": -100,
// "max": 100,
// "step": 1
// }
// },
// "off-b": {
// "cat": "none",
// "group": "CIS",
// "title": "增益补偿(背面)",
// "desc": "背面的增益补偿量",
// "type": "int",
// "ui-pos": 46,
// "auth": 0,
// "size": 4,
// "cur": 0,
// "default": 0,
// "range": {
// "min": -100,
// "max": 100,
// "step": 1
// }
// },
// "paper-on": {
// "cat": "none",
// "group": "feeder",
// "title": "纸张就绪",
// "desc": "纸张已经在进纸台上放置好",
// "type": "bool",
// "fix-id": 34912,
// "ui-pos": 10,
// "auth": 0,
// "readonly": true,
// "size": 4,
// "auto": false,
// "ownread": true,
// "cur": false,
// "default": false
// },
// "double-chk": {
// "cat": "none",
// "group": "feeder",
// "title": "双张检测",
// "desc": "检测是否有两张或者多张纸同时搓进",
// "type": "string",
// "ui-pos": 18,
// "auth": 0,
// "size": 16,
// "cur": "超声波",
// "default": "超声波",
// "range": ["超声波", "禁用"]
// },
// "is-staple": {
// "cat": "none",
// "group": "feeder",
// "title": "装订检测",
// "desc": "检测是否有订书钉存在",
// "type": "bool",
// "fix-id": 34861,
// "ui-pos": 20,
// "auth": 0,
// "size": 4,
// "cur": true,
// "default": true
// },
// "motor-speed": {
// "cat": "none",
// "group": "feeder",
// "title": "走纸速度",
// "desc": "设置走纸电机的速度,张\/分PPM",
// "type": "int",
// "ui-pos": 25,
// "auth": 0,
// "size": 4,
// "cur": 100,
// "default": 100,
// "range": [{
// "dev-model!=G200": 70
// }, {
// "dev-model!=G200": 80
// }, {
// "dev-model!=G200": 90
// }, 100, {
// "dev-model==G200": 110
// }, {
// "dev-model==G200": 120
// }, {
// "dev-model==G200": 130
// }]
// },
// "is-check-askew": {
// "cat": "none",
// "group": "feeder",
// "title": "歪斜检测",
// "desc": "检测进纸是否歪斜",
// "type": "bool",
// "fix-id": 34868,
// "ui-pos": 22,
// "auth": 0,
// "size": 4,
// "cur": true,
// "default": true
// },
// "askew-range": {
// "cat": "none",
// "group": "feeder",
// "title": "歪斜容忍度",
// "desc": "值越小,能容忍得送入文稿歪斜角度越小",
// "type": "int",
// "fix-id": 34869,
// "ui-pos": 23,
// "auth": 0,
// "size": 4,
// "cur": 3,
// "default": 3,
// "range": {
// "min": 1,
// "max": 7,
// "step": 1
// },
// "depend": "is-check-askew==true"
// },
// "cis-len": {
// "cat": "base",
// "group": "关于",
// "title": "镜头长",
// "desc": "图像采集镜头的长度单位为毫米mm",
// "type": "int",
// "ui-pos": 30,
// "auth": 0,
// "unit": "mm",
// "readonly": true,
// "size": 4,
// "auto": false,
// "cur": 3888,
// "default": 3888
// },
// "motor-ver": {
// "cat": "none",
// "group": "关于",
// "title": "电机驱动版本",
// "desc": "电机板驱动程序版本号",
// "type": "string",
// "fix-id": 34909,
// "ui-pos": 16,
// "auth": 0,
// "readonly": true,
// "size": 24,
// "auto": false,
// "cur": "",
// "default": ""
// },
// "fpga-ver": {
// "cat": "none",
// "group": "关于",
// "title": "CIS控制器版本",
// "desc": "镜头参数控制驱动程序版本号",
// "type": "string",
// "ui-pos": 17,
// "auth": 0,
// "readonly": true,
// "size": 24,
// "auto": false,
// "cur": "",
// "default": ""
// }
// }

View File

@ -41,18 +41,23 @@ typedef struct SMB_CONFIG
unsigned int color_mode : 1; unsigned int color_mode : 1;
unsigned int paper : 1; unsigned int paper : 1;
unsigned int double_paper : 1; unsigned int double_paper : 1;
unsigned int staple_enable : 1;//5 unsigned int staple_enable : 1;//5
unsigned int error_clean : 1; unsigned int error_clean : 1;
unsigned int status_init : 1; unsigned int status_init : 1;
unsigned int pick_paper : 1; unsigned int pick_paper : 1;
unsigned int skew_enable : 1; unsigned int skew_enable : 1;
unsigned int skew_parameter : 3; unsigned int skew_parameter : 3;
unsigned int key_staple_enable : 1;//8 unsigned int key_staple_enable : 1;//8
unsigned int iic_config_addr : 7; unsigned int iic_config_addr : 7;
unsigned int slow_moire : 1; unsigned int slow_moire : 1;
unsigned int v_setting : 2;//10 unsigned int v_setting : 2;//10
unsigned int speed_set_enable : 1; unsigned int speed_set_enable : 1;
unsigned int double_out_en : 1; unsigned int double_out_en : 1;
unsigned int dpi_mode : 2; unsigned int dpi_mode : 2;
// unsigned int sleep_parameter : 2;//6 // unsigned int sleep_parameter : 2;//6
// unsigned int dpi600:1; // unsigned int dpi600:1;

View File

@ -457,11 +457,11 @@ dyn_mem_ptr async_scanner::handle_scan_start(LPPACK_BASE pack, uint32_t* used, p
FILE* dst = fopen(("/tmp/scan_" + std::to_string(lpinfo->pos.paper_ind) + ".bmp").c_str(), "wb"); FILE* dst = fopen(("/tmp/scan_" + std::to_string(lpinfo->pos.paper_ind) + ".bmp").c_str(), "wb");
if(dst) if(dst)
{ {
std::string bih(utils::bitmap_info_header(lpinfo->width, lpinfo->height, lpinfo->bpp * lpinfo->channels, lpinfo->resolution_x, lpinfo->resolution_y)), std::string bih(utils::bitmap_info_header(lpinfo->width, lpinfo->height, lpinfo->bpp, lpinfo->resolution_x, lpinfo->resolution_y)),
bfh(utils::bitmap_file_header((BITMAPINFOHEADER*)&bih[0])); bfh(utils::bitmap_file_header((BITMAPINFOHEADER*)&bih[0]));
fwrite(bfh.c_str(), 1, bfh.length(), dst); fwrite(bfh.c_str(), 1, bfh.length(), dst);
fwrite(bih.c_str(), 1, bih.length(), dst); fwrite(bih.c_str(), 1, bih.length(), dst);
fwrite(data->ptr(), 1, data->get_rest(), dst); fwrite(data->ptr(), 1, ((BITMAPINFOHEADER*)&bih[0])->biSizeImage, dst);
fclose(dst); fclose(dst);
} }
data->release(); data->release();

View File

@ -26,143 +26,3 @@ public:
virtual char* get_value(const char* name, void* value, size_t* size, int* err = nullptr) override; virtual char* get_value(const char* name, void* value, size_t* size, int* err = nullptr) override;
}; };
// {
// "dev-vid": {
// "cat": "base",
// "group": "关于",
// "title": "USB-VID",
// "desc": "设备制造商在USB组织的ID",
// "type": "string",
// "fix-id": 34898,
// "ui-pos": 10,
// "auth": 0,
// "readonly": true,
// "size": 16,
// "auto": false,
// "cur": "3072",
// "default": "3072"
// },
// "dev-pid": {
// "cat": "base",
// "group": "关于",
// "title": "USB-PID",
// "desc": "设备在USB组织中的产品ID",
// "type": "string",
// "fix-id": 34899,
// "ui-pos": 11,
// "auth": 0,
// "readonly": true,
// "size": 16,
// "auto": false,
// "cur": "0306",
// "default": "0306"
// },
// "dev-name": {
// "cat": "base",
// "group": "关于",
// "title": "设备名称",
// "desc": "设备名称",
// "type": "string",
// "fix-id": 34900,
// "ui-pos": 12,
// "auth": 0,
// "readonly": true,
// "size": 96,
// "auto": false,
// "cur": "300NewTx",
// "default": "300NewTx"
// },
// "dev-model": {
// "cat": "base",
// "group": "关于",
// "title": "产品系列",
// "desc": "设备所属产品系列名称",
// "type": "string",
// "fix-id": 34901,
// "ui-pos": 13,
// "auth": 0,
// "readonly": true,
// "size": 96,
// "auto": false,
// "cur": "G200",
// "default": "G200"
// },
// "dev-sn": {
// "cat": "base",
// "group": "关于",
// "title": "序列号",
// "desc": "设备序列号",
// "type": "string",
// "fix-id": 34902,
// "ui-pos": 14,
// "auth": 0,
// "readonly": true,
// "size": 32,
// "auto": false,
// "ownread": true,
// "cur": "GB20231201",
// "default": "GB20231201"
// },
// "fmw-ver": {
// "cat": "base",
// "group": "关于",
// "title": "固件版本",
// "desc": "设备固件版本号",
// "type": "string",
// "fix-id": 34903,
// "ui-pos": 15,
// "auth": 0,
// "readonly": true,
// "size": 32,
// "auto": false,
// "cur": "G2393B0500",
// "default": "G2393B0500"
// },
// "roller-life": {
// "cat": "base",
// "group": "关于",
// "title": "滚轴寿命",
// "desc": "该设备滚轴过纸的最大张数",
// "type": "int",
// "fix-id": 34907,
// "ui-pos": 20,
// "auth": 0,
// "readonly": true,
// "size": 4,
// "auto": false,
// "cur": 450000,
// "default": 450000
// },
// "ip-addr": {
// "cat": "base",
// "group": "关于",
// "title": "IP",
// "desc": "设备联网时所分配的IP地址",
// "type": "string",
// "fix-id": 34904,
// "ui-pos": 21,
// "auth": 0,
// "readonly": true,
// "size": 96,
// "auto": false,
// "ownread": true,
// "cur": "0",
// "default": "0"
// },
// "mac-addr": {
// "cat": "base",
// "group": "关于",
// "title": "MAC",
// "desc": "设备网卡地址",
// "type": "string",
// "fix-id": 34905,
// "ui-pos": 22,
// "auth": 0,
// "readonly": true,
// "size": 96,
// "auto": false,
// "ownread": true,
// "cur": "0",
// "default": "0"
// }
// }

View File

@ -1278,12 +1278,12 @@ namespace utils
{ {
int pal[] = { 0, 0x0ffffff }; int pal[] = { 0, 0x0ffffff };
stream += std::string((char*)pal, sizeof(pal)); stream += std::string((char*)pal, sizeof(pal));
bih.biClrUsed = _countof(pal); ((BITMAPINFOHEADER*)&stream[0])->biClrUsed = _countof(pal);
} }
else if(bpp == 8) else if(bpp == 8)
{ {
stream += std::string((char*)global_info::gray_pallete, sizeof(global_info::gray_pallete)); stream += std::string((char*)global_info::gray_pallete, sizeof(global_info::gray_pallete));
bih.biClrUsed = _countof(global_info::gray_pallete); ((BITMAPINFOHEADER*)&stream[0])->biClrUsed = _countof(global_info::gray_pallete);
} }
return std::move(stream); return std::move(stream);

View File

@ -960,3 +960,36 @@ bool gb_json::operator!=(const gb_json& r)
{ {
return !(*this == r); return !(*this == r);
} }
bool gb_json::revise_number_type(bool dbval)
{
bool chg = false;
if (dbval)
{
// int -> double
if (type_ == VAL_TYPE_INT)
{
type_ = VAL_TYPE_FLOAT;
simple_val_.dval = simple_val_.nval;
chg = true;
}
else
chg = type_ == VAL_TYPE_FLOAT;
}
else
{
// double -> int
if (type_ == VAL_TYPE_FLOAT)
{
type_ = VAL_TYPE_INT;
simple_val_.nval = simple_val_.dval + .5f;
chg = true;
}
else
chg = type_ == VAL_TYPE_INT;
}
return chg;
}

View File

@ -115,6 +115,11 @@ public:
bool operator==(const gb_json& r); bool operator==(const gb_json& r);
bool operator!=(const gb_json& r); bool operator!=(const gb_json& r);
// [2024-01-13] double value maybe consider as integer if the number just an integer, this method is to set numbre to right type
// dbval - true: make integer to double and simple_val_.dval = simple_val_.nval;
// false: make double to integer and simple_val_.nval = simple_val_.dval
bool revise_number_type(bool dbval);
}; };
#ifdef DUMP_JSON_OBJECT_LIFE #ifdef DUMP_JSON_OBJECT_LIFE

View File

@ -248,6 +248,7 @@ enum opt_visible_level // "visible" field
#define SANE_STD_OPT_NAME_CIS_DELAY "act-after" #define SANE_STD_OPT_NAME_CIS_DELAY "act-after"
#define SANE_STD_OPT_NAME_CIS_FRAME_H "frame-h" #define SANE_STD_OPT_NAME_CIS_FRAME_H "frame-h"
#define SANE_STD_OPT_NAME_CIS_SAMPLE "sample" #define SANE_STD_OPT_NAME_CIS_SAMPLE "sample"
#define SANE_STD_OPT_NAME_CIS_SP "cis-sp"
#define SANE_STD_OPT_NAME_CIS_EXPO_FB "expo-fb" #define SANE_STD_OPT_NAME_CIS_EXPO_FB "expo-fb"
#define SANE_STD_OPT_NAME_CIS_EXPO_FG "expo-fg" #define SANE_STD_OPT_NAME_CIS_EXPO_FG "expo-fg"
#define SANE_STD_OPT_NAME_CIS_EXPO_FR "expo-fr" #define SANE_STD_OPT_NAME_CIS_EXPO_FR "expo-fr"
@ -258,6 +259,8 @@ enum opt_visible_level // "visible" field
#define SANE_STD_OPT_NAME_CIS_GAIN_BACK "gain-b" #define SANE_STD_OPT_NAME_CIS_GAIN_BACK "gain-b"
#define SANE_STD_OPT_NAME_CIS_OFFSET_FRONT "off-f" #define SANE_STD_OPT_NAME_CIS_OFFSET_FRONT "off-f"
#define SANE_STD_OPT_NAME_CIS_OFFSET_BACK "off-b" #define SANE_STD_OPT_NAME_CIS_OFFSET_BACK "off-b"
#define SANE_STD_OPT_NAME_CIS_STRETCH_H "stretch-h"
#define SANE_STD_OPT_NAME_CIS_STRETCH_V "stretch-v"
#define SANE_STD_OPT_NAME_MOTOR_SPEED "motor-speed" #define SANE_STD_OPT_NAME_MOTOR_SPEED "motor-speed"
// //
// 借鉴TWAIN协议固定ID的做法定义SANE属性的固定ID - 这里与TWAIN中的ID保持一致以方便TWAIN的调用 // 借鉴TWAIN协议固定ID的做法定义SANE属性的固定ID - 这里与TWAIN中的ID保持一致以方便TWAIN的调用

View File

@ -1239,6 +1239,12 @@ bool device_option::arrange_raw_json(sane_opt_provider* sop)
child->get_value("type", str); child->get_value("type", str);
if (str != JSON_SANE_TYPE_GROUP) // omit group if (str != JSON_SANE_TYPE_GROUP) // omit group
{ {
if (str == JSON_SANE_TYPE_FIXED)
{
// revise cur and default
device_option::revise_number_type(child, true);
}
if(no_grp_) if(no_grp_)
{ {
insert_option(child, sop); insert_option(child, sop);
@ -1329,7 +1335,7 @@ void device_option::init_depends(gb_json* opt)
delete v; delete v;
} }
} }
gb_json* device_option::copy_opt(gb_json* from) gb_json* device_option::copy_opt(gb_json* from, bool* changed_cur)
{ {
std::string text(from->to_string()); std::string text(from->to_string());
gb_json* to = new gb_json(); gb_json* to = new gb_json();
@ -1377,16 +1383,55 @@ gb_json* device_option::copy_opt(gb_json* from)
{ {
std::string val(init_value_[to->key()]->value(&device_option::calc_simple_logic_expression, this)); std::string val(init_value_[to->key()]->value(&device_option::calc_simple_logic_expression, this));
std::string type(""); std::string type("");
bool apply_cur = false, rdo = false;
// should we change current value ??? - answer: add boolean field "bind" to specify
if (!from->get_value("bind", apply_cur))
apply_cur = false;
if (!from->get_value("readonly", rdo))
rdo = false;
to->get_value("type", type); to->get_value("type", type);
if (changed_cur)
*changed_cur = apply_cur;
if (type == JSON_SANE_TYPE_BOOL) if (type == JSON_SANE_TYPE_BOOL)
{
to->set_value("default", *(bool*)val.c_str()); to->set_value("default", *(bool*)val.c_str());
else if(type == JSON_SANE_TYPE_INT) if (apply_cur)
{
to->set_value("cur", *(bool*)val.c_str());
update_provider_value(to->key().c_str(), &val[0], rdo);
}
}
else if (type == JSON_SANE_TYPE_INT)
{
to->set_value("default", *(int*)val.c_str()); to->set_value("default", *(int*)val.c_str());
else if(type == JSON_SANE_TYPE_FIXED) if (apply_cur)
{
to->set_value("cur", *(int*)val.c_str());
update_provider_value(to->key().c_str(), &val[0], rdo);
}
}
else if (type == JSON_SANE_TYPE_FIXED)
{
to->set_value("default", *(double*)val.c_str()); to->set_value("default", *(double*)val.c_str());
else if(type == JSON_SANE_TYPE_STRING) if (apply_cur)
to->set_value("default", (const wchar_t*)val.c_str()); {
to->set_value("cur", *(double*)val.c_str());
update_provider_value(to->key().c_str(), &val[0], rdo);
}
}
else if (type == JSON_SANE_TYPE_STRING)
{
to->set_value("default", val.c_str());
if (apply_cur)
{
to->set_value("cur", val.c_str());
update_provider_value(to->key().c_str(), &val[0], rdo);
}
}
else if (changed_cur)
*changed_cur = false;
} }
// 4: range value ... // 4: range value ...
@ -1526,6 +1571,7 @@ bool device_option::to_now(bool init, bool* changed)
while (from) while (from)
{ {
std::string name(from->key()); std::string name(from->key());
bool cur_chged = false;
if (init) if (init)
init_depends(from); init_depends(from);
@ -1543,12 +1589,12 @@ bool device_option::to_now(bool init, bool* changed)
} }
} }
to = copy_opt(from); to = copy_opt(from, &cur_chged);
from->release(); from->release();
if (to) if (to)
{ {
// copy cur value ... // copy cur value ...
if (now_) if (now_ && !cur_chged)
{ {
gb_json* now = nullptr; gb_json* now = nullptr;
now_->get_value(to->key().c_str(), now); now_->get_value(to->key().c_str(), now);
@ -1626,6 +1672,32 @@ bool device_option::to_now(bool init, bool* changed)
return now_ != nullptr; return now_ != nullptr;
} }
void device_option::update_provider_value(const char* name, void* value, bool skip_first)
{
if (src_.count(name))
{
sane_opt_provider* opt = nullptr;
if (skip_first)
{
opt = src_[name]->get_following(name);
}
else
{
opt = src_[name];
opt->add_ref();
}
while (opt)
{
opt->set_value(name, value);
sane_opt_provider* next = opt->get_following(name);
opt->release();
opt = next;
}
}
}
std::string device_option::option_value(gb_json* jsn, bool def_val) std::string device_option::option_value(gb_json* jsn, bool def_val)
{ {
@ -1658,6 +1730,54 @@ std::string device_option::option_value(gb_json* jsn, bool def_val)
return std::move(type); return std::move(type);
} }
void device_option::revise_number_type(gb_json* opt, bool to_double)
{
gb_json* child = nullptr;
opt->get_value("cur", child);
if (child)
{
if (child->is_leaf_node())
child->revise_number_type(to_double);
//else
// no object now, fixed me if be object
child->release();
}
opt->get_value("default", child);
if (child)
{
if (child->is_leaf_node())
child->revise_number_type(to_double);
else
{
gb_json* v = child->first_child();
while (v)
{
if (v->is_leaf_node())
v->revise_number_type(to_double);
v->release();
v = child->next_child();
}
}
child->release();
}
opt->get_value("range", child);
if (child)
{
gb_json* v = child->first_child();
while (v)
{
if (v->is_leaf_node())
v->revise_number_type(to_double);
v->release();
v = child->next_child();
}
child->release();
}
}
std::string device_option::trans_group(const char* utf8, bool to_title) std::string device_option::trans_group(const char* utf8, bool to_title)
{ {
@ -1787,18 +1907,7 @@ int device_option::update_data(const char* name, void* value, bool reorder_if_ne
err = SCANNER_ERR_ACCESS_DENIED; err = SCANNER_ERR_ACCESS_DENIED;
// following ... // following ...
if (src_.count(name)) update_provider_value(name, value, true);
{
sane_opt_provider* opt = src_[name]->get_following(name);
while(opt)
{
opt->set_value(name, value);
sane_opt_provider* next = opt->get_following(name);
opt->release();
opt = next;
}
}
} }
else else
{ {
@ -1807,22 +1916,7 @@ int device_option::update_data(const char* name, void* value, bool reorder_if_ne
// pass to sane_opt_provider ... // pass to sane_opt_provider ...
err = SCANNER_ERR_OK; err = SCANNER_ERR_OK;
if (src_.count(name)) update_provider_value(name, value);
{
sane_opt_provider* opt = src_[name];
opt->add_ref();
while (opt)
{
int r = opt->set_value(name, value);
if (r)
err = r;
sane_opt_provider* next = opt->get_following(name);
opt->release();
opt = next;
}
}
child->get_value("type", type); child->get_value("type", type);
utils::to_log(LOG_LEVEL_DEBUG, "set option '%s' value to '%s' = %d.\n", name, sane_opt_provider::sane_value_2_text(type.c_str(), value).c_str(), err); utils::to_log(LOG_LEVEL_DEBUG, "set option '%s' value to '%s' = %d.\n", name, sane_opt_provider::sane_value_2_text(type.c_str(), value).c_str(), err);

View File

@ -181,12 +181,14 @@ class device_option : public refer
void insert_option(gb_json* opt, sane_opt_provider* from, const char* group = nullptr); void insert_option(gb_json* opt, sane_opt_provider* from, const char* group = nullptr);
bool arrange_raw_json(sane_opt_provider* sop); // create origin_ and re-arrange groups bool arrange_raw_json(sane_opt_provider* sop); // create origin_ and re-arrange groups
void init_depends(gb_json* opt); void init_depends(gb_json* opt);
gb_json* copy_opt(gb_json* from); gb_json* copy_opt(gb_json* from, bool *changed_cur = nullptr);
int visibility(gb_json* jsn); int visibility(gb_json* jsn);
bool to_now(bool init, bool* changed); bool to_now(bool init, bool* changed);
void update_provider_value(const char* name, void* value, bool skip_first = false/*readonly value should skip first*/);
protected: protected:
static std::string option_value(gb_json* jsn, bool def_val); static std::string option_value(gb_json* jsn, bool def_val);
static void revise_number_type(gb_json* opt, bool to_double);
template<class T> template<class T>
static condition_value* to_condition_value(gb_json* jsn, const char* key, const char* type, device_option* parent) static condition_value* to_condition_value(gb_json* jsn, const char* key, const char* type, device_option* parent)

View File

@ -50,72 +50,3 @@ public:
int get_current_user_login_times(void); int get_current_user_login_times(void);
}; };
// {
// "user-name": {
// "cat": "none",
// "group": "用户",
// "title": "用户名",
// "desc": "登录用户账号",
// "type": "string",
// "fix-id": 39173,
// "ui-pos": 10,
// "auth": 0,
// "size": 32,
// "cur": "",
// "default": ""
// },
// "user-pwd": {
// "cat": "none",
// "group": "用户",
// "title": "密码",
// "desc": "登录用户账号密码",
// "type": "string",
// "fix-id": 39174,
// "ui-pos": 11,
// "auth": 0,
// "size": 32,
// "cur": "",
// "default": ""
// },
// "login": {
// "cat": "none",
// "group": "用户",
// "title": "登录",
// "desc": "用户登录",
// "type": "button",
// "fix-id": 39168,
// "ui-pos": 20,
// "auth": 0,
// "affect": 6,
// "size": 4,
// "auto": false
// },
// "logout": {
// "cat": "none",
// "group": "用户",
// "title": "注销",
// "desc": "用户登出",
// "type": "button",
// "fix-id": 39169,
// "ui-pos": 21,
// "auth": 0,
// "affect": 6,
// "size": 4,
// "auto": false
// },
// "dev-sn": {
// "cat": "base",
// "group": "关于",
// "title": "序列号",
// "desc": "设备序列号",
// "type": "string",
// "fix-id": 34902,
// "ui-pos": 14,
// "pos": 100,
// "auth": 0,
// "size": 32,
// "auto": false,
// "cur": "",
// "default": ""
// }
// }

View File

@ -59,9 +59,9 @@ add_packagedirs("sdk")
add_defines("BUILD_AS_DEVICE") add_defines("BUILD_AS_DEVICE")
add_defines("VER_MAIN=2") add_defines("VER_MAIN=2")
add_defines("VER_FAMILY=300") add_defines("VER_FAMILY=200")
add_defines("VER_DATE=20240111") add_defines("VER_DATE=20240113")
add_defines("VER_BUILD=15") add_defines("VER_BUILD=4")
target("conf") target("conf")
set_kind("phony") set_kind("phony")