FTView Graphic Strings Search Replace

Embed Size (px)

DESCRIPTION

FT View

Citation preview

FactoryTalk View Graphic STRINGS Search and Replace User Manual

Table of ContentsIntroduction Basic XML Concepts Special Characters in XML Step 1 - Exporting Graphic Displays To XML Files Step 2 Searching For STRINGS Step 3 Replacing STRINGS Step 4 Importing XML Files Into Graphic Displays Issues and Miscellaneous Notes

IntroductionThis document discusses how you can perform search and replace operations on STRINGS that are contained within graphic displays. When we refer to the term STRINGS in this document, we are referring to tags, expressions, commands or text assigned to objects. Text can be captions, tooltips or label text. A quick overview of these steps is described as follows: Step 1: Export the graphic displays to XML files. Step 2: Search through these exported XML files looking for STRINGS and save those STRINGS found to a second set of XML files. As well, a cross-reference listing of all the STRINGS found in all the XML files will be saved in a single text file named $All Strings Found.txt. Step 3: Perform search and replace of STRINGS within this second set of XML files and save those changes back into the second set of XML files. Step 4: Import this second set of XML files back into the original graphic displays. This will cause the STRINGS that were replaced in the XML files to also be replaced in the graphic displays. The steps above are implemented using the graphics Import and Export wizard found in FactoryTalk View Studio and the FTView Graphics Strings Search and Replace program that accompanies this document. Before we continue with the search and replace description, we need to give a little background on some basic XML concepts for those readers not familiar with XML.

Basic XML ConceptsThis chapter describes some basic XML concepts. An XML file is a text file that is formatted to describe a particular kind of data. XML files typically have the extension .xml. XML files can be very simple or very complicated. It all depends on the information described by the XML file. In its simplest form, an XML consists of a header and a root element as shown below: The header is . Without going into a lot of details, just make sure your XML files have this header line. The root element in this XML file is . XML documents consist of elements and attributes. Elements can represent many things. In the case of graphic displays, the elements are used to describe objects, states of objects, animations, connections, object keys, display settings, etc. Elements are described with a start tag and an end tag. (NOTE: The use of the word tag in this chapter refers to an XML concept, not an FactoryTalk View concept.) The start tag of an element looks like this: . The end tag looks like this: . In between the start and end tags of an element, there can be other elements, referred to as child elements. For example, in the following piece of XML, the element is a child element of the root element . The element represents a Numeric Display object. When any element does not contain child elements, it can be described in a shorthand fashion where the start and end tags are combined together as follows: . The resulting XML document looks like this: Elements can contain attributes. Attributes are used to describe properties of the element. The attributes are located just after the start tag name. Attributes have values just like properties do and these values are defined in quotes after the attribute name. The following piece of XML shows 2 attributes of the element named name and height with the attribute values NumericDisplay1 and 38 respectively. . One important attribute of these graphic display XML files is the attribute named xsi:noNamespaceSchemaLocation. This attribute describes whether the XML file is for Machine Edition or Supervisory Edition graphic displays. This attribute will have the value "Gfx-ME1.xsd" for Machine Edition displays or the value "Gfx-SE1.xsd" for Supervisory Edition displays. Depending on which version of FTView Studio you used to export the XML files, you will see different versions (e.g. Gfx-SE3.xsd will be seen in CPR9).

Special Characters in XMLFor the most part, the attribute value can contain any UNICODE character. However, there are 5 characters that cannot be used in attribute values because these characters are used by the XML language itself. So, whenever one of these characters is needed within an attribute value, a special string sequence must be used instead. The following table shows these 5 special XML characters and their string sequence equivalent. XML Special Character < > & New line Note: This is not a visible character. Table 1: Special XML Characters For example, the following expression: if Temperature < 100 then AlarmOne else AlarmTwo would show up in the XML as follows: if Temperature < 100 then AlarmOneelse AlarmTwo You will notice these string sequences being specified in all the graphic display XML files exported by FactoryTalk View Studio. You will also notice them in the $Search Results.txt file generated by the Search operation described below. Finally, you will notice that the replacement text file described below requires that you use these string sequences when you are specifying expressions that use these characters. Note: When you open up an XML file in Internet Explorer (IE), it does not display the special sequence equivalents. Instead, IE will actually display the XML characters. However, it will not display the sequence as a new line but rather it will simply display it as a space character. For example, if you were to display the XML above in IE, you would see it as:

String Sequence Equivalent > < & "

Step 1 - Exporting Graphic Displays To XML FilesTo export a graphic display to an XML file, do the following steps from FactoryTalk View Studio: 1. 2. 3. Open an application that contains some graphic displays with some STRINGS assigned to some graphic objects. From the application tree, right-click on the item labeled Displays or Global Objects (under the Graphics item) and select the Import and Export menu. From the Import and Export wizard that is launched, select the Export option and then select all the graphic displays to export. You will then need to specify a folder where these XML files will be saved to. After the export of the graphic displays has completed, open your Windows File Explorer program and navigate go to the folder where you exported the graphic displays to. Note the following files in this folder that were created by the export operation: a. One XML file for each graphic display exported (e.g. Pump.xml). These files contain all the information about all the graphic displays. b. A file named BatchImport_.xml. This is a batch file that contains a list of all the files exported. It is used during a batch import operation (i.e. importing a set of XML files in one step). c. A file named DisplaysExport.txt. This file contains a log of any problems that might have occurred during the export operation.

4.

At this point, it would be a good idea to view the XML files to see how they are structured. Open up one of the XML files that corresponds to one of the graphic displays using your Internet Explorer (IE). On a typical Windows computer, if you just double-click an XML file it will open up in IE and will be color coded to highlight the different parts of the file. You will not be able to edit the program from IE. If you want to edit the file, open it using Notepad. Open the batch import file named BatchImport_.xml. Note that it contains a list of the XML files that you exported. You will need this file to import the XML files back into FactoryTalk View Studio to update the graphic displays in a batch fashion. The XML files exported describe an entire graphic display, including display settings, graphic objects, properties, connections, animations, tags, expressions, embedded variables, key assignments, object keys, commands, grouping, and wallpaper. The following is an example of a simple XML file representing a graphic display with 3 objects on it: a Text object, an SE Button and a Rectangle object.

As you can see, there is a lot of XML information to process for such a simple display. Most of the information in the XML file describes the properties of objects (e.g. height="41") on the display and includes their assigned tags (e.g. expression="tag1"). We are interested in the STRING information in the XML file. Search and replace operations will be performed on these STRING attributes and will be described in subsequent chapters.

Step 2 Searching For STRINGSThe next step is to search through all the XML files exported and search for STRINGS. The search operation is done using the FTView Graphics Strings Search and Replace program. Start up the program and perform the following steps: 1. 2. 3. 4. 5. 6. Select the Search Tab. Select a folder where the set of XML files to search through are located. Select a different folder where a second set of XML files will be saved to that contains just the STRINGS found. Select which kinds of STRINGS you are in interested in searching for (e.g. animation tags, commands) in the various check-boxes and radio buttons. Click the Report Setup button and select which kinds of information you are interested in saving in the $All Strings Found.txt text file generated. Press the Search button.

The set of XML files that the program will be searching through would typically be created by the export operation in FactoryTalk View Studio as described in Step 1 of this document. The program will open up each XML file and search for those attributes that contain STRINGS. There are a number of different attributes in these graphic displays that contain STRINGS. You can select which STRINGS to search for by choosing the various check-boxes and radio buttons as described in the next section.

Selecting Which Strings To Search For If you select the Tags and expressions in animations check-box, the program will search for the following STRING attributes: The expression attribute of the various animation elements (e.g. ). For example: The minTag and maxTag attributes of the child element under the various animation elements (e.g. ) . For example: If you select the Tags and expressions in connections check-box, the program will search for the following STRING attributes: The expression and optionalExpression attributes of the elements. These elements can be assigned to FactoryTalk View native objects or to ActiveX objects. For example:

If you select the Tags in global object parameters check-box, the program will search for the following STRING attributes: The value attribute of the elements. The element can be assigned to global objects. For example: If you select the Tags and expressions in miscellaneous objects (SE only) check-box, the program will search for the following STRING attributes: The tag attribute of the element of the Supervisory Edition (SE) elements. For example: The tag attribute of the SE element. For example: The currentTag attribute of the child elements of object elements in SE. For example: If you select the Commands (SE only) check-box, the program will search for the following STRING attributes (SE only): The startupCommand and shutdownCommand attributes of the element. For example: The pressAction, repeatAction and releaseAction attributes of: the child element of the and elements; the child element of the element; and the child element of the SE element. For example:

If you select the All text radio button, the program will search for the following STRING attributes: The caption attribute of many objects. For example: The titleBarText attribute of the element. For example: The label attribute of the element under the and elements (SE only). For example: The toolTipText attribute of many object and group elements (SE only). For example: The headingTitle attribute of the and elements in Machine Edition (ME). For example: The headerTextAckTime, headerTextAlarmTime, and headerTextMessage attribute of the element (ME only). For example:

The titleActiveAlarmsMode, titleAllAlarmsMode, titlePastAlarmsMode, headerTextAccumulatedTime, headerTextAlarmQuantity, headerTextAlarmState, headerTextMessage, headerTextTriggerLabel and headerTextTriggerValue attributes of the element (ME only). For example:

If you select the Text that contains only embedded variables radio button, the program will search for the following STRING attributes: It will search through all the caption attributes of all the objects that use this attribute and search for embedded variables within that attribute. A caption attribute is considered to have an embedded variable if it contains either of the strings /*N:, /*LN:, /*S: or /*LS: . These strings are the prefixes for numeric and string embedded variables, respectively. For example: Selecting the Report Options When you perform the Search operation, you will generate a set of XML files with the minimal STRING information in them. In addition to those XML files generated, the Search operation will also generate a text file containing a list of all the STRINGS found in all the XML files. This file is called $All Strings Found.txt and it will be saved in the folder specified in the second text box on the Search tab. This file is saved in a TAB delimited format where there are potentially seven columns of information separated by TAB characters. You can specify which columns of information will be saved when you press the Report Setup button and then enabling or disabling the columns you are interested in saving. By default, all the columns of information will be saved. You can also specify whether this file is saved in Unicode or ANSI format. Saving the file in Unicode format will allow you to save any STRING in any language. However, if you know that your XML files only contain English or Western European STRINGS, then we recommend you use save in ANSI format because the file takes up less disk space and the file is more easily readable by text editors and text searching programs. Performing the Search When you press the Search button, the program will search for all these STRING attributes in the set of XML files defined in the first folder specified and save the results of that search to a second set of XML files in the second folder specified. The XML files in the second folder will only contain the minimal amount of XML information needed to describe where the STRINGS are being used on the graphic display. This minimal information is basically the name of the object or group where the STRING is assigned, the name of the child element that describes the STRING usage (e.g. ) plus the STRING attributes where the STRINGS are assigned. Open up one of the XML files generated in the second set of XML files to see the difference in the amount of information in the file. For example, the following is what the XML file shown above in Step 1 will look like after the Search operation has been performed by the program:

In addition to those XML files generated you can also view the $All Strings Found.txt to see a list of all the STRINGS found in all the XML files. Because this file is saved in a TAB delimited format, it is easily viewable in Microsoft Excel. The following diagram shows what an example of what this file will look like in Microsoft Excel.

The last column with the heading #STRING is the column that shows the value of the STRING attribute. The other columns show the context of the string such as what graphic display it is located on, what object is it associated with etc. If you are interested in viewing the data in a different sort order (for example, if you want to sort the information by the #STRING TYPE column, you need to select all the cells in the spreadsheet then click on the Data > Sort menu. From the dialog that is presented, you can select the #STRING TYPE column. This file can also be viewed using any text editor such as Notepad.

Step 3 Replacing STRINGSAt this point, we have created a new set of XML files that contain just the minimal amount of information to describe all the STRINGS that are used in the various graphic displays. Now, we want to go through these XML files and perform search and replace operations on these STRINGS. If you want, you could open up these XML files in Notepad (or some text editor) and perform the search and replace using the Replace menu of Notepad. This would be slow if you had a lot of files to process or if you had a lot of different search and replace operations to perform. A quicker and more efficient way of performing these search and replace operations would be to use the program that accompanies this document. The program makes it easy to do this because it will perform the search and replace operation on a set of XML files in one step automatically. As well, the program will allow you to specify multiple search and replace operations on each file. In order to perform the replace tag operation using the program, you first need to create a replacements text file named $Replacements.txt. This file must be located in the same folder where the XML files are located. This replacements text file describes a list of strings to search for and a list of strings to replace them with. Each search/replace string pairs must be on a single line of this file and be separated with a TAB character. Alternatively, if you want to replace a search string with nothing then just specify one string on the line. For example, the following is an example of this replacements text file (NOTE: The TAB character is not visible):tag1 [N1] \Folder1 tag2 [N2]

This replacements text file is specifying that the string tag1 should be replaced with the string tag2, the string [N1] should be replaced with the string [N2] and the string \Folder1 should be replaced with nothing. NOTE: The strings in this replacements text file do not have to be full string replacements of the STRINGS found, they can just be partial string replacements. Once you have created the replacements text file, then run the program and perform the following steps: 1. 2. 3. 4. Select the Replace Tab. Select a folder where the set of XML files to perform replace operations on are located. Select which kinds of STRINGS you are in interested in replacing (e.g. animation tags, commands) in the various check-boxes and radio buttons. Press the Replace button.

When you press the Replace button, the program opens up each XML file in the folder specified and searches for those attributes that can contain the STRINGS you are interested in replacing (see Step 2 for a list of those attributes). Then for each STRING attribute value found, the program will perform ALL the replacements as defined by the replacements text file. After the complete XML file has been processed, if it has changed it will be re-saved back to its original location. This search and replace is repeated for all the XML files in this folder. If you dont want to modify these XML files during the Replace operation, you should back these XML files up to a different folder before performing this step. You should open up these XML files and verify visually that the tag replacements have worked as expected. After that, the next step is to import these XML files back into your graphic displays which will update the displays with the new tag names.

Step 4 Importing XML Files Into Graphic DisplaysWe now have a set of XML files with the desired STRING replacements. Now we need to import these XML files back into the original graphic displays. When we import these XML files into the graphic displays, the information contained in the XML files will be applied to the existing objects on the existing graphic displays. Since the XML files contain mostly STRING information, it means that only the STRING information will be modified in the graphic displays when the import has completed. In other words, the appearance (e.g. color ) and location (e.g. height and width) of the objects will not be modified as a result of the import. To import an XML file into an existing graphic display, do the following steps from FactoryTalk View Studio: 1. 2. 3. 4. Copy the batch import file named BatchImport_.xml that you created in Step 1 to the folder that contains the modified XML files. Open the application that contains the graphic displays that you want exported to XML in Step 1. From the application tree, right-click on the item labeled Displays or Graphic Objects (under the Graphics item) and select the Import and Export menu. From the Import and Export wizard that is launched, do the following: a. Select the Import option. b. Select Yes if you want to backup the graphic displays before performing the import (optional step). Select the folder to backup the graphic displays to. c. Select the Multiple displays batch import file option. d. Browse to your BatchImport_.xml file you copied above. e. Select the Update existing objects on the display option to update existing objects. f. Press Finish to perform the import. When the wizard has completed, the graphic displays will be updated with the new STRINGS.

Issues and Miscellaneous Notes1. There is a known issue in RSView Studio 3.2 whereby you cannot import object key information from an XML file if those object keys are defined on group objects. This only applies to SE. There is a known issue in RSView Studio 3.2 whereby some of the TabIndex properties of the objects will be modified as a result of the import even though the TabIndex property is not specified in the XML file. This only applies to SE. When you define Color Animation in the XML file using the element, you need to specify all the child elements named that define the various colors in the animation. Even if you want to just update the tag assigned to the element, you still need to include these child elements. The program includes these elements automatically for you. The following XML demonstrates these color elements.

2.

3.