Barcode Scan States: To Create the Set of Scan States

This activity will walk you through the creation of the set of barcode scan states.

Story

Suppose that you are implementing a scan mode for a custom barcode-driven form. The barcode scan class of this form uses the WarehouseManagementSystem<TSelf,TGraph> base scan class.

You need to define two new scan states for this scan mode: one input state and one confirmation state. Three other input states will be inherited from the base scan class.

Process Overview

You will create particular instances of the ScanState<TScanState> class in the ScanMode<TScanBasis>.CreateStates() method.

System Preparation

Before you begin performing the step of this activity, do the following:

  1. Prepare an MYOB Acumatica instance as described in the Test Instance: To Deploy an Instance prerequisite activity.
  2. Create a barcode scan class as described in the Barcode Scan Class: To Create a Barcode Scan Class prerequisite activity.
  3. Define the required properties of the scan mode as described in the Barcode Scan Mode: To Define the Required Properties prerequisite activity.

Step: Defining the Set of Scan States

To create the set of scan states, in the scan mode class, add the following code.

public sealed class CountMode : ScanMode
{
    ...
  
    protected override IEnumerable<ScanState<INScanCount>> CreateStates()
    {
        yield return new RefNbrState(); // new state introduced in the CountMode
        yield return new LocationState(); // state inherited from WMSBase
        yield return new InventoryItemState(); // state inherited from WMSBase
        yield return new LotSerialState(); // state inherited from WMSBase
        yield return new ConfirmState(); // new state introduced in the CountMode
    } 
  
    ...
}