OEE | Scheduling OEE Production Runs by Material via Scripting
Schedule Production Runs via Scripting
Example Scripts for scheduling production runs based on material information or work orders.
Scheduling with existing Work Orders
|
woName = 'WO123' eqPath = 'JR Brews\\EDH\\Packaging\\Packaging Line 1' newStartDate = system.date.addHours(system.date.now(),2) quantity = 1000
woObj = system.mes.workorder.getMESWorkOrder(woName) matObj = system.mes.loadMESObject(woObj.getMaterialRefUUID())
searchPattern = matObj.getName() + '-*' + eqPath.replace('\\',':')
results = system.mes.getAvailableOperations(eqPath,searchPattern, False, True)
if results.size() == 1: opDef = results.get(0).getMESObject() allowOverlapping = False category = 'Active' schedule = system.mes.createSchedule(opDef) scheduleList = system.mes.scheduleOperations(schedule, newStartDate, allowOverlapping, category) for ndx in range(scheduleList.size()): scheduleOperations = scheduleList.get(ndx) objTypeName = scheduleOperations.getMESObjectType().getName() if objTypeName == 'OperationsSchedule': scheduleOperations.setScheduleProductionCount(quantity) elif objTypeName == 'RequestSegment' and (scheduleOperations.getComplexPropertyCount('ResponseMaterial') > 0): if scheduleOperations.getAvailableMaterialOptions('Material Out').size() > 0: scheduleOperations.setMaterial('Material Out', matObj.getName(), eqPath, quantity) system.mes.saveSchedule(scheduleList)
|
Scheduling without Work Orders
|
def scheduleMatRun(matName, line, startDate, startTime, qty): lineObj = system.mes.loadMESObject(line, 'Line') eqPath = lineObj.getEquipmentPath() matList = system.mes.oee.getEquipmentAvailableMaterial(eqPath, matName) matLink = matList.get(0) searchString = matName + '-' + eqPath.replace('\\', ':') opList = system.mes.getAvailableOperations(eqPath, searchString, True, True) opDef = opList.get(0).getMESObject() schedule = system.mes.createSchedule(opDef) startDate = startDate.split('-') startTime = startTime.split(':') startDate = system.date.getDate(int(startDate[0]), int(startDate[1])-1, int(startDate[2])) startDate = system.date.setTime(startDate, int(startTime[0]), int(startTime[1]), int(startTime[2])) dueDate = system.date.addDays(startDate, 5) scheduleList = system.mes.scheduleOperations(schedule, startDate, dueDate, True, 'Active') for ndx in range(scheduleList.size()): scheduleOperations = scheduleList.get(ndx) print scheduleOperations objTypeName = scheduleOperations.getMESObjectType().getName() if objTypeName == 'OperationsSchedule': scheduleOperations.setScheduleProductionCount(qty) elif objTypeName == 'RequestSegment' and (scheduleOperations.getComplexPropertyCount('ResponseMaterial') > 0): if scheduleOperations.getAvailableMaterialOptions('Material Out').size() > 0: scheduleOperations.setMaterial('Material Out', matName, eqPath, qty) print 'set work order scheduled qty', scheduleOperations system.mes.saveSchedule(scheduleList) scheduleMatRun('PC_01', 'Line 1', '2017-05-24', '17:02:01', 150) |
Result
OperationsSchedule (a09bc3ae-afbe-4b52-899a-b146355d6d71, PC_01-Enterprise:Site 1:Area 1:Line 1 Schedule, 0 parents, 0 children, 0 custom properties, 1 complex properties)
OperationsRequest (4e1d973e-66aa-4221-bdc2-6a2a255b86cd, PC_01-Enterprise:Site 1:Area 1:Line 1, 0 parents, 0 children, 0 custom properties, 2 complex properties)
RequestSegment (b57531c6-03ae-4152-9a7f-637c5b161ca2, PC_01-Enterprise:Site 1:Area 1:Line 1_CO, 0 parents, 0 children, 0 custom properties, 7 complex properties)
RequestSegment (6f505601-8dc4-4b81-822f-904628bb3a43, PC_01-Enterprise:Site 1:Area 1:Line 1, 0 parents, 0 children, 0 custom properties, 7 complex properties)
set work order scheduled qty RequestSegment (6f505601-8dc4-4b81-822f-904628bb3a43, PC_01-Enterprise:Site 1:Area 1:Line 1, 0 parents, 0 children, 0 custom properties, 7 complex properties)