Sepasoft MES Module Suite
batch.unit.changeAllocationPriority
Overview
The changeAllocationPriority script function updates the priority of a waiting unit allocation request. Use it when a batch is already active and competing for equipment, and you need to raise or lower its place in the allocation order. Requests that have already been allocated cannot be changed.
Syntax
Python |
system.mes.batch.unit.changeAllocationPriority(allocationRequest, newPriority) |
Required Parameters
|
Parameter |
Type |
Description |
|
allocationRequest |
BatchAllocationRequest |
The waiting allocation request to update. Typically obtained from getAllocationList(). |
|
newPriority |
Integer |
The new priority value. 1 is the highest priority. Lower numbers are preferred over higher numbers when the allocation manager selects the next request. |
Return Value
|
Type |
Description |
|
None |
The function returns no value. |
Priority Values
Common priority constants on BatchAllocationRequest:
|
Constant |
Value |
Meaning |
|
PRIORITY_HIGHEST |
1 |
Highest priority |
|
PRIORITY_HIGH |
25 |
High |
|
PRIORITY_DEFAULT |
50 |
Default (used when a request is first created) |
|
PRIORITY_LOW |
75 |
Low |
|
PRIORITY_LOWEST |
100 |
Lowest priority |
You can pass any integer; the constants above are conventional values. When multiple requests compete for the same unit or unit class, the allocation manager orders them by priority (ascending), then by request date/time.
Behavior Notes
|
Situation |
Behavior |
|
Waiting request found |
Priority is updated on the active request in the allocation list. |
|
Request already allocated |
Raises an exception. Allocated requests cannot have priority changed. |
|
Request not found / no longer active |
Raises an exception. The request must still be present in the active allocation list. |
|
Active batch vs. queue priority |
Once a batch is executing, use this function for unit allocation order. Use system.mes.batch.queue.changeEntryPriority() only while the batch queue entry is not active. |
Exceptions
|
Exception |
When |
|
Exception |
The specified request was not found or is no longer active. |
|
Exception |
The request has already been allocated. |
Scope / Availability
|
Context |
Availability |
|
Gateway scripts |
Available |
|
Client / Designer scripts |
Available via RPC |
|
Perspective / Vision |
Available when calling system.mes.batch.unit from script |
Example Usage
Minimal example
Python |
requests = system.mes.batch.unit.getAllocationList(0, 2147483647, '', False, True) system.mes.batch.unit.changeAllocationPriority(requests[0], 1) |
Raise priority for a waiting request by batch ID
Python |
batchID = 'BID-1001' pageSize = 2147483647 # Waiting allocations only (includeAllocation=False, includeWaiting=True) waiting = system.mes.batch.unit.getAllocationList(0, pageSize, '', False, True) for request in waiting: if request.getBatchID() == batchID: # 1 = highest; run ahead of other waiting requests for the same unit/class system.mes.batch.unit.changeAllocationPriority(request, 1) break |
Lower priority using a named constant
Python |
waiting = system.mes.batch.unit.getAllocationList(0, 2147483647, 'MixTank', False, True) for request in waiting: if request.getBatchID() == 'BID-1002': system.mes.batch.unit.changeAllocationPriority( request, request.PRIORITY_LOW # 75 ) break |
Related Functions
-
getAllocationList() — Returns active and/or waiting BatchAllocationRequest objects; use it to obtain the request passed to changeAllocationPriority.
- changeEntryPriority() (system.mes.batch.queue) — Changes batch queue entry priority while the entry is not active. Does not change unit allocation priority for an already-executing batch.
Sepasoft MES Module Suite