Utilizing Multiple Optional Materials in a Segment 3.0

Overview

Some processes have multiple types of material inputs and outputs.  Depending on the information provided by operators and/or SCADA, some material resources are optional.  The following script example demonstrates how to determine, after the fact through scripting, which material resources were utilized in a Response Segment.

Applies To and Version Info

This feature applies to Track and Trace and is available in 3.8x versions and later.

Details

The Response Segment's complex properties are handled in the script function below, with line-by-line comments for clarity.

Scripting

In the following script example, a Response Segment is loaded, then the Response Material Complex Properties are retrieved.  For each Response Material Complex Property, the lot UUID is printed.  Note that an optional material resource that was not utilized would have a null UUID.

Code
##UUID of a Response Segment
UUID = '1d41ff8d-b990-4a42-acb5-66526d2e7368'

##Load the Response Segment
seg = system.mes.loadMESObject(UUID)

##Print the complex Property Count for response materials
print seg.getComplexPropertyCount('ResponseMaterial')

##Get the names of the response material complex properties on the response segment object.
list = seg.getComplexPropertyItemNames('ResponseMaterial')

##iterate through the materials
for i in range(len(list)):

	##Get the object (the material resource)
	cmplxP = seg.getComplexProperty('ResponseMaterial', i)

	##print out the UUID of the Material Lot for that material resource.  
	##If the UUID is NULL, then it's not in use.
	print cmplxP.getName()
	print cmplxP.getLotUUID() 
	print cmplxP.getMaterialRef().getMESObject().getName()
	print cmplxP.getQuantity()

Note here in the result panel that the script produces the Material Resource name (Complex Property Name) as defined in the segment, as well as the lot UUID for the lot used, the type of material, and the quantity of the Material Lot.

Both material resources are configured as optional, and "Material Out 2" is not used in this example segment. Note that it has a null (i.e. None) UUID or quantity.

Result

Code
Material Out
be204bd5-8a91-4ab6-b84f-44a01e894994
TestMat1
10.0

Material Out 2
None
TestMat1
None


References

Response Segment

Material Lot

AbstractMESObject

system.mes.loadMESObject

Keywords

Track and Trace, Complex Property, Complex Properties, Response Material, Material Resources, Material References, Optional Materials, Response Segment Information