Add Operation Information Panel To Trace Graph

Track and Track Graph

The Trace Graph provides a high-level view of all materials produced and consumed over the lifecycle of a given material lot.  

Material Lots are displayed as inputs and outputs of each operation. There may be a desired to show additional information about a given operation. 

This topic demonstrates how to display additional information about a given operation using the Perspective Trace Graph.

Components:

Resource:

Import the zip file in the designer for the completed example screen.

Example:

In this example, we use the Node Clicked right-click event to trigger an embedded view on the left to display information about a given operation:

Script for nodeClicked event:

Python
def runAction(self, event):
if event.getType() == 'ResponseSegment':
self.getSibling("emb_opInfo").props.params.responseSegUUID = event.getUUID()
else:
self.getSibling("emb_opInfo").props.params.responseSegUUID = ''

# Example if a material lot is selected, retrieve the lot object, determine if an artifact is present, and show a popup if so.
# if event.getType() == 'MaterialLot':
# lotUUID = event.getUUID()
# lotObj = system.mes.loadMESObject(lotUUID)
# if 'some artifact' in lotObj.getAllArtifactNames():
# system.perspective.openPopup('inspectionresults', 'Your/view', {'lotUUID':lotUUID})

Here we are pushing the response segment UUID to the embedded view.  The view contains script to populate itself based on the segment data.

In the embedded view, we have a Markdown component which will display the data in a friendly manner. 

On the View parameter responseSegUUID value change, we retrieve the uuid, load the object, and load desired data about the operation.


Python
def valueChanged(self, previousValue, currentValue, origin, missedEvents): 
respSegUUID = currentValue.value
markup = ''
if len(respSegUUID) > 0:
seg = system.mes.loadMESObject(respSegUUID)

markup = '# **' + seg.getName() + '**
'
markup += '**Started:** ' +str(seg.getPropertyValue('BeginDateTime')) +'

'
markup += '**Ended:** ' +str(seg.getPropertyValue('EndDateTime')) +'

'

operationUUID = seg.getPropertyValue('OperationsResponseRefUUID')
opResponse = system.mes.loadMESObject(operationUUID)

#Get the MES object link of where the operation is running
eqLink = opResponse.getEquipmentLink()

markup += '## Processing Equipment
'
markup += '**Type**: '+ str(eqLink.getMESObjectType()) + '

'
markup += '**Name**: '+ eqLink.getName() +'

'

complexProps = seg.getComplexPropertyCount('ResponseMaterial')

props = {}
uiList = []
for i in range(complexProps):
prop = seg.getComplexProperty('ResponseMaterial',i)
#material prop name
propName = prop.getName()
if prop.hasSegmentRefUUID():
#lot number
lotName = prop.getMaterialLot().getName()
#material def name
matName = prop.getMaterialRef().getName()
#location
location = prop.getEquipmentRef().getName()
#quantity
quantity = prop.getQuantity()
#begintime
begin = prop.getBeginDateTime()
#end time
end = prop.getEndDateTime()
#use
use = prop.getUse()

lotSequence = prop.getLotRefSequence()
eqPath = eqLink.getMESObject().getEquipmentPath()

customProps = []
lot = system.mes.loadMaterialLot(lotName, lotSequence, eqPath, False)

for cp in lot.getAllCustomProperties():
customProps.append(cp.getName() + ':' + str(cp.getValue()))

#Sublots
sublots = []
for lot in lot.getChildCollection():
sublots.append(system.mes.getMESObjectLink(lot).getName())

finalProp = {use:
{
'propName' : propName,
'lotName' : lotName,
'matName' : matName,
'location' : location,
'quantity' : quantity,
'begin' : begin,
'end': end,
'customProps': customProps,
'sublots':sublots
}
}

else:
finalProp = {'unused':{'propName':propName}}

#update relevant material
if props.has_key(finalProp.keys()[0]):
props[finalProp.keys()[0]].append(finalProp[finalProp.keys()[0]])
#create new list of material
else:
props.update({finalProp.keys()[0]:[finalProp[finalProp.keys()[0]]]})

useOrder = ['In','Out','Consumable','By-Product']
for use in useOrder:
first = True
for key, values in props.items():
if key == use:
for matProp in values:
if first == True:
markup += '## **Material - ' + key + '**
'
else:
markup += '
'
markup += '|' + matProp['propName'] + ':||
'
markup += '|--|--|
'
markup += '|Lot No:|' + matProp['lotName'] + '|
'
markup += '|Material|' + matProp['matName'] + '|
'
markup += '|Location|' + matProp['location'] + '|
'
markup += '|Quantity|' + str(matProp['quantity']) + '|
'
markup += '|Begin Date Time|' + str(matProp['begin']) + '|
'
markup += '|End Date Time|' + str(matProp['end']) + '|
'
#custom properties
if matProp['customProps']:
for cp in matProp['customProps']:
markup += '|' + cp.split(':')[0] + '|' + cp.split(':')[1] + '|
'
first = False
#sublots
if matProp['sublots']:
for sublot in matProp['sublots']:
markup += '| |'+ sublot + '|
'


self.getChild("root").getChild("Markdown").props.source = markup


Related