superwaba.ext.xplat.io.scanner
Class Scanner

java.lang.Object
  |
  +--superwaba.ext.xplat.io.scanner.Scanner

public class Scanner
extends Object

Scanner accesses the Symbol barcode scanner.

Scanner access is only available when running under a native SuperWaba VM, it is not supported when running under Java.

Since there is only one scanner per device, the scanner class is static. Activating the scanner causes the physical scanner to be powered, and enables the trigger. Deactivating the scanner removes power from the scanner and prevents scans from taking place. The scanner should always be deactivated at the end of processing to prevent excessive battery drain.

When the scanner is activated, scan events will appear in the MainWindow's onEvent method. The scan events will contain a String describing either the item scanned or a battery error. Deactivating the scanner prevents scan events from being delivered.

You can change this behaviour by calling setContinuousScanning(false), which will cause each call to activate() to only allow a single scan.

Since barcodes can have many formats, this class includes a method to register the barcode types with the scanner. These types must each be individually set as parameters to the scanner. After all the parameter types have been set, the commitBarcodeParams method must be called to register the parameters with the scanner. Once this is done the scanner is able to decode the specified barcode types.

A typical processing sequence is given below:

 if (!Scanner.active())
     return;
 if (!Scanner.setBarcodeParam(Scanner.BARCODABAR, true))
     return;
 if (!Scanner.setBarcodeParam(Scanner.BARBOOKLAND_EAN, true))
     return;
 if (!Scanner.commitBarcodeParams())
     return;
 ...
 if (!Scanner.deactivate())
      return;

 


Field Summary
static int BARBOOKLAND_EAN
          To be used in the setBarcodeParam method
static int BARCODABAR
          To be used in the setBarcodeParam method
static int BARCODE128
          To be used in the setBarcodeParam method
static int BARCODE39
          To be used in the setBarcodeParam method
static int BARCODE93
          To be used in the setBarcodeParam method
static int BARD2OF5
          To be used in the setBarcodeParam method
static int BAREAN13
          To be used in the setBarcodeParam method
static int BAREAN8
          To be used in the setBarcodeParam method
static int BARI2OF5
          To be used in the setBarcodeParam method
static int BARISBT128
          To be used in the setBarcodeParam method
static int BARMSI_PLESSEY
          To be used in the setBarcodeParam method
static int BARTRIOPTICCODE39
          To be used in the setBarcodeParam method
static int BARUCC_EAN128
          To be used in the setBarcodeParam method
static int BARUPCA
          To be used in the setBarcodeParam method
static int BARUPCE
          To be used in the setBarcodeParam method
static int BARUPCE1
          To be used in the setBarcodeParam method
static int BARUPCEANCOUPONCODE
          To be used in the setBarcodeParam method
static boolean isActive
           
static int LINEAR_SECURITY_LEVEL_PARAM
          To be used in the setParam method
static Control listener
           
static int MSI_PLESSEY_ALGORITHMS_PARAM
          To be used in the setParam method
static int MSI_PLESSEY_CHECKDIGIT_PARAM
          To be used in the setParam method
static int MSI_PLESSEY_OPTIONS_PARAM
          To be used in the setParam method
static int PREAMBLE_PARAM
          To be used in the setParam method.
static int SCAN_ANGLE_PARAM
          To be used in the setParam method
static int SCAN_DATA_TRANSMISSION_PARAM
          To be used in the setParam method
static int SUPPLEMENTALS_PARAM
          To be used in the setParam method
static int TRANSMIT_CHECKDIGIT_PARAM
          To be used in the setParam method.
static int TRANSMIT_CODEID_PARAM
          To be used in the setParam method
static int TRIGGERING_PARAM
          To be used in the setParam method
 
Constructor Summary
Scanner()
           
 
Method Summary
protected static void _onEvent(int type)
          Dispatch the event to the current listener (associated through the listener public member.
static boolean activate()
          Activate the scanner.
static boolean commitBarcodeParams()
          Commit the barcode parameters to the scanner.
static boolean deactivate()
          Deactivate the scanner.
static String getData()
          Get the decoded string of what has been scanned.
static String getScanManagerVersion()
          Get the scan manager version as a String.
static String getScanPortDriverVersion()
          Get the Scanner Port Driver version as a String.
static boolean setBarcodeLength(int barcodeType, int lengthType, int length1, int length2)
          Set the length of a barcode.
static boolean setBarcodeParam(int barcodeType, boolean enable)
          Set a scanner parameter defining whether a barcode format will be used in scanning.
static void setContinuousScanning(boolean continuous)
          Set whether activate() will continuously scan (the default), or stop after a single scan.
static boolean setParam(int type, int barcodeType, int value)
          Set a parameter for the barcode.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, toString, wait, wait
 

Field Detail

BARCODE39

public static final int BARCODE39
To be used in the setBarcodeParam method

BARUPCA

public static final int BARUPCA
To be used in the setBarcodeParam method

BARUPCE

public static final int BARUPCE
To be used in the setBarcodeParam method

BAREAN13

public static final int BAREAN13
To be used in the setBarcodeParam method

BAREAN8

public static final int BAREAN8
To be used in the setBarcodeParam method

BARD2OF5

public static final int BARD2OF5
To be used in the setBarcodeParam method

BARI2OF5

public static final int BARI2OF5
To be used in the setBarcodeParam method

BARCODABAR

public static final int BARCODABAR
To be used in the setBarcodeParam method

BARCODE128

public static final int BARCODE128
To be used in the setBarcodeParam method

BARCODE93

public static final int BARCODE93
To be used in the setBarcodeParam method

BARMSI_PLESSEY

public static final int BARMSI_PLESSEY
To be used in the setBarcodeParam method

BARUPCE1

public static final int BARUPCE1
To be used in the setBarcodeParam method

BARTRIOPTICCODE39

public static final int BARTRIOPTICCODE39
To be used in the setBarcodeParam method

BARUCC_EAN128

public static final int BARUCC_EAN128
To be used in the setBarcodeParam method

BARBOOKLAND_EAN

public static final int BARBOOKLAND_EAN
To be used in the setBarcodeParam method

BARISBT128

public static final int BARISBT128
To be used in the setBarcodeParam method

BARUPCEANCOUPONCODE

public static final int BARUPCEANCOUPONCODE
To be used in the setBarcodeParam method

TRIGGERING_PARAM

public static final int TRIGGERING_PARAM
To be used in the setParam method

LINEAR_SECURITY_LEVEL_PARAM

public static final int LINEAR_SECURITY_LEVEL_PARAM
To be used in the setParam method

SUPPLEMENTALS_PARAM

public static final int SUPPLEMENTALS_PARAM
To be used in the setParam method

TRANSMIT_CHECKDIGIT_PARAM

public static final int TRANSMIT_CHECKDIGIT_PARAM
To be used in the setParam method. Needs barcodeType.

PREAMBLE_PARAM

public static final int PREAMBLE_PARAM
To be used in the setParam method. Needs barcodeType.

MSI_PLESSEY_CHECKDIGIT_PARAM

public static final int MSI_PLESSEY_CHECKDIGIT_PARAM
To be used in the setParam method

MSI_PLESSEY_OPTIONS_PARAM

public static final int MSI_PLESSEY_OPTIONS_PARAM
To be used in the setParam method

MSI_PLESSEY_ALGORITHMS_PARAM

public static final int MSI_PLESSEY_ALGORITHMS_PARAM
To be used in the setParam method

TRANSMIT_CODEID_PARAM

public static final int TRANSMIT_CODEID_PARAM
To be used in the setParam method

SCAN_DATA_TRANSMISSION_PARAM

public static final int SCAN_DATA_TRANSMISSION_PARAM
To be used in the setParam method

SCAN_ANGLE_PARAM

public static final int SCAN_ANGLE_PARAM
To be used in the setParam method

isActive

public static boolean isActive

listener

public static Control listener
Constructor Detail

Scanner

public Scanner()
Method Detail

activate

public static boolean activate()
Activate the scanner. Return true if the scanner could be activated, false otherwise. (A false condition may arise if batteries have run too low, or if the unit does not have the scan library installed.

setBarcodeParam

public static boolean setBarcodeParam(int barcodeType,
                                      boolean enable)
Set a scanner parameter defining whether a barcode format will be used in scanning. Choose from one of the barcode types given above.
Parameters:
barcodeType - the type of barcode under consideration
enable - a flag to enable or disable decoding barcodes of this type.

setContinuousScanning

public static void setContinuousScanning(boolean continuous)
Set whether activate() will continuously scan (the default), or stop after a single scan.
Parameters:
continuous - true if activate() continuously scans, false if it will only schedule a single scan

setParam

public static boolean setParam(int type,
                               int barcodeType,
                               int value)
Set a parameter for the barcode. You can use the xxx_PARAM constants to know which parameter to set, and also the values below for their values. Be careful because some functions may require also the barcode type.
    // triggering modes
    #define LEVEL                                       0x00
    #define PULSE                                       0x02
    #define HOST                                        0x08

    // Linear code type security
    #define SECURITY_LEVEL0                             0x00
    #define SECURITY_LEVEL1                             0x01
    #define SECURITY_LEVEL2                             0x02
    #define SECURITY_LEVEL3                             0x03
    #define SECURITY_LEVEL4                             0x04

    // UPC/EAN Supplementals
    #define IGNORE_SUPPLEMENTALS                        0x00
    #define DECODE_SUPPLEMENTALS                        0x01
    #define AUTODISCRIMINATE_SUPPLEMENTALS              0x02

    // Transmit Check Digit options
    #define DO_NOT_TRANSMIT_CHECK_DIGIT                 0x00
    #define TRANSMIT_CHECK_DIGIT                        0x01

    // Preamble options
    #define NO_PREAMBLE                                 0x00
    #define SYSTEM_CHARACTER                            0x01
    #define SYSTEM_CHARACTER_COUNTRY_CODE               0x02

    // CheckDigit verification options
    #define DISABLE_CHECK_DIGIT 					           0x00
    #define USS_CHECK_DIGIT                             0x01
    #define OPCC_CHECK_DIGIT                            0x02

    // MSI Plessey checkdigit options
    #define ONE_CHECK_DIGIT                             0x00
    #define TWO_CHECK_DIGITS                            0x01

    // MSI Plessey check digit algorithms
    #define MOD10_MOD11                                 0x00
    #define MOD10_MOD10                                 0x01

    // Transmit Code ID Character options
    #define AIM_CODE_ID_CHARACTER                       0x01
    #define SYMBOL_CODE_ID_CHARACTER                    0x02

    // Scan data transmission formats
    #define DATA_AS_IS                                  0x00
    #define DATA_SUFFIX1                                0x01
    #define DATA_SUFFIX2                                0x02
    #define DATA_SUFFIX1_SUFFIX2                        0x03
    #define PREFIX_DATA                                 0x04
    #define PREFIX_DATA_SUFFIX1                         0x05
    #define PREFIX_DATA_SUFFIX2                         0x06
    #define PREFIX_DATA_SUFFIX1_SUFFIX2                 0x07

    // Scan angle options
    #define SCAN_ANGLE_WIDE 					              0xB6
    #define SCAN_ANGLE_NARROW					              0xB5
 

commitBarcodeParams

public static boolean commitBarcodeParams()
Commit the barcode parameters to the scanner. Returns true if the operation is successful and false otherwise.

setBarcodeLength

public static boolean setBarcodeLength(int barcodeType,
                                       int lengthType,
                                       int length1,
                                       int length2)
Set the length of a barcode. The lengthType must be one of the following values:
    // Length types for the barcode SetLengths calls
    #define ANY_LENGTH                                  0x00
    #define ONE_DISCRETE_LENGTH                         0x01
    #define TWO_DISCRETE_LENGTHS                        0x02
    #define LENGTH_WITHIN_RANGE                         0x03
 

getData

public static String getData()
Get the decoded string of what has been scanned. If an error occurs a null String will be returned.

getScanManagerVersion

public static String getScanManagerVersion()
Get the scan manager version as a String. If an error occurs or if this method is called before the Scanner is initialized, a null String will be returned.

getScanPortDriverVersion

public static String getScanPortDriverVersion()
Get the Scanner Port Driver version as a String. If an error occurs or if this method is called before the Scanner is initialized, a null String will be returned.

deactivate

public static boolean deactivate()
Deactivate the scanner. Returns true if the operation is successful and false otherwise.

_onEvent

protected static void _onEvent(int type)
Dispatch the event to the current listener (associated through the listener public member. Called from the native library. If there are no assigned listeners, the event is sent to the top most window, and the window is validated.