Zebra Plastic Card Printers.

Zebra Plastic Card Printers come in a variety of styles and price ranges, including single-sided printers, dual sided printers, and security printers

Healthy Solutions for Healthcare.

The healthcare industry benefits from barcoding. Barcoding enhances patient safety and operational efficiency.

Seagull Scientific Products

Seagull Scientific BarTender is an industry-leading label design and barcode software. Seagull Scientific also develops true Windows printer drivers for bar code and thermal printers.

MC 9190G

The Ability To Satisfy Your Company Software Requirements.

Wireless Broadband

The unrivalled Motorola portfolio of Point-to-Point (PTP), Point-to-Multipoint (PMP), and Mesh Wide Area Network (MWAN), WLAN and VoWLAN solutions make governments, enterprises, and service providers more agile by helping them deploy voice, video, and data applications right where they need them.

Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Monday, 4 May 2009

Scan & Store: Scan Barcodes directly into any Database

Are you looking for a basic inventory solution or you are just interested in registering items based on their barcode?

The data acquisition software TWedge provides an elegant solution - TWedge captures data from arbitrary devices (like a serial or USB barcode scanner) and can be configured to store captured data directly into any ODBC database.

Additional database software is NOT required! 

Smart Software Wedge

Configuration of TWedge is extremely flexible: The data acquisition functionality can be configured to meet your exact requirements. TWedge is able to perform read/write access to files, databases and may also simulate keystrokes.

To implement the required functionality you need:

  • A serial (or USB) barcode scanner. The used COM port as well as the interface parameters are important (most likely it will be 9600,N,8,1 - meaning 9600 bits per second, no parity, 8 data bits, 1 stop bit)
  • TWedge (download)

Determine Bluetooth COM Port

For this example I use a Bluetooth bar code scanner (Metrologic Voyager). The scanner provides scanned data via COM3. This serial interface was adjusted manually in the services dialog of the available Bluetooth Devices on Microsoft Windows:

Configure TWedge Interface

Now start TWedge and configure the interface parameters. Adjust COM3 as displayed in the Bluetooth dialog above:

Test Scanner Communication

The next step is to test the interface configuration: just start communication in TWedge. Whenever you scan a barcode the number should appear in the protocol window:

Provide a Database

Now its time to connect the barcode scanner with a database. For demonstration purposes we use an empty database which was pre-installed by the setup application of TWedge:  A so-called System DSN which is named TWedge_Sample.

On 32 bit Windows you can check out the installed DSN by opening the Data Sources (ODBC) administration (Windows Control Panel - Administrative Tools - Set up data sources (ODBC)). If you are running Vista x64 then execute the command c:\windows\SysWOW64\odbcad32.exe to view this dialog:

On Vista systems the database is usually stored in the folder C:\ProgramData\TEC-IT\TWedge\2.1\Examples\Database. When you open this database with Microsoft Access you see two tables. The example below stores captured data in the initial empty table tbl_Scans:

Configure Software Wedge

In order to configure TWedge open the script editor and select the predefined template which is named Database - Write. Double click it and close the script editor. This script reads data from the configured interface, determines the current date and time and enters the scanned data in the database mentioned above.

Data Acquisition

Start device communication again and scan some barcodes:

Finished! Barcodes are stored in Database

That's all! TWedge connects to the barcode scanner via the configured COM3. It waits for scans - and whenever a barcode was scanned it enters the barcode number into the database. And this is the result– the scanned barcodes are stored with some additional information like date/time and hostname:

Tuesday, 23 December 2008

Data Acquisition Software TWedge 2.0 Released

Merry Christmas!
It's Christmas. In Austria that usually includes snow, silence (for some people), last-minute gift-shopping (for most people) and holidays. For TEC-IT customers this also means that the new version of the data acquisition software TWedge was released to the public.

New and Flexible Data Acquisition Software
TWedge version 2.0 captures data from serial, USB, Bluetooth or TCP/IP based devices and forwards this data to arbitrary applications or databases.



The highlight of TWedge is the embedded scripting language (based on JavaScript). Using this scripting language any user can embed custom logic or data acquisition functions. It is very easy to extend the functionality of this software wedge, even direct database access functions (via ODBC) and file access methods are available.

Downloads
Check out the demo version: scriptable data acquisition software
Press release: Universal Data-Acquisition Software

Example (Simple)
After adjusting the interface for data acquisition (e.g. serial port COM1, 9600 baud, 8 data bits, 1 stop bit, no parity) TWedge should be supplied with at least one script which is called whenever data is received via the configured interface.

The perfect place for this script is the the OnData() section. TWedge also offers OnStart(), OnStop(), OnTimer() and OnHotkey() - I assume you guess what these scripts are for.

A very simple OnData() script looks like this:

// start of script
SendKeyStrokes(DATA);
// end of script

The function SendKeyStrokes() simple converts captured data into virtual keystrokes. In other words: Using this simple command TWedge works as keyboard wedge. The captured data is available in the variable DATA by default (TWedge ensures correct device communication).

Example (Complex)
A more complex script writes captured data into a database. OnStart() is used for database initialization and it gets called by TWedge automatically whenever the user invokes device communication:

// start of script
// open the database
if (!myDB.Open("DSN=TWedge_Sample;"))
{
MessageBox("Could not open database TWedge_Sample!");
return;
}

// delete all records stored in a previous session
myDB.Execute ("DELETE * from tbl_Scans");
// end of script

Each time TWedge receives data from the external device it calls the function OnData(). The OnData()-code below enters captured data into the database (along with the hostename and the current date/time):

// start of script
// get the current date and time
var d = new Date();
// d.getMonth returns the month zero-based (e.g. 0=January, 11=December); thus add 1
var sDate = (d.getMonth() + 1) + "-" + d.getDate() + "-" + d.getFullYear();
var sTime = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();

// build the INSERT statement
var insert = "INSERT INTO tbl_Scans (ProdID, ScanDate, ScanTime, Host) VALUES (";
insert += "'" + DATA + "', ";
insert += "'" + sDate + "', ";
insert += "'" + sTime + "', ";
insert += "'" + "localhost" + "');";

// execute the INSERT statement
var nRet = myDB.Execute(insert);
if (nRet < -1) MessageBox ("Error during INSERT:" + myDB.LastError); else if (nRet == -1) MessageBox ("This should not happen when executing an INSERT statement"); else MessageBox (nRet + " record(s) inserted!"); // end of script


Nice - But I don't know JavaScript!
Don't worry. TWedge comes with predefined scripts for common usage scenarios (e.g. keyboard wedge functionality). Just select the template which matches your requirements. Or contact TEC-IT for support.

End of Post
Merry Christmas and a Happy New Year!