self - A reference to the component that is invoking this function
sourceTable - A reference to the table that the rows were dragged from.
rows - An array of the row indices that were dragged, in the order they were selected.
rowData - A dataset containing the rows that were dragged.
equipmentPath - The path for the equipment item that the user dropped on.
category - The schedule category that the user dropped on.
dateTime - The date and time at the point where the drop occured.
Client
from java.util import Calendar
if rowData.getRowCount() == 0:
system.gui.messageBox('A row must be selected.', 'Information')
return
if rowData.getRowCount() > 1:
system.gui.messageBox('A single row must be selected.', 'Information')
return
#Get any of the column values from the Power Table component that will be used for scheduling
opName = rowData.getValueAt(0, "Operation")
durationInHrs = rowData.getValueAt(0, 0)
eqLink = system.mes.getMESObjectLinkByEquipmentPath(equipmentPath)
operDef = system.mes.loadMESObject(opName, 'OperationsDefinition')
print "Creating schedule entry for ", operDef
objList = system.mes.createSchedule(operDef)
for obj in objList:
objType = obj.getMESObjectType().getName()
if objType == 'OperationsSchedule':
obj.setPropertyValue('ScheduleDurationSec', durationInHrs * 3600)
elif objType == 'RequestSegment':
#Calling setEquipmentLink with a specific equipment link based on the equipmentPath, will force it to be scheduled on the one equipment item.
#Comment the setEquipmentLink line to find the equipment item that can best accommodate the dateTime
obj.setEquipmentLink(eqLink)
#Create and save work order number in a custom property
# cp = {'WO' : ['String', wo, 'Production work order', True, False]}
# obj.setCustomPropertyValues(cp)
#Alternatively, the current time can be used instead of the dateTime that is based on the drop location.
#Alternatively, the end time can be omitted and the segment be configured to estimate completion time based on target production count.
cal = Calendar.getInstance()
cal.setTime(dateTime)
cal.add(Calendar.MINUTE, int(60 * durationInHrs))
try:
objList = system.mes.scheduleOperations(objList, dateTime, cal.getTime(), True, 'Active')
system.mes.saveSchedule(objList)
self.refresh()
except:
#If we throw an error here, its likely that the operation is not defined for this line.
#Ideally using <any equipment> class for an operation will fix this issue,
#but we will gracefully handle it if the line is not part of the eqClass for the dropped operation
system.gui.messageBox("This operation is probably not configured for this line. Please add the line to this operation and try again.")