Skip to end of metadata
Go to start of metadata

Overview

The Sepasoft Barcode Scanner component allows barcode scanner devices to connect to the Ignition software as if it were a keyboard. From the viewpoint of Ignition, the input data stream from the scanner is indistinguishable from manually typing on a keyboard. Follow the instructions below to connect and configure your barcode scanner device (or download the pre-built window at the bottom of the page).

Barcode Scanner component only works in Client

The Barcode Scanner component can only interface with a USB-based scanner device from a launched Client. The module does not work properly in Preview Mode in the Ignition Designer. It may 'appear' to work, but it will only behave based on the state of your scripting from the last time you launched a Client. In Preview Mode, new script edits will be ignored until a Client is launched and then the script the component follows will 'update' and behave with the current script state (and then remain as is until the next Client launch).


The Barcode Scanner Module has not changed from MES 1.0 to  MES 2.0 so this KB is applicable to both.


More info:

Barcode Scanner

Barcode Scanner Module Overview



Installation

The following are required:

  1. Barcode Scanning device (USB) with a configured preamble/prefix string.
  2. Sepasoft Barcode Scanner Module (software module for Ignition).
  3. Window built in Ignition (launched as a Client), running a Barcode Scanner component (and any other HMI elements to support the scanning activity).

Barcode Scanner Device

Follow the instructions in your barcode scanner's manual. Overall, it will require plugging the scanner into a USB port on the same computer that is running the the Barcode Scanner component on an Ignition window. The barcode scanner device will then need to be programmed to send whatever prefix/preamble your design requires (a unique string of characters that identifies the scanner to the Barcode Scanner component).

Default Preamble Value

The Sepasoft Barcode Scanner component has a default Preamble value of "\u0002" (without the quotes). Generally, this is just fine to use as a preamble/prefix in a production environment. Refer to the script function system.barcode.scanner.decode, which has more information on preamble/prefix, postamble and separator defaults.


Here is the manual for the barcode scanner device used for this KB : https://www.idautomation.com/barcode-scanners/programming-manuals/SC7-USB-2D-Barcode-Scanner-Manual.pdf 








Hand Held IDAutomation USB 2D Barcode Imager


Sepasoft Barcode Scanner Module

  1. Download the Sepasoft Barcode Scanner module from https://www.sepasoft.com/downloads/.


  2. Install the module from the Ignition Gateway page (Configure tab → Modules section) in the same way as installing other Sepasoft MES modules.



Sample Project

After installing the items above, follow the instructions below to build a sample project that will get your scanning device working in Ignition.

Ignition Window with Components

  1. Create a new window. Right-click on the window entry in the Project Browser and check the box for Open on Startup (so the page opens automatically when you launch the Client).

  2. Drag on an Ignition Text Field component. This will be where scanned barcode value will be displayed (pushed to it by the Barcode Scanner component you'll be adding next. Add an Ignition Label component with "Barcode Scan Value" if you want.

  3. Drag on a Barcode Scanner component.
    1. Set the Preamble string to whatever you configured your scanner with, or leave it at the default value of "\u0002" (no quotes).
    2. Set the Separator string to whatever you configured your scanner with, or leave it at the default value of "\u001D" (no quotes).
    3. Right-click on the Barcode Scanner component and select Scripting... Install the following sample script in the onBarcodeReceived event handler (if necessary, change 'Text Field' in the script above to whatever you named your text field component):

       script for onBarcodeReceived event handler
      #Store the result of the scan in a dictionary
      result = event.toDict()
      print result
      
      #Take the first index of that dictionary key and apply to variable
      barcodeText = result['Default'][0]
      
      ##EXAMPLE USE CASES:
      
      #Write the barcodeText to a text field on screen
      event.source.parent.getComponent('Text Field').text = barcodeText
      
      #Write the barcodeText to a tag in the Ignition Tag Server
      #tagPath = "Nuts Unlimited/Scan2"
      #system.tag.write(tagPath, barcodeText)
      
      #Write the barcodeText to a database
      #query = 'INSERT INTO someTable (columnName) VALUES (?)'
      #key = system.db.runUpdateQuery(query, [barcodeText], dbName, '', True, False)
      #print key

      The script above is similar to what is provided on the documentation page Barcode Scanner Module Overview, but with two of the display methods commented out for this sample project.








Launch and Test Your Window

  1. After saving your project, launch your new window as a Client (press F10).

  2. Scan anything with a barcode that you have handy. The code should be displayed in the Text Field component.

  3. Scan a different barcode and confirm that the code changes.

  4. (Optional) Follow the steps in Checking Scanner Configuration to increase the log level on the Barcode Scanner module, to provide more detailed output in the Console log:

     Sample Console log output
    17:25:46.761 [AWT-EventQueue-0] DEBUG PMIBarcodeController - ------- Resetting elapsed time: 23741. Looking for preamble of: \\u0002
    17:25:46.769 [AWT-EventQueue-0] DEBUG PMIBarcodeController - ------- Preamble found: \u0002. Start buffering...
    17:25:46.777 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, Ctrl, char: \uffff (?)
    17:25:46.778 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 6  buffer: 3  echo 0
    17:25:46.778 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.779 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, B, char: \u0002 ()
    17:25:46.780 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 9  buffer: 4  echo 0
    17:25:46.781 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.781 [AWT-EventQueue-0] DEBUG PMIBarcodeController - ########## Possible preamble = Keyevent ID: 402, B, char: \u0002 ()
    17:25:46.841 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, 0, char: \u0030 (0)
    17:25:46.843 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 71  buffer: 7  echo 0
    17:25:46.843 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.849 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, 7, char: \u0037 (7)
    17:25:46.850 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 79  buffer: 10  echo 0
    17:25:46.851 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.857 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, 2, char: \u0032 (2)
    17:25:46.858 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 86  buffer: 13  echo 0
    17:25:46.859 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.865 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, 7, char: \u0037 (7)
    17:25:46.866 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 95  buffer: 16  echo 0
    17:25:46.867 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.873 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, 8, char: \u0038 (8)
    17:25:46.874 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 103  buffer: 19  echo 0
    17:25:46.875 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.881 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, 5, char: \u0035 (5)
    17:25:46.883 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 111  buffer: 22  echo 0
    17:25:46.883 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.889 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, 1, char: \u0031 (1)
    17:25:46.890 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 119  buffer: 25  echo 0
    17:25:46.891 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.897 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, 0, char: \u0030 (0)
    17:25:46.899 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 126  buffer: 28  echo 0
    17:25:46.899 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.905 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, 1, char: \u0031 (1)
    17:25:46.906 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 134  buffer: 31  echo 0
    17:25:46.907 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.921 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, 1, char: \u0031 (1)
    17:25:46.922 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 151  buffer: 34  echo 0
    17:25:46.923 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.929 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, 2, char: \u0032 (2)
    17:25:46.930 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 159  buffer: 37  echo 0
    17:25:46.931 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.937 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, 8, char: \u0038 (8)
    17:25:46.938 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 166  buffer: 40  echo 0
    17:25:46.939 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.969 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Keyevent ID: 402, Enter, char: \u000a (
    )
    17:25:46.970 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Handled: true  Buffering: true  Elapsed Time: 198  buffer: 43  echo 0
    17:25:46.970 [AWT-EventQueue-0] DEBUG PMIBarcodeController - -
    17:25:46.971 [AWT-EventQueue-0] DEBUG PMIBarcodeController - ########## Possible preamble = Keyevent ID: 402, Enter, char: \u000a (
    )
    17:25:47.170 [AWT-EventQueue-0] DEBUG PMIBarcodeController -  *** Input Timeout KeyEventHandler SI (readtime 200) ***
    17:25:47.171 [AWT-EventQueue-0] DEBUG PMIBarcodeController -  si.buffer: [Key Pressed, B, \u0002]
     [Key Released, Ctrl, \uFFFF]
     [Key Released, B, \u0002]
     [Key Pressed, 0, 0]
     [Key Released, 0, 0]
     [Key Pressed, 7, 7]
     [Key Released, 7, 7]
     [Key Pressed, 2, 2]
     [Key Released, 2, 2]
     [Key Pressed, 7, 7]
     [Key Released, 7, 7]
     [Key Pressed, 8, 8]
     [Key Released, 8, 8]
     [Key Pressed, 5, 5]
     [Key Released, 5, 5]
     [Key Pressed, 1, 1]
     [Key Released, 1, 1]
     [Key Pressed, 0, 0]
     [Key Released, 0, 0]
     [Key Pressed, 1, 1]
     [Key Released, 1, 1]
     [Key Pressed, 1, 1]
     [Key Released, 1, 1]
     [Key Pressed, 2, 2]
     [Key Released, 2, 2]
     [Key Pressed, 8, 8]
     [Key Released, 8, 8]
     [Key Pressed, Enter, \n]
     [Key Released, Enter, \n]
    
    17:25:47.173 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Barcode Scanner si.Regex target 072785101128
      pattern: \u0002.* = found: true
    17:25:47.174 [AWT-EventQueue-0] DEBUG PMIBarcodeController - Barcode Scanner Decode Results: Default
    17:25:47.174 [AWT-EventQueue-0] DEBUG PMIBarcodeController - value[0] = 072785101128
    {u'Default': [072785101128]}
    17:25:47.177 [AWT-EventQueue-0] DEBUG PMIBarcodeController - si.buffer: 
    17:25:47.177 [AWT-EventQueue-0] DEBUG PMIBarcodeController - si.echo  : 
    17:25:47.178 [AWT-EventQueue-0] DEBUG PMIBarcodeController - *** End of Input Timeout, Elapsed Time: 406



  5. Done! You're ready to implement a barcode scanner in your production environment.


Barcode Scanner Sample Window

Here is the window pre-built and ready for you to run and experiment with (with the default preamble "\u0002"):
Barcode Scanner Sample Window