Device.pm

filter: Statementstmt 15.1% 20 / 132 Branchbran 2.5% 2 / 78 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 20.0% 4 / 20 Podpod 87.5% 7 / 8 totaltotal 13.5% 33 / 243 CC 39 SCAR 36.5
CC
39
Cov
10%
_setPageSource
132.0
new
30.0
shutdown
30.0
CRAP 38.7
↑ Summary Job.pm »
1 #================================ Device.pm ===================================
2 # Filename: Device.pm
3 # Description: Physical Page Class for Scanners.
4 # Original Author: Dale M. Amon
5 # Revised by: $Author: amon $
6 # Date: $Date: 2008-08-28 23:31:43 $
7 # Version: $Revision: 1.2 $
8 # License: LGPL 2.1, Perl Artistic or BSD
9 #
10 #==============================================================================
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Fault::DebugPrinter;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 package Scanner::Device;
16 1 ▶use vars qw{@ISA};
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 @ISA = qw( UNIVERSAL );
18  
19 #==============================================================================
20 # Class Methods
21 #==============================================================================
22 1 $Scanner::DEFAULT_SCANNER = "umax";
23  
24 0 ▶sub defaultScannerIs ($$) {
Subroutine defaultScannerIs: not called CC=4 SCAR=30.0
Pod documented
25 0 my ($class, $scanner) = @_;
26 0 ▶ defined $scanner || return 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $scanner or return 0 0 0 0
27 0 ▶ if (Scanner::Device->_validateScanner ($scanner)) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Scanner::Device"->_validateScanner($scanner)) 0 0 0
28 0 $Scanner::DEFAULT_SCANNER = lc $scanner;
29
30 # Apply a kludge for the hp5590. It cannot deal with 150dpi.
31 0 my ($type) = (split ":", $scanner);
32 0 ▶ if ($type eq "hp5590") {Scanner::Device->defaultDpiIs (200);}
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "hp5590") 0 0 0
33 0 return 1;
34 }
35 0 return 0;
36 }
37  
38 #------------------------------------------------------------------------------
39 1 $Scanner::DEFAULT_DPI = 150;
40  
41 0 ▶sub defaultDpiIs ($$) {
Subroutine defaultDpiIs: not called CC=3 SCAR=24.8
Pod documented
42 0 my ($class, $dpi) = @_;
43 0 ▶ defined $dpi || return 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $dpi or return 0 0 0 0
44 0 ▶ if (Scanner::Device->_validateDpi ($dpi)) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Scanner::Device"->_validateDpi($dpi)) 0 0 0
45 0 $Scanner::DEFAULT_DPI = $dpi; return 1;
46 }
47 0 return 0;
48 }
49  
50 #------------------------------------------------------------------------------
51 1 $Scanner::DEFAULT_PAGESOURCE = "flatbed";
52  
53 0 ▶sub defaultPageSourceIs ($$) {
Subroutine defaultPageSourceIs: not called CC=3 SCAR=24.8
Pod documented
54 0 my ($class, $pgsrc) = @_;
55 0 ▶ defined $pgsrc || return 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $pgsrc or return 0 0 0 0
56 0 ▶ if (Scanner::Device->_validatePageSource ($pgsrc)) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Scanner::Device"->_validatePageSource($pgsrc)) 0 0 0
57 0 $Scanner::DEFAULT_PAGESOURCE = lc $pgsrc;
58 0 return 1;
59 }
60 0 return 0;
61 }
62  
63 #------------------------------------------------------------------------------
64 1 $Scanner::DEFAULT_SHUTDOWN = 0;
65  
66 0 ▶sub defaultShutdownIs ($$) {
Subroutine defaultShutdownIs: not called CC=2 SCAR=17.9
Pod documented
67 0 my ($class, $shutdown) = @_;
68 0 ▶ $shutdown=0 if !defined ($shutdown);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $shutdown 0 0 0
69 0 $Scanner::DEFAULT_DPI = $shutdown;
70 0 return 1;
71 }
72  
73 #------------------------------------------------------------------------------
74 # If there are Environment variables defined for $SCANNER or
75 # $SCANNER_AUTO_SHUTDOWN, use them. This must be done after all the above set
76 # up so this code will override the defaults.
77  
78 1 ▶if (defined $ENV{'SCANNER'})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"SCANNER"}) 0 1 1
79 0 {Scanner::Device->defaultScannerIs ($ENV{'SCANNER'});}
80  
81 1 ▶if (defined $ENV{'SCANNER_AUTO_SHUTDOWN'})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"SCANNER_AUTO_SHUTDOWN"}) 0 1 1
82 0 {Scanner::Device->defaultShutdownIs ($ENV{'SCANNER_AUTO_SHUTDOWN'});}
83  
84 #==============================================================================
85  
86 0 ▶sub new ($$) {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
87 0 my $class = shift;
88 0 my %params = @_;
89 0 my $self = bless {}, $class;
90
91 # Order dependance: scanner type must be set before pagesource and dpi as
92 # the allowable values may be scanner dependant.
93 #
94 0 ▶ $self->_setScanner (\%params) || return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->_setScanner(\%params) or return undef 0 0 0
95 0 ▶ $self->_setPageSource (\%params) || return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->_setPageSource(\%params) or return undef 0 0 0
96 0 ▶ $self->_setDpi (\%params) || return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->_setDpi(\%params) or return undef 0 0 0
97
98 0 ▶ $self->_initScanner (\%params) || return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->_initScanner(\%params) or return undef 0 0 0
99 0 return $self;
100 }
101  
102 #==============================================================================
103 # Object Methods
104 #==============================================================================
105  
106 0 ▶sub scan ($$$) {
Subroutine scan: not called CC=3 SCAR=24.8
Pod documented
107 0 my ($self,$page,$dpath) = @_;
108
109 0 my ($x,$y) = $page->ScanDimensions;
110 0 my $pagetitle = $page->pagetitle;
111 0 my ($dpi,$dev,$pgsrc,$extra) = @$self{'dpi','scanner','pagesource','extra'};
112 0 ▶ my $SourceArg = ($pgsrc eq "NotApplicable") ?
Branch: 1 branch
BranchTrueFalseTotal
$pgsrc eq 'NotApplicable' ? : 0 0 0
113 "" : "--source $pgsrc ";
114 0 my $tmpfile = File::Spec->catfile ($dpath,"tmp.pnm");
115 0 my $dstfile = File::Spec->catfile ($dpath,"$pagetitle.jpeg");
116
117 0 Fault::DebugPrinter->dbg1
118 ("scanimage --device-name=\"$dev\" --mode Color --resolution $dpi -x $x -y $y $SourceArg $extra > \"$tmpfile\" 2> /dev/null");
119
120 0 system "scanimage --device-name=\"$dev\" --mode Color --resolution $dpi -x $x -y $y $SourceArg $extra > \"$tmpfile\" 2> /dev/null";
121
122 0 ▶ if ($page->landscape) {
Branch: 1 branch
BranchTrueFalseTotal
if ($page->landscape) { } 0 0 0
123 0 system "convert -rotate -90 \"$tmpfile\" \"$dstfile\"";}
124 else {
125 0 system "convert \"$tmpfile\" \"$dstfile\"";}
126
127 0 unlink "$tmpfile";
128 0 return 1;
129 }
130  
131 #------------------------------------------------------------------------------
132  
133 0 ▶sub shutdown ($) {
Subroutine shutdown: not called CC=5 SCAR=34.0
Pod documented
134 0 my $self = shift;
135 0 ▶ if ($self->{'type'} eq "hp") { }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "hp") 0 0 0
136 0 ▶ if ($self->{'type'} eq "umax") { }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "umax") 0 0 0
137 0 ▶ if ($self->{'type'} eq "hp5590") { }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "hp5590") 0 0 0
138
139 # This is the only way I can turn off the lamp after we are done.
140 0 ▶ if ($self->{'type'} eq "gt68xx") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "gt68xx") 0 0 0
141 system ("scanimage -d \"" .
142 0 $self->{'scanner'} .
143 "\" --lamp-off-at-exit=yes --dont-scan 2> /dev/null") ;
144 }
145 0 return 1;
146 }
147  
148 #------------------------------------------------------------------------------
149  
150 0 ▶sub DESTROY ($) {
Subroutine DESTROY: not called CC=2 SCAR=17.9
151 0 my $self = shift;
152 0 ▶ $self->shutdown if ($Scanner::DEFAULT_SHUTDOWN);
Branch: 1 branch
BranchTrueFalseTotal
if $Scanner::DEFAULT_SHUTDOWN 0 0 0
153 0 return $self;}
154  
155  
156 #-----------------------------------------------------------------------------
157  
158 0 ▶sub info ($$) {
Subroutine info: not called CC=1 SCAR=6.9
Pod undocumented
159 0 my ($self,$str) = @_;
160 0 my $u = $self->{'units'};
161  
162 printf "[Scanner]\n" .
163 "Scanner: %s\n" .
164 "Type: %s\n" .
165 "Device id: %s\n" .
166 "Page source: %s\n" .
167 "Dots per inch: %d\n",
168 $self->{'scanner'},
169 $self->{'type'},
170 $self->{'deviceid'},
171 $self->{'pagesource'},
172 0 $self->{'dpi'};
173 0 return $self;
174 }
175  
176 #==============================================================================
177 # Internal Class Methods
178 #==============================================================================
179 # STUB METHODS. ALWAYS RETURNS TRUE FOR NOW.
180
181 0 ▶sub _validateScanner ($$) {shift; my $s = lc shift; return 1;}
Subroutine _validateScanner: not called CC=1 SCAR=6.9
182 0 ▶sub _validatePageSource ($$) {my $c = shift; my $p = lc shift; return 1;}
Subroutine _validatePageSource: not called CC=1 SCAR=6.9
183 0 ▶sub _validateDpi ($$) {shift; my $s = lc shift; return 1;}
Subroutine _validateDpi: not called CC=1 SCAR=6.9
184  
185 #==============================================================================
186 # Internal Object Methods
187 #==============================================================================
188 # All of these methods use an input parameter hash.
189 #------------------------------------------------------------------------------
190  
191 0 ▶sub _setScanner ($$) {
Subroutine _setScanner: not called CC=4 SCAR=30.0
192 0 my ($self, $params) = @_;
193 my $scanner = (defined $params->{'scanner'}) ?
194 0 ▶ lc $params->{'scanner'} : $Scanner::DEFAULT_SCANNER;
Branch: 1 branch
BranchTrueFalseTotal
defined $params->{'scanner'} ? : 0 0 0
195 0 ▶ $self->_validateScanner($scanner) || (return 0);
Branch: 1 branch
BranchTrueFalseTotal
$self->_validateScanner($scanner) or return 0 0 0 0
196
197 0 @$self{'scanner','type','deviceid'} = ($scanner, split ":", $scanner,2);
198
199 # Apply kludge for hp5590
200 0 ▶ if ($self->{'type'} eq "hp5590") {Scanner::Device->defaultDpiIs (200);}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "hp5590") 0 0 0
201
202 0 return 1;
203 }
204  
205 #------------------------------------------------------------------------------
206 # ASSUMES: _setScanner has been executed beforehand.
207  
208 0 ▶sub _setPageSource ($$) {
Subroutine _setPageSource: not called CC=11 SCAR=48.8
209 0 my ($self, $params) = @_;
210 0 my $extra = "";
211 0 my $pgsrc = "NotApplicable";
212  
213 my $pagesource = (defined $params->{'pagesource'}) ?
214 0 ▶ lc $params->{'pagesource'} : $Scanner::DEFAULT_PAGESOURCE;
Branch: 1 branch
BranchTrueFalseTotal
defined $params->{'pagesource'} ? : 0 0 0
215  
216 # If we get something wierd, default to flatbed.
217 0 ▶ $pagesource = "flatbed"
Branch: 1 branch
BranchTrueFalseTotal
if $pagesource ne "flatbad" and $pagesource ne "adf" 0 0 0
Condition0%0/3
$pagesource ne "flatbad" and $pagesource ne "adf"
!ll&&!rl&&r
000
MC/DC0%0/2
$pagesource ne "flatbad" and $pagesource ne "adf"
$pagesource ne "flatbad" $pagesource ne "adf"
Truth table0%0/3
A and B
A= $pagesource ne "flatbad"B= $pagesource ne "adf"
ABresult
0X0
100
111
218 if (($pagesource ne "flatbad") and ($pagesource ne "adf"));
219  
220 # I do not know what XPA is
221 # Normal|ADF|XPA [Normal]
222 0 ▶ if ($self->{'type'} eq "hp") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "hp") 0 0 0
223 0 ▶ $pgsrc = ($pagesource eq "flatbed") ? "Normal" : "ADF";
Branch: 1 branch
BranchTrueFalseTotal
$pagesource eq 'flatbed' ? : 0 0 0
224 0 $extra = ""
225 }
226 # I do not know what ADF Duplex is... the backend cannot even handle
227 # regular ADF. It scans one page and ejects the next two for no reason.
228 # Flatbed|ADF|ADF Duplex [Flatbed]
229 0 ▶ if ($self->{'type'} eq "hp5590") {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'type'} eq 'hp5590') { } 0 0 0
elsif ($self->{'type'} eq 'umax') { } 0 0 0
elsif ($self->{'type'} eq 'gt68xx') { } 0 0 0
230 0 ▶ $pgsrc = ($pagesource eq "flatbed") ? "Flatbed" : "ADF";
Branch: 1 branch
BranchTrueFalseTotal
$pagesource eq 'flatbed' ? : 0 0 0
231 0 $extra = ""
232 }
233 # Flatbed [Flatbed]
234 elsif ($self->{'type'} eq "umax") {
235 0 $pgsrc = "Flatbed";
236 0 $extra = "";
237 }
238 # I do not know how to make this option active.
239 #Flatbed|Transparency Adapter [inactive]
240 elsif ($self->{'type'} eq "gt68xx") {
241 0 $pgsrc = "NotApplicable";
242 0 $extra = "--auto-warmup=yes --lamp-off-at-exit=no"
243 }
244 else {
245 0 $pgsrc = "NotApplicable";
246 0 $extra = "";
247 }
248  
249 0 ▶ $self->_validatePageSource($pgsrc) || (return 0);
Branch: 1 branch
BranchTrueFalseTotal
$self->_validatePageSource($pgsrc) or return 0 0 0 0
250 0 $self->{'pagesource'} = $pgsrc;
251 0 $self->{'extra'} = $extra;
252 0 return 1;
253 }
254  
255 #------------------------------------------------------------------------------
256  
257 0 ▶sub _setDpi ($$) {
Subroutine _setDpi: not called CC=3 SCAR=24.8
258 0 my ($self, $params) = @_;
259 my $dpi = (defined $params->{'dpi'}) ?
260 0 ▶ $params->{'dpi'} : $Scanner::DEFAULT_DPI;
Branch: 1 branch
BranchTrueFalseTotal
defined $params->{'dpi'} ? : 0 0 0
261 0 ▶ $self->_validateDpi($dpi) || (return 0);
Branch: 1 branch
BranchTrueFalseTotal
$self->_validateDpi($dpi) or return 0 0 0 0
262 0 $self->{'dpi'} = $dpi;
263 0 return 1;
264 }
265  
266 #------------------------------------------------------------------------------
267 # Device specific setup, if any.
268  
269 0 ▶sub _initScanner ($$) {
Subroutine _initScanner: not called CC=5 SCAR=34.0
270 0 my ($self, $params) = @_;
271 0 ▶ if ($self->{'type'} eq "hp") { }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "hp") 0 0 0
272 0 ▶ if ($self->{'type'} eq "umax") { }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "umax") 0 0 0
273 0 ▶ if ($self->{'type'} eq "hp5590") { }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "hp5590") 0 0 0
274
275 # This is the only way I can enable the lamp control features!
276 0 ▶ if ($self->{'type'} eq "gt68xx") {$ENV{'SANE_DEBUG_GT68XX'}=1;}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "gt68xx") 0 0 0
277 0 return 1;
278 }
279
280 #==============================================================================
281 # Pod Documentation
282 #==============================================================================
283 # You may extract and format the documention section with the 'perldoc' cmd.
284  
285 =head1 NAME
286  
287 Scanner::Device - Class to control scanner hardware via SANE scanimage CLI.
288  
289 =head1 SYNOPSIS
290  
291 use Scanner::Device;
292  
293 $obj = Scanner::Device->new ( hashargs );
294 $bool = Scanner::Device->defaultScannerIs ($scanner);
295 $bool = Scanner::Device->defaultDpiIs ($dpi);
296 $true = Scanner::Device->defaultShutdownIs ($bool);
297 $bool = Scanner::Device->defaultPageSourceIs ($pgsrc);
298 $bool = $obj->scan ($pgobj,$dpath);
299 $bool = $obj->shutdown;
300  
301 =head1 Inheritance
302  
303 UNIVERSAL
304  
305 =head1 Description
306  
307 Creates Scanner::Device objects that represent a scanner to which Scanner::Page
308 objects may be passed for scanning.
309  
310 =head1 Examples
311  
312 use Scanner::Device;
313 use Scanner::Device::Page;
314 my $bool = Scanner::Device->defaultScannerIs ("hp:libusb:001:010");
315 $bool = Scanner::Device->defaultDpi (150);
316 $bool = Scanner::Device->defaultPageSourceIs ("adf");
317  
318 my $scanner = Scanner::Device->new;
319 my $pg = Scanner::Page->new ( 'date' => "20040830",
320 'title' => "DailyBoggle",
321 'pageid' => "001",
322 );
323 my $bool = $scanner->scan ( $pg );
324  
325 =head1 Class Variables
326  
327 $Scanner::DEFAULT_SCANNER Default is "umax". If there is an $SCANNER
328 Environment variable, that value will be used
329 instead.
330  
331 $Scanner::DEFAULT_DPI Default is 150 dpi. If the Scanner is an
332 hp5590, it will be set to 200 dpi instead.
333  
334 $Scanner::DEFAULT_PAGESOURCE Default source is "flatbed".
335  
336 $Scanner::DEFAULT_SHUTDOWN Default is false, for no shutdown.
337  
338 =head1 Instance Variables
339  
340 scanner Default device is "umax" or the contents of the Environment
341 variable $SCANNER. It can also be a usb device like
342 "hp:libusb:001:01"
343  
344 type The device type portion of the scanner string.
345  
346 deviceid The device address portion of the scanner string.
347  
348 pagesource Default page source is "flatbed". It can be either 'flatbed'
349 or 'adf' for automatic document feeder. This value will be used
350 to select the best available and possibly device specific internal
351 setting for 'devpgsrc', as allowed by scanimage.
352  
353 devpgsrc Best match to requested 'pagesource' that is available on the
354 scanner 'type'.
355  
356 extra Type dependant args. These are set automatically based on 'type'.
357  
358 dpi Default value of dots per inch is 150. scanimage measure pages in
359 mm and uses dpi to measure resolution. Don't ask me, ask them.
360  
361 =head1 Environment Variables
362  
363 $SCANNER If defined and if it contains a valid scanner device string at
364 load time, it will be used as the default scanner.
365  
366 $SCANNER_AUTO_SHUTDOWN
367 If defined at load time, it will be used as the default boolean
368 value for $Scanner::DEFAULT_SHUTDOWN.
369  
370 =head1 Class Methods
371  
372 Note that argument validity checking is not implimented yet.
373  
374 =over 4
375  
376 =item B<$bool = Scanner::Device-E<gt>defaultScannerIs ($device)>
377  
378 Set the default device for the Scanner::Device class. The device string
379 may be anything allowed by the scanimage program. You can find
380 out what is available using the command:
381  
382 scanimage -L
383  
384 If the device argument is missing, the value defaults to "umax" for
385 no better reason than that is was the scanner I had when I first
386 wrote this code.
387  
388 If the device is an hp5590, the default dpi setting is raised from
389 150 dpi to 200 dpi since that scanner does not have a 150 dpi setting.
390  
391 Returns true on success and false if there is no arg or it is not a
392 scanner device string.
393  
394 =item B<$bool = Scanner::Device-E<gt>defaultDpiIs ($dpi)>
395  
396 Set the default dots per inch for the Scanner::Device Class. The dpi integer
397 may be anything allowed by the scanner.
398  
399 Returns true on success and false if there is no arg or it is not a
400 valid dpi value.
401  
402 =item B<$bool = Scanner::Device-E<gt>defaultPageSourceIs ($pgsrc)>
403  
404 Set the Class default scanner page source. Flatbed/Normal or ADF (automatic
405 document feeder). "flatbed" or "normal" means the scanner table; "adf" means
406 use an automatic document feeder.
407  
408 Note that at object-creation time the appropriate device
409 tupe dependant pseudonym of flatbed or normal will be used regardless of
410 which was named the default.
411  
412 The page source string will in some cases be internally mapped to scanner
413 specific equivalents, for example flatbed=>normal for some HP scanners.
414 Either flatbed or normal is acceptable on input. The appropriate
415 one will be used when actually communicating with the scanner.
416  
417 Returns true on success and false if there is no arg or it is not a
418 valid page source.
419  
420 =item B<$bool = Scanner::Device-E<gt>defaultShutdownIs ($boolean)>
421  
422 Set the default for shutdown after a scan. 1 means carry out special shutdown
423 such as turning off the lamp, if required; 0 or undef means do not do so. It
424 is often useful not to do a shutdown if you are scanning multiple pages as it
425 can slow down your scanning immensely.
426  
427 The $boolean arg should be 1 or 0 to make things easier to understand, but
428 it can be absolutely anything. whatever it is will be interpreted as true
429 or false, ie "anystring" is true; "" is false, undef is false, etc.
430  
431 Always returns true.
432  
433 =item B<$obj = Scanner::Device-E<gt>new (scanner =E<gt> $devicestr, pagesource =E<gt> $src, dpi =E<gt> $dpi>
434  
435 This is the Class method for creating new Scanner::Device objects and has
436 three option args:
437  
438 scanner => scanner type as returned by
439 "scanimage -L" [OPT: default is "umax"]
440  
441 pagesource => flatbed|adf. Any other value will be changed to flatbed.
442 [OPT: default is "flatbed"]
443  
444 dpi => integer [OPT: default is 150 dpi]
445  
446 It returns either a pointer to the newly created and initialized object
447 or undef if the object could not be created.
448  
449 =back 4
450  
451 =head1 Instance Methods
452  
453 =over 4
454  
455 =item B<$bool = $obj-E<gt>scan ($pageobj,$dpath)>
456  
457 Scan the page identified by the pageobj and create an appropriately named file
458 at $dpath. The $dpath location must be a directory that is writeable to the
459 user.
460  
461 Returns true if it succeeds.
462  
463 If debug is enabled, it will print the generated scanimage command line before
464 executing it.
465  
466 =item B<$bool = $obj-E<gt>shutdown>
467  
468 Turn the scanner off if it is a type which requires special handling that we
469 know about. Only used for Mustek at the moment, noop otherwise.
470  
471 =back 4
472  
473 =head1 Private Class Methods
474  
475 None.
476  
477 =head1 Private Instance Methods
478  
479 None.
480  
481 =head1 Errors and Warnings
482  
483 None.
484  
485 =head1 KNOWN BUGS
486  
487 See TODO.
488  
489 =head1 SEE ALSO
490  
491 Scanner::Page, Scanner::Format.
492  
493 =head1 AUTHOR
494  
495 Dale Amon <amon@vnl.com>
496  
497 =cut
498
499 #=============================================================================
500 # CVS HISTORY
501 #=============================================================================
502 # $Log: Device.pm,v $
503 # Revision 1.2 2008-08-28 23:31:43 amon
504 # Major rewrite. Shuffled code between classes and add lots of features.
505 #
506 # Revision 1.1 2008-08-25 19:58:36 amon
507 # Changed name of Scanner.pm to Scanner/Device.pm
508 #
509 # Revision 1.3 2008-08-19 15:06:07 amon
510 # Added SCANNER_AUTO_SHUTDOWN Env variable. Also send scan shutdown output to
511 # dev null. Use unlink instead of system call to rm; changes to handle updates
512 # in Page class.
513 #
514 # Revision 1.2 2008-08-07 19:52:16 amon
515 # Upgrade source format to current standard.
516 #
517 # Revision 1.1.1.1 2008-01-20 17:59:30 amon
518 # Classes for scanner use abstractions.
519 #
520 # 20070506 Dale Amon <amon@islandone.org>
521 # Add support for hp5590 SANE backend.
522 #
523 # 20070501 Dale Amon <amon@islandone.org>
524 # Added support for $SCANNER environment variable.
525 #
526 # 20060615 Dale Amon <amon@islandone.org>
527 # Added code to set the Environment variable required by the mustek
528 # to get at most of the special features like lamp control.
529 #
530 # 20060416 Dale Amon <amon@islandone.org>
531 # I patched the code 'temporarily' around 20051024 because
532 # the Mustek A3 USB does not accept the --source option and
533 # cannot be shut up over it. I now have sorted that problem
534 # out by adding a source type of "NotApplicable" which suppresses
535 # the --source entirely.
536 #
537 # 20050825 Dale Amon <amon@islandone.org>
538 # Umax uses flatbed where hp used normal. I generalized
539 # _setPageSource to convert one to the other depending on
540 # the type, hp or umax. Type is now parsed from the scanner
541 # string by _setScanner. Also fixed some minor bugs in
542 # the mostly unused default*****Is class methods.
543 #
544 # 20050710 Dale Amon <amon@islandone.org>
545 # Made dpi a modifiable default. A couple weeks ago I
546 # also added scanner type and document source option
547 # support, although with stubs on the validation
548 # routines.
549 #
550 # 20050228 Dale Amon <amon@islandone.org>
551 # BAD NEWS: scanimage just de-generalized and
552 # has made things like resolution and colour
553 # into device specific parameters! I've had to lock this
554 # down to work only on Umax so I can get work done!
555 # *** MUST REGENERALIZE ****
556 #
557 # 20040819 Dale Amon <amon@islandone.org>
558 # Created.
559 #
560 1 1;
↑ Summary Job.pm »