Appendix B - Coding For Pos Barcode Applications; Introduction; Suggested Application Structure; Suspending And Resuming The Application - Honeywell 26079 User Manual

Wearable solution with windows embedded
Table of Contents

Advertisement

B
Coding for POS Barcode Applications

Introduction

Using the Microsoft Point of Service API and the various application templates that are available (Pivot App, Hub App, etc), it is
fairly simple to develop a straightforward scanning application for a Windows 8.1 phone-based device. The online documenta-
tion at
https://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.pointofservice.aspx
However details are very important. For a truly practical, production-quality user experience, you must code for the following
application life cycle transitions:

• Suspending and resuming the application

• Switching back and forth between the scanning application and another application
• Connecting and disconnecting an external scanner
The scanner stack, that is, the structures created by creating, claiming, enabling, and providing enabled symbologies and set-
tings profiles, gets destroyed or corrupted on any of these transitions. It must be rebuilt when the application resumes. Therefore
the application life cycle state must be internally tracked to allow this rebuilding.
The following discussion assumes non-Silverlight application development in the NET framework (C#, managed C++, or Visual
Basic). Any coding below will be in C# syntax. Visual Basic and C++ will look similar.

Suggested Application Structure

You should add all scanner support as static objects in the singleton derived App object (for instance App : Application), which
all application templates provide for you when first creating the application. That way the scanning support is available to all
pages of your app. The App object also provides the callbacks supporting application lifecycle transitions.
Suspending and Resuming the Application
On creation of a Windows Phone project, the application template you choose will generate an App object that already has an
OnSuspending() callback method. You will probably need to generate your own OnResuming() callback method by chaining to
the application's Resume event, which should be pre-generated by the application template. In Visual Studio C#, there is good
support for creating such a method using the "+=" operator and the TAB key on the Resume event.
Be sure and track the acts of suspending and resuming in persistent state variables in the App object.
To restore scanning when resuming, call
BarcodeScanner
bcs = BarcodeScanner.CreateById();
ClaimedBarcodeScanner
• cbcs.EnableScanner();
• cbcs.SetActiveSymbologiesAsync( List<uint>symsToEnable );
• cbcs.SetActiveProfileAsync( List<string>profilesToEnable );

Switching Between Applications

This is similar to suspending and resuming. Your code doesn't need to know any difference.
Connecting and Disconnecting External Scanners
You will need to add a static instance of Windows.Devices.Enumeration.DeviceWatcher in order to receive callbacks when
the connection state of an external scanner changes. There are a number of callbacks that must be present in your code for full
support of connection changes:
DeviceAdded()
Called by the OS when a device connects. You should track this event in persistent state variables. When this event occurs,
you should recreate the scanning stack as follows:
BarcodeScanner
ClaimedBarcodeScanner
• cbcs.EnableScanner();
• cbcs.SetActiveSymbologiesAsync( List<uint>symsToEnable );
• cbcs.SetActiveProfileAsync( List<string>profilesToEnable );
cbcs = bcs.ClaimScannerAsync();
bcs = BarcodeScanner.CreateById();
cbcs = bcs.ClaimScannerAsync();
is clear and easy to use.
B - 1

Advertisement

Table of Contents
loading

Table of Contents