Custom properties can be added to any MES object using the MES Object Editor component or with script functions. Custom properties can be nested, meaning a custom property can be added to a custom property. This allows defining a structure to custom properties such as WidthHeight and Depth custom properties can be added beneath a Dimension custom property. Custom properties have a production visible option that will show the property in the MES Property Value Editor component. This provides a method to keep custom properties hidden and not show them to operators or other end users. If the custom property is visible to the end users, the required option will make sure a value is entered before ending an operation.

Custom properties belong to AbstractMESObject which is the base object for every Track & Trace and OEE 2.0 object. See the custom property section of the AbstractMESObject reference for a listing of the custom property functions.


 

Adding Custom Properties using the MES Object Editor

The MES Object Editor has built-in support to add custom properties to any of the MES object types that can be configured using the MES Object Editor. These objects include Equipment Objects, Material Class & Material Definition, Personnel Class & Personnel, Process Segment, Operations Definition, Operations Segment.

MES object types that custom properties cannot be added to using the MES Object Editor include Material Lot, Material Sublot, MES Work OrderRequest SegmentOperations Response and Response Segment, because they are only created during production. However custom properties can be added to these objects using scripting.


 

Custom Property Inheritance Between MES Objects

Many MES objects have parent-child relationships which allows for custom properties to be inherited. As an example, Material Definitions, will inherit any custom properties defined for the parent Material Class that they belong to. Any custom properties added and configured locally on the Material Definition that have the same name as the inherited custom property, will replace it only on the instance of the child object. Furthermore, the properties are accessible separately through the MESObject's getInheritedProperties and getCustomProperties methods and are viewable from different locations within the MES Object Editor Component.

In the image on the right, the Material Class TestClass1 has a custom property called ClassLevelCP.


 

When the TestMat1 Material Definition is selected, the locally configured Custom Property TestCP1 is shown. Note that the inherited custom property ClassLevelCP from the parent Material Class does not appear in the Information Panel, nor will it be returned by the obj.getCustomProperties() method. The obj.getCustomProperties() method will return TestCP1 for the TestMat1 Material Definition.


 

When examining the settings for the Material Definition in the example, note that the locally configured Custom Property and the Inherited Custom Property from the Material Class parent are both shown in the main information panel. To retrieve the inherited value, the obj.getInheritedProperties() method should be used, returning ClassLevelCP. Note that the inherited value is not unique to the Material Definition but is a property of the Material Class. The inherited value can be over-ridden at the child level by adding a custom property on the child with the same name as the property of the parent.


 

Scripting Function for Manipulating Custom Properties

Read custom property from MES Object
#Read custom property from MES object.
 
#Load the material class object named Vinegar.
mesObject = system.mes.loadMESObject("Vinegar", "MaterialClass")
 
#Print value of custom property pH
print mesObject.getPropertyValue('pH')
Add new custom property to MES Object
#Add new custom property to MES object.
 
#Load the material class object named Mounting Plate.
mesObject = system.mes.loadMESObject('Mounting Plate', 'MaterialDef')
 
#Add a new custom property named Width.
mesObject.addCustomProperty('Width', 'Float8', 'Width of mounting plate', 'mm', True, True)
Add new custom property to MES Object and set its value
#Add new custom property to MES object.
 
#Load the material class object named Vinegar.
mesObject = system.mes.loadMESObject('Vinegar', 'MaterialClass')
 
#Add a new custom property named pH.
mesObject.addCustomProperty('pH', 'Float8')
 
#Set the value of pH to 5.1
mesObject.setPropertyValue('pH', 5.1)
The following code snippets show how multiple custom properties can be added, updated, deleted and queried against any MES Object type. 
Note that as of this time (2.9.2 SP5), using 'DateTime' as a datatype parameter does not seem to work. If you are storing a date, store it as a string and then convert it back to a datetime object when you need it.

def deleteCustomProperties(mesObject):
	#This function will delete all custom properties of the passed object and return the updated object instance
	cpList = mesObject.getCustomPropertiesFull()
	for key in cpList:
		mesObject.removeCustomProperty(key) 
		
	system.mes.saveMESObject(mesObject)
	return system.mes.loadMESObject(mesObject.getUUID())
	
############################################################
def updateCustomProperties(mesObject, cpList):
	#This function will update the passed object with the list of custom properties 
	#and return the updated object instance. If the custom properties do not exist, they will be created
	
	mesObject.setCustomPropertyValues(cpList)
	system.mes.saveMESObject(mesObject)
	return system.mes.loadMESObject(mesObject.getUUID())	


############################################################
def getCustomProperties(mesObject):
	#This function returns all custom properties of the passed object
	cpList = mesObject.getAllCustomProperties()
	for item in cpList:
		print 'Custom Property Settings for ', item.getName()
		print 'Value - ', item.getValue()
		print 'Units - ', item.getUnits()
		print 'DataType - ', item.getIgnitionDataType()
		print 'Description - ', item.getDescription()
		print
    
############################################################


name = 'WO-0001'
objType = 'WorkOrder'

#Here we will define the custom property settings to be added to the MES Object
#Note datatypes 'DateTime' and 'Text' do not work
cpName = 'Start Date'
cpDataType = 'String'
cpVal= system.date.now()
cpDesc = 'Start Date for this WO'
cpUnits = 'No Units'
cpList = {cpName : [cpDataType , cpVal, cpDesc , cpUnits]}

#This is an example of how to pass multiple custom property settings
#cpList = {'Amps' : [current_dataType , current, current_desc , current_units], 'Volts': [volts_dataType , volts, volts_desc, volts_units]}

mesObject = system.mes.loadMESObject(name, objType)
mesObject = deleteCustomProperties(mesObject)	#We only need to delete the custom property if we are trying to change the units, seems to be a bug
mesObject = updateCustomProperties(mesObject, cpList)

getCustomProperties(mesObject)
  • No labels