BatchMasterLogic Object

Sepasoft MES Module Suite

BatchMasterLogic 

In the Sepasoft MES Module Suite, the BatchMasterLogic object serves as the foundational architectural container for all recipe-related logic. It is designed to encapsulate the procedural requirements of a batch process, functioning either as a reusable template or as a functional reference within a higher-level workflow. From a systems architecture perspective, this object ensures that logic remains consistent and manageable across the entire batch execution lifecycle by providing a structured environment for Procedures, Unit Procedures, and Operations.

Properties

The following table outlines the core properties that define a BatchMasterLogic object:

Property
Description

UUID

A Universally Unique Identifier providing a distinct link to the object within the MES database.

Name

The user-defined string used to identify the logic object.

Description

A user-provided explanation of the logic object's purpose or function.

Enabled

A boolean flag indicating whether the logic is active and available for use in the system.

Creator

Login details at time of creation

Logic Type

Defines the structural level: Procedure, Unit Procedure, or Operation.

See Batch Procedure Recipe Elements and Valid Workflow Structures in Batch Procedure.

Procedure
Unit Procedure
Operation

The system differentiates between these logic types to maintain procedural integrity. While a Procedure or Operation focuses on logical flow, a Unit Procedure specifically requires an Equipment reference. This reference links the logic to a Batch Unit Class; failing to provide a valid equipment link prevents the logic from interacting with the physical production model. Beyond these static attributes, the object utilizes dynamic methods to construct the actual workflow and logic steps.

Equipment

This is only required if the Logic Type is set to Unit Procedure. It is a reference to a Batch Unit Class and represents the equipment that is required for the Unit Procedure

Steps

This is a complex property that holds logic steps that are the elements of the SPC diagram

MESPropertyUUID Unique identifier
Name User-given name
Enable Enable for use in the system
Phase Reference refers to the Phase to execute
Element Type

Batch Recipe Logic Validation

See Batch Batch Recipes

Start
Terminator
SubLogic
Phase
OrBegin
OrEnd
AndBegin
AndEnd
TimeStamp

Timestamp on save

Transitions

This is a complex property that holds logic transitions that are the conditions of the workflow.

MESPropertyUUID
Name
Enable
Expression
TimeStamp

Links

This is a complex property that holds the links that define the connections between the Steps and Transitions

MESPropertyUUID
Name
Enable
SourceRef
DestinationRef
TimeStamp

Parameters

This is a complex property that holds phase-parameter definitions. This is the same complex property class as used by the BatchPhase class

MESPropertyUUID Unique identifier
Name User-given name
Enable Enabled in the system
Type
Input (Read only tags that can be read from field devices)
Output (Value will be written to tags that can be sent to field devices)
Parameter Value Origin

Fixed value in recipe

Prompt operator

Calculated

Defer to Operation, Unit Procedure, or Procedure parameter values.

Data Type

String

Byte

Short

Integer

Long

Float

Double

Date

Boolean

Reference (this type of parameter holds a UUID to another object. In the batch recipe editor component, the UUID is converted to a readable name.)

Enum Definition Name

(If this property is defined, then the value can only be a valid ENUM option.)

Current Value

(The Value and Current Value properties will equal each other unless an Enum Definition Name is defined. In that case, the Current Value property will equal the ENUM name and the Value will equal the ENUM ordinal value. For example, if Test = 1, then the Current Value property will equal “Test” and the Value property will equal 1.

Value

(See Current Value above)

Default Value

Value by default

Minimum Value

Minimum value allowed

Maximum Value

Maximum value allowed

Enable Expression

(This is a logical expression that evaluates to determine if a parameter should be enabled. The expression can only refer to other parameters of the same BatchPhase. For example, a parameter named mode can be set to ‘Concentration’ or ‘Amount’, and enabled states for other parameters can change based on the expression of Mode = ‘Concentration’ or Mode = ‘Amount’ )

Calculation

Ignition tag expression can be used but then the calculation will not be synchronized between MES servers in an enterprise architecture.

TimeStamp

System timestamp

BatchMasterLogic Methods and Property Values

Note

In MES 3.81.12 SP5, MES 4.83.1 SP5, and later, addStep can be called with only a phase name or a phase link. Omitted arguments are filled in.

Argument

When it is omitted

stepOrder

The next available order is used.

name

For a Unit Procedure or Operation step, the name of the logic object is used when that object was passed in. Otherwise the name is generated the same way as in the Recipe Editor: the logic prefix plus the step order. Procedure steps use P, Unit Procedure steps use UP, and Operation steps use O. Examples: P1, UP2, O3. If that name is already used, _1, _2, and so on are appended.

Logic reference

Required when the phase is Unit Procedure or Operation. Pass the logic object or a link to it. Other phases do not take a logic reference.

A phase name, phase link, or phase object is required. These calls add a normal phase step at the next order, with a generated name:

Python
step = logic.addStep('Timer 10')
step = logic.addStep(system.mes.batch.phase.getPhaseLink('Timer 10'))

These calls set the name, the order, or both:

Python
logic.addStep('Mix', 'Timer 10')
logic.addStep(4, 'Timer 10')
logic.addStep('Mix', 4, 'Timer 10')
logic.addStep('Mix', system.mes.batch.phase.getPhaseLink('Timer 10'))

A Unit Procedure or Operation step also needs the logic created with createLogic:

Python
unitProcedure = procedure.createLogic('Charge Tank')
procedure.addStep(unitProcedure)

operation = unitProcedure.createLogic('Heat')
unitProcedure.addStep('Heat', operation)

The same calls accept a phase link or logic link in place of the phase name or logic object. addStep(name, stepOrder, phaseLink, logicRefLink) is unchanged.

If addStep is called before a Start step exists, a Start step is still inserted and linked to the new step. The Start step is created from the Start phase, so the expected Start parameters are present.

BatchQueueEntry


Method

Same as

getControlRecipeLink()

getRecipeControlLink()

getRecipeLink()

getRecipeControlLink()

getRecipe()

Returns the BatchControlRecipe for the queue entry.

getControlRecipe()

getRecipe()


BatchMasterRecipe and BatchControlRecipe


Method

Same as

getProcedureLogic()

Returns the procedure logic for the recipe.

getProcedure()

getProcedureLogic()


Name

Description
addLink(int sourceStepOrder, int destStepOrder)

Adds an outgoing link from the source step to be an incoming link on the destination step.

addStep(String name, int stepOrder, MESObjectLink phaseLink, MESObjectLink logicRefLink)

Adds a new step to the Logic with the given name and order with the type of the phase link passed in. This should be a Unit Procedure or Operation phase type. The logicRefLink should be created from createLogic. Do not use templates directly, always go through the BatchMasterLogic.createLogic method. Returns the new BatchMasterLogicStepsProperty.

addStep(String name, int stepOrder, MESObjectLink phaseLink)

Adds a new step to the Logic with the given name and order with the type of the phase link passed in. Returns the new BatchMasterLogicStepsProperty.

createLogic(String name)

Creates Unit Procedure or Operation logic using the specified name, returns the created BatchMasterLogic representing the Unit Procedure or Operation.

createLogic(MESObjectLink templateLink, String name)

Creates Unit Procedure or Operation logic using the specified name from a template link. This returns all the BatchMasterLogic copied from the template, with the passed in template BatchMasterLogic being at index 0.

isTemplateValid()

Boolean

Returns void

getLogicType() Returns Batch logic types
setUnitClassRef(MESObjectLink mesObjectLink) Returns void
getUnitClassRef() Returns MESObjectLink
getSteps() List < BatchMasterLogicStepsProperty >
getStepsWithSublogic() List<BatchMasterLogicStepsProperty>
getSublogicLinks() List<MESObjectLink>
addParameter(String name) AbstractBatchParametersProperty
removeParameter(String name) Returns void
renameParameter(String existingName, String newName) Returns void
removeAllParameters() Returns void
getAllParameters() List<BatchMasterParametersProperty>
getParameters(BatchItemPath filterPath) List<BatchMasterParametersProperty>
getVisibleParameters(BatchItemPath filterPath) List<BatchMasterParametersProperty>
getParameter(BatchItemPath paramPath) BatchMasterParametersProperty
findParameterByFriendlyName(String paramFriendlyName) BatchMasterParametersProperty
getParameterValueAsString(BatchItemPath paramPath) Returns string

Returns the BatchMasterLogic Object:

  • system.mes.batch.recipe.createTemplate(name, parentLink)

Workflow Construction: Steps, Links, and Transitions

Steps and links form the "connective tissue" of a batch process, defining the sequential and conditional flow of operations. Precise ordering and phase referencing are essential to ensure the MES execution engine follows the intended path without conflict.

The addStep method is the primary tool for building this structure. It exists in two main variations:

Note

In MES 3.81.12 SP3, MES 4.83.1 SP3, and later, addStep adds a Start step when the logic does not already have one, then links that Start step to the step you are adding. The Start step uses the order you passed. Your step’s order is one higher. If you add the Start step yourself, add the link yourself.

  • addStep(name, phaseLink) adds a step at the next order. The next order is one higher than the highest order already on the logic. The first step is order 0.
  • addStep(phaseLink) adds a step at the next order and assigns the name. The name is the logic-type prefix plus the order. Unit Procedure and Unit Procedure Template use UP, so the first unnamed step is UP0. A name that is already used becomes UP0_1, UP0_2, and so on.
  • setTransitionExpression(expression) sets Transition_Expression on a Transition step. On any other step, it does nothing.
  • getTransitionExpression() returns Transition_Expression on a Transition step. On any other step, it returns None.
  • getPhaseType() returns the phase type. getLogicPhaseType() returns the same type.
  • getOrder() returns the step order. getLogicOrder() and getStepOrder() return the same order. 
  1. Standard Step: addStep(String name, int stepOrder, MESObjectLink phaseLink) — Adds a functional step at a specific point in the sequence.

  2. Reference Step: addStep(String name, int stepOrder, MESObjectLink phaseLink, MESObjectLink logicRefLink) — Adds a step requiring a link to Unit Procedure or Operation logic. The logicRefLink must be derived from an object created via the createLogic method.

To guide the definition of step functions, the programmer must specify an Element Type. Valid types include:

  • Start / Terminator: Defines the entry and exit points of the logic.

  • Phase: Represents an individual execution phase.

  • SubLogic: Allows for nested logic structures.

  • AndBegin / AndEnd and OrBegin / OrEnd: Defines parallel or alternative execution paths.

Once steps are defined, the addLink(int sourceStepOrder, int destStepOrder) method creates an outgoing link from the source step to serve as an incoming link on the destination. By linking these stepOrder integers, the programmer dictates the exact path the batch engine will follow.

Script Example

Create a Batch Recipe based on a Template

This example uses an existing Unit Procedure template to build out a recipe via script.

Reference documentation for this example:

Python
# Load recipe class and template
recipe_class = system.mes.batch.recipe.loadRecipeClass('Template Test', None)
template = system.mes.batch.recipe.loadTemplate('GUI Template', None)

# Create a new Recipe
recipe = system.mes.batch.recipe.createRecipe('Script Using Template Example', recipe_class.asLink())

# Add procedures to recipe...
procedure = recipe.createLogic('Procedure')

# Create 2 Unit Procedures from the first item in the template list 
unit_procedure_1 = procedure.createLogic(template[0].asLink(), 'Unit Procedure')
unit_procedure_2 = procedure.createLogic(template[0].asLink(), 'Unit Procedure')

# Add steps to the procedure
procedure.addStep("P1", 1, system.mes.batch.phase.getBuiltInPhaseLink('Start'))
# Note additional argument that sets the unit procedure logic from what was created above
p2 = procedure.addStep("P2", 2, system.mes.batch.phase.getBuiltInPhaseLink('Unit Procedure'), unit_procedure_1[0].asLink())
p3 = procedure.addStep("P3", 3, system.mes.batch.phase.getBuiltInPhaseLink('Transition'))
# Note additional argument that sets the unit procedure logic from what was created above
p4 = procedure.addStep("P4", 4, system.mes.batch.phase.getBuiltInPhaseLink('Unit Procedure'), unit_procedure_2[0].asLink())
p5 = procedure.addStep("P5", 5, system.mes.batch.phase.getBuiltInPhaseLink('Transition'))
procedure.addStep("P6", 6, system.mes.batch.phase.getBuiltInPhaseLink('Terminator'))
p3.setParameterValue('Transition_Expression', 'P2.Complete = True')
p5.setParameterValue('Transition_Expression', 'P4.Complete = True')

# Configure links
procedure.addLink(1, 2)
procedure.addLink(2, 3)
procedure.addLink(3, 4)
procedure.addLink(4, 5)
procedure.addLink(5, 6)

# Save the recipe and all the logic
saveList = system.mes.object.list.createList()
saveList.add(recipe)
saveList.add(procedure)
# Note unit_procedure_1 and unit_procedure_2 are lists and can have additional logic for Operations, add all items to the save list
saveList.addAll(unit_procedure_1)
saveList.addAll(unit_procedure_2)
system.mes.batch.recipe.saveRecipe(saveList)


Sepasoft MES Module Suite