Set Recipe Value Security Through Scripting

Sepasoft MES Module Suite

Setting Machine Recipe Value Security

The following script illustrates how to set security role settings for a recipe value and how to revert the inherit property of the recipe value security settings through scripting. 

Python
linePath = event.source.parent.getComponent('MES Object Selector').equipmentItemPath
  
# Get a list of all the recipe entries under this path
recipeVals = system.recipe.getDefaultValues(linePath, "1", "")
 
# Cycle through the list
for ndx in range(recipeVals.size()):
     
    # Get the recipe item at this point
    recipeItem = recipeVals.get(ndx)
     
    # Get the name of the item
    recipeItemName = recipeItem.getName()
    print recipeItemName
 
    # Get the security object for this item
    secInfo = system.recipe.getRecipeValueSecurity(linePath, recipeItemName, False)
  
    #Cycle through and print the setting for each role
    #for ndx in range(secInfo.getSecurityRoleCount()):
    #   recSec = secInfo.getSecurityRole(ndx)
    #   print recSec.getSecurityRole()
    #   print recSec.isAllowEdit()
  
    # Get the security info for a specific role
    secRole = secInfo.getSecurityRole('Supervisor')
  
    # Allow the role to edit
    secRole.setAllowEdit(True)
  
    #This must be set otherwise it will inherit from the parent
    secInfo.setInherit(False)
    print secRole.getMinValue()
    print secRole.getMaxValue()
  
    # if you know the datatype or you know the item by name you can set the min and max for the role
    #if recipeItemName == 'FanSpeed':
    #   secRole.setMinValue(32.5)
    #   secRole.setMaxValue(212.0)
    #print
 
    #Update the security settings
    system.recipe.updateRecipeValueSecurity(secInfo)

Sepasoft MES Module Suite