• 26.05.2024, 12:35
  • Registrieren
  • Anmelden
  • Sie sind nicht angemeldet.

 

Script to show image based on pressure

Montag, 28. November 2016, 00:13

Anyone know why this script doesn't work? The pressure is 0.04 bar (shown correctly under the image), but it shows the image for high pressure (above 0.8). It's the standard Aqualis script with a few modifications.

---
<UserControl
x:Name="this"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" d:DesignHeight="50" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<!--Simpe databinding example-->
<!--1. set up connection for this item (ie. temperature sensor)-->
<!--2. bind values to your own usercontrol-->
<!--Binding example-->
<!--Content="{Binding ElementName=this, Path=DataContext.Value, FallbackValue=no data available}"-->

<!--default background-->
<Rectangle Grid.Row="0" Grid.RowSpan="1" Fill="#FF78949A" Opacity="1.0"/>
<Rectangle Grid.Row="1" Grid.RowSpan="1" Fill="#FFF0F0F0" Opacity="1.0"/>
<Rectangle Grid.Row="2" Grid.RowSpan="1" Fill="#FFF0F0F0" Opacity="1.0"/>

<!--Content: binding to source value: -->
<!--Content: ElementName=this -->
<!--Content: Path=DataContext.Value, for connetion to actual connected value -->
<Label
Content="{Binding ElementName=this, Path=DataContext.Value, FallbackValue=no data available}"
ContentStringFormat="Pressure: {0:#,#0.00} Bar"
Grid.Row="2"
Opacity="1.0"
Height="Auto"
Width="Auto"
Foreground="#FF000000"
FontSize="13"
FontFamily="Segoe UI"
FontWeight="Normal"
Margin="0,0,0,0"
Padding="0,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center" />

<!--Content: binding to source value: -->
<!--Content: ElementName=this -->
<!--Content: Path=DataContext.DataName, for connetion to actual connected value name -->
<Label
Content="{Binding ElementName=this, Path=DataContext.DataName, FallbackValue=no data available}"
Grid.Row="0"

Opacity="1.0"
Height="Auto"
Width="Auto"
Foreground="#FFEEEEEE"
FontSize="11"
FontFamily="Segoe UI"
FontWeight="Normal"
Margin="3,0,0,0"
Padding="0,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center" />

<Image
Grid.Row="1"
Opacity="1.0"
Height="Auto"
Width="Auto"
Margin="5,5,5,5"
Stretch="Uniform"
StretchDirection="Both" >
<Image.Style>
<Style TargetType="{x:Type Image}">
<Setter Property="Source" Value="D:/aquasuite/Content/images/Pressure_low.png" />

<Style.Triggers>
<DataTrigger
Value="True"
Binding="{Binding ElementName=this, Path=DataContext.Value, ConverterParameter=0.5, Converter={StaticResource CompareSmalerConverter}}">
<Setter Property="Source" Value="D:/aquasuite/Content/images/Pressure_low.png"/>
</DataTrigger>

<DataTrigger
Value="True"
Binding="{Binding ElementName=this, Path=DataContext.Value, ConverterParameter=0.5, Converter={StaticResource CompareGreaterEqualConverter}}">
<Setter Property="Source" Value="D:/aquasuite/Content/images/Pressure_medium.png"/>
</DataTrigger>

<DataTrigger
Value="True"
Binding="{Binding ElementName=this, Path=DataContext.Value, ConverterParameter=0.8, Converter={StaticResource CompareGreaterEqualConverter}}">
<Setter Property="Source" Value="D:/aquasuite/Content/images/Pressure_high.png"/>
</DataTrigger>

</Style.Triggers>
</Style>
</Image.Style>
</Image>





</Grid>
</UserControl>

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »SverreMunthe« (28. November 2016, 00:15)

Montag, 28. November 2016, 11:34

ConverterParameter=0.5, Converter={StaticResource CompareGreaterEqualConverter}}"
ConverterParameter=0.8, Converter={StaticResource CompareGreaterEqualConverter}}"
... you have to remove one of this conditions

Montag, 28. November 2016, 12:37

ConverterParameter=0.5, Converter={StaticResource CompareGreaterEqualConverter}}"
ConverterParameter=0.8, Converter={StaticResource CompareGreaterEqualConverter}}"
... you have to remove one of this conditions


How do I make a test for 3 levels then?

Test 1: Is it low? (Lower than 0.5)
Test 2: Is it high? (Greater or Equal to 0.5)
Test 3: Is it higher still? (Greater or Equal to 0.8)

This part of the script is identical to the Aqualis fill-level script that comes with Aquasuite.

Montag, 28. November 2016, 12:47

you have to start your compare with the highest value

Montag, 28. November 2016, 14:43

you have to start your compare with the highest value


What is the number in ConverterParameter? I want to measure something (pressure) that has to be lower than 0.1 (low), higher than or equal to 0.1 (medium) and higher or equal to 0.25 (high). Do I just enter these numbers? That doesn't seem to work for values lower than 1 (0.9, 0.8 etc.). ?(

I'm to old to learn new languages. I know Cobol, Fortran, C, Basic, Pascal, Turbo Pascal, Visual Basic even a strange language called Omnis7 and probably more, but these script languages are to far removed from what I'm used to. :cursing:

Montag, 28. November 2016, 14:46

Another thing. Editing a script directly in the item (display) doesn't show lines below the screen, ie. the part of the script you have to scroll down to see. Is this a known bug, or am I doing something wrong?

Montag, 28. November 2016, 15:11

I can confirm that. Must be new. Sebastian has already left the office. He will take a look at this tomorrow.

Montag, 28. November 2016, 15:13

I can confirm that. Must be new. Sebastian has already left the office. He will take a look at this tomorrow.


I've had this since 2012, so I'm not sure if it's a bug.

Montag, 28. November 2016, 15:30

I can not remember that I have seen this problem in older versions.

Montag, 28. November 2016, 16:01

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »SverreMunthe« (28. November 2016, 16:03)

Montag, 28. November 2016, 16:20

Hehe, they can not help you because for them it is just a random code fragment. They do not know that this is part of a software that does already process a lot of other stuff in the background.

Montag, 28. November 2016, 17:10

Hehe, they can not help you because for them it is just a random code fragment. They do not know that this is part of a software that does already process a lot of other stuff in the background.


Guess I have to wait for Sebastian. :)

Ähnliche Themen