Document Viewer

Sepasoft MES Module Suite

Document Management in an OEE Production Run

This example uses the Document Management components for Perspective to create an OEE Production Run that displays input fields within a document. A production run is initiated, and that document is loaded. The document inputs are handled and saved, and the production run is ended.


Success

Required items and configuration to complete the steps below:

  • Modules Installed
    • Production
    • OEE
    • Document Management
  • Configuration
  • Material created and configured to run on a Line for OEE

    Configuring Document Management in Designer

    You create and edit documents with the Document Editor in design-time and view documents in the Document Viewer component at runtime. In the system, documents are artifacts that are attached to MES Objects.  This example uses the MES Object Selector component with the Document Editor to associate a Line MES object to a document artifact. Then, uses the Document Viewer to display instructions with input fields during an OEE run. The input values are printed to the console.

     Setting Up a Document Editor in a Perspective View

    • In Ignition Designer on a Perspective View, add an MES Object Selector component.
    • Set the property includeMESLineObjects to True.
    • Add a Document Editor Component, and bind the editor to the selector:
    ../mesObjectSelector.props.selectedMESObject

    Creating and Saving a Document

      Create a document artifact with text fields and checkboxes. The document is saved and later loaded during the production run. 

    • In Designer, in Play mode, select a Line in the MES Object Selector.
    • Create a document with text fields and checkboxes.
    • Add a name to the selectedArtifactName property and then in the design area, click Play and then the Save icon in the Document Editor.


    Scripts and Methods for Document Handling

    In Ignition Designer, design a Perspective View like this one:


    Add a Label and a Text Entry. Keep the property defaults and name them.

    • Add a Document Viewer component from the Perspective Component Palette.
    • Select the Document Viewer, right click and select Configure Events...
    • Add the script below to the documentSaved event.
    Python
    def runAction(self, event):
        message = event['inputValues']
        system.perspective.print(message)
        
        self.props.selectedMESObject = ''
        self.props.selectedArtifactName = ''
        self.props.showSaveButton = False



    Start Production Run Functionality

    The script initializes a production run using OE downtime, equipment path, and material name.

    • Add a Start Production Run button. 
    • Add the script below to the onActionPerformed event.
    • Make sure Line and material name match your configuration. And Apply and Save.
    Python
    def runAction(self, event):
        eqPath = 'Enterprise\Site\Area\Dark Chocolate Line'
        matName = 'Blend77'
        
        seg = system.mes.oee.beginOEERun(matName, eqPath)
        system.mes.oee.endOEEChangeover(eqPath)

     

    Load and Save Document

    The script loads a master document using the getArtifactValueByName method.  The script saves the document inputs and updates the document viewer component. 

  • Add a Load Copy of Master Document button. 
  • Add the script below to the onActionPerformed event.
  • Success

    Notice the end of the script where a dictionary is built. The Document Viewer needs these functions to return the name-value pairs.

    See in the code:

    ##Build this dictionary for the doc viewer component selected MES Object

    ##Pass the dictionary to the viewer and the document name to the viewer



    Python
    def runAction(self, event):
        ##Get Relevant information:
        eqPath = 'Enterprise\Site\Area\Dark Chocolate Line'
        matName = 'Blend77'
        docName = self.getSibling("TextField").props.text
        
        ##Load the Line where the document master is found:
        eq = system.mes.loadMESObjectByEquipmentPath(eqPath)
        ##Retrieve the Document
        docValue = eq.getArtifactValueByName(docName)
        
        ##Load the Response Segment that is currently running:
        segs = system.mes.getCurrentSegments(eqPath)
        seg = segs.get(0).getMESObject()
        
        ##Create the Artifact with the loaded document on the current Response Segment:
        ##Note this could be repeated with different names for the document if multiple docs of the same type 
        ##would be associated with the same response segment.
        seg.createArtifact(docName, docValue, 1)
        seg = seg.update()
        
        ##Build this dictionary for the doc viewer component selected MES Object:
        dict = {"mesObjectUUID":seg.getUUID(),"mesObjectType":seg.getMESObjectTypeName(),"equipmentPath":"","name":seg.getName(),"disabled":False,"childCount":-1}
            
        ##Pass the dictionary to the viewer and the document name to the viewer    
        self.getSibling("docDocumentViewer").props.selectedMESObject = dict
        self.getSibling("docDocumentViewer").props.selectedArtifactName = docName
        self.getSibling("docDocumentViewer").props.showSaveButton = True


    End Production

  • Add a End Production Run button. 
  • Add the script below to the onActionPerformed event.
  • Python
    def runAction(self, event):
        eqPath = 'Enterprise\Site\Area\Dark Chocolate Line'
        matName = 'Blend77'
        
        system.mes.oee.endOEEProduction(eqPath)


    Remove Artifact

    The script removes an artifact from an MES object using the remove complex property method.

  • Add a Remove Artifact button. 
  • Add the script below to the onActionPerformed event.
  • Python
    def runAction(self, event):
        ##Load the object where the artifact resides
        ##e.g. the Line, Response Segment, Material, etc.
        obj = system.mes.loadMESObject('Material 1', 'MaterialDef')
        ##An Artifact is a complex property within the MES Object Model, so remove the complex property of type "Artifact":
        obj.removeComplexProperty('Artifact','Specific Artifact Name')
        ##Save your changes to the object you've modified
        system.mes.saveMESObject(obj)



    Run an OEE and add values. Look at the console for values.

    • On the Perspective View where the Document Viewer is and in Play mode, click Start Production Run.
    • Then, click Load Copy of Master Document.


    • Enter some values in the document. Then save the document by clicking the checkmark at the bottom of the page.
    • Click End Production Run.
    • Click Remove Artifact.

    Notice in the Output Console, the name-value pairs that represent the form element and its value.


    Sepasoft MES Module Suite