com.sap.ip.me.api.pios.scanner
Class ScannerConnection

java.lang.Object
  extended bycom.sap.ip.me.api.pios.connection.Connection
      extended bycom.sap.ip.me.api.pios.scanner.ScannerConnection

public abstract class ScannerConnection
extends Connection

ScannerConnection defines a connection (session) with a specific scanner. Scanner readings are executed and results are returned within the context of a connection. It includes methods to be called to activate the scanner laser programmatically or to activate the scanner and wait for a trigger to be pulled and read some data.

Example: Reading barcodes using WEDGE mode.

Description: Set scanner parameters, open a scanner connection and start reading via wedge mode.

 
 		Connector connector = Connector.getInstance();
 			
 		DriverInfo[] scanners = connector.listDrivers(ConnectionType.SCANNER);
 			
 		ScannerParameters parameters = new ScannerParameters(scanners[0]);
 
 		parameters.setMode(ScannerParameters.WEDGE);
 			
		ScannerConnection scanner = (ScannerConnection) connector.open(parameters); 
 			
 		scanner.addSymbology(new Code39(Code39.FULLASCII));
 
 		scanner.startRead(); //This will start wedge mode scanning
 			
 		//Add some code here to keep scanning until needed.
  
 		scanner.endRead();  //This will stop wedge mode scanning
 			
 		scanner.close(); 			
 
 

To determine if a required scanner functionality is provided by a driver use a DriverInfo instance provided by the connector.

Example: Determine is a scanner supports wedge mode.
 
		Connector connector = Connector.getInstance();
	
		DriverInfo[] scanners = connector.listDrivers(ConnectionType.SCANNER);
	 	
		if (scanners[0].isAttributeSupported(ScannerConnection.Attributes.WEDGE_MODE)) {
			//Add some code here 
		}    
 
 

Since:
MI 2.5
Author:
Abaco
See Also:
Connection, PIOSException, ScannerListener, ScannerException

Nested Class Summary
static interface ScannerConnection.Attributes
          Contains all possible attribute names for the scanner.
 
Field Summary
static long BEEP_OFF
          Constant to indicate beep off option.
static long BEEP_ON_FAIL
          Constant to indicate beep on fail option.
static long BEEP_ON_READ
          Constant to indicate beep on read option.
static long UPC_EAN_ADDON_DIGITS_REQUIRED
          Constant to indicate that add-on digits are required for UPC/EAN symbologies.
static long UPC_EAN_FIVE_DIGIT_ADDON
          Constant to indicate the five digit addon option for UPC/EAN symbologies.
static long UPC_EAN_TWO_DIGIT_ADDON
          Constant to indicate the two digit addon option for UPC/EAN symbologies.
 
Fields inherited from class com.sap.ip.me.api.pios.connection.Connection
attributesFileName, cfgFile, opened, parameters
 
Constructor Summary
protected ScannerConnection()
          Constructs a new scanner connection.
 
Method Summary
abstract  void addSymbology(Symbology symbology)
          Adds a symbology (and its options/preferences) to be read by the scanner.
abstract  void endRead()
          Cancels a previous StartRead request.
abstract  long getOptions()
          Returns the scanner options mask.
abstract  byte[] getPostamble()
          Returns the scanner postamble.
abstract  byte[] getPreamble()
          Returns the scanner preamble.
abstract  java.util.Enumeration getSymbologies()
          Returns an enumeration of the symbologies added.
abstract  void removeSymbology(int symbologyType)
          Removes a symbology type from the list of symbologies to be read by the scanner.
abstract  void setEventListener(ScannerListener listener)
          Sets an event listener for the scanner.
abstract  void setOptions(long options)
          Sets the scanner options mask.
abstract  void setPostamble(byte[] postamble)
          Sets the scanner postamble.
abstract  void setPreamble(byte[] preamble)
          Sets the scanner preamble.
abstract  void setSoftTrigger(boolean enabled)
          Sets the scan engine laser beam to an On/Off position.
abstract  void startRead()
          Enables the scanner to read barcodes.
 
Methods inherited from class com.sap.ip.me.api.pios.connection.Connection
close, getParameters, isOpen, open
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEEP_ON_READ

public static final long BEEP_ON_READ
Constant to indicate beep on read option. This is the default option.

See Also:
Constant Field Values

BEEP_ON_FAIL

public static final long BEEP_ON_FAIL
Constant to indicate beep on fail option.

See Also:
Constant Field Values

BEEP_OFF

public static final long BEEP_OFF
Constant to indicate beep off option.

See Also:
Constant Field Values

UPC_EAN_TWO_DIGIT_ADDON

public static final long UPC_EAN_TWO_DIGIT_ADDON
Constant to indicate the two digit addon option for UPC/EAN symbologies.

See Also:
Constant Field Values

UPC_EAN_FIVE_DIGIT_ADDON

public static final long UPC_EAN_FIVE_DIGIT_ADDON
Constant to indicate the five digit addon option for UPC/EAN symbologies.

See Also:
Constant Field Values

UPC_EAN_ADDON_DIGITS_REQUIRED

public static final long UPC_EAN_ADDON_DIGITS_REQUIRED
Constant to indicate that add-on digits are required for UPC/EAN symbologies.

See Also:
Constant Field Values
Constructor Detail

ScannerConnection

protected ScannerConnection()
                     throws PIOSException
Constructs a new scanner connection.

Throws:
PIOSException - thrown if an error is detected while creating/ opening the scanner connection.
Method Detail

setEventListener

public abstract void setEventListener(ScannerListener listener)
                               throws ScannerException
Sets an event listener for the scanner.

Parameters:
listener - the scanner listener
Throws:
ScannerException - thrown if scanner wedge mode option was selected for this connection or if a callback function is being processed due to a successful non-blocking call to startRead and no subsequent calls to the endRead method were made.

setSoftTrigger

public abstract void setSoftTrigger(boolean enabled)
                             throws UnsupportedException,
                                    ScannerException
Sets the scan engine laser beam to an On/Off position. The client application must coordinate control of the scanner with the user. When the scanner is turned on, its behavior is controlled by the trigger mode. That is, in one shot mode, the laser turns off when a barcode is scanned.

Parameters:
enabled - value of scanner laser beam (true if On, false otherwise)
Throws:
UnsupportedException - thrown if enabling or disabling the laser bean is not supported by the scanner driver
ScannerException - thrown if a successful startRead call do not occur before using this function or if an error occurs while communicating with the scanner.

startRead

public abstract void startRead()
                        throws ScannerException
Enables the scanner to read barcodes. When scan aware mode is used, this call enables the application to receive future barcode reads in form of events (Non-Blocking). If instead, wedge mode is used, scanned data is input as if it were typed directly into the keyboard.

Throws:
ScannerException - thrown if a callback function is being processed due to a successful non-blocking call to startRead and no subsequent calls to the endRead method were made. Also if an error occurs while configuring the scanner symbologies or options. If no event listener has been set when the connection mode is scan aware an exception will be thrown. If an error occurs while communicating with the scanner an exception will be thrown.

endRead

public abstract void endRead()
                      throws ScannerException
Cancels a previous StartRead request. This method prevents future scanner barcode data to be collected by the application.

Throws:
ScannerException - thrown if an error occurs while communicating with the scanner.

addSymbology

public abstract void addSymbology(Symbology symbology)
                           throws ScannerException,
                                  UnsupportedException
Adds a symbology (and its options/preferences) to be read by the scanner. Any changes performed to the symbology object after a successful call to this method will not have any effect on the scanner.

Parameters:
symbology - the symbology to be read by the scanner
Throws:
ScannerException - thrown if a callback function is being processed due to a successful non-blocking call to startRead and no subsequent calls to the endRead method were made or if the symbology has been previously added.
UnsupportedException - thrown if the symbology (or its options) are unsupported by the scanner.
See Also:
Symbology

removeSymbology

public abstract void removeSymbology(int symbologyType)
                              throws ScannerException
Removes a symbology type from the list of symbologies to be read by the scanner.

Parameters:
symbologyType - the symbology type to remove
Throws:
ScannerException - thrown if a callback function is being processed due to a successful non-blocking call to startRead and no subsequent calls to the endRead method were made or if the symbology has not been previously added.
See Also:
Symbology

getSymbologies

public abstract java.util.Enumeration getSymbologies()
                                              throws ScannerException
Returns an enumeration of the symbologies added. The enumeration returned from this call is a copy of what is currently in the scanner, subsequent changes to the symbologies objects will not have any effect on the scanner.

Returns:
Enumeration An enumeration of configured symbologies.
Throws:
ScannerException - thrown if an error occurs while communicating with the scanner.
See Also:
Enumeration

getPreamble

public abstract byte[] getPreamble()
                            throws ScannerException
Returns the scanner preamble.

Returns:
A byte array containing the preamble.
Throws:
ScannerException - thrown if an error occurs while communicating with the scanner.

getPostamble

public abstract byte[] getPostamble()
                             throws ScannerException
Returns the scanner postamble.

Returns:
A byte array containing the postamble.
Throws:
ScannerException - thrown if an error occurs while communicating with the scanner.

setPreamble

public abstract void setPreamble(byte[] preamble)
                          throws ScannerException
Sets the scanner preamble.

Parameters:
preamble - the byte array containing the preamble value to configure
Throws:
ScannerException - thrown if a callback function is being processed due to a successful non-blocking call to startRead and no subsequent calls to the endRead method were made .

setPostamble

public abstract void setPostamble(byte[] postamble)
                           throws ScannerException
Sets the scanner postamble.

Parameters:
postamble - the byte array containing the postamble value to configure
Throws:
ScannerException - thrown if a callback function is being processed due to a successful non-blocking call to startRead and no subsequent calls to the endRead method were made.

getOptions

public abstract long getOptions()
                         throws ScannerException
Returns the scanner options mask.

Returns:
The scanner options mask.
Throws:
ScannerException - thrown if an error occurs while communicating with the scanner.

setOptions

public abstract void setOptions(long options)
                         throws ScannerException,
                                UnsupportedException
Sets the scanner options mask.

Parameters:
options - the scanner options mask
Throws:
ScannerException - thrown if a callback function is being processed due to a successful non-blocking call to startRead and no subsequent calls to the endRead method were made.
UnsupportedException - thrown if the scanner options are unsupported by the scanner.


Copyright © 2005 SAP AG. All Rights Reserved.