Skip to content

(Use case) Load content dynamically into content control (Dashboard)

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

Requirements

  • Automation Studio 4.4
  • mappView 5.4

Description

This -->sample<-- shows how to create dynamic dashboard to show information from optional components. In this example the machine has 4 drives that all have the same information. Since the drives are optional each one can be enabled or disabled on the start page. The sample page consists of 4 content controls that are dynamically filled on page load. An OPC variable store the information if a content is visible.

Image

Implementation

  • Add a new page and define the layout
  • Create multiple toggle buttons to enable or disable the dashboard items
  • Connect the toggle buttons to an OPC variable that stores the information if an item is visible
  • Add a second page and define the layout
  • Add group boxes and add a content control inside of each group box
  • Add a content file for each content control
  • Create the event binding to switch between the contents

The main work is done by the event binding code in "start.eventbinding". When the sample page is loaded the eventbinding checks each OPC variable to see if the content should be visible. Then the event handler compares the page name and OPC variable and loads or unloads the content.

Event binding file

<?xml version="1.0" encoding="utf-8"?>
<EventBindingSet id="eventbindingStart" xmlns="http://www.br-automation.com/iat2014/eventbinding/v2" xmlns:types="http://www.br-automation.com/iat2015/widgetTypes/v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<Bindings>
		<!-- Load content for each field when page sample is loaded />-->
		<EventBinding>
			<Source xsi:type="clientSystem.Event" event="ContentLoaded" />			
			
			<!-- Read data points to check if content should be visible />-->	
			<Operand name="ContentIsVisible1" datatype="BOOL">
				<ReadTarget xsi:type="opcUa.NodeAction.Read" refId="::AsGlobalPV:Motor[1].IsVisible" >
					<Method xsi:type="opcUa.NodeAction.GetValue" />
				</ReadTarget>
			</Operand>	
			<Operand name="ContentIsVisible2" datatype="BOOL">
				<ReadTarget xsi:type="opcUa.NodeAction.Read" refId="::AsGlobalPV:Motor[2].IsVisible" >
					<Method xsi:type="opcUa.NodeAction.GetValue" />
				</ReadTarget>
			</Operand>	
			<Operand name="ContentIsVisible3" datatype="BOOL">
				<ReadTarget xsi:type="opcUa.NodeAction.Read" refId="::AsGlobalPV:Motor[3].IsVisible" >
					<Method xsi:type="opcUa.NodeAction.GetValue" />
				</ReadTarget>
			</Operand>	
			<Operand name="ContentIsVisible4" datatype="BOOL">
				<ReadTarget xsi:type="opcUa.NodeAction.Read" refId="::AsGlobalPV:Motor[4].IsVisible" >
					<Method xsi:type="opcUa.NodeAction.GetValue" />
				</ReadTarget>
			</Operand>	
						
			<!-- Load content for each field when page sample is loaded and content is set to visible />-->		
			<EventHandler condition="contentId=&quot;contentSample&quot; AND ContentIsVisible1=true" >
				<Action>
					<Target xsi:type="widgets.brease.ContentControl.Action" contentRefId="contentSample" widgetRefId="ContentControl1">
						<Method xsi:type="widgets.brease.ContentControl.Action.LoadContent" contentId="contentDyn1"/>
					</Target>
				</Action>
			</EventHandler>
			<EventHandler condition="contentId=&quot;contentSample&quot; AND ContentIsVisible1=false" >
				<Action>
					<Target xsi:type="widgets.brease.ContentControl.Action" contentRefId="contentSample" widgetRefId="ContentControl1">
						<Method xsi:type="widgets.brease.ContentControl.Action.UnloadContent" />
					</Target>
				</Action>
			</EventHandler>			
			<EventHandler condition="contentId=&quot;contentSample&quot; AND ContentIsVisible2=true" >
				<Action>
					<Target xsi:type="widgets.brease.ContentControl.Action" contentRefId="contentSample" widgetRefId="ContentControl2">
						<Method xsi:type="widgets.brease.ContentControl.Action.LoadContent" contentId="contentDyn2"/>
					</Target>
				</Action>
			</EventHandler>
			<EventHandler condition="contentId=&quot;contentSample&quot; AND ContentIsVisible2=false" >
				<Action>
					<Target xsi:type="widgets.brease.ContentControl.Action" contentRefId="contentSample" widgetRefId="ContentControl2">
						<Method xsi:type="widgets.brease.ContentControl.Action.UnloadContent" />
					</Target>
				</Action>
			</EventHandler>			
			<EventHandler condition="contentId=&quot;contentSample&quot; AND ContentIsVisible3=true" >
				<Action>
					<Target xsi:type="widgets.brease.ContentControl.Action" contentRefId="contentSample" widgetRefId="ContentControl3">
						<Method xsi:type="widgets.brease.ContentControl.Action.LoadContent" contentId="contentDyn3"/>
					</Target>
				</Action>
			</EventHandler>
			<EventHandler condition="contentId=&quot;contentSample&quot; AND ContentIsVisible3=false" >
				<Action>
					<Target xsi:type="widgets.brease.ContentControl.Action" contentRefId="contentSample" widgetRefId="ContentControl3">
						<Method xsi:type="widgets.brease.ContentControl.Action.UnloadContent" />
					</Target>
				</Action>
			</EventHandler>
			<EventHandler condition="contentId=&quot;contentSample&quot; AND ContentIsVisible4=true" >
				<Action>
					<Target xsi:type="widgets.brease.ContentControl.Action" contentRefId="contentSample" widgetRefId="ContentControl4">
						<Method xsi:type="widgets.brease.ContentControl.Action.LoadContent" contentId="contentDyn4"/>
					</Target>
				</Action>
			</EventHandler>
			<EventHandler condition="contentId=&quot;contentSample&quot; AND ContentIsVisible4=false" >
				<Action>
					<Target xsi:type="widgets.brease.ContentControl.Action" contentRefId="contentSample" widgetRefId="ContentControl4">
						<Method xsi:type="widgets.brease.ContentControl.Action.UnloadContent" />
					</Target>
				</Action>
			</EventHandler>						
		</EventBinding>
	</Bindings>
</EventBindingSet>
Clone this wiki locally