Scripting help needs for Track and Trace project

Hi all,

I’m new to ignition and working on track and trace mes module.
I have created hierarchy of production model for my project as described in MES User manual. With the help of the Track_And_Trace_Demo project, further developed material classes and its definitions, equipment classes and its definitions, personnel classes and its definitions.
Assigned these above mentioned classes and their definition to segments and operations. Tested all the segments and create lot numbers with the help of the sample operation screen in the same demo project. So as per this created perfectly a complete genealogy of the product and checked it in TraceGraph Screen.
But now the same segments and operations, I would like to run it via scripts which can be triggered on the specific events.

Please provide me the sample script format with Segment entries like In/Out Material, Equipment, Personnel Classes and their Definitions.

Thanks

This is a fairly old topic but I’ll post some TnT scripts I’ve used:

[code]##########################################################################

getting the lot quantity of a particular lot in inventory

filter = system.mes.object.filter.createFilter()
filter.setEnableStateName(‘ENABLED’)
filter.setMESObjectTypeName(‘MaterialLot’)
filter.setMESObjectNamePattern(“20150105-011055”) # This is a lot number (aka lot name)
objs = system.mes.loadMESObjects(filter)
materialDef = ‘Steel Out’ # This is as defined in the application by the user…
for i in range(len(objs)) :
if objs[i].getLocationLink().toString() == “Inventory” :
rsUUID = objs[0].getPropertyValue(‘ResponseSegmentUUID’)
respSeg = system.mes.loadMESObject(rsUUID)
prop = respSeg.getComplexProperty(‘Lot’,materialDef )
print prop.getValue(“LotQuantity”)[/code]

[code]###################################################################################

search inventory…

result is a dataset…

from java.util import Calendar

start = Calendar.getInstance()
start.add(Calendar.YEAR,-1)
end = Calendar.getInstance()
end.add(Calendar.YEAR,1)
filter = system.mes.inventory.filter.createFilter()
filter.setIncludeCompleteLots(True)
filter.setBeginDateTime(start.getTime())
filter.setEndDateTime(end.getTime())
filter.setEquipmentClassName(‘Steel Unloading’) # can also use setEquipmentPath(equipPath)
results = system.mes.getInventory(filter)
print results.getValueAt(0,“LotName”)[/code]

[code]###############################################################################

Searching for a particular lot…

filter = system.mes.object.filter.createFilter()
obj = system.mes.loadMESObjects(filter)
lotName = ‘20141210-064015’
for i in range(len(obj)) :
if str(obj[i].getMESObjectType()) == “Material Lot” :
if obj[i].getName() == lotName :
print obj[i].getName()
print dir(obj[i])[/code]

Hope some of that’s useful.

Kurt

1 Like