Barcode Scan Class: General Information
A barcode scan class is the main class of a barcode-driven form.
Learning Objectives
In this chapter, you will learn how to do the following:
- Create a barcode scan class
- Make the barcode scan class usable
Applicable Scenarios
You create a barcode scan class if you are creating a custom barcode-driven MYOB Acumatica form.
Core Class
BarcodeDrivenStateMachine<TSelf, TGraph> is the core class of the MYOB barcode-driven engine. This is a generic graph extension that connects all components of the barcode-driven engine. The class implements the IBarcodeDrivenStateMachine interface and inherits from the PXGraphExtension<TGraph> class. All components can access the core class via their Basis property.
using
directive for the
PX.BarcodeProcessing
namespace to the source files.The core class contains the components shown in the following diagram. For details about the properties and methods of the core class, see BarcodeDrivenStateMachine<TSelf,TGraph> Class.
Barcode Scan Class
- The class is enclosed with itself in the
TSelf
type parameter. All the components of the barcode scan class will have the TScanBasis type parameter set to the class passed into theTSelf
type parameter. - The class has a host graph in the
TGraph
type parameter. For details about the host graph, see the next section of this topic.
You then implement abstract members of the barcode scan class.
As is true of any other graph extension, the barcode scan class can contain views, actions,
event handlers, and any other types of members. However, to make the barcode-driven part of
the extension work, you must implement the CreateScanModes()
abstract
method. This method returns the set of scan modes available on the barcode-driven form. The
scan mode creates and maintains scan states, transitions between them, available commands,
and user dialogs. Scan modes are parameterized with the current barcode scan class type.
Host Graph
The host graph is a supplementary graph that connects the barcode scan class with the target graph to which the barcode-driven engine functionality is applied.
You can use one of the following ways to introduce a host graph:
- By making the host graph an empty descendant of an existing graph.
With this approach, you reuse the business logic of the existing graph, while the barcode scan class is applied only to that descendant and not to the original graph. Therefore, both versions of the graph (the original one and the one with the barcode scan functionality) are available in the system.
The barcode scan class and all its components can use the inherited functionality of the host graph by accessing the Graph property of the barcode scan class.
- By making the host graph a new empty graph (that is, a direct descendant of the
PXGraph<T>
class).This approach is useful when the original graph you want to utilize is pretty expensive to use, so you want to instantiate it manually and only when it is actually needed. That is, you want to instantiate it manually only when the barcode scan class applies the changes accumulated during scan cycles.