Skip to main content
Version: Next

LMES Code Generation Process Logic

This document describes in detail the processing logic of the code generation link (GenerateCodeActivity), which is responsible for generating unique barcodes based on a series of rules and inputs.

Flowchart​

Detailed Processing Steps

1. Start and Function Check​

When the process flows to the "Code Generation" link, the system first determines whether the GenerateCode function is in the Enabled state from the process context data (ProcessModel).

  • Yes: If the function is enabled, the process continues to execute.
  • No: If the function is disabled, the system records the description "Code generation function disabled" in the process variable and directly ends the current link.

2. Read Context Info​

The system reads the following key information from the process data (Flow.DataItems) for subsequent barcode generation:

  • Product Identification Code (GenerateCodeProductVariableValue): A code used to uniquely identify the product, with the highest priority.
  • Customer Name (GenerateCodeCustomerNameVariableValue): Used to filter specific barcode rules in certain scenarios.
  • Barcode Rule ID (GenerateCodeBarcodeRule): Directly specify the GUID of the barcode generation rule to be used.

3. Determine Barcode Generation Rule​

The system determines which barcode generation rule (barcodeId) to use according to the following priority order based on the read information:

3.1. Based on "Product Identification Code"​

If a Product Identification Code is provided:

  1. The system uses this identification code to query the corresponding product model (ProductModel).
  2. If the product model cannot be found, the process records an error message and terminates.
  3. If the product is found, the system combines Section ID and Product ID to query the most matching barcode generation rule.

3.2. Based on "Barcode Rule ID" (Hidden Feature, Secondary Development Extension)​

If no product identification code is provided, but a Barcode Rule ID is directly specified:

  1. The system attempts to parse the string into a GUID.
  2. If parsing fails, the process records an error message and terminates.
  3. If parsing succeeds, this GUID is directly used as the barcode generation rule ID.

3.3. Based on Current Context (Work Order/Formula)​

If none of the above information is provided:

  1. The system calls the GetCurrentProduct method to attempt to infer the product currently being produced from the currently applied Formula, Work Order, or Inspection Task.
  2. If the current product cannot be determined, the process records an error message and terminates.
  3. If the product information is successfully obtained, the system uses the Product ID, Process ID, and optional Customer Name to query the matching barcode generation rule.

4. Generate Barcode​

After successfully determining the barcode generation rule ID (barcodeId):

  1. If barcodeId is empty (i.e., no applicable rule is found), the process records an error message and terminates.
  2. The system calls the barcode service (IBarcodeProvider.GenerateAsync), passing in barcodeId, Process ID, and Station ID, to request the generation of a new barcode.

5. Distribute Generation Result​

The return result of the barcode generation service determines the final status of the process:

  • Success:

    • The generated barcode string is written into the process data GenerateCodeBarcodeVariableValue.
    • The system records a success log containing the generated code content.
  • Failure:

    • The failure reason and related error information are written into the process data GenerateCodeDescriptionValue.
    • The system records a warning log containing detailed failure reasons.

6. End​

After completing the result distribution, the logic execution of the GenerateCodeActivity link is completed, and the process continues to flow to the next step according to the design. Subsequent operations such as signal reset and result clearing are handled by other links in the process.