Skip to content

(Use case) Switch text with a PLC variable

Stephan Stricker edited this page Apr 21, 2020 · 2 revisions

Requirements

  • Automation Studio 4.5
  • mappView 5.9

Description

This -->sample<-- shows how to dynamically change a text in mappView depending on a PLC variable. The text is located in a text file which allows you to switch between languages. The sample is based on the mappView help (11eb265c-2891-41d9-a2bf-4f4810269bab)

Preperation

  • Add a project language to your project if it does not already exist
  • Add a text snippet file
  • Add a localized text file

Image

Text file

Open the localized text file and a few lines. Change the namespace to "IAT" and make sure the Text ID is Status followed by a dot and a number.

Image

Snippet file

Open the snippet file, define a snippet set id and add a snippet line for text.

<?xml version="1.0" encoding="utf-8"?>
<SnippetsSet id="TextSnippets" xmlns="http://www.br-automation.com/iat2015/snippet/engineering/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Snippets>
		<Snippet id="SnippetStatus" xsi:type="session" type="IndexText" formatItem="Status.{1}" />
	</Snippets>
</SnippetsSet>

Add text output

Open the page where the status text should be displayed. Add a new text output and name it "StatusTextOutput"

Text file

Go to the physical view and open the *.vis file. Add the snippet set to the configuration.

  <SnippetsSets>
    <SnippetsSet refId="TextSnippets"/>
  </SnippetsSets>

Binding file

Open the binding file that belongs to the content page or create a new binding file and add the following bindings. The first binding connects that PLC variable TestVar1 to the snippet. The second binding connects the snippet to the text output widget.

<Binding mode="oneWay">
  <Source xsi:type="opcUa" refId="::AsGlobalPV:TestVar1" attribute="value"/>
  <Target xsi:type="snippet" refId="SnippetStatus" attribute="value"/>
</Binding>
	
<Binding mode="oneWay">
  <Source xsi:type="snippet" refId="SnippetStatus" attribute="value" />
  <Target xsi:type="brease" widgetRefId="StatusTextOutput" contentRefId="contentStart" attribute="value" />
</Binding>

Text configuration

Make sure that the text file create in the first step is added to the text system in the configuration view. Add a text system configuration if it does not exist.

Image

Clone this wiki locally