Skip to content

(Event Binding) Event binding builder

Stephan Stricker edited this page Nov 7, 2019 · 5 revisions

Description

The event file builder can be used to quickly copy and paste an event binding. Copy the code from chapter 1-4 to create an event binding.


1 Outer frame

Start with the outer frame of the event binding.

<EventBinding>
  <!-- Add a description for the event binding here />-->


</EventBinding>

2 Event triggers

Add one event trigger of the following type. Read this for more details.

OPC UA variable

  <Source xsi:type="opcUa.Event" refId="::Program:boolVariable" event="ValueChanged" />

The trigger creates the two internal variable newValue and oldValue. The values can be used later for conditions.

Session variable

Variable

  <Source xsi:type="session.Event" refId="variable1" event="ValueChanged"/>

Timer

  <Source xsi:type="session.Timer.Event" refId="AutoLogOutTimer" event="Elapsed"/>

The trigger creates the two internal variable newValue and oldValue. The values can be used later for conditions.

Client System

  • KeyBoard Events
<Source xsi:type="clientSystem.Event" event="KeyPress" />
<Source xsi:type="clientSystem.Event" event="KeyUp" />
<Source xsi:type="clientSystem.Event" event="KeyDown" />

The trigger creates the two variable keyASCII and key. The value can be used later for conditions.

<EventHandler condition="keyASCII = 97" >
<EventHandler condition="key = &quot;ArrowLeft&quot;" >
  • Gesture Events
<Source xsi:type="clientSystem.Event" event="SystemSwipe" />

The trigger creates one variable direction. The value can be used later for conditions.

<EventHandler condition="direction=&quot;fromTop&quot;">
  • ContentLoaded Event
<Source xsi:type="clientSystem.Event" event="ContentLoaded" />

The trigger creates the two variables contentId and visuId. These values can be used later for conditions.

<EventHandler condition="contentId=&quot;Content1&quot;">
  • DisabledClick Event
<Source xsi:type="clientSystem.Event" event="DisabledClick" />

The trigger creates the three variables contentId, widgetId and hasPermission. These values can be used later for conditions.

<EventHandler condition="contentId=&quot;Content1&quot;">
  • DialogOpened Event
<Source xsi:type="clientSystem.Event" event="DialogOpened" />

The trigger creates one variable dialogId. This value can be used later for conditions.

<EventHandler condition="dialogId=&quot;Dialog1&quot;">
  • DialogClosed Event
<Source xsi:type="clientSystem.Event" event="DialogClosed" />

The trigger creates one variable dialogId. This value can be used later for conditions.

<EventHandler condition="dialogId=&quot;Dialog1&quot;">

Widget

<Source xsi:type="widgets.brease.Button.Event" contentRefId="Content1" widgetRefId="Button1" event="Click"/>

2.1 Operand (Optional)

Operands can be used to load additional variables into an event binding.

Data type of the operand can be BOOL, ANY_REAL, ANY_INT, ANY_STRING, BOOL_ARRAY, ANY_REAL_ARRAY, ANY_INT_ARRAY, ANY_STRING_ARRAY, DATE_AND_TIME

OPC UA operands

<!-- Read value from PLC />-->	
<Operand name="ContentIsVisible1" datatype="BOOL">
  <ReadTarget xsi:type="opcUa.NodeAction.Read" refId="::AsGlobalPV:Motor[1].IsVisible" >
    <Method xsi:type="opcUa.NodeAction.GetValue" />
  </ReadTarget>
</Operand>

Session operands

<!-- Read session variable />-->	
<Operand name="InputValue2" datatype="ANY_INT">
  <ReadTarget xsi:type="session.VariableAction.Read" refId="InputValue2" > 
    <Method xsi:type="session.VariableAction.GetValue" /> 
  </ReadTarget>
</Operand>	

Widget operands

<!-- Read widget property />-->	
<Operand name="contentid" datatype="ANY_STRING">
  <ReadTarget xsi:type="widgets.brease.ContentControl.ReadAction" contentRefId="Content1" widgetRefId="ContentControl1" > 
    <Method xsi:type="widgets.brease.ContentControl.Action.GetContentId" />
  </ReadTarget>
</Operand>

3 Event handler

This is the part that gets executed when a trigger is fired. Pick 3.1 or 3.2 and add 3.3 if necessary.

3.1 Event handler without condition

When the action should be executed all the time use this frame for the handler.

<EventHandler>

</EventHandler>

3.2 Event handler with Condition

In some cases it can be necessary to combine the event trigger with additional conditions. For details about comparison see this options. Boolean values use the notation "newValue" for true and "NOT newValue" for false.

<!-- New value smaller 20, old value greater 10 />-->
<EventHandler condition="newValue &lt; 20 AND oldValue &gt; 10" >

</EventHandler>
<!-- String value is not equal 'correct' />-->
<EventHandler condition="value &lt;&gt; &quot;correct&quot;">

</EventHandler>

3.3 Execute multiple actions (Optional)

If the event handler must execute multiple actions use a sequence frame.

<Sequence>
  <Step order="0">
      ...
  </Step>
  <Step order="1">
      ...
  </Step>
</Sequence>

4 Event actions

Actions are executed when a trigger is fired. The following targets can be used for actions. Read this for more details. Use the following outer frame for the event action and then copy one of the targets below into it.

  <Action>

  </Action>

OPC UA variable

  • SetValueBool
<Target xsi:type="opcUa.NodeAction" refId="::Program:Variable1" >
  <Method xsi:type="opcUa.NodeAction.SetValueBool" value="true" />
</Target>

Use false to reset the variable

  • ToggleValueBool
<Target xsi:type="opcUa.NodeAction" refId="::Program:Variable1" >
  <Method xsi:type="opcUa.NodeAction.ToggleValueBool"/>
</Target>
  • SetValueNumber
<Target xsi:type="opcUa.NodeAction" refId="::Program:Variable1" >
  <Method xsi:type="opcUa.NodeAction.SetValueNumber" value="37.1" />
</Target>
  • AddValue
<Target xsi:type="opcUa.NodeAction" refId="::Program:Variable1" >
  <Method xsi:type="opcUa.NodeAction.AddValue" value="2" />
</Target>
  • SetValueString
<Target xsi:type="opcUa.NodeAction" refId="::Program:Variable1" >
  <Method xsi:type="opcUa.NodeAction.SetValueString" value="Hello World" />
</Target>
  • SetValueDateAndTime
<Target xsi:type="opcUa.NodeAction" refId="::Program:Variable1" >
  <Method xsi:type="opcUa.NodeAction.SetValueDateTime" value="2018-02-23T09:33:30Z" />
</Target>
  • GetValue
<ReadTarget xsi:type="opcUa.NodeAction.Read" refId="::Program:Variable1" >
  <Method xsi:type="opcUa.NodeAction.GetValue" />
</ReadTarget>
  • GetServerStatus
<ReadTarget xsi:type="opcUa.SystemAction.Read" serverAlias="extern" >
  <Method xsi:type="opcUa.SystemAction.GetServerStatus" />
</ReadTarget>

Session variable

Session variables exist for each client connection as individual set of data.

  • SetValueBool
<Target xsi:type="session.VariableAction" refId="Variable1" >
  <Method xsi:type="session.VariableAction.SetValueBool" value="false" />
</Target>

Use false to reset the variable

  • ToggleValueBool
<Target xsi:type="session.VariableAction" refId="Variable1" >
  <Method xsi:type="session.VariableAction.ToggleValueBool" />
</Target>
  • SetValueNumber
<Target xsi:type="session.VariableAction" refId="Variable1" >
  <Method xsi:type="session.VariableAction.SetValueNumber" value="4.8" />
</Target>
  • AddValue
<Target xsi:type="session.VariableAction" refId="Variable1" >
  <Method xsi:type="session.VariableAction.AddValue" value="-4.8" />
</Target>
  • SetValueString
<Target xsi:type="session.VariableAction" refId="Variable1" >
  <Method xsi:type="session.VariableAction.SetValueString" value="Hello World" />
</Target>
  • SetValueDateAndTime
<Target xsi:type="session.VariableAction" refId="Variable1" >
  <Method xsi:type="session.VariableAction.SetValueDateTime" value="2018-02-23T09:33:30Z" />
</Target>
  • GetValue
<ReadTarget xsi:type="session.VariableAction.Read" refId="Variable1" >
 <Method xsi:type="session.VariableAction.GetValue" />
</ReadTarget>
  • Start (Timer)
<Target xsi:type="session.TimerAction" refId="RepetitivTimer" >
 <Method xsi:type="session.TimerAction.Start" interval="1000" />
</Target>
  • Stop (Timer)
<Target xsi:type="session.TimerAction" refId="RepetitivTimer" >
  <Method xsi:type="session.TimerAction.Stop" />
</Target>
  • IsRunning (Timer)
<ReadTarget xsi:type="session.TimerAction.Read" refId="RepetitivTimer" >
  <Method xsi:type="session.TimerAction.IsRunning" />
</ReadTarget>

Client System

  • OpenDialog
<Target xsi:type="clientSystem.Action">
    <Method xsi:type="clientSystem.Action.OpenDialog" dialogId="dialog1" horizontalPos="left" verticalPos="top" />
</Target>
  • CloseDialog
<Target xsi:type="clientSystem.Action">
    <Method xsi:type="clientSystem.Action.CloseDialog" dialogId="dialog1" />
</Target>
  • ShowMessageBox
<Target xsi:type="clientSystem.Action">
    <Method xsi:type="clientSystem.Action.ShowMessageBox" type="OKCancel" message="$MachineStoppedText" header="Warning!" icon="Warning"  />
</Target>
<Result>
    <ResultHandler condition="result = 4">
    ...
    </ResultHandler>
</Result>
  • Action.Navigate
<Target xsi:type="clientSystem.Action"> <Method xsi:type="clientSystem.Action.Navigate" pageId="mainpage" /> </Target>
  • LoadContentInArea
<Target xsi:type="clientSystem.Action">
    <Method xsi:type="clientSystem.Action.LoadContentInArea" contentId="Content3" areaId="A1" pageId="MainPage" />
</Target>
The action returns the result for load successful
  • LoadContentInDialogArea
<Target xsi:type="clientSystem.Action">
    <Method xsi:type="clientSystem.Action.LoadContentInDialogArea" contentId="Content3" areaId="A1" dialogId="Dialog1" />
</Target>
The action returns the result for load successful
  • ChangeTheme
<Target xsi:type="clientSystem.Action">
    <Method xsi:type="clientSystem.Action.ChangeTheme" theme="MyNewTheme" />
</Target>
  • Login
<EventBinding>
    <Source xsi:type="opcUa.Event" refId="::Program:startLogin" event="ValueChanged" />
			
    <Operand name="user" datatype="ANY_STRING">
        <ReadTarget xsi:type="opcUa.NodeAction.Read" refId="::Program:user">
            <Method xsi:type="opcUa.NodeAction.GetValue" />
        </ReadTarget>
    </Operand>

    <Operand name="pwd" datatype="ANY_STRING">
        <ReadTarget xsi:type="opcUa.NodeAction.Read" refId="::Program:pwd">
            <Method xsi:type="opcUa.NodeAction.GetValue" />
        </ReadTarget>
    </Operand>

    <EventHandler condition="newValue = 1">
        <Action>
            <Target xsi:type="clientSystem.Action">
                <Method xsi:type="clientSystem.Action.Login" userName="=user" password="=pwd" />
            </Target>
        </Action>
    </EventHandler>
</EventBinding>
  • Logout
<Target xsi:type="clientSystem.Action"> 
  <Method xsi:type="clientSystem.Action.Logout"/> 
</Target>
  • SetLanguage
<Target xsi:type="clientSystem.Action">
    <Method xsi:type="clientSystem.Action.SetLanguage" value="en" />
</Target>
  • SetMeasurementSystem
<Target xsi:type="clientSystem.Action">
    <Method xsi:type="clientSystem.Action.SetMeasurementSystem" value="imperial" />
</Target>
  • ScrollContent
<Target xsi:type="clientSystem.Action">
    <Method xsi:type="clientSystem.Action.ScrollContent" contentId="Content2" position="top" duration="2000" />
</Target>
The action returns the result for load successful
  • OpenDialogAtTarget
<Target xsi:type="clientSystem.Action">
    <Method xsi:type="clientSystem.Action.OpenDialogAtTarget" dialogId="dialog1" horizontalPos="left" verticalPos="bottom" target="StartContent_Button1" horizontalDialogAlignment="left" verticalDialogAlignment="middle"/>
</Target>

Widget

These are actions that can be executed on widgets. See the Automation Studio help for details what events can be triggered by each widget.

<Target xsi:type="widgets.brease.Button.Action" contentRefId="Content1" widgetRefId="Button1" >
  <Method xsi:type="widgets.brease.Button.Action.SetEnable" value="true"/>
</Target>
Clone this wiki locally