BatchUnitClass Object

Sepasoft MES Module Suite

BatchUnitClass Object

A BatchUnitClass is an MES object that defines which batch phases are available to equipment assigned to that class. Unit classes form a hierarchy under the root BatchRootUnitClass (Unit Classes). Child classes inherit phases from their parent chain and can add phases of their own. Recipes reference a unit class to constrain which phases can appear in unit-procedure steps, and MESUnit equipment objects are assigned to a unit class so the Batch Unit Manager and runtime know which phase UDTs to expose.

Obtain BatchUnitClass instances from system.mes.batch.unitclass helpers or by loading from an MESObjectLink.

Success Persist changes with system.mes.batch.unitclass.save() — not system.mes.saveMESObject().

Obtaining a BatchUnitClass

Python
# By name (returns MESObjectLink; call getMESObject() for the full object)
link = system.mes.batch.unitclass.getLink('Mixer Class')
unitClass = link.getMESObject()

# List child unit classes under the root
unitClasses = system.mes.batch.unitclass.getList(None, 0, 100, '')

# Create a new unsaved unit class (parent defaults to BatchRootUnitClass)
unitClass = system.mes.batch.unitclass.create('New Mixer Class', None)

# Copy configuration from an existing class
sourceLink = system.mes.batch.unitclass.getLink('Mixer Class')
unitClass = system.mes.batch.unitclass.copy(sourceLink, 'Mixer Class Copy')

Object Hierarchy

Relationship

Allowed type

Notes

Parent

BatchRootUnitClass or BatchUnitClass

Single parent only (SINGLE_PARENT). If none is set at save time, the root unit class is assigned automatically.

Children

BatchUnitClass

Nested unit classes; child names must still be globally unique across all unit classes.

Success

Phases are not copied into a new child at creation time. Instead, phases defined on ancestors are visible through getParentPhaseLinks() and getAllPhaseLinks(). Phases added directly on the class are returned by getPhaseLinks().

Core Properties

These properties are inherited from AbstractMESObject and apply to every BatchUnitClass.

Property

Access

Type

Description

Name

getName() / setName(name)

String

Globally unique unit class name.

Description

getDescription() / setDescription(description)

String

Optional description.

UUID

getUUID()

String

Stable object identifier.

Enabled

isEnabled() / setEnabled(value)

Boolean

Whether the object is active. Removal disables the object rather than deleting it.

Unit Icon Path

getPropertyValue('UnitIconPath') / setPropertyValue('UnitIconPath', path)

String

Path to an Ignition icon representing this unit class in the UI. Defaults to empty.

BatchUnitClass Methods

Method

Return type

Description

getMESObjectTypeName()

String

Returns BatchUnitClass.

asLink()

MESObjectLink

Lightweight link to this object (UUID, name, type).

getPhaseCount()

int

Number of phases assigned directly on this class (not including inherited parent phases).

getPhaseLinks()

List of MESObjectLink

Phase links assigned directly on this class.

getParentPhaseLinks()

List of MESObjectLink

Phases inherited from the parent unit class hierarchy. Returns an empty list when the parent is BatchRootUnitClass.

getAllPhaseLinks()

List of MESObjectLink

Union of inherited and directly assigned phases. Use this when determining which phases a class (and its equipment) can run.

addPhase(phaseLink)

None

Assign a BatchPhase to this class. phaseLink must reference a BatchPhase. Raises an exception if the phase is already on this class or already inherited from a parent.

removePhase(phaseLink)

None

Remove a directly assigned phase. Raises NoSuchElementException if the phase is not on this class.

removeAllPhases()

None

Remove every phase assigned directly on this class.

hasPhase(phaseLink)

Boolean

Returns True if the phase is assigned directly on this class (not inherited).

getChildLinks()

List of MESObjectLink

Child unit class links, sorted by name.

getPrimaryParentLink()

MESObjectLink

Link to the parent unit class or root.

getParentCollection()

MESObjectCollection

Parent links for this object.

getChildCollection()

MESObjectCollection

Child unit class links.

getLinksToRelatedObjects(includeOutgoingReferences)

List of MESObjectLink

Related master recipe logic and all phase links (direct and inherited).

isModified()

Boolean

Whether in-memory changes have not been saved.

Change-tracking helpers (phase edits)

Used internally during save validation; rarely needed in scripts.

Method

Return type

Description

isPhaseAdded()

Boolean

Whether a phase was added since load.

getAddedPhases()

Set of MESObjectLink

Phases marked as newly added.

isPhaseRemoved()

Boolean

Whether a phase was removed since load.

getRemovedPhases()

Set of MESObjectLink

Phases marked as removed.

Scope / Availability

Context

How to access

Gateway scripts

system.mes.batch.unitclass.* and methods on objects returned by those calls

Batch Designer / client scripts

Same module via RPC (BatchClientUnitClassScript)

Perspective / engineering

system.mes.batch.unitclass for CRUD; BatchUnitClassManager component for UI editing

Unit class names must be globally unique across the entire hierarchy, not just among siblings.

Events

Event

Name

Description

New

BatchUnitClass - New

Fires when a new unit class instance is created. Use to initialize defaults (for example, set UnitIconPath or assign standard phases).

Exceptions and Constraints

Situation

Behavior

addPhase(None) or non-BatchPhase link

Exception: "A link to a batch phase was not provided."

Duplicate phase on same class

Exception: phase name already added.

Phase already on a parent class

Exception: phase already added to a parent (prevents redundant assignment).

removePhase for a phase not on this class

NoSuchElementException

remove on a class with assigned units

Exception: units are still assigned.

Duplicate phase name across class and inheritance at save

Save validation fails via checkDuplicatePhases.

Save with duplicate global name

Exception: "A batch unit class named (…) already exists."


Success

Removing a unit class disables it, clears its direct phases, and requires that no MESUnit objects remain assigned to it and that no master recipe logic still references it.

Example Usage

Minimal example — look up a class and list available phases

Python
link = system.mes.batch.unitclass.getLink('Mixer Class')
unitClass = link.getMESObject()

for phaseLink in unitClass.getAllPhaseLinks():
    print(phaseLink.getName())

Complex example — create a child class, assign phases, and save

Python
# Resolve parent and phase links
parentLink = system.mes.batch.unitclass.getLink('Generic Vessel')
chargePhaseLink = system.mes.batch.phase.getPhaseLink('Charge')
mixPhaseLink = system.mes.batch.phase.getPhaseLink('Mix')

# Create and configure the new class
unitClass = system.mes.batch.unitclass.create('Reactor A Class', parentLink)
unitClass.setDescription('Phases for Reactor A vessels')
unitClass.setPropertyValue('UnitIconPath', 'material/factory')

# Inherited phases from parent are available via getAllPhaseLinks() without addPhase
# Add phases specific to this class
unitClass.addPhase(chargePhaseLink)
unitClass.addPhase(mixPhaseLink)

# Persist (required after create/modify)
savedClass = system.mes.batch.unitclass.save(unitClass)
print('Saved %s with %d direct phases' % (
    savedClass.getName(),
    savedClass.getPhaseCount()
))

List equipment assigned to a unit class

Python
classLink = system.mes.batch.unitclass.getLink('Reactor A Class')
assignedUnits = system.mes.batch.unitclass.getAssignedUnitLinks(classLink)

for unitLink in assignedUnits:
    print(unitLink.getName())

Copy an existing class and adjust phases

Python
sourceLink = system.mes.batch.unitclass.getLink('Reactor A Class')
copy = system.mes.batch.unitclass.copy(sourceLink, 'Reactor B Class')

# Remove a direct phase inherited from the copy source
phaseToRemove = system.mes.batch.phase.getPhaseLink('Mix')
if copy.hasPhase(phaseToRemove):
    copy.removePhase(phaseToRemove)

system.mes.batch.unitclass.save(copy)

Related Functions

Module: system.mes.batch.unitclass

Related modules:









Sepasoft MES Module Suite