Sepasoft MES Module Suite
system.mes.batch.queue.addEntry(masterRecipeLink, batchName, batchID, priority, scale, quantity, unitAssignments, batchParameters, processCellPath)
Adds a new batch to the batch queue. For enterprise, see Enterprise Batch Queue Management.
addEntry(masterRecipeLink, batchName, batchID, priority, scale, quantity, unitAssignments, batchParameters, processCellPath) → BatchQueueEntry
Syntax
addEntry(masterRecipeLink, batchName, batchID, priority, scale, quantity, unitAssignments, batchParameters, processCellPath)
Parameters
MESObjectLink masterRecipeLink - A link to the master recipe to execute.
|
Version specific: As of MES 3.81.11 RC1 MESObjectLink can reference a BatchMasterRecipe or a BatchFormula. |
String batchName - Optional name of the batch for reference. Multiple batches can have the same batchName.
|
Version specific: As of MES 3.81.10 SP7 and later, the parameter batchName is optional. |
String batchID - A unique batch ID for the batch. Batch IDs cannot be reused for any batches in the queue or that have previously been run.
Integer priority - The numeric priority with 1 being the highest. This is used for general reference and by the allocation manager.
Double scale - Optional value that can be used in calculations within the recipe.
Double quantity - Required size of the batch. This can be used in calculations within the recipe. It is also used by the allocation manager to ensure it falls between unit capacities during assigning allocations.
|
Versions 3.81.6 RC 2 and later: Added parameters to this function: unitAssignments, batchParameters, processCellPath |
PyDictionary unitAssignments - Optional. A Python dictionary specifying the units to use for this batch where the key is the name of the Unit Procedure and the value is the unit equipment path.
Example:
{'Unit Procedure 1':'Enterprise\\Site\\Area\\Process Cell\\Unit A'}Optionally, pass in None for no assignments. When no units are assigned, the batch system automatically assigns the first unit under the Process Cell in the equipment hierarchy as defined in the Equipment Model under Equipment Manager.
If one or more invalid unitAssignments are passed in the dictionary, then an exception is thrown stating such.
PyDictionary batchParameters - Optional. A Python dictionary specifying batch parameter values at the Procedure level as parameter name-value pairs. Example: {'Param1':10, 'Param2':True}. Optionally, pass in None for no assignments.
String processCellPath - Optional. A process cell path if creating recipes from the Enterprise Root, the path needs to match where the recipe will sync.
Returns
A BatchQueueEntry for the new batch.
Scope
All
Using the system.mes.batch.queue.addEntry Function
These scripting examples detail how to programmatically create and manage batch entries within a Manufacturing Execution System (MES), a critical capability for modern production environments. The strategic importance of this function lies in its ability to automate production scheduling and enable seamless integration with external systems, such as an Enterprise Resource Planning (ERP) platform. By leveraging this function, organizations can achieve centralized control over distributed manufacturing operations, ensuring data consistency and process integrity. To effectively use this function, it is essential to first understand the foundational equipment model concepts that inform the function's parameters.
Foundational Concepts: The ISA88 Equipment Model
A clear understanding of the physical equipment model is essential for correctly targeting batch operations. The MES Batch Procedure module is designed to be compliant with the ISA88 standard, providing a structured and hierarchical representation of production assets. This model ensures that scripts can reliably and unambiguously direct batch jobs to the correct physical equipment on the plant floor.
Process Cell
A Process Cell is a logical grouping that represents all the physical equipment required for a complete production line. This can encompass various manufacturing types, including continuous processes, converting lines, discrete manufacturing, or packaging lines. It serves as the primary container for a set of related production activities.
Unit
A Unit represents a specific piece of equipment where a batch control operation is executed. During batch execution-time, there is a strict one-to-one relationship between a Unit Procedure (a step in a recipe) and a physical Unit. A Unit is allocated to a Unit Procedure when the Unit Procedure step becomes active in the recipe, linking the procedural logic to the physical asset that will perform the work.
Equipment Hierarchy
The equipment model follows a clear hierarchical path structure, which is used to uniquely identify any asset within the enterprise. This path is fundamental for targeting batch operations correctly.
Enterprise > Site > Area > Process Cell > Unit
With these core concepts established, we can now examine the detailed syntax and parameters of the system.mes.batch.queue.addEntry() function itself.Function Deep Dive: system.mes.batch.queue.addEntry()
The system.mes.batch.queue.addEntry() function is the primary scripting command for creating new batch entries in the MES queue. It provides a powerful interface for automating the initiation of production runs with precise control over recipe selection, quantity, and equipment allocation. This section deconstructs its syntax and defines its most critical parameters.
Function:
system.mes.batch.queue.addEntry(masterRecipeLink, batchName, batchID, priority, scale, quantity, unitAssignments, batchParameters, processCellPath)
Key Parameter Definitions for these examples:
masterRecipeLink: The link to the master recipe that this batch will execute.
batchName: The unique name for the batch entry.
batchID: The unique identifier for the batch entry.
priority: The priority of the batch in the queue.
scale: The scale for the batch execution.
quantity: The quantity for the batch execution.
unitAssignments: A dictionary used to explicitly allocate a specific Equipment Unit to a procedure within the recipe (e.g., {'P2': unitPath}).
processCellPath: The explicit equipment path to the Process Cell that should run the batch.
The system uses these parameters to construct and place the batch job. The processCellPath, in particular, is a key argument that directly influences the system's logic for determining where the batch should be executed, as detailed in the following section.Core Operational Logic and Process Cell Targeting
The system employs a sophisticated logic to determine the correct Process Cell for a new batch entry. This logic is crucial for ensuring that batches are executed on the intended equipment, especially in a distributed environment with multiple sites or production lines. The behavior is primarily driven by the processCellPath parameter and the context from which the function is called.
Conditional Behavior (from Enterprise Level)
When the system.mes.batch.queue.addEntry() function is called from the Enterprise level, its behavior changes based on whether the processCellPath is provided.
When processCellPath IS provided:
The Batch Queue Entry is created directly on the target Site gateway. It is then synchronized up to the Enterprise for centralized visibility.
When processCellPath IS NOT provided:
Scenario 1: If the Enterprise itself has a configured Process Cell, the system assumes the Enterprise can execute the batch. The entry is created at the Enterprise level and will not sync down to a Site.
Scenario 2: If the Enterprise does not have its own Process Cell, the entry automatically syncs down to the Site that is capable of executing the associated recipe.
The four targeting methods detailed below are the mechanisms the system uses to determine the Process Cell, which in turn dictates which of the conditional Enterprise-level synchronization behaviors is triggered.
Methods for Targeting a Process Cell
There are four primary methods the system can use to identify the target Process Cell for a new batch:
Direct Specification: Providing the explicit equipment path in the processCellPath argument. This is the most direct and unambiguous method.
Unit Derivation: Deriving the Process Cell from the parent of a Unit specified in the unitAssignments argument.
Automatic (Single Cell): In a simple configuration with only one Process Cell, the system will automatically select it without requiring an explicit path.
Unit Class Derivation: Deriving the Process Cell from the parent of a Unit that is assigned to the Unit Class specified within the recipe's Unit Procedure.
The following section provides practical code examples to demonstrate how this logic is applied in common implementation scenarios.
Practical Implementation: Code Examples
This section presents three practical, scripted examples that demonstrate how to add batch queue entries in different common scenarios. These examples range from a simple, single-cell setup to more complex configurations involving explicit equipment allocation, illustrating the flexibility of the system.mes.batch.queue.addEntry() function.
Example 1: Implicit Process Cell in a Single-Cell Environment
Scenario: In a simple site-level configuration with only one Process Cell, the processCellPath parameter is not required. The system can automatically infer and assign the batch to the correct queue. This automatic assignment is based on the Unit Procedure configuration within the batch recipe, where a Unit Class is selected, which in turn links to the site's available Equipment Units.Python |
#Getting required params and objects bid = 'batch123' recipeClassName = 'Test' recipeName = 'ConsumeMaterialLot' recClassLink = system.mes.getMESObjectLinkByName('BatchMasterRecipeClass', recipeClassName) masterRecipeLink = system.mes.batch.recipe.getRecipeLink(recipeName, recClassLink) system.mes.batch.queue.addEntry(masterRecipeLink=masterRecipeLink, batchName=bid, batchID=bid, priority=1.0, scale=1.0, quantity=1.0) |
Example 2: Explicitly Specifying the Process Cell
Scenario: In an environment with multiple Process Cells, it is best practice to explicitly direct the batch to the correct production equipment. This script uses the processCellPath argument to remove any ambiguity.Python |
#Getting required params and objects bid = 'batch123' recipeClassName = 'Test' recipeName = 'ConsumeMaterialLot' recClassLink = system.mes.getMESObjectLinkByName('BatchMasterRecipeClass', recipeClassName) masterRecipeLink = system.mes.batch.recipe.getRecipeLink(recipeName, recClassLink) processCellPath = 'New Enterprise\\New Site\\New Area\\New Process Cell' system.mes.batch.queue.addEntry(masterRecipeLink=masterRecipeLink, batchName=bid, batchID=bid, priority=1, scale=1.0, quantity=1.0, processCellPath=processCellPath) |
Outcome Analysis: The explicit processCellPath argument ensures the batch is added to the batch queue of the specified "New Process Cell". This method is essential for reliable scheduling in complex manufacturing environments.
Example 3: Specifying Process Cell and Equipment Allocation
Scenario: This advanced example demonstrates how to not only target a Process Cell but also pre-assign a specific Equipment Unit (Unit 5) to a procedure within the batch recipe (identified by the name 'P2').
Code:
Python |
#Getting required params and objects bid = 'batch123' recipeClassName = 'Test' recipeName = 'ConsumeMaterialLot' recClassLink = system.mes.getMESObjectLinkByName('BatchMasterRecipeClass', recipeClassName) masterRecipeLink = system.mes.batch.recipe.getRecipeLink(recipeName, recClassLink) unitPath = 'New Enterprise\\New Site\\New Area\\New Process Cell\\Unit 5' system.mes.batch.queue.addEntry(masterRecipeLink=masterRecipeLink, batchName=bid, batchID=bid, priority=1, scale=1.0, quantity=1.0, unitAssignments={'P2':unitPath}) |
Outcome Analysis: The unitAssignments dictionary forces the allocation of Unit 5 to the P2 procedure for this specific batch run. This provides granular control over equipment usage. The Process Cell is derived using the "Unit Derivation" method described previously, as the system identifies the parent of the explicitly assigned Unit 5.
These practical examples transition from the "how-to" of scripting to the broader strategic context of using these functions within an enterprise architecture.
System Design Philosophy
A fundamental design principle of this architecture is the prioritization of data correctness over system availability. In practice, this means batch operations are designed to fail if network connectivity to a remote site is down. This intentional behavior prevents data discrepancies that could arise from operating on stale information, guaranteeing that all decisions are based on the most current and accurate state of the system.
ERP Order Update Workflow
A common application of enterprise-level batch operations is handling order modifications from an external system like an ERP. The following workflow demonstrates how to use the full suite of batch commands to ensure data integrity when an order is updated.
Receive Change Notification: The Enterprise gateway receives a notification from the ERP system that an existing production order has been modified.
Verify Batch Status: Before making changes, the system checks if the corresponding batch has already started by calling system.mes.batch.queue.getStatus(batchID).
Remove Existing Batch (If Inactive): If the status check confirms the batch has not yet started, the old, outdated batch entry is deleted by calling system.mes.batch.queue.removeEntry().
Create New Batch with Updated Data: Finally, a new batch entry is created with the updated information from the ERP by calling system.mes.batch.queue.addEntry().
This deliberate workflow, born from the system's design philosophy, is further governed by a set of strict operational rules essential for maintaining system integrity.
Important Considerations and System Limitations
To build robust and predictable workflows, it is crucial to understand the system's operational rules and limitations. Adhering to these constraints will prevent unexpected errors and ensure system integrity.
Command Execution Restrictions
There is an absolute rule governing command execution: The Enterprise is explicitly forbidden from executing commands on a Site child Batch. To "reset" a batch, users must call the system.mes.batch.queue.removeEntry() function. Attempting to execute other commands from the Enterprise to modify a batch's state will fail.
Understanding Race Conditions
A potential race condition can occur during a multi-step batch update process. For example, if a user fetches batch information, modifies it locally, then deletes the old batch to add the new one, another user could modify the batch on the remote system between the read and delete operations. This could lead to inconsistent data.
However, this is not a concern under the following two conditions:
The new batch being created is not based on the data from the old one.
The system enforces a policy where batches are immutable and are never written to after their initial creation.
Adherence to these guidelines and a clear understanding of the function's operational logic are crucial for implementing successful and reliable batch automation solutions.
Sepasoft MES Module Suite