Creating and Editing MES Documents

Sepasoft MES Module Suite

MES Document

The MES Document Editor component is used to edit HTML documents for use in the manufacturing environment. It functions as a text editor to create and maintain user-interactive documentation, such as instructions for assembly workers, warning notes and data-entry forms for record keeping. Documents are stored as Artifacts on MES Objects (e.g. Material Definitions, Process Segments).


Visual Editor, HTML Source and Page Preview Modes

Visual Editor

The Visual Editor tab is editing environment where users can make additions and edits to the contents of the document Artifact, using the functionality in the Toolbar. The HTML source code is continually created and updated as the user adds/edits content. The HTML code is visible and editable in the HTML Source tab (see below).

HTML Source

The HTML source code for the document Artifact is continually created and updated as the user adds/edits content in the Visual Editor tab, which is immediately viewable and editable in the HTML Source tab:

Page Preview

To see how the document Artifact will look when displayed in the MES Document Viewer component, click the Page Preview tab:



Loading a Document

The MES Document Editor component doesn't 'load' a document in the traditional way text editing applications do, using an 'Open' command. Instead, the component uses its Selected MES Object and Artifact Name properties to navigate to an existing Artifact on an MES Object (these properties are typically ties to an MES Object Selector and MES Artifact Selector, respectively). The selected HTML-based document will then appear in the editing window of the component.



Creating a Document

Documents are HTML-format Artifacts, so they can be created by typing or pasting content in the MES Document Editor's text-editing window and clicking Create New Artifact (), or created separately as Artifacts on MES Objects via scripting.

Using Create New Artifact

Information

In order to be able to create a new document Artifact on the selected MES Object, the Allow Creation of New Artifacts? property must be set to True, so that the Create New Artifact () button will be populated on the left side of the Tool Bar.

  • Set the Selected MES Object property of the MES Document Editor with the MESObjectLink of the object to create a new Artifact on.

  • Click Create New Artifact (). A pop-up will ask for the name of the new document Artifact to create:


  • A new document Artifact will be created on the selected MES Object containing the current contents of the editing window.

Using Scripting

Refer to MES Artifacts for further details on creating Artifacts on MES Objects.

Example: The code below creates a new, versioned Artifact on the Material Definition Machine Oil that contains a string of HTML text. The new document Artifact is shown below in an MES Document Editor editing window.

Script to create a new document Artifact

Code
#Create a new versioned HTML document Artifact on an existing Material Definition object
mat_def = system.mes.loadMESObject('Machine Oil', 'MaterialDef')
mat_def.createArtifact('My New Document', '<b>This</b> is the text in the new document.', True)
system.mes.saveMESObject(mat_def)


Importing from an External Document Source

Often existing documentation needs to be imported to MES.  Since the MES Document Management module uses documents in HTML with imbedded images, documents need to be saved as xhtml.  Here is an example where a document is saved from a word processor application, then imported to MES.

Import Doc and Attach to a Material Definition

Code
##Load the MES Object that will be the host for the document, through the Artifact feature.
obj = system.mes.loadMESObject('Cab Sav', 'MaterialDef')
##Define the file path for the XHTML (has imbedded base64 images)
filePath = "C:\Users\USERNAME\Downloads\test_doc.xhtml"
##Define the artifact name.
artifactName = 'Test Doc'
##Load the document into local memory in Ignition
htmlDoc = system.file.readFileAsString(filePath, 'ASCII')
##Get names of artifacts
artifactNames = obj.getAllArtifactNames()
##If the artifact exists, set it, otherwise, create it.
if artifactName in artifactNames:
	obj.setArtifactValue(artifactName, htmlDoc)
else:
	##If we were running this for the first time, we would create the artifact:
	##Note that the parameters here are the document name, the value of the doc (in this case the xhtml), and a version flag (true
	## since we want to version this document).
	obj.createArtifact(artifactName, htmlDoc, True)
##Save the object with it's new artifact.
system.mes.saveMESObject(obj)

Text Editor

The text editor functionality is provided as both 'inline' (e.g. highlight text and use Ctrl-B to bold it) and via a Tool Bar, as show below. The functions in the Tool Bar provide basic document-handling, text-editing and formatting functionality, plus several user-interactive functions that allow factory line operators to enter data, indicate instruction-step completion or decision-making results.

MES Document Editor Tool Bar


Document Handling

These functions provide the ability to save a new document (which creates a new document Artifact on the selected MES Object, or updates an existing Artifact), preview and print the current document, and set up the page layout. 

IconFunctionDescription

Create New Artifact

Creates a new document Artifact on the selected MES Object containing the current contents of the editing window. The name for the new Artifact will come from the pop-up it provides for the user:

If the name of an existing Artifact on the selected MES Object is entered, an error message will be displayed. Select a unique name.

Information

This button is only populated on the left side of the Tool Bar when the Allow Creation of New Artifacts? property is set to True.

Save FileSaves (and optionally versions) the current contents of the editing window to the currently-selected document Artifact.

Print FilePrints the document pages. 

Page Setup

Configures the document pages for printing.


Print Preview

Displays the document pages as it will be printed.


Copy to ClipboardCopy the selected text to the clipboard.

Cut to ClipboardClip out the selected text to the clipboard.

Paste from ClipboardPaste the selection stored in the clipboard to the cursor position in the editing window.

Insert Image


Insert an image into the text, either from a URL located on the internet or from a file on your local machine or network.

Undo

Undo: Undo the last action carried out by the user.  For each successive press of the undo button a preceding user action will be undone.

RedoRedo: Redo the last action carried out by the user.  For each successive press of the redo button a preceding user action will be carried out again.

Spellchecker

Starts spellchecking the document from the beginning, prompting the user for a correction at each instance found.

As-You-Type Spellchecker

Spellchecks inline as the user types. Provides red wavy underlining at each instance found. Right-clicking on the instance provides alternative word suggestions, as well as the ability to add/remove the word to/from a local dictionary. 

Find

Finds each instance of the string entered in the Find what field, starting from the current cursor position in the document. Options are available to search upwards or downwards in the document, as well as using specific search criteria.

If Highlight search is selected, then every instance of the string entered will become highlighted (unselect the Highlight search box to remove the highlighting):

Replace

Replace a string found in the document with another, starting from the current cursor position in the document. Options are available to find-and-replace upwards or downwards in the document, as well as using specific find-and-replace criteria.

Insert HyperlinkInsert a hyperlink in the text to a link that is accessible on the Internet.

Copy FormattingCopies all the formatting in the selected area in order to apply it to another area in the editing window.

Show ParagraphsShows the paragraph objects.

Zoom InIncreases the viewing size of the text without changing the formatting.


Zoom Out

Decreases the viewing size of the text without changing the formatting.


Font Style

Select the font style for the currently-selected text.

Font

Select the font for the currently-selected text.

Font Size

Select the font size for the currently-selected text.

Font Properties

Select the font properties for the currently-selected text.

BoldBold the currently-selected text.

ItalicItalicize the currently-selected text.

UnderlineUnderline the currently-selected text.


Strikethrough

Strikethrough the currently-selected text.


Align LeftLeft-align the currently-selected text.

Align CenterCenter-align the currently-selected text.

Align RightRight-align the currently-selected text.

Align JustifiedJustify the currently-selected text.

Increase IndentMoves the indentation of the current line one tabulator to the right.

Decrease IndentMoves the indentation of the current line one tabulator to the left.

Numbered ListMakes the currently-selected lines into a numbered list.

Bulleted ListMakes the currently-selected lines into a bulleted list.

Borders

Adds a border around the line at the current position. If more than one line is selected, then the border is applied to each line separately.

Customizations for each side of the border:

  • Line type (solid, dotted, etc)
  • Line thickness
  • Line color (opens palette picker)

Clicking on any color swatch opens the Choose Border Color dialog box:

Foreground

Changes the foreground color. Click to open the Choose Foreground Color dialog box:

Highlight Color


Changes the background color. Click to open the Choose Background Color dialog box:


Checkbox

Inserts a Checkbox at the current position. Any number of Checkboxes may be selected (checked) at the same time in a document.

Right-click on any Checkbox and select Form Field Properties to set its properties:

Radio Button

Inserts a Radio Button at the current position. Any number of Radio Buttons may be selected at the same time in a document by default, but they can be 'grouped' (assigned the same group name) in the Radio Button Properties dialog box (see below) and then only one radio button in that group can be selected at a time (clicking another Radio Button in the group deselects the previous selection).

Right-click on any Radio Button and select Form Field Properties to set its properties:

Drop-down Menu

Inserts a Drop-down Menu at the current position.

Right-click on any Drop-down Menu and select Form Field Properties to set its properties:

Items can be added by clicking the Add Item button. The Height property can be set to force the box to remain fixed in height at the number of lines specified. The order of the entries can be modified by selecting an item and clicking Up or Down to move it in relation to the other entries.

Text Box

Inserts a one-line Text Box at the current position.

Right-click on any Text Box and select Form Field Properties to set its properties:

The Size in Characters property can be set to force the box to remain fixed in width to the number of characters specified. If the Field Type property is set to password, then all characters entered will be displayed as asterisks:

Text Area

Inserts a multi-line Text Area at the current position.

Right-click on any Text Area and select Form Field Properties to set its properties:

The Number of Lines property can be set to force the box to remain fixed in height at the number of lines specified. The Size in Characters property can be set to force the box to remain fixed in width to the number of characters specified. An initial text value can be populated into the Initial Value property, to act as a prompt to the user about how to enter data.



Sepasoft MES Module Suite