Skip to content

(Use case) Change style on variable change

Stephan Stricker edited this page Sep 1, 2022 · 8 revisions

Requirements

  • Automation Studio 4.4
  • mappView 5.4

Implementation

  • Add a new theme to the project
  • Add a new style set package
  • Add a new style file, add the style definition below and add the file to the styleset
  • Add the event binding in the event binding file

Notes

Only styleable properties can be changed. See the widget documentation for details. Only properties that have not been changed from the default can be changed. For example, if the backColor of a widget has been changed in the editor to a different value, then the backColor can no longer be changed by an event action.

Add new theme

Add a new theme to the project and add the theme to the .vis file in the configuration view

  <StartTheme themeRefId="BuRTheme1" />
  <Themes>
    <Theme refId="BuRTheme1"/>
  </Themes>

Style set package

Add a new style set package and copy the following code into the style set file.

<?xml version="1.0" encoding="utf-8"?>
<StylesSet id="stylesset_1" xmlns="http://www.br-automation.com/iat2015/stylesset/engineering/v1">
  <Styles refId="CMStyles" />
</StylesSet>

Styles definition

Add a new styles file to the style set and copy the following code into it.

<?xml version="1.0" encoding="utf-8"?>
<Styles id="CMStyles" xmlns="http://www.br-automation.com/iat2015/styles/engineering/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<Style id="Output_OK" xsi:type="widgets.brease.NumericOutput" backColor="#2FC43B" fontSize="16px"/>
	<Style id="Output_ERR" xsi:type="widgets.brease.NumericOutput" backColor="#A81717" fontSize="16px"/>	
</Styles>

Event binding file

Adjust the following items:

  • OPC Variable -> ::ConditionM:CM_data_analyse.RmsStatus
  • Content page -> ConditionAnalyse_content
  • Style -> Output_OK, Output_ERR
<EventBinding>
  <Source xsi:type="opcUa.Event" refId="::ConditionM:CM_data_analyse.RmsStatus" event="ValueChanged"/>
  
  <EventHandler condition="newValue=0">
    <Action>
      <Target xsi:type="widgets.brease.NumericOutput.Action" contentRefId="ConditionAnalyse_content" widgetRefId="labRmsStatus" >
        <Method xsi:type="widgets.brease.NumericOutput.Action.SetStyle" value="Output_OK" />
      </Target>
    </Action>							
  </EventHandler>
  
  <EventHandler condition="newValue &gt;0">
    <Action>
      <Target xsi:type="widgets.brease.NumericOutput.Action" contentRefId="ConditionAnalyse_content" widgetRefId="labRmsStatus" >
        <Method xsi:type="widgets.brease.NumericOutput.Action.SetStyle" value="Output_ERR" />
      </Target>
    </Action>							
  </EventHandler>
  
</EventBinding>
Clone this wiki locally