Adding the Production Equipment Model via Script
These code examples include pseudo-code and have been functionalized. Working in the base system.mes. library and working with object links. For batch, we will add that framework of: Process Cell and Unit.
Functionalizing enables saving in the Scripts folder in the Project Browser and calling the function where needed.
|
If you are using the starter project and want to leverage the automation scripts for batches, name all equipment exactly as given. |
Rename the Enterprise
Python |
def do(obj,ss): mm = dir(obj) for m in mm: if ss.upper() in m.upper(): print m currentEnterpriseName = 'New Enterprise' enterpriseName = 'Enterprise' def setEnterpriseName(currentEnterpriseName, enterpriseName): mesObjectTypeName = 'Enterprise' # get the Enterprise object eqpLink = system.mes.getMESObjectLinkByName(mesObjectTypeName, currentEnterpriseName) eqp = eqpLink.getMESObject() # set the new name eqp.setName(enterpriseName) # save eqp.save() |
To call this function:
Python |
setEnterpriseName(currentEnterpriseName, enterpriseName) |
Create the New Equipment: Site
The Enterprise is the Site object's parent.
Python |
currentEnterpriseName = 'New Enterprise' enterpriseName = 'Enterprise' siteName = 'Site' siteDescription = 'My Site' # create a new site object mesObjectTypeName = 'Site' eqp = system.mes.createMESObject(mesObjectTypeName) # set the name eqp.setName(siteName) # set the description -optional eqp.setDescription(siteDescription) # set the active flag to True eqp.setActive(True) # set the parent object parentMesObjectTypeName = 'Enterprise' parentLink = system.mes.getMESObjectLinkByName(parentMesObjectTypeName, enterpriseName) eqp.addParent(parentLink) # save eqp.save() |
Create the New Equipment: Area
Python |
currentEnterpriseName = 'New Enterprise' enterpriseName = 'Enterprise' siteName = 'Site' siteDescription = 'My Site' areaName = 'Area' areaDescription = 'my area' def createArea(areaName, areaDescription, siteName): # create a new area object mesObjectTypeName = 'Area' eqp = system.mes.createMESObject(mesObjectTypeName) # set the name eqp.setName(areaName) # set the description eqp.setDescription(areaDescription) # set the active flag to True eqp.setActive(True) # set the parent object parentMesObjectTypeName = 'Site' parentLink = system.mes.getMESObjectLinkByName(parentMesObjectTypeName, siteName) eqp.addParent(parentLink) # save eqp.save() |
Create the New Equipment: Process Cell
Python |
currentEnterpriseName = 'New Enterprise' enterpriseName = 'Enterprise' siteName = 'Site' siteDescription = 'My Site' areaName = 'Area' areaDescription = 'my area' processCellName = 'Process Cell' processCellDescription = 'my process cell' def createProcessCell(processCellName, processCellDescription, areaName): # create a new object mesObjectTypeName = 'ProcessCell' eqp = system.mes.createMESObject(mesObjectTypeName) # set the name eqp.setName(processCellName) # set the description eqp.setDescription(processCellDescription) # set the active flag to True eqp.setActive(True) # set the parent object parentMesObjectTypeName = 'Area' parentLink = system.mes.getMESObjectLinkByName(parentMesObjectTypeName, areaName) eqp.addParent(parentLink) # set the checkboxes eqp.setRemoveCompleteFromQueue(False) eqp.setRemoveHeldFromQueue(False) # save eqp.save() |
Create the New Equipment: Unit
Python |
currentEnterpriseName = 'New Enterprise' enterpriseName = 'Enterprise' siteName = 'Site' siteDescription = 'My Site' areaName = 'Area' areaDescription = 'my area' processCellName = 'Process Cell' processCellDescription = 'my process cell' unitName = 'Premix 2' unitDescription = 'aaa' phaseClassName = 'Demo' parentPhaseClass = None unitClassName = 'Premix' parentUnitClassName = 'Demo' def createUnit(unitName, unitDescription, processCellName): # create a new object mesObjectTypeName = 'Unit' eqp = system.mes.createMESObject(mesObjectTypeName) # set the name eqp.setName(unitName) # set the description eqp.setDescription(unitDescription) # set the active flag to True eqp.setActive(True) # set the parent object parentMesObjectTypeName = 'ProcessCell' parentLink = system.mes.getMESObjectLinkByName(parentMesObjectTypeName, processCellName) eqp.addParent(parentLink) # save eqp.save() |
Calling these Functions
Add these calls to the end:
Python |
setEnterpriseName(currentEnterpriseName, enterpriseName) createSite(siteName, siteDescription, enterpriseName) createArea(areaName, areaDescription, siteName) createProcessCell(processCellName, processCellDescription, areaName) createUnit(unitName, unitDescription, processCellName) |