Added option "source" which can be used to simulate an Automatic Document Feeder

(ADF). Added copyright header to test.h.
merge-requests/1/head
Henning Geinitz 2006-01-02 22:55:44 +00:00
rodzic 78f4ed984b
commit 7b03fc2168
6 zmienionych plików z 108 dodań i 7 usunięć

Wyświetl plik

@ -12,6 +12,10 @@
warmup message 5 seconds after starting the warm-up.
* doc/descriptions/unsupported.desc: Added Visioneer 9450
USB. Updated comments for Plustek S(T)12.
* backend/test.c backend/test.conf backend/test.h
doc/sane-test.man doc/descriptions/test.desc:
Added option "source" which can be used to simulate an Automatic
Document Feeder (ADF). Added copyright header to test.h.
2006-01-01 Oliver Schwartz <Oliver.Schwartz@gmx.de>

Wyświetl plik

@ -1,7 +1,9 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 2002, 2003 Henning Meier-Geinitz <henning@meier-geinitz.de>
Copyright (C) 2002-2006 Henning Meier-Geinitz <henning@meier-geinitz.de>
Changes according to the sanei_thread usage by
Gerhard Jaeger <gerhard@gjaeger.de>
This file is part of the SANE package.
This program is free software; you can redistribute it and/or
@ -43,7 +45,7 @@
This backend is for testing frontends.
*/
#define BUILD 27
#define BUILD 28
#include "../include/sane/config.h"
@ -183,6 +185,11 @@ static SANE_Int int_array_constraint_word_list[] = {
-42, 0, -8, 17, 42, 42
};
static SANE_String_Const source_list[] = {
SANE_I18N ("Flatbed"), SANE_I18N ("Automatic Document Feeder"),
0
};
static double random_factor; /* use for fuzzyness of parameters */
/* initial values */
@ -197,6 +204,7 @@ static SANE_Word init_depth = 8;
static SANE_Bool init_hand_scanner = SANE_FALSE;
static SANE_Bool init_three_pass = SANE_FALSE;
static SANE_String init_three_pass_order = "RGB";
static SANE_String init_scan_source = "Flatbed";
static SANE_String init_test_picture = "Solid black";
static SANE_Bool init_invert_endianess = SANE_FALSE;
static SANE_Bool init_read_limit = SANE_FALSE;
@ -396,6 +404,22 @@ init_options (Test_Device * test_device)
od->constraint.range = &resolution_range;
test_device->val[opt_resolution].w = init_resolution;
/* opt_scan_source */
od = &test_device->opt[opt_scan_source];
od->name = SANE_NAME_SCAN_SOURCE;
od->title = SANE_TITLE_SCAN_SOURCE;
od->desc = SANE_I18N("If Automatic Document Feeder is selected, the feeder will be 'empty' after 10 scans.");
od->type = SANE_TYPE_STRING;
od->unit = SANE_UNIT_NONE;
od->size = max_string_size (source_list);
od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
od->constraint_type = SANE_CONSTRAINT_STRING_LIST;
od->constraint.string_list = source_list;
test_device->val[opt_scan_source].s = malloc (od->size);
if (!test_device->val[opt_scan_source].s)
return SANE_STATUS_NO_MEM;
strcpy (test_device->val[opt_scan_source].s, init_scan_source);
/* opt_special_group */
od = &test_device->opt[opt_special_group];
od->name = "";
@ -1420,7 +1444,7 @@ print_options (Test_Device * test_device)
SANE_Status
sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize)
sane_init (SANE_Int * __sane_unused__ version_code, SANE_Auth_Callback __sane_unused__ authorize)
{
FILE *fp;
SANE_Int linenumber;
@ -1436,8 +1460,6 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize)
test_device = 0;
previous_device = 0;
DBG (2, "sane_init: version_code= %p, authorize=%p\n",
(void *) version_code, (void *) authorize);
DBG (1, "sane_init: SANE test backend version %d.%d.%d from %s\n", V_MAJOR,
V_MINOR, BUILD, PACKAGE_STRING);
@ -1508,6 +1530,9 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize)
if (read_option (line, "depth", param_int,
&init_depth) == SANE_STATUS_GOOD)
continue;
if (read_option (line, "scan-source", param_string,
&init_scan_source) == SANE_STATUS_GOOD)
continue;
if (read_option (line, "test-picture", param_string,
&init_test_picture) == SANE_STATUS_GOOD)
continue;
@ -1733,6 +1758,7 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle)
test_device->eof = SANE_FALSE;
test_device->bytes_total = 0;
test_device->pass = 0;
test_device->number_of_scans = 0;
return SANE_STATUS_GOOD;
}
@ -2016,6 +2042,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action,
case opt_string:
case opt_string_constraint_string_list:
case opt_string_constraint_long_string_list:
case opt_scan_source:
if (strcmp (test_device->val[option].s, value) == 0)
{
DBG (4, "sane_control_option: option %d (%s) not changed\n",
@ -2237,6 +2264,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action,
case opt_string:
case opt_string_constraint_string_list:
case opt_string_constraint_long_string_list:
case opt_scan_source:
strcpy (value, test_device->val[option].s);
DBG (4, "sane_control_option: get option %d (%s), value=`%s'\n",
option, test_device->opt[option].name, (SANE_String) value);
@ -2463,6 +2491,19 @@ sane_start (SANE_Handle handle)
return SANE_STATUS_INVAL;
}
if (test_device->pass == 0)
{
test_device->number_of_scans++;
DBG (3, "sane_start: scanning page %d\n", test_device->number_of_scans);
if ((strcmp (test_device->val[opt_scan_source].s, "Automatic Document Feeder") == 0) &&
(((test_device->number_of_scans) % 11) == 0))
{
DBG (1, "sane_start: Document feeder is out of documents!\n");
return SANE_STATUS_NO_DOCS;
}
}
test_device->scanning = SANE_TRUE;
test_device->cancelled = SANE_FALSE;
test_device->eof = SANE_FALSE;

Wyświetl plik

@ -28,6 +28,9 @@ resolution_max 1200.0
resolution_quant 1.0
resolution 50.0
# Scan source (Flatbed, Automatic Document Feeder)
scan-source Flatbed
# Draw test picture ("Solid black", "Solid white", "Color pattern", "Grid")
test-picture "Solid black"

Wyświetl plik

@ -1,3 +1,48 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 2002-2006 Henning Meier-Geinitz <henning@meier-geinitz.de>
This file is part of the SANE package.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
As a special exception, the authors of SANE give permission for
additional uses of the libraries contained in this release of SANE.
The exception is that, if you link a SANE library with other files
to produce an executable, this does not by itself cause the
resulting executable to be covered by the GNU General Public
License. Your use of that executable is in no way restricted on
account of linking the SANE library code into it.
This exception does not, however, invalidate any other reasons why
the executable file might be covered by the GNU General Public
License.
If you submit changes to SANE to the maintainers to be included in
a subsequent release, you agree by submitting the changes that
those changes may be distributed with this exception intact.
If you write modifications of your own for SANE, it is your choice
whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice.
This backend is for testing frontends.
*/
#ifndef test_h
#define test_h
@ -23,6 +68,7 @@ typedef enum
opt_three_pass, /* 5 */
opt_three_pass_order,
opt_resolution,
opt_scan_source,
opt_special_group,
opt_test_picture,
opt_invert_endianess,
@ -93,6 +139,7 @@ typedef struct Test_Device
SANE_Bool scanning;
SANE_Bool cancelled;
SANE_Bool eof;
SANE_Int number_of_scans;
}
Test_Device;

Wyświetl plik

@ -10,7 +10,7 @@
;
:backend "test" ; name of backend
:version "1.0-26" ; version of backend
:version "1.0-28" ; version of backend
:manpage "sane-test" ; name of manpage (if it exists)
:url "http://www.meier-geinitz.de/sane/test-backend/" ; backend's web page

Wyświetl plik

@ -1,4 +1,4 @@
.TH sane-test 5 "24 Jul 2002" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy"
.TH sane-test 5 "2 Jan 2006" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy"
.IX sane-test
.SH NAME
sane-test \- SANE backend for testing frontends
@ -58,6 +58,12 @@ Option
.B resolution
sets the resolution of the image in dots per inch.
.PP
.PP
Option
.B source
can be used to simulate an Automatic Document Feeder (ADF). After 10 scans, the
ADF will be "empty".
.PP
.SH SPECIAL OPTIONS
Option