superwaba.ext.xplat.io.scanner
Class Scanner

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

public class Scanner
extends java.lang.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;

 
To make a Symbol MC3000 work with the I2OF5 barcode, you must call:
 // MUST BE CALLED *** BEFORE *** SCANNER.ACTIVATE !!!!
 Scanner.setParam(Scanner.WAITING_TIME_PARAM, 0, 3000); // 3rd parameter must be something > 0!
 if (Scanner.activate())
 {
    Scanner.setBarcodeParam(Scanner.BARI2OF5, true);
    Scanner.setBarcodeLength(Scanner.BARI2OF5, 2, 8, 8);
    ...
 


Field Summary
static int BARBOOKLAND_EAN
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARCODABAR
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARCODE128
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARCODE39
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARCODE93
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARD2OF5
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BAREAN13
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BAREAN8
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARI2OF5
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARISBT128
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARMSI_PLESSEY
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARTRIOPTICCODE39
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARUCC_EAN128
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARUPCA
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARUPCE
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARUPCE1
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
static int BARUPCEANCOUPONCODE
          To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.
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
static int WAITING_TIME_PARAM
          To be used in the setParam method for Windows CE only.
 
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 java.lang.String getData()
          Get the decoded string of what has been scanned.
static java.lang.String getScanManagerVersion()
          Get the scan manager version as an hexadecimal String.
static java.lang.String getScanPortDriverVersion()
          Get the Scanner Port Driver version as an hexadecimal String.
static boolean isPassive()
          Returns true if this scanner is a passive one.
static boolean setBarcodeLength(int barcodeType, int lengthType, int min, int max)
          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.
static boolean trigger()
          Triggers the scanner for passive scanners.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BARCODE39

public static final int BARCODE39
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARUPCA

public static final int BARUPCA
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARUPCE

public static final int BARUPCE
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BAREAN13

public static final int BAREAN13
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BAREAN8

public static final int BAREAN8
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARD2OF5

public static final int BARD2OF5
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARI2OF5

public static final int BARI2OF5
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARCODABAR

public static final int BARCODABAR
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARCODE128

public static final int BARCODE128
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARCODE93

public static final int BARCODE93
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARMSI_PLESSEY

public static final int BARMSI_PLESSEY
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARUPCE1

public static final int BARUPCE1
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARTRIOPTICCODE39

public static final int BARTRIOPTICCODE39
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARUCC_EAN128

public static final int BARUCC_EAN128
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARBOOKLAND_EAN

public static final int BARBOOKLAND_EAN
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARISBT128

public static final int BARISBT128
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

BARUPCEANCOUPONCODE

public static final int BARUPCEANCOUPONCODE
To be used in the setBarcodeParam method with Symbol scanners; for SocketCom ones, see the method for the avail codes.

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

WAITING_TIME_PARAM

public static final int WAITING_TIME_PARAM
To be used in the setParam method for Windows CE only. Sets the time that the scanner thread will wait for a beam. if value is <= 0, it waits FOREVER. Otherwise, waits for the given number of milisseconds. MUST BE CALLED BEFORE SCANNER.ACTIVATE !!!

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. For SocketCom scanners, you must use the following values:
SYMB_CODE11 = 0,         // 0
SYMB_CODE128,
SYMB_CODE39,
SYMB_CODE49,
SYMB_CODE93,
SYMB_CODE39_FULL_ASCII,  // 5
SYMB_TRIOPTIC_CODE39,
SYMB_UPC_A,
SYMB_UPC_E,
SYMB_UPC_E0,
SYMB_UPC_E1,             // 10
SYMB_EAN_8,
SYMB_EAN_13,
SYMB_BOOKLAND_EAN,
SYMB_UCC_EAN_128,
SYMB_CODABAR,            // 15
SYMB_CODABLOCK,
SYMB_DISCRETE_2_5,
SYMB_IATA_2_5,
SYMB_INTERLEAVED_2_5,
SYMB_ISBT,               // 20
SYMB_MATRIX_2_5,
SYMB_MSI_PLESSEY,
SYMB_RSS14,
SYMB_TLCODE39,

// 2-D Barcodes
SYMB_AUSTRALIAN_POSTAL,  // 25
SYMB_AZTEC,
SYMB_AZTEC_MESA,
SYMB_BRITISH_POSTAL,
SYMB_CANADIAN_POSTAL,
SYMB_DATAMATRIX_CODE,    // 30
SYMB_DUTCH_POSTAL,
SYMB_JAPANESE_POSTAL,
SYMB_MAXICODE,
SYMB_MICROPDF,
SYMB_OCR,                // 35
SYMB_PDF,
SYMB_QR_CODE,
SYMB_US_PLANET_POSTAL,
SYMB_US_POSTNET_POSTAL,
SYMB_ALL_SYMBOLOGIES     // 40
 
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. Not implemented in the Windows CE platform.
    // 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. Not used in the Windows CE platform.

setBarcodeLength

public static boolean setBarcodeLength(int barcodeType,
                                       int lengthType,
                                       int min,
                                       int max)
Set the length of a barcode. The lengthType must be one of the following values:
Parameters:
barcodeType - One of the BARxxxx constants
lengthType - 0 (Variable length, min and max are ignored), 1 (length = min), 2 (length = min || length = max), 3 (min <= length <= max)
min - The minimum value
max - The maximum value

getData

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

getScanManagerVersion

public static java.lang.String getScanManagerVersion()
Get the scan manager version as an hexadecimal 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 java.lang.String getScanPortDriverVersion()
Get the Scanner Port Driver version as an hexadecimal 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.

isPassive

public static boolean isPassive()
Returns true if this scanner is a passive one. Passive scanners must be triggered programatically, using the trigger method. Currently, all SocketCom scanners are passive, and all others are not.
Since:
SuperWaba 5.7

trigger

public static boolean trigger()
Triggers the scanner for passive scanners. The barcode will be returned in the ScanEvent event.
Since:
SuperWaba 5.7