Design

Carry out the following steps for the example in the project interface:

  1. Open a view in the workspace.
  2. Switch to the Xamlview here and copy the following XAML code into the LayoutRoot node.
    <Grid x:Name="grdSample" Margin="41,142.048,67,138.191" HorizontalAlignment="Left" VerticalAlignment="Top"> <Grid.RowDefinitions> <RowDefinition Height="0.216*"/> <RowDefinition Height="0.784*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="0.221*"/> <ColumnDefinition Width="0.378*"/> <ColumnDefinition Width="0.401*"/> </Grid.ColumnDefinitions> <Border BorderBrush="Black" BorderThickness="1" Margin="0" Grid.RowSpan="2" CornerRadius="10" Background="#FFFB5B2B"/> <Border BorderBrush="Black" BorderThickness="1" Grid.Column="1" Margin="0" Grid.RowSpan="2" CornerRadius="10" Background="#FF3437F9"/> <Border BorderBrush="Black" BorderThickness="1" Grid.Column="2" Margin="0" Grid.RowSpan="2" CornerRadius="10" Background="#FF7DFF00"/> <vw:NumericVarIn x:Name="viRawValue" Margin="10,66.788,10,0" VariableName="Ch1.RawValue" Grid.Row="1" Height="40.658" VerticalAlignment="Top"/> <vw:Label Height="19" VerticalAlignment="Top" Margin="10,39.788,10,0" Text="Sensor raw value" Grid.Row="1" d:LayoutOverrides="VerticalAlignment"/> <vw:Label Width="220" Height="21.333" VerticalAlignment="Top" Margin="10,39.788,10,0" Text="Distance (sensor independent)" Grid.Column="1" Grid.Row="1" d:LayoutOverrides="VerticalAlignment"/> <vw:NumericVarIn x:Name="vinSensorIndependent" Margin="10,66.788,10,0" VariableName="Ch1.SensorIndependent" RenderTransformOrigin="0.5,0.5" Grid.Column="1" Grid.Row="1" VerticalAlignment="Top" Height="40.658"> <vw:NumericVarIn.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="0"/> <TranslateTransform/> </TransformGroup> </vw:NumericVarIn.RenderTransform> </vw:NumericVarIn> <vw:Label Height="24" VerticalAlignment="Top" Margin="10,4.454,10,0" Text="Language dependent distance" d:LayoutOverrides="VerticalAlignment" Grid.Column="2" Grid.Row="1"/> <vw:NumericVarIn x:Name="vinLangDepDist" Margin="10,26.618,70,0" VariableName="Ch1.SensorIndependent_Lng" Grid.Column="2" Grid.Row="1" Height="41.66" VerticalAlignment="Top"/> <vw:Label Margin="10,84.449,10,0" Text="Language dependent distance (ext.)"  Grid.Column="2" Height="20" VerticalAlignment="Top" Grid.Row="1"/> <vw:NumericVarIn x:Name="vinLangDepDistExt" Margin="10,108.449,70,98.688" VariableName="Ch1.SensorIndependent_Ext" Grid.Column="2" Grid.Row="1"/> <vw:Switch x:Name="swtAdaptSensor" Width="91.08" HorizontalAlignment="Right" Margin="10,123.114,245.168,84.688" TextOff="Type A" TextOn="Type B" VariableName="DistanceSensorAdaptionSwitch" Grid.Column="1" Grid.Row="1" RenderTransformOrigin="0.295,0.849"/> <vw:Switch x:Name="swtNormal_Milli" Width="71.474" HorizontalAlignment="Left" Margin="120.026,186.093,0,0" VariableName="DistanceSensorExtendedSwitch" BitNumber="1" TextOff="Normal" TextOn="Milli" Grid.Column="2" Grid.Row="1" Height="40.833" VerticalAlignment="Top"/> <vw:Button x:Name="btn1031" Width="48" Height="40.833" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,186.093,0,0" Text="DE" d:LayoutOverrides="HorizontalAlignment" Grid.Column="2" Grid.Row="1"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <vw:ChangeLanguageAction LCID="1031"/> <vw:ResetBitAction VariableName="DistanceSensorExtendedSwitch"/> </i:EventTrigger> </i:Interaction.Triggers> </vw:Button> <vw:Button x:Name="btn1033" Width="48.5" Height="40.833" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="62.0000000000001,186.093,0,0" Text="GB" Grid.Column="2" Grid.Row="1"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <vw:ChangeLanguageAction LCID="1033"/> <vw:SetBitAction VariableName="DistanceSensorExtendedSwitch"/> </i:EventTrigger> </i:Interaction.Triggers> </vw:Button> <TextBlock HorizontalAlignment="Right" Margin="0,33.788,10,0" TextWrapping="Wrap" Text="{Binding UnitText, ElementName=vinLangDepDist}" Width="56" Height="27.333" VerticalAlignment="Top" Grid.Column="2" Grid.Row="1"/> <TextBlock HorizontalAlignment="Right" Margin="0,123.104,19.606,98.688" TextWrapping="Wrap" Text="{Binding UnitText, ElementName=vinLangDepDistExt}" Width="46.394" Grid.Column="2" Grid.Row="1"/> <vw:NumericVarIn HorizontalAlignment="Left" Margin="196,195.124,0,0" Width="66" VariableName="DistanceSensorExtendedSwitch" Grid.Column="2" Grid.Row="1" Height="24.825" VerticalAlignment="Top"/> <TextBlock Margin="0,15.618,0,13.785" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" HorizontalAlignment="Centre"><Run FontSize="21.333" Language="en-de" Text="PLC"/></TextBlock> <TextBlock Grid.Column="1" Margin="0,21.618,0,7.784" TextWrapping="Wrap" d:LayoutOverrides="Height" HorizontalAlignment="Centre"><Run FontSize="21.333" Language="en-de" Text="Kernel"/></TextBlock> <TextBlock Grid.Column="2" HorizontalAlignment="Center" Margin="0,18.952,0,10.452" TextWrapping="Wrap" d:LayoutOverrides="Height" FontSize="21.333"><Run Language="de-de "Text="Surface"/></TextBlock> </Grid>
  3. Switch back to the Design view.

The control elements parameterised in this way have the following function:

vinRawValue

(VariableName = Ch1.RawValue)

Has a link to the PLC value without conversions. The PLC value can be simulated and entered here.

swtAdaptSensor
Switches the switching variable of the DistanceSensorAdaption unit class and thus the adaptation to the corresponding sensor types.
vinSensorIndependent

(VariableName = Ch1.SensorIndependent)

Uses the variable definition that contains the conversion for standardising the two sensor types.

btn1031

The click event has a link to two actions:

  • The language is changed to German via a ChangeLanguageAction.
  • In the changeover variable for the LengthConversionExtended unit class, bit 0 is set to 0 via a ResetBitAction.
btn1033

Here, too, there are two functions:

  • The language is changed to English via a ChangeLanguageAction.
  • In the changeover variable for the LengthConversionExtended unit class, bit 0 is set to 1 via a SetBitAction.

The switchover variables are set in conjunction with the function of the swtNormal_Milli control element.

swtNormal_Milli

Manipulates bit 1 in the changeover variable for the LengthConversionExtended unit class. Together with the two control elements btn1031 and btn1033, the following combinations result for the control variable:

Language Function Value of the switching variable (bit-combined) Displayed unit
EN Normal 0 (00) cm
GB Normal 1 (01) in.
EN Milli 2 (10) mm
GB Milli 3 (11) mil.
vinLangDepDist

(VariableName = Ch1.SensorIndependent_Lng)

Represents the variable value, which is first standardised using the unit class (process) and then converted into cm or inches using the language-dependent unit class.

A TextBlock also represents the unit text. The Text property of the TextBlock element is linked to the UnitText property of the NumericVarIn via a data binding.

vinLangDepDistExt

(VariableName = Ch1.SensorIndependent_Ext)

Represents the variable value, which is first standardised using the unit class (process) and then converted into cm, mm, inch or mil using the variable-dependent unit class LengthConversionExtended.

The unit text is also displayed here using a TextBlock element.