Page 1 of 1
Displayformat
Posted: Wed Jul 30, 2014 9:39 am
by iXUser
From my PLC I get a array of timestamps and I want to show them in textboxes.
Is there any way to convert this timestamp into a human-readable format (HH:mm:ss) in AnalogNumeric-Boxes?
Is there a posibilty / description about how to code an custom display-format / ValueConverter?
I tried to write my own custom control, but it won't work, because the target-system is Windows CE 5, and newer Visual Studio (Express) Versions seem not to support this anymore.
Re: Displayformat
Posted: Wed Jul 30, 2014 10:40 am
by Doug H.
In what format are the timestamps in the array? Also what controller are you using? If no conversion is needed and based on the controller, what you could do is create a tag for each space in the array to display those timestamps.
Re: Displayformat
Posted: Thu Jul 31, 2014 2:00 am
by iXUser
Hi Doug,
thanks for your fast response!
The time is calculated in seconds as of January 1, 1970, 00:00 hours.
(CoDeSys Standard DATE_AND_TIME)
When I import the tags, I can set the 'DateTime' - Format. But in the AnalogNumeric it will show a 10-digit number.
I would rather not use an expression with an additional tag.
Since this adds a lot of extra Tags (error-prone) in my project. I would expect, that I can use the original tags by simply changing the display-format.
Later I would also like to give the user the posibility to modify the Time and/or Date. And I believe with expressions and additional tags, this becomes quite complex.
Re: Displayformat
Posted: Thu Jul 31, 2014 3:09 am
by iXUser
I figured, that with the label, I have the posibility to add Text- and ValueConverters.
I would like to add an custom converter here for Date and Time.
And I would like to apply these converters also to editable AnalogNumerics.
In WPF I can do that simply by applying a IValueConverter-Class to the binding.
But how can I do that in HMI-Builder?
When I tried to edit the XAML, HMIBuilder overwrites all modifications in XAML.
Code: Select all
<nac:Label Background="#00FFFFFF" Foreground="#FF000000" FontFamily="Tahoma" FontSize="20" FontStyle="Normal" FontWeight="Normal" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" Padding="5,0,5,1" Name="Text12" Width="Auto" Height="Auto" RenderTransformOrigin="0.5,0.5" Visibility="Visible" Panel.ZIndex="12" Canvas.Left="629" Canvas.Top="248">
<nac:Label.Resources>
<ResourceDictionary>
<nacd:RawConverter x:Key="TextConverter" DefaultValue="01.01.1970-00:00:00" />
<nacd:RawConverter x:Key="ValueConverter" DefaultValue="{x:Null}" />
</ResourceDictionary>
</nac:Label.Resources>
<nac:Label.Text>
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type nai:IScreenWindow}}" Path="FirstOut_TimeEvent" Converter="{StaticResource TextConverter}" ValidatesOnExceptions="True">
<Binding.FallbackValue>00:00:00</Binding.FallbackValue>
</Binding>
</nac:Label.Text>
<nac:Label.Value>
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type nai:IScreenWindow}}" Path="FirstOut_TimeEvent"
****Converter={StaticResource ValueConverter}"*****
ValidatesOnExceptions="True" />
</nac:Label.Value>
<nac:Label.TextDecorations>
<TextDecorationCollection />
</nac:Label.TextDecorations>
<nac:Label.TextIntervalMapper>
<nacd:StringIntervalMapper DefaultValue="00:00:00" />
</nac:Label.TextIntervalMapper>
</nac:Label>